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

沒有留言:

張貼留言

Modbus FC=1 (Coils read) & FC=15 (Coils Write)

Modbus FC=1  (Coils read)  & FC=15 (Coils Write)   「從 Modbus 設備讀取多個線圈(Coils)狀態,並立刻將這些狀態原封不動地轉寫到另一個記憶體位址(起始位址 16)」 。 整個流程使用了知名套件 node-red...