Codiode

Parameterized Module Width

MediumVerilog / SystemVerilogBuild3 solved

Write the adder once and let the instantiating module choose its width. A parameter is what makes one RTL file serve an 8-bit bus and a 64-bit bus.

This module computes the arithmetic sum of two unsigned input vectors. The bit width of the inputs and the resulting sum is defined by a parameter named WIDTH. The module must output the sum and a single-bit carry-out flag that asserts when the addition overflows the parameterised width.

Parameter Type Default Description
WIDTH integer 8 Bit width of the operands and sum
Signal Direction Width Description
a input WIDTH First unsigned operand
b input WIDTH Second unsigned operand
sum output WIDTH Arithmetic sum of a and b
cout output 1 Carry out from the most significant bit

Constraints

  • The module must declare a parameter WIDTH with a default value of 8
  • The addition must be purely combinational
  • The cout signal must accurately reflect the carry-out of the most significant bit for the instantiated WIDTH
  • Input vectors a and b must be treated as unsigned integers

Topics

ArithmeticCombinational LogicVerilog BasicsParameters

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 6 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.