Verilog practice / Problem 6
4-bit adder with carry
Add the 4-bit numbers a and b and the carry in cin. The low 4 bits of the result go to sum and the fifth bit goes to cout. For example, 9 + 8 + 0 = 17, so sum = 1 and cout = 1.
Ports
| Name | Direction | Bits |
|---|---|---|
a | input | 4 |
b | input | 4 |
cin | input | 1 |
sum | output | 4 |
cout | output | 1 |
How it's checked
The test tries the input combinations and checks every output for each one.
Stuck? Read the lesson Half, full and ripple adders.
add4.vCtrl + Enter runs