2020年5月13日 星期三

Verilog D Flip-Flop

Verilog D Flip-Flop 



module D_FF (clk,D,Q);
input clk,D;
output reg Q;
always@(posedge clk)
begin
Q=D;
end
endmodule


`timescale 100ns/1ns
module tb;

reg clk,D;
wire Q;

always #10 clk = ~clk;

D_FF UUT(clk,D,Q);
 initial begin
    // 1. Initialize testbench variables
clk=1'b0; D=1'b0;
   
    // 2. 
    repeat (2) @ (posedge clk);
    D <= 1;
    repeat (3) @ (posedge clk);

    // 3.  
    D <=0; 
    repeat(2) @ (posedge clk);
    D <= 1;

    // 4.  
    repeat (5) @ (posedge clk);
    $stop;
 
  end

endmodule

沒有留言:

張貼留言

2026 作業3 RFID+ Telegram 練習

 2026 作業3  RFID+ Telegram  練習 (Wokwi 與 Telegram 二者溝通訊息反映比較慢 ) 歡迎 Alex 使用 RFID 控制系統 /on : 開啟 LED /off : 關閉 LED /flash : 閃爍模式 /timer : 開啟 5 秒 ...