2020年5月13日 星期三

Verilog D Latch

Verilog D Latch 

module D_Latch(en,D,Q,Qbar);
input en,D;
output reg Q,Qbar;

always@(en or D)
begin
if (en) begin
Q=D;
Qbar=~D;
end
else
Q=Q;
Qbar=Qbar;
end

endmodule

`timescale 100ns/1ns
module tb;

reg  en,D;
wire Q,Qbar;

D_Latch UUT(en,D,Q,Qbar);
initial begin
en=1'b1;D=1'b0;
#10;
en=1'b1;D=1'b1;
#10;
en=1'b0;D=1'b0;
#10;
en=1'b0;D=1'b1;
#10;
$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...