黑金time篇booth乘法器Verilog赋值错误怎么解决
时间:10-02
整理:3721RD
点击:
module booth_multiplier_module(
input CLK,
input reset,
input Start_Sig,
input[7:0]A,
input[7:0]B,
output[16:0]Product,
output[7:0]SQ_a,
output[7:0]SQ_s,
output[16:0]SQ_p
);
reg[3:0]i;
reg[7:0]a;
reg[7:0]s;
reg[16:0]p;
reg[3:0]X;
reg isDone;
always @ (posedge CLK or negedge reset)
if(!reset)
begin
i<=0;
a<=8'd0;
s<=8'd0;
p<=17'd0;
X<=4'd0;
isDone<=1'd0;
end
else if(Start_Sig)
case(i)
0:
begin
a<=A;s<=(~A+1'b1);p<={8'd0,B,1'b0};i<=i+1'b1;
end
1:
if(X==8)
begin
X<=4'd0;i<=i+4'd2;
end
else if(p[1:0]==2'b01)
begin
p<={p[16:9]+a,p[8:0]};i<=i+1'b1;
end
else if(p[1:0]==2'b10)
begin
p<={p[16:9]+s,p[8:0]};i<=i+1'b1;
end
else
i<=i+1'b1;
2:
begin
p<={p[16],p[16:1]};i<=i-1'b1;
end
3:
begin
isDone<=1'b1;i<=i+1'b1;
end
4:
begin
isDone<=0;i<=4'd0;
end
endcase
assign Done_Sig = isDone;
assign SQ_a = a;
assign SQ_s= s;
assign SQ_p=p;
assign Product=p[16:1];
endmodule
`timescale 1 ns/ 1 ps
module booth_multiplier_module_vlg_tst();
// constants
// general purpose registers
reg eachvec;
// test vector input registers
reg [7:0] A;
reg [7:0] B;
reg CLK;
reg Start_Sig;
reg reset;
// wires
wire [16:0] Product;
wire [7:0] SQ_a;
wire [16:0] SQ_p;
wire [7:0] SQ_s;
reg Done_Sig;
// assign statements (if any)
booth_multiplier_module i1 (
// port map - connection between master ports and signals/registers
.A(A),
.B(B),
.CLK(CLK),
.Product(Product),
.SQ_a(SQ_a),
.SQ_p(SQ_p),
.SQ_s(SQ_s),
.Start_Sig(Start_Sig),
.reset(reset)
);
initial
begin
reset=0;
#10 reset=1;
CLK<=0;
forever #10 CLK=~CLK;
end
reg[3:0]i;
always @(posedge CLK or negedge reset)
if(!reset)
begin
i<=4'd0;
A<=8'd0;
B<=8'd0;
Start_Sig<=1'b0;
end
case(i)
0://A=2,B=4
if(Done_Sig)
begin
Start_Sig <= 1'b0;
i <= i + 1'b1;
end
else
begin
A<=8'd2;B<=8'd4;
Start_Sig<=1'b1;
end
1:
if(Done_Sig)
begin
Start_Sig<=1'b0;i<=i+1'b1;
end
else
begin
A<=8'b11111100;
B<=8'd4;
Start_Sig<=1'b1;
end
2:
if(Done_Sig)
begin
Start_Sig<=1'b0;i<=i+1'b1;
end
else
begin
A<=8'd127;
B<=8'b10000001;
Start_Sig<=1'b1;
end
3:
if(Done_Sig)
begin
Start_Sig<=1'b0;i<=i+1'b1;
end
else
begin
A<=8'b10000001;
B<=8'b10000001;
Start_Sig<=1'b1;
end
4:
i<=4'd4;
endcase
endmodule
仿真时总是出现错误# ** Error: F:/chengxu1/booth_multiplier_module/simulation/modelsim/booth_multiplier_module.vt(79): near "<=": syntax error, unexpected "<=", expecting "IDENTIFIER" or "TYPE_IDENTIFIER" or '#' or '('
input CLK,
input reset,
input Start_Sig,
input[7:0]A,
input[7:0]B,
output[16:0]Product,
output[7:0]SQ_a,
output[7:0]SQ_s,
output[16:0]SQ_p
);
reg[3:0]i;
reg[7:0]a;
reg[7:0]s;
reg[16:0]p;
reg[3:0]X;
reg isDone;
always @ (posedge CLK or negedge reset)
if(!reset)
begin
i<=0;
a<=8'd0;
s<=8'd0;
p<=17'd0;
X<=4'd0;
isDone<=1'd0;
end
else if(Start_Sig)
case(i)
0:
begin
a<=A;s<=(~A+1'b1);p<={8'd0,B,1'b0};i<=i+1'b1;
end
1:
if(X==8)
begin
X<=4'd0;i<=i+4'd2;
end
else if(p[1:0]==2'b01)
begin
p<={p[16:9]+a,p[8:0]};i<=i+1'b1;
end
else if(p[1:0]==2'b10)
begin
p<={p[16:9]+s,p[8:0]};i<=i+1'b1;
end
else
i<=i+1'b1;
2:
begin
p<={p[16],p[16:1]};i<=i-1'b1;
end
3:
begin
isDone<=1'b1;i<=i+1'b1;
end
4:
begin
isDone<=0;i<=4'd0;
end
endcase
assign Done_Sig = isDone;
assign SQ_a = a;
assign SQ_s= s;
assign SQ_p=p;
assign Product=p[16:1];
endmodule
`timescale 1 ns/ 1 ps
module booth_multiplier_module_vlg_tst();
// constants
// general purpose registers
reg eachvec;
// test vector input registers
reg [7:0] A;
reg [7:0] B;
reg CLK;
reg Start_Sig;
reg reset;
// wires
wire [16:0] Product;
wire [7:0] SQ_a;
wire [16:0] SQ_p;
wire [7:0] SQ_s;
reg Done_Sig;
// assign statements (if any)
booth_multiplier_module i1 (
// port map - connection between master ports and signals/registers
.A(A),
.B(B),
.CLK(CLK),
.Product(Product),
.SQ_a(SQ_a),
.SQ_p(SQ_p),
.SQ_s(SQ_s),
.Start_Sig(Start_Sig),
.reset(reset)
);
initial
begin
reset=0;
#10 reset=1;
CLK<=0;
forever #10 CLK=~CLK;
end
reg[3:0]i;
always @(posedge CLK or negedge reset)
if(!reset)
begin
i<=4'd0;
A<=8'd0;
B<=8'd0;
Start_Sig<=1'b0;
end
case(i)
0://A=2,B=4
if(Done_Sig)
begin
Start_Sig <= 1'b0;
i <= i + 1'b1;
end
else
begin
A<=8'd2;B<=8'd4;
Start_Sig<=1'b1;
end
1:
if(Done_Sig)
begin
Start_Sig<=1'b0;i<=i+1'b1;
end
else
begin
A<=8'b11111100;
B<=8'd4;
Start_Sig<=1'b1;
end
2:
if(Done_Sig)
begin
Start_Sig<=1'b0;i<=i+1'b1;
end
else
begin
A<=8'd127;
B<=8'b10000001;
Start_Sig<=1'b1;
end
3:
if(Done_Sig)
begin
Start_Sig<=1'b0;i<=i+1'b1;
end
else
begin
A<=8'b10000001;
B<=8'b10000001;
Start_Sig<=1'b1;
end
4:
i<=4'd4;
endcase
endmodule
仿真时总是出现错误# ** Error: F:/chengxu1/booth_multiplier_module/simulation/modelsim/booth_multiplier_module.vt(79): near "<=": syntax error, unexpected "<=", expecting "IDENTIFIER" or "TYPE_IDENTIFIER" or '#' or '('