ROM Inference via Case
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= 128addr= 1:data= 176addr= 2:data= 218addr= 3:data= 246addr= 4:data= 255addr= 5:data= 246addr= 6:data= 218addr= 7:data= 176addr= 8:data= 128addr= 9:data= 79addr= 10:data= 38addr= 11:data= 9addr= 12:data= 0addr= 13:data= 9addr= 14:data= 38addr= 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
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