Octal-to-Binary Encoder
beginner · combinational · 45 XP
Sign in to write your solution, run it in the simulator and submit it for grading.
Sign in or create a free account →Problem
Octal-to-Binary Encoder
An encoder converts a **one-hot** input to a compact binary code. The inverse of a decoder.
Input: 8-bit one-hot `in[7:0]` (exactly one bit is high). Output: 3-bit binary `out[2:0]`.
| in (one-hot) | out |
|---------------|-----|
| 8'b00000001 | 000 |
| 8'b00000010 | 001 |
| 8'b00000100 | 010 |
| 8'b00001000 | 011 |
| 8'b00010000 | 100 |
| 8'b00100000 | 101 |
| 8'b01000000 | 110 |
| 8'b10000000 | 111 |
Use `case(in)` with one-hot input patterns. Default output: `3'b000`.
Constraints
- Use case inside always @(*). Include a default branch.
Examples
Input: in=8'b00001000
Output: out=3'b011 (decimal 3)
Input: in=8'b10000000
Output: out=3'b111 (decimal 7)
Common questions
- What does the Octal-to-Binary Encoder problem ask you to build?
- Octal-to-Binary Encoder An encoder converts a **one-hot** input to a compact binary code. The inverse of a decoder. Input: 8-bit one-hot `in[7:0]` (exactly one bit is high). Output: 3-bit binary `out[2:0]`.
- What constraints does Octal-to-Binary Encoder have?
- Use case inside always @(*). Include a default branch.
- What is an example input and output for Octal-to-Binary Encoder?
- Input in=8'b00001000 gives output out=3'b011 (decimal 3).
- Which Verilog concepts does Octal-to-Binary Encoder practise?
- combinational, encoder, case, always, one-hot.