CodiodeCodiode
Home
Problem Solving
Skill Tracks
My Assignments
Contests
Leaderboard
Community
Settings
Codiode/Problems/Combinational Logic

Explicit Binary Literals

EasyVerilog / SystemVerilogBuildFree1 solved

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 enable is 0, the output must be 00000000 regardless of the mode value.
  • All generated patterns must be assigned using explicitly sized binary literals.

Topics

CombinationalSyntaxConstants

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.

Sign in to solve

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.

Related problems

  • Single Continuous AssignmentEasy
  • Basic Vector ConcatenationEasy
  • Ternary Operator MuxEasy
  • Underscores for ReadabilityEasy
  • Left Hand Side ConcatenationEasy
  • Inout Port MechanicsEasy
  • Hexadecimal and Octal LiteralsEasy
  • Vector Port EndiannessEasy

Browse all problems · Learning tracks