Verilog-比特流可以在硬件上工作,但模拟不能';不编译
我使用Verilog设置FPGA,使其每秒闪烁一次LED。这是一种方法:Verilog-比特流可以在硬件上工作,但模拟不能';不编译,verilog,verilator,Verilog,Verilator,我使用Verilog设置FPGA,使其每秒闪烁一次LED。这是一种方法: `default_nettype none module pps(i_clk, o_led); parameter CLOCK_RATE_HZ = 12_000_000; input wire i_clk; output wire o_led; reg [23:0] counter; initial counter = 0; always @(posedge i_c
`default_nettype none
module pps(i_clk, o_led);
parameter CLOCK_RATE_HZ = 12_000_000;
input wire i_clk;
output wire o_led;
reg [23:0] counter;
initial counter = 0;
always @(posedge i_clk)
if (counter < CLOCK_RATE_HZ/2 - 1)
begin
counter <= counter + 1'b1;
end
else
begin
counter <= 0;
o_led <= !o_led;
end
endmodule
前两个makefile目标(all
&flash
)工作正常,当比特流文件上传到主板时,LED以1Hz的频率闪烁。很好
但是,当我尝试模拟此模块时,我运行makefile targetsimulate
,得到一个错误:
┌───┐
│ $ │ ziga > ziga--workstation > 003--pps
└─┬─┘ /dev/pts/13
└─> make simulate
verilator --trace -Wall -cc pps.v
%Error-PROCASSWIRE: pps.v:72: Procedural assignment to wire, perhaps intended var (IEEE 2017 6.5): o_led
%Error: Exiting due to 1 error(s)
%Error: See the manual and http://www.veripool.org/verilator for more assistance.
%Error: Co`
有人能解释一下怎么回事吗?设计已经在硬件上运行了(!),那么为什么我的模拟不能编译呢?如何使此示例也适用于模拟?正如错误消息所述,对
导线进行程序分配是非法的。例如,程序赋值是在始终
块内进行的赋值。您将o_led
声明为导线
,但随后在始终
块中分配给它。您应该在始终
块中使用reg
类型。参考IEEE标准1800-2017第10.4节程序分配
更改:
output wire o_led;
致:
wire
类型用于连续指定,例如使用assign
关键字
output wire o_led;
output reg o_led;