本文介绍了谁能帮我创建一个 Verilog 测试平台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何人都可以帮我创建一个测试平台或仅为我的以下代码创建输入代码吗?我正在使用 XILINX.
Can anyone help me create a testbench or just the input code for my following code? I'm using XILINX.
module fsmb (input rst,clk,a,
output reg x);
parameter sta = 2'b00, stb = 2'b01, stc = 2'b10,
std = 2'b11;
reg[1:0] st, nst;
always @(posedge clk)
begin
if (rst)
st <= 2'b00;
else
st <= nst;
end
always @*
begin
st = nst; x =0'b0;
case (st)
sta: if(a) nst = stb;
else nst = sta;
stb: if(a) nst = stc;
else nst = stb;
stc: begin
if(a) nst = stc;
else nst = std;
x =1'b1;
end
std: begin
if(a) nst = stc;
else nst = sta;
x = 1'b1;
end
default: nst = sta;
endcase
end
endmodule
推荐答案
Testbench 101
- 创建一个新模块 (tb).
- 为 DUT 的每个输入创建一个 reg.
- 为 DUT 的每个输出创建一条连线.
- 创建 DUT 的实例.
- 将您的 regs 和电线连接到您的 DUT.
- 生成时钟
- 推动您的其他投入
- 为您的输出创建检查器(我将把它留给您).
示例:
module tb;
reg rst,clk,a;
wire x;
initial begin
clk = 0;
forever #5 clk = ~clk;
end
initial begin
rst = 1;
a = 0;
#50 rst = 0;
#50 $finish;
end
fsmb fsmb (
.clk (clk),
.rst (rst),
.a (a),
.x (x)
);
endmodule
其他简单的测试平台示例在 EDA playgound 上提供.您可以注册一个免费帐户并查看示例,例如:已发布的 Playgounds ->D触发器
Other simple testbench examples are provided on EDA playgound. You can sign up for a free account and look at samples such as: Published Playgounds -> D flip flop
这篇关于谁能帮我创建一个 Verilog 测试平台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!