I'm having trouble assigning a value to a wire inside an if block. I would have thought this would be fairly straight forward, but the error I'm getting is:
near "assign": syntax error, unexpected assign, expecting IDENTIFIER or TYPE_IDENTIFIER or NETTYPE_IDENTIFIER.
This is my module code:
module fulladder(input logic S, a, b, cin,
output logic s, cout);
wire b_;
assign b_ = b;
always_comb
begin
if (S) begin:
assign b_ = ~b;
end
end
wire p, g;
assign p = a ^ b;
assign g = a & b;
assign s = p ^ cin;
assign cout = g | (p & cin);
endmodule
I'm trying to invert b if S=1 (convert A + B into A - B using 2's-complement).
Is this approach workable? Can anyone see what I'm doing wrong?