回复 51# 甲壳虫
当然要加代码 否则tb怎么和dut链接在一起。 建议你找个最简单例子先把基本方法弄熟。verilog入门书都有的。
我的tb如下:
- `timescale 1 ps/ 1 ps
- module calculation_vlg_tst();
- // constants
- // general purpose registers
- reg eachvec;
- // test vector input registers
- reg clk;
- reg rst_n;
- // wires
- wire [7:0] avg;
- wire [7:0] indata;
- wire [7:0] outdata;
- wire [7:0] rd_addr;
- wire we;
- wire [7:0] wr_addr;
- // assign statements (if any)
- calculation i1 (
- // port map - connection between master ports and signals/registers
- .avg(avg),
- .clk(clk),
- .indata(indata),
- .outdata(outdata),
- .rd_addr(rd_addr),
- .rst_n(rst_n),
- .we(we),
- .wr_addr(wr_addr)
- );
- initial
- begin
- // code that executes only once
- // insert code here --> begin
- clk = 1'b0;
- rst_n = 1'b1;
- #10 rst_n = 1'b0;
- #10 rst_n = 1'b1;
- // --> end
- $display("Running testbench");
- end
- always #50 clk = ~clk;
-
- always
- // optional sensitivity list
- // @(event1 or event2 or .... eventn)
- begin
- // code executes for every event on sensitivity list
- // insert code here --> begin
-
- @eachvec;
- // --> end
- end
- endmodule
复制代码 |