Codiode

Parameterized Equality Comparator

EasyVerilog / SystemVerilogBuild2 solved

Cache tag checks, match filters and branch conditions all reduce to "are these two vectors equal?". One parameterized comparator covers every width.

The module compares two input vectors of identical, parameterized width. It asserts a single-bit output high if all corresponding bits in the two input vectors are identical. The output is driven low if any bit position differs.

This is a purely combinational circuit. There is no clock or reset. The output must reflect the comparison of the current inputs at all times.

Signal Direction Width Description
WIDTH parameter integer Bit-width of the inputs; defaults to 8
a input WIDTH First operand
b input WIDTH Second operand
eq output 1 Asserts to 1 if a and b are strictly equal; 0 otherwise

Constraints

  • The module must correctly handle any positive integer value for WIDTH, including 1.
  • The output eq must be exactly 1 bit wide regardless of the input width.
  • The design must be purely combinational with no latches or registers.
  • The default value for the WIDTH parameter must be 8.

Topics

combinationalarithmeticparameterization

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 Combinational RTL

Problem 6 of 15 in the Combinational RTL track.

Related problems

Browse all problems · Verilog practice problems · Learning tracks

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