2020年1月3日 星期五

Master-Slave D Flip-Flop

Master-Slave D Flip-Flop




module MastreSlave_D_FF(d,reset,clk,q,qbar);
 input d,clk,reset;
 output q,qbar;
 Master M1(d,reset,clk,qx,qbarx);
 Master S2(qx,reset,!clk,q,qbar);
endmodule

module Master(d,reset,clk,q,qbar);
 input d,reset,clk;
 output reg q,qbar;
 initial
  q = 0;
 always @(posedge clk)begin
if(~reset)begin
q <= d;
qbar <= !d;
end
else begin
q <= 1'bz;
qbar <= 1'bz;
end
 end

endmodule


// 時間單位 100ns, 時間精確度100 ps
`timescale 100ns/100ps    
module Test_bench;

// Inputs
reg clk=0,d=0,reset=1;

// Outputs
wire q,qba;

// Instantiate the Unit Under Test (UUT)
//module MastreSlave_D_FF(d,reset,clk,q,qbar);
MastreSlave_D_FF UUT(d,reset,clk,q,qba);

   initial begin
    $monitor(clk,d,reset,q,qba);
    // Initialize Inputs
#25 d=1; 
reset=0;
#25 d=0; 
#25 d=1; 
#25 d=1; 
reset=1;
#25 d=0; 
reset=0;
#25 d=1;
#25 d=0; 
#25 d=1; 
#25 d=0;
   end

   always #10 clk<=~clk;
   initial begin
#300;   // 模擬終止時間  300 ns
$stop;
   end
endmodule



沒有留言:

張貼留言

2024產專班 作業2 (純模擬)

2024產專班 作業2  (純模擬) 1) LED ON,OFF,TIMER,FLASH 模擬 (switch 控制) 2)RFID卡號模擬 (buttom  模擬RFID UID(不從ESP32) Node-Red 程式 [{"id":"d8886...