Codiode

Port Width Mismatch

MediumVerilog / SystemVerilogBuildFree7 solved

A port declared narrower than the signal connected to it silently drops the upper bits. An 8-bit arithmetic logic unit computes the bitwise AND of two 8-bit buses to mask control signals. Full 8-bit precision is required; losing the upper nibble corrupts every operation that touches the high byte.

The solution module must accept two 8-bit inputs A and B and drive an 8-bit output Y equal to their bitwise AND. The circuit is purely combinational. There is no clock or reset.

Simulation shows Y = 15 for inputs A = 255 and B = 255. The upper four bits of the output evaluate to zero instead of retaining their expected high state. Inspect the code and correct the fault.

Signal Direction Width Description
A input 8 First operand
B input 8 Second operand
Y output 8 Bitwise AND result; must reflect all 8 bits

Constraints

  • Do not change the top-level module interface.
  • The output must be strictly combinational; no clock or flip-flops.
  • Ensure all internal wire declarations match the widths of the ports they connect to.

Topics

DebugSyntaxVerilog

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.

Free to solve. A Codiode account keeps your progress.

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