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



沒有留言:

張貼留言

習題解答 (5/6)

  第五章 習題解答 一、 錯誤偵測技術 1. 何謂循環冗餘檢查法 (CRC)? 是一種根據傳輸資料產生簡短固定位數校驗碼的演算法。發送端將資料除以一個特定的多項式,得到的「餘數」即為 CRC 碼並隨資料發送;接收端以同樣多項式除之,若餘數為 0 則代表資料傳輸正確。 2. 何...