Full Adder and the Implicit Net Trap
A full adder computes the sum and carry of two 1-bit inputs plus a carry-in. In a hierarchical multi-bit adder, a typo in any one internal wire name creates a silent disconnection that corrupts all higher-order bit positions without producing a compile error under default Verilog net type rules.
The solution module accepts A, B, and Cin and drives Sum and Cout. All logic is purely combinational and gate-level.
Simulation shows Cout = 0 for inputs A = 1, B = 1, Cin = 0 and A = 0, B = 1, Cin = 1. The carry output fails to assert when expected. The module compiles without errors, but silent logic disconnections exist. Inspect the code and correct the fault.
| Signal | Direction | Width | Description |
|---|---|---|---|
A |
input | 1 | First operand |
B |
input | 1 | Second operand |
Cin |
input | 1 | Carry input |
Sum |
output | 1 | XOR sum of A, B and Cin |
Cout |
output | 1 | Carry output; asserted when two or more inputs are 1 |
Constraints
- All logic is purely combinational; no clock or flip-flops.
- Do not alter the module interface or port definitions.
- You must add
`default_nettype nonebefore the module declaration so the compiler flags any undeclared identifiers. - All internal wires must be explicitly declared.
Topics
Solve this problem
Write the module in Verilog, SystemVerilog or VHDL. Your submission is compiled and simulated against the problem's testbench. You get the waveform back, not a stored answer.
This problem is part of Codiode Pro. The statement above is free to read.
The circuit builder and code editor need a desktop screen. On a phone, read the problem here and open it on a laptop to solve.
Part of Verilog Syntax and Language Basics
Problem 22 of 25 in the Verilog Syntax and Language Basics track.
Related problems
Browse all problems · Verilog practice problems · Learning tracks