Verilog unsigned non-restoring division. Syntax Error: "I give up" Icarus Verilog
Verilog unsigned non-restoring division. Syntax Error: "I give up" Icarus Verilog
我想知道为什么我的 Iverilog 编译器会在模块末尾抛出“我放弃”错误。错误是:
DivisionsSchaltwerk.v:64: syntax error I give up
我的除法有 Verilog 代码,它使用 AQ 移位无符号非恢复除法算法的更改版本。第 64 列在 endmodule
部分。
module Division(
input clock,
input start,
input [31:0] a,
input [31:0] b,
output [31:0] q,
output [31:0] r
);
reg[31:0] AQ;
reg[31:0] B;
reg[31:0] R;
reg[5:0] count;
reg running;
assign q = AQ;
assign r = R;
always @(posedge clock) begin
if (start) begin
R <= 0;
AQ <= a;
B <= b;
count <= 6'd32;
running <= 1;
end
else if (count == 0) begin
running <=0;
if(R<0) begin
R <= R + B;
end
else begin
R <= R - B;
end
end
if (running) begin
if (R<0) begin
R <= R<<1;
R[0] <= AQ[32];
AQ <= AQ<<1;
end
if(R<0) begin
AQ[0] <= 0;
R <= R + B;
count <= count -6'd1;
end
else begin
AQ[0] <= 1;
R <= R - B;
count <= count - 6'd1;
end
end
else begin
R <= R<<1;
R[0] <= AQ[32];
AQ <= AQ<<1;
end
if(R<0) begin
AQ[0] <= 0;
R <= R + B;
count <= count -6'd1;
end
else begin
AQ[0] <= 1;
R <= R - B;
count <= count - 6'd1;
end
endmodule
您的代码有 12 个“开始”和 11 个“结束”字词。尝试更正缩进以找出缺少的“结尾”。
您的代码有两种类型的错误:
- 编译错误
- 编译警告
编译错误是您的 always
块中缺少 end
。其他模拟器,例如 edaplayground 上的模拟器,会产生稍微有用(和常见)的错误消息,例如:
endmodule
|
xmvlog: *E,NOTSTT : expecting a statement [9(IEEE)].
再加上代码的缩进不一致,这通常意味着 begin/end
对不匹配。此外,您可以使用 emacs
自动重新缩进您的代码:
emacs --batch DivisionsSchaltwerk.v -f verilog-batch-indent
您还会收到编译警告,例如:
R[0] <= AQ[32];
|
xmelab: *W,BNDWRN : Bit-select or part-select index out of declared bounds.
您将 AQ
声明为 [31:0]。您真的要使用 AQ[31]
吗?
这是你的自动缩进 always
块匹配 begin/end
:
always @(posedge clock) begin
if (start) begin
R <= 0;
AQ <= a;
B <= b;
count <= 6'd32;
running <= 1;
end
else if (count == 0) begin
running <=0;
if(R<0) begin
R <= R + B;
end
else begin
R <= R - B;
end
end
if (running) begin
if (R<0) begin
R <= R<<1;
R[0] <= AQ[32];
AQ <= AQ<<1;
end
if(R<0) begin
AQ[0] <= 0;
R <= R + B;
count <= count -6'd1;
end
else begin
AQ[0] <= 1;
R <= R - B;
count <= count - 6'd1;
end
end
else begin
R <= R<<1;
R[0] <= AQ[32];
AQ <= AQ<<1;
end
if(R<0) begin
AQ[0] <= 0;
R <= R + B;
count <= count -6'd1;
end
else begin
AQ[0] <= 1;
R <= R - B;
count <= count - 6'd1;
end
end
我想知道为什么我的 Iverilog 编译器会在模块末尾抛出“我放弃”错误。错误是:
DivisionsSchaltwerk.v:64: syntax error I give up
我的除法有 Verilog 代码,它使用 AQ 移位无符号非恢复除法算法的更改版本。第 64 列在 endmodule
部分。
module Division(
input clock,
input start,
input [31:0] a,
input [31:0] b,
output [31:0] q,
output [31:0] r
);
reg[31:0] AQ;
reg[31:0] B;
reg[31:0] R;
reg[5:0] count;
reg running;
assign q = AQ;
assign r = R;
always @(posedge clock) begin
if (start) begin
R <= 0;
AQ <= a;
B <= b;
count <= 6'd32;
running <= 1;
end
else if (count == 0) begin
running <=0;
if(R<0) begin
R <= R + B;
end
else begin
R <= R - B;
end
end
if (running) begin
if (R<0) begin
R <= R<<1;
R[0] <= AQ[32];
AQ <= AQ<<1;
end
if(R<0) begin
AQ[0] <= 0;
R <= R + B;
count <= count -6'd1;
end
else begin
AQ[0] <= 1;
R <= R - B;
count <= count - 6'd1;
end
end
else begin
R <= R<<1;
R[0] <= AQ[32];
AQ <= AQ<<1;
end
if(R<0) begin
AQ[0] <= 0;
R <= R + B;
count <= count -6'd1;
end
else begin
AQ[0] <= 1;
R <= R - B;
count <= count - 6'd1;
end
endmodule
您的代码有 12 个“开始”和 11 个“结束”字词。尝试更正缩进以找出缺少的“结尾”。
您的代码有两种类型的错误:
- 编译错误
- 编译警告
编译错误是您的 always
块中缺少 end
。其他模拟器,例如 edaplayground 上的模拟器,会产生稍微有用(和常见)的错误消息,例如:
endmodule
|
xmvlog: *E,NOTSTT : expecting a statement [9(IEEE)].
再加上代码的缩进不一致,这通常意味着 begin/end
对不匹配。此外,您可以使用 emacs
自动重新缩进您的代码:
emacs --batch DivisionsSchaltwerk.v -f verilog-batch-indent
您还会收到编译警告,例如:
R[0] <= AQ[32];
|
xmelab: *W,BNDWRN : Bit-select or part-select index out of declared bounds.
您将 AQ
声明为 [31:0]。您真的要使用 AQ[31]
吗?
这是你的自动缩进 always
块匹配 begin/end
:
always @(posedge clock) begin
if (start) begin
R <= 0;
AQ <= a;
B <= b;
count <= 6'd32;
running <= 1;
end
else if (count == 0) begin
running <=0;
if(R<0) begin
R <= R + B;
end
else begin
R <= R - B;
end
end
if (running) begin
if (R<0) begin
R <= R<<1;
R[0] <= AQ[32];
AQ <= AQ<<1;
end
if(R<0) begin
AQ[0] <= 0;
R <= R + B;
count <= count -6'd1;
end
else begin
AQ[0] <= 1;
R <= R - B;
count <= count - 6'd1;
end
end
else begin
R <= R<<1;
R[0] <= AQ[32];
AQ <= AQ<<1;
end
if(R<0) begin
AQ[0] <= 0;
R <= R + B;
count <= count -6'd1;
end
else begin
AQ[0] <= 1;
R <= R - B;
count <= count - 6'd1;
end
end