Explicit Binary Literals
Pattern generators are frequently used in hardware testbenches and Built-In Self-Test (BIST) engines to stimulate datapath logic with known bit patterns. Hardcoding decimal values obscures the shape of these test vectors, so explicit binary literals are heavily preferred to document the hardware intent.
The module acts as a combinational test pattern generator. It receives a 1-bit enable and a 3-bit mode selector. When enable is 0, the output pattern is always 00000000. When enable is 1, the module outputs a specific 8-bit binary pattern on the pattern port based on the value of mode:
- Mode 0:
00000000(All zeros) - Mode 1:
10101010(Alternating bits, starting with 1) - Mode 2:
11110000(Upper nibble set) - Mode 3:
00001111(Lower nibble set) - Mode 4:
11001100(Alternating pairs) - Mode 5:
00110011(Inverted alternating pairs) - Mode 6:
11111111(All ones) - Mode 7:
10000001(MSB and LSB set)
This is a purely combinational circuit. There is no clock or reset involved.
| Signal | Direction | Width | Description | |--------|-----------|-------|-------------| | enable | input | 1 | Active-high enable signal | | mode | input | 3 | Selects the test pattern to output | | pattern | output | 8 | The generated 8-bit test pattern |
Constraints
- The module must be purely combinational.
- The output must be exactly 8 bits wide.
- If
enableis 0, the output must be00000000regardless of themodevalue. - All generated patterns must be assigned using explicitly sized binary literals.
Topics
Solve this problem
Write the module in Verilog, SystemVerilog or VHDL. Your submission is compiled and simulated against a real 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.