verilog 中 "generate" 和 "endgenerate" 附近的语法错误
Syntax error near "generate" and "endgenerate" in verilog
我是 Verilog 的新手,我正在尝试使用 Verilog 实现单精度浮点加减法。我收到一个我无法更正的错误。谁能帮帮我吗?
模块添加模块(Rs、Re、Rm、As、Ae、Am、Bs、Be、Bm);
//Declarations of ports
Rs,Re,Rm;
As,Bs;
input [7:0] Ae,Be;
input [22:0] Am,Bm;
reg [7:0] Re;
reg [22:0] Rm;
reg Rs;
//wire declarations.
wire [23:-1] C;
assign C[-1] = 0;
wire [23:1] sum;
//variable declaration.
genvar count;
always @(*)
begin
//Add two mantissas.
if ((As^Bs)==0)
begin
generate //getting error here "Syntax error near "generate"."
for(count=0;count<24;count=count+1)
begin
add add_1(.c_out(C[count]),.sum(sum[count]),.in1(tempAm[count]),.in2(tempBm[count]),.c_in(C[count-1]));
end
endgenerate //syntax error near "endgenerate"
end
else
begin
generate //Syntax error near "generate".
for(count=0;count<24;count=count+1)
begin
subtract sub_1(.c_out(C[count]),.dif(sum[count]),.in1(tempAm[count]),.in2(tempBm[count]),.c_in(C[count]));
end
endgenerate //Syntax error near "endgenerate".
end
end
endmodule
提前致谢。 :)
在 Verilog 中,当您实例化 一个模块时,这意味着您正在向电路板添加额外的硬件。
必须在模拟开始前添加此硬件(即在编译时)。在这里,您可以 not add/remove 硬件在每个时钟脉冲。
一旦实例化,模块将 executed/checked 用于模拟的 每个时间戳 ,直到结束。
因此,要执行任何模块,只需实例化它,向其提供 clk 和其他所需的输入,然后 在子模块本身中添加 always 块.
一旦硬件被实例化,它就会根据其中的逻辑执行,整个生命周期。
你在错误的地方实例化了模块。 generate
块的使用必须 在 任何程序块之外完成。
// generate outside any other blocks
generate
for(count=0;count<24;count=count+1)
begin
add add_1(.c_out(C[count]),.sum(sum[count]),.in1(tempAm[count]),.in2(tempBm[count]),.c_in(C[count-1]));
end
endgenerate
always @(*)
begin
// Other stuff here.
end
如果你想操纵subtract sub_1
模块的输入信号,只需操纵C
、sum
和在addModule
模块。由于它们已连接,因此更改也应 反映 在 subtract sub_1
模块中。
有关生成块的更多信息,请参阅 Module Instantiation, Generate block example and a 链接。
我是 Verilog 的新手,我正在尝试使用 Verilog 实现单精度浮点加减法。我收到一个我无法更正的错误。谁能帮帮我吗?
模块添加模块(Rs、Re、Rm、As、Ae、Am、Bs、Be、Bm);
//Declarations of ports
Rs,Re,Rm;
As,Bs;
input [7:0] Ae,Be;
input [22:0] Am,Bm;
reg [7:0] Re;
reg [22:0] Rm;
reg Rs;
//wire declarations.
wire [23:-1] C;
assign C[-1] = 0;
wire [23:1] sum;
//variable declaration.
genvar count;
always @(*)
begin
//Add two mantissas.
if ((As^Bs)==0)
begin
generate //getting error here "Syntax error near "generate"."
for(count=0;count<24;count=count+1)
begin
add add_1(.c_out(C[count]),.sum(sum[count]),.in1(tempAm[count]),.in2(tempBm[count]),.c_in(C[count-1]));
end
endgenerate //syntax error near "endgenerate"
end
else
begin
generate //Syntax error near "generate".
for(count=0;count<24;count=count+1)
begin
subtract sub_1(.c_out(C[count]),.dif(sum[count]),.in1(tempAm[count]),.in2(tempBm[count]),.c_in(C[count]));
end
endgenerate //Syntax error near "endgenerate".
end
end
endmodule
提前致谢。 :)
在 Verilog 中,当您实例化 一个模块时,这意味着您正在向电路板添加额外的硬件。
必须在模拟开始前添加此硬件(即在编译时)。在这里,您可以 not add/remove 硬件在每个时钟脉冲。
一旦实例化,模块将 executed/checked 用于模拟的 每个时间戳 ,直到结束。
因此,要执行任何模块,只需实例化它,向其提供 clk 和其他所需的输入,然后 在子模块本身中添加 always 块.
一旦硬件被实例化,它就会根据其中的逻辑执行,整个生命周期。
你在错误的地方实例化了模块。 generate
块的使用必须 在 任何程序块之外完成。
// generate outside any other blocks
generate
for(count=0;count<24;count=count+1)
begin
add add_1(.c_out(C[count]),.sum(sum[count]),.in1(tempAm[count]),.in2(tempBm[count]),.c_in(C[count-1]));
end
endgenerate
always @(*)
begin
// Other stuff here.
end
如果你想操纵subtract sub_1
模块的输入信号,只需操纵C
、sum
和在addModule
模块。由于它们已连接,因此更改也应 反映 在 subtract sub_1
模块中。
有关生成块的更多信息,请参阅 Module Instantiation, Generate block example and a