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



沒有留言:

張貼留言

作業2 MQTT (Relay + DHT22) 控制 ------- 利用Node-Red

作業2 MQTT (Relay + DHT22) 控制 ------- 利用Node-Red 1) 安裝Node-Red  https://ithelp.ithome.com.tw/articles/10201795 https://www.youtube.com/watch?v...