Codiode

ROM Inference via Case

MediumVerilog / SystemVerilogBuildFree

A small lookup table, such as 16 points of a sine wave, can be a case statement. Synthesis turns it into logic, with no RAM block needed.

The module acts as an asynchronous read only memory containing a 16-sample sine wave. It receives a 4-bit address representing the phase index and outputs the corresponding 8-bit amplitude. The output must react immediately to any change in the address input using purely combinational logic.

The memory must contain the following exact values for each address:

  • addr = 0: data = 128
  • addr = 1: data = 176
  • addr = 2: data = 218
  • addr = 3: data = 246
  • addr = 4: data = 255
  • addr = 5: data = 246
  • addr = 6: data = 218
  • addr = 7: data = 176
  • addr = 8: data = 128
  • addr = 9: data = 79
  • addr = 10: data = 38
  • addr = 11: data = 9
  • addr = 12: data = 0
  • addr = 13: data = 9
  • addr = 14: data = 38
  • addr = 15: data = 79
Signal Direction Width Description
addr input 4 Phase index for the lookup table
data output 8 Amplitude value corresponding to the phase index; purely combinational

Constraints

  • The circuit must be purely combinational with no clock or reset dependencies
  • All 16 possible input addresses must map to the exact specified integer values
  • The design must not infer latches; all branches must be explicitly defined

Topics

MemoryCombinational LogicDSPSynthesis Intuition

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 Synthesis Intuition

Problem 10 of 25 in the Synthesis Intuition track.

Related problems

Browse all problems · Verilog practice problems · Learning tracks

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