为什么这行会遇到错误:期待左括号('(')[12.1.2] [7.1(ieee)]?
我有一个简单乘数的Verilog代码,如下所示,该代码需要两个32-B输入,分为两个(16-B MSB和16-B LSB),并乘以:
parameter WordLen1 = 32, WordLen2 = 16;
output [WordLen2-1:0] M;
input clk;
input signed [WordLen1-1:0] X, W1;
reg signed [WordLen1-1 :0] X_reg, W1_reg, M;
wire signed [WordLen2-1:0] mul1, mul2, M_out;
assign mul1 = X_reg[31:16] * W1_reg[31:16]; <--- 16-b MSB
assign mul2 = X_reg[15:0] * W1_reg[15:0]; <--- 16-b LSB
assign M_out = mul1 + mul2;
always@(posedge clk)
begin
X_reg <= X;
W1_reg <= W1;
M <= M_out;
end
endmodule
代码的测试台,如下:
注意:注意:输入是从两个具有32-B值的外部文本文件中读取的。
module testbench;
reg clk;
parameter WL1 = 32, WL2 = 16;
reg [WL1-1:0] Xinarray [0:1]; // define memory arrays to hold inputs
reg [WL1-1:0] W1inarray [0:1];
logic signed [WL1-1:0] X,W1; <------ Error : Expecting a left parenthesis
endmodule
我在测试工作台上遇到以下错误:
logic signed [WL1-1:0] X,W1;
|
ncvlog: *E,EXPLPA (../src/mult_hidden_tb.v,9|11): expecting a left parenthesis ('(') [12.1.2][7.1(IEEE)].
logic signed [WL1-1:0] X,W1;
|
ncvlog: *E,EXPLPA (../src/mult_hidden_tb.v,9|17): expecting a left parenthesis ('(') [12.1.2][7.1(IEEE)].
logic signed [WL1-1:0] X,W1;
|
ncvlog: *E,EXPLPA (../src/mult_hidden_tb.v,9|24): expecting a left parenthesis ('(') [12.1.2][7.1(IEEE)].
logic signed [WL1-1:0] X,W1;
|
ncvlog: *E,EXPLPA (../src/mult_hidden_tb.v,9|27): expecting a left parenthesis ('(') [12.1.2][7.1(IEEE)].
我不确定我在做什么错。
I have a Verilog code for a simple multiplier as shown below, which takes two 32-b inputs which are split into two (16-b MSB and 16-b LSB) and multiplied:
parameter WordLen1 = 32, WordLen2 = 16;
output [WordLen2-1:0] M;
input clk;
input signed [WordLen1-1:0] X, W1;
reg signed [WordLen1-1 :0] X_reg, W1_reg, M;
wire signed [WordLen2-1:0] mul1, mul2, M_out;
assign mul1 = X_reg[31:16] * W1_reg[31:16]; <--- 16-b MSB
assign mul2 = X_reg[15:0] * W1_reg[15:0]; <--- 16-b LSB
assign M_out = mul1 + mul2;
always@(posedge clk)
begin
X_reg <= X;
W1_reg <= W1;
M <= M_out;
end
endmodule
The testbench for the code is below:
Note : The inputs are read from two external text files having 32-b values each.
module testbench;
reg clk;
parameter WL1 = 32, WL2 = 16;
reg [WL1-1:0] Xinarray [0:1]; // define memory arrays to hold inputs
reg [WL1-1:0] W1inarray [0:1];
logic signed [WL1-1:0] X,W1; <------ Error : Expecting a left parenthesis
endmodule
I am getting the following error in my test bench:
logic signed [WL1-1:0] X,W1;
|
ncvlog: *E,EXPLPA (../src/mult_hidden_tb.v,9|11): expecting a left parenthesis ('(') [12.1.2][7.1(IEEE)].
logic signed [WL1-1:0] X,W1;
|
ncvlog: *E,EXPLPA (../src/mult_hidden_tb.v,9|17): expecting a left parenthesis ('(') [12.1.2][7.1(IEEE)].
logic signed [WL1-1:0] X,W1;
|
ncvlog: *E,EXPLPA (../src/mult_hidden_tb.v,9|24): expecting a left parenthesis ('(') [12.1.2][7.1(IEEE)].
logic signed [WL1-1:0] X,W1;
|
ncvlog: *E,EXPLPA (../src/mult_hidden_tb.v,9|27): expecting a left parenthesis ('(') [12.1.2][7.1(IEEE)].
I'm not sure what I'm doing wrong.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要检查ncverilog工具将代码编译为系统Verilog代码,而不是verilog。
“逻辑”数据类型在系统Verilog中定义。
但是在Verilog中,“逻辑”未定义。
在Verilog中,您可以使用“电线”或“ reg”。
因此,如果要将代码编译为Verilog,则必须将“逻辑”更改为“ Reg”或“ Wire”。
但是,该变量不能在“始终”(或“初始”)和“分配”中使用。
如果输入端口(将X和W1定义为顶部模块的输入),则可以使用“初始”或“始终”块中使用的“ reg”。
You need to check ncverilog tool compile the code as system verilog code, not as verilog.
"logic" data type is defined in system verilog.
But in Verilog, "logic" is not defined.
In Verilog, you can use "wire" or "reg".
So if you want to compile the code as verilog, "logic" must changed into "reg" or "wire".
But then the variable cannot be used in "always"(or "initial") and "assign" together.
In case of input port(you defined X and W1 as input at your top module), you may use "reg" used at "initial" or "always" block.