4 / 36 · Konzept
Decoders and enable signals
Turn a binary address into one active output.
Lektionen sind frei lesbar. Schreibe dich ein, um deinen Fortschritt zu speichern.
Die Übersetzung ist noch nicht verfügbar. Die Originallektion wird angezeigt. (English)
Learning goals
- Select one of four outputs using two address bits.
- Define the output when the decoder is disabled.
One address selects one output.
A 2-to-4 decoder maps addresses 00, 01, 10 and 11 to 0001, 0010, 0100 and 1000. For y[3:0], the rightmost bit is y[0].
Define y=0000 when en=0. Exactly one output is active only when en=1. Include this qualification in the verification rule.
always_comb begin
y = 4'b0000;
if (en) begin
case (address)
2'b00: y = 4'b0001;
2'b01: y = 4'b0010;
2'b10: y = 4'b0100;
2'b11: y = 4'b1000;
default: y = 4'b0000;
endcase
end
endAssign a value on every path.
A combinational output must be determined by current inputs. Assigning 0000 first defines the disabled path. Missing assignments can unintentionally infer a latch that retains a previous value.
This is a logic excerpt, not a complete top module. Declare the address, en and y ports and widths before using it in a project.
Selbst ausprobieren
What is y[3:0] for en=1 and address=10? What if en=0?
Erklärung lesen
Enabled: 0100, with only y[2] set. Disabled: 0000.