verilog - 当 32 无法正常工作时,verilog 与门
问题描述
与门
module andgate
#(parameter Port_Num = 2,
parameter WIDTH=8)
(
input [(WIDTH-1):0] a,
input [(WIDTH-1):0] b,
input [(WIDTH-1):0] c,
input [(WIDTH-1):0] d,
input [(WIDTH-1):0] e,
input [(WIDTH-1):0] f,
input [(WIDTH-1):0] g,
input [(WIDTH-1):0] h,
output [(WIDTH-1):0] q
);
assign q = (a & b & c & d & e & f & g & h);
endmodule
angate_sim
`timescale 1ns / 1ps
module andgate_sim();
// input
reg a=0;
reg b=0;
reg c=1;
reg d=1;
reg e=1;
reg f=1;
reg g=1;
reg h=1;
//outbut
wire q;
andgate #(8,1) u(.a(a),.b(b),.c(c),.d(d),.e(e),.f(f),.g(g),.h(h),.q(q));
always #100 a=~a;
initial begin
#100 a=1;
#100 begin a=0;b=1;end
#100 a=1;
#60000000 $finish;
end
initial
begin
$dumpfile("wave2.vcd");
$dumpvars(0, andgate_sim);
end
endmodule
当我测试测试台时,它像这样正常工作
iverilog -o Ex2 andgate.v andgate_sim.v
vvp -n Ex2 -lxt2
gtkwave wave2.vcd
然后我试着像这样做一个与门* 32
`timescale 1ns / 1ps
module andgate32_sim( );
// input
reg [31:0] a=32'h00000000;
reg [31:0] b=32'h00000000;
reg [31:0] c=32'hffffffff;
reg [31:0] d=32'hffffffff;
reg [31:0] e=32'hffffffff;
reg [31:0] f=32'hffffffff;
reg [31:0] g=32'hffffffff;
reg [31:0] h=32'hffffffff;
//outbut
wire [31:0] q;
andgate #(8,32) u(.a(a),.b(b),.c(c),.d(d),.e(e),.f(f),.g(g),.h(h),.q(q));
always #100
begin
a <= 32'hffffffff;
end
always #200
begin
a <= 32'h00000000;
b <= 32'hffffffff;
end
always #300
begin
a <= 32'h007fa509;
end
always #400
begin
a <= 32'hffffffff;
end
initial begin
#100 a <= 32'hffffffff;
#100 begin a <= 32'h00000000;b <= 32'hffffffff;end
#100 a <= 32'h007fa509;
#100 a <= 32'hffffffff;
#60000000 $finish;
end
initial
begin
$dumpfile("wave2-2.vcd");
$dumpvars(0, andgate32_sim);
end
endmodule
但是当我像以前一样做这些步骤时
iverilog -o Ex2 andgate.v andgate32_sim.v
vvp -n Ex22 -lxt2
gtkwave wave2-2.vcd
波浪中没有这样的东西
wave2-2.vcd 里面没有waves 其实应该是wave2-2.vcd 里面的东西。 请你帮助我好吗 ?
解决方案
您正在尝试运行另一个已编译的测试平台“Ex22”而不是“Ex2”。
提示:您可以使用参数并将它们传递给实例化,如下所示:
localparam WIDTH = 32;
localparam Port_Num = 8;
// input
reg [WIDTH-1:0] a=32'h00000000;
reg [WIDTH-1:0] b=32'h00000000;
reg [WIDTH-1:0] c=32'hffffffff;
reg [WIDTH-1:0] d=32'hffffffff;
reg [WIDTH-1:0] e=32'hffffffff;
reg [WIDTH-1:0] f=32'hffffffff;
reg [WIDTH-1:0] g=32'hffffffff;
reg [WIDTH-1:0] h=32'hffffffff;
//outbut
wire [WIDTH-1:0] q;
andgate #(.Port_Num (Port_Num), .WIDTH (WIDTH)) u(.a(a),.b(b),.c(c),.d(d),.e(e),.f(f),.g(g),.h(h),.q(q));
推荐阅读
- ruby - 如何对未定义的局部变量进行异常处理?
- powershell - 将标题从一个csv复制到另一个,用于多个文件
- node.js - MariaDB 连接关闭并导致错误
- python - 如何检查是否已使用 Python 中的字典扫描了集合中的所有项目?
- python - 使用flask-sqlalchemy,如何在数据库表列中指定用户定义的数据类型
- node.js - 续集关联不使用打字稿
- javascript - 无法模拟构造函数的属性:ReferenceError: EventSource is not defined (Jest, Enzyme)
- javascript - 动态替换/生成 div 中的 HTML 内容 | .NET + jQuery
- ethereum - 转自失败
- python - 文件“mtrand.pyx”,第 905 行,在 numpy.random.mtrand.RandomState.choice TypeError:'dict_keys' 对象不能被解释为整数