I'm trying to write a module Inc_dec(L) that receives and number a, and two bits inc and dec and updates the sum and overflow/underflow according to the sum of a+inc+dec. In case of an overflow the sum is updated to 0, if an underflow occurs, the sum is L-1, otherwise no change.
Here is my code:
module Inc_Dec(a, inc, dec, sum, overflow, underflow);
parameter L = 10;
parameter N = $clog2(L);
input [N-1:0] a;
input inc, dec;
output reg [N-1:0] sum;
output overflow, underflow;
wire [1:0] sum_inc;
wire [N-1:0] sum_adder;
wire co;
wire ci;
reg dec_exp;
reg dec_reg;
reg of;
reg uf;
assign overflow = of;
assign underflow = uf;
//assign sum = sum_adder;
Adder #(2) add1 ({0,inc}, {dec_exp,dec_reg}, 0, sum_inc, co);
Adder #(N) add2 (a, { {(N-2){1'b0}},sum_inc }, 0, sum_adder, co);
always @(*) begin
if (dec > 0) begin
dec_reg = 1;
dec_exp = 1;
end
else begin
dec_reg = 0;
dec_exp = 0;
` end
if({co,sum_adder} >= L) begin
of = 1;
uf = 0;
sum = 0;
end
else if({co,sum_adder} < 0) begin
uf = 1;
of = 0;
sum = L-1;
end
else begin
of = 0;
uf = 0;
sum = sum_adder[N-1:0];
end
end
endmodule
But I'm getting a syntax error near endmodule, plus some other errors I don't understand such as: Macro is not defined. can anyone help me find the problem?