我正在尝试调试下面显示的代码。我是SystemVerilog的新手,希望我可以从中学习。让我知道任何建议。
我收到的错误是:
Error-[ICPD] Invalid procedural driver combination
"divide.v", 2
Variable "Q" is driven by an invalid combination of procedural drivers.
Variables written on left-hand of "always_comb" cannot be written to by any
other processes, including other "always_comb" processes.
"divide.v", 2: logic [7:0] Q;
"divide.v", 8: always_comb begin
if (x <= R) begin
...
"divide.v", 5: Q = 8'b0;
Error-[ICPD] Invalid procedural driver combination
"divide.v", 2
Variable "R" is driven by an invalid combination of procedural drivers.
Variables written on left-hand of "always_comb" cannot be written to by any
other processes, including other "always_comb" processes.
"divide.v", 2: logic [7:0] R;
"divide.v", 8: always_comb begin
if (x <= R) begin
...
"divide.v",6: R = y;
我的SystemVerilog代码是:
module divider(input logic [7:0] x,y,
output logic [7:0] Q,R);
initial
begin
Q = 8'd0;
R = y;
end
always_comb
begin
if (x<=R)
begin R <= R - x; Q <= Q + 8'd1; end
end
endmodule
module test1;
logic [7:0] x,y,Q,R;
divider Divider1 (x,y,Q,R);
initial
begin
x = 8'd2;
y = 8'd8;
end
endmodule
答案 0 :(得分:2)
通常,在Verilog / SystemVerilog中,您无法从两个并行块(有一些例外)分配给变量。您从两个地方分配R
和Q
:initial
块和always_comb
块。
虽然initial
块仅运行一次,但它在模拟开始时与always_comb
块并行运行,这违反了此规则。
为什么不摆脱initial
阻止并执行always_comb
中的所有内容?
always_comb
begin
Q = 8'd0; // set initial value of Q
R = y; // set initial value of R
.... //THE REST OF THE ALGORITHM
end
此外,您缺少使用循环!
答案 1 :(得分:1)
编写System Verilog(或任何HDL)和用任何软件语言(C / C ++,Java等)编写之间的一个重要区别是System Verilog旨在促进描述硬件结构,同时允许对于类似软件的测试平台,软件语言旨在允许用户向解释器,VM或实际硬件发出指令。话虽如此,您需要首先考虑您要描述的硬件,然后编写相关的HDL代码。有很多帖子描述了HDL和软件语言之间的差异(例如:Can Verilog/Systemverilog/VHDL be considered actor oriented programming languages?)。
查看您的代码和流程图,看来您正在尝试使用System Verilog作为编程语言而不是HDL。例如,初始块通常仅用于测试台,而不用于模块本身。此外,由于您的算法是连续的,很可能您需要一个时钟信号和寄存器,但您的代码缺乏这两种方式。
理想情况下,在尝试编写任何HDL之前,您应该很好地了解如何设计数字硬件系统,因为这是您应该使用HDL的心态。目标通常是将硬件设计转换为HDL,因此理解数字设计将有助于澄清很多。