【发布时间】:2019-12-16 14:18:06
【问题描述】:
我尝试编译以下代码:
module sample (
input logic [31:0] data_i,
output logic [31:0] data_o
);
`define SUBNORMAL 31'b0
/*Intermediate storage of input data*/
logic [15:0] data_str_0;
bit sign_0;
initial begin
data_str_0 = data_i[31:16] ;
end
/*Assigning the sign bit*/
initial begin
sign_0 = data_str_0[15];
end
/*Exponent calculation*/
logic [4:0] exp_hf_0;
logic [7:0] exp_sf_0;
initial begin
exp_hf_0 = data_str_0 [14:10];
end
/*Adjusting the bias*/
always @(*)
begin
exp_sf_0 = exp_hf_0 + 8'd112;
end
/*Mantissa calculation*/
logic [9:0] man_hf_0;
logic [22:0] man_sf_0;
initial begin
man_hf_0 = data_str_0 [9:0];
end
always @(*)
begin
man_sf_0 = {man_hf_0,13'b0};
end
/*Packing the output*/
always @(*)
begin
if (exp_sf_0 == 5'b0 && man_sf_0 != 10'b0)
data_o = '{sign_0,SUBNORMAL};
end
endmodule
但是我收到以下错误消息:
**错误:sample.sv(52): (vlog-2730) 未定义变量:'SUBNORMAL'。
我的意图是将 SUBNORMAL 常量值与 sign_0 绑定,并将其分配给 data_o。
谁能给我建议一个解决方案?
【问题讨论】:
-
在 C 中,当您使用用
#define定义的符号时,您不需要#;在(系统)Verilog中,您确实需要添加反引号,如工具所说。 -
反引号后出现以下错误。 (vlog-13174) 非法分配模式。元素的数量 (2) 与类型的宽度 (32) 不匹配。
标签: arrays system-verilog