Codiode

Addition with Carry Out

MediumVerilog / SystemVerilogBuild4 solved

Add two 8-bit numbers and the answer can need 9 bits. Drop the ninth and 200 + 100 quietly becomes 44.

This module takes two 8-bit unsigned integers and computes their sum. To prevent overflow, the result is stored in a 9-bit vector. The most significant bit of this vector acts as the carry out flag, while the lower 8 bits represent the standard addition sum.

This circuit is strictly combinational. There are no clocks, resets, or sequential elements.

Signal Direction Width Description
a input 8 First unsigned operand
b input 8 Second unsigned operand
sum output 9 The 9-bit sum of a and b; sum[8] captures the carry out

Constraints

  • Output sum must be exactly 9 bits wide
  • The circuit must be purely combinational
  • Unsigned arithmetic must be used for all calculations

Topics

CombinationalArithmeticOperators

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 12 of 25 in the Verilog Syntax and Language Basics track.

Related problems

Browse all problems · Verilog practice problems · Learning tracks

Solve this on a laptopSend yourself the link and continue there.