SystemVerilog #67 · 2026-11-29 · Signed compare · Easy · about 12 min

A signed reading against an unsigned limit

cmp_gate compares a temperature reading with a limit and tells a controller where the reading stands. The reading is a signed 8-bit number (-128 to 127). The limit comes from a register and is an unsigned 8-bit number (0 to 255). Both are plain numbers, and the comparison is the ordinary one between those two values.

Exactly one of three outputs is 1, with no clock involved (the module is purely combinational):

  • lt: the reading is less than the limit
  • eq: the reading equals the limit
  • gt: the reading is greater than the limit

Examples:

reading limit result
20 100 lt
100 100 eq
101 100 gt
0 0 eq

Fill in cmp_gate in gate.sv.

Write and run your answer in the browser. The hidden tests check it, and it’s free.