4-bit Priority Encoder
Problem Description
Implement a 4-bit priority encoder that converts the highest priority active input bit to a binary code.
Module Interface
- Inputs:
in
: 4-bit input data
- Outputs:
out
: 2-bit encoded outputvalid
: 1-bit valid signal
Expected Behavior
- Priority (highest to lowest): in[3] > in[2] > in[1] > in[0]
- When in[3] = 1: out = 11, valid = 1
- When in[3] = 0 and in[2] = 1: out = 10, valid = 1
- When in[3:2] = 00 and in[1] = 1: out = 01, valid = 1
- When in[3:1] = 000 and in[0] = 1: out = 00, valid = 1
- When in = 0000: out = 00, valid = 0
No Waveform Data
Submit your Verilog code using Cmd+Enter to see the simulation results and waveform visualization.