3

Binary addition on A and B and outputs it along with proper carry bit. I'm not sure how to implement the carry bit

A and B are 4 bit inputs

C is 1 bit output that is used for the carry bit

module addop(C , O , A , B);
   input [3:0] A;
   input [3:0] B;
   output [3:0] O;
   output       C;

   assign C1 = A[0] + B[0];
   assign C2 = A[0] + B[1];
endmodule
0

1 Answer 1

6

You may want to use a concatenation operator {} here.

module addop(C, O, A, B);
   input [3:0] A;
   input [3:0] B;
   output [3:0] O;
   output       C;

   assign {C, O} = A + B;
endmodule

Your synthesis tool will be responsible in converting them into logic gates.

See this question which is related to concatenation:

What do curly braces mean in Verilog?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.