2012年10月13日 星期六

Verilog HDL: Test Bench for 4 bit Counter


源自http://asic-soc.blogspot.tw/2012/06/verilog-hdl-test-bench-for-4-bit.html

Verilog HDL: Test Bench for 4 bit Counter

Test Bench for 4 bit Counter:
module tb_4bitcounter
reg tclk,trst;
wire [3:0]tq;
counter_4bit C1(.tq(q), .tclk(clk), .trst(rst)); instantiate counter to be tested.
initial
begin
#0 trst=1’b0; //tclk=1’b?;
#5 trst=1’b1; //tclk=1’b1;
#100 trst=1’b1; //tclk=1’b0;
end

tclk=1’b0; //tclk=1’b0;
#10 tclk=1’b1; //forever
#20 tclk=1’b0; //#10 tclk=~tclk;
end        //end
endmodule
initial
#500 $stop;
end
initial
$monitor
(trst=%b, tclk=%b, tq=%d “, trst, tclk,tq)
end
Another way:
module tb_4bitcounter
reg tclk,trst,ten;
wire [3:0] tq;
initial
tclk=1’b0;
always
#20 tclk=~tclk; //generate clock
initial
trst=1’b1; //generate reset signal
#20 trst=1’b0;
#700 trst=1’b1;
end
counter_4bit C1(.tq(q), .tclk(clk), .trst(rst)); //instantiate counter to be tested.
$monitor
(trst=%b, tclk=%b, tq=%d “, trst, tclk,tq)
endmodule
always  //initial

沒有留言:

張貼留言

ESP32 微控制器 採集的環境數據,經由 MQTT 協定 轉換並寫入工業標準的 Modbus 暫存器 中

  一個典型的 IoT(物聯網)與工業自動化系統整合(SCADA/機台連線) 的架構圖。它透過 Node-RED 作為核心資料網關,將前端 ESP32 微控制器 採集的環境數據,經由 MQTT 協定 轉換並寫入工業標準的 Modbus 暫存器 中。 1. 各模組功能拆解...