I got an assignment to make a 4-bit booth multiplier with unsigned inputs in Verilog.
I've only used verilog a few times before this, so I'm not too familiar in writing case
statements in it.
module booth(ina,inb,out);
input [3:0] ina, inb;
output[7:0] out;
reg[2:0] p1,p2;
reg[5:0] temp1, temp2;
assign p1={inb[2],inb[1],0};
assign p2={inb[3],inb[2],inb[1]};
always @(*)
begin
out = 8'b00000000;
case(p1)
3'b000: temp1=0;
3'b010: temp1=ina;
3'b100:temp1=-2 * ina;
3'b110:temp1= -ina;
endcase
end
begin
case(p2)
3'b000,3'b111: temp2=0;
3'b001,3'b010: temp2=ina;
3'b011:temp2=2 * ina;
3'b100:temp2=-2 * ina;
3'b101,3'b110:temp2= -ina;
endcase
temp2 = temp2<<2;
end
assign out=temp1+temp2;
endmodule
How am I supposed to write two case
statements in a row?
I get a syntax error:
syntax error near text: "begin"; expecting "endmodule". Check for and fix any syntax errors that appear immediately before or at the specified keyword.