Menu
Coddy logo textTech

Decoder Design

Teil des Abschnitts Grundlagen der Verilog-Journey von Coddy. Lektion 85 von 90.

challenge icon

Aufgabe

Ein decoder nimmt eine Binärzahl als input und schaltet basierend auf dieser Zahl genau einen output ein. Der eingeschaltete output wird als "one-hot" bezeichnet, weil nur ein Bit aktiv (1) und alle anderen kalt (0) sind.

Wahrheitstabelle (2-zu-4-Decoder)

Input (in)out0out1out2out3
001000
010100
100010
110001

Modulschnittstelle

PortRichtungBreiteBeschreibung
ininput2 BitsBinärer input (0 bis 3)
out0output1 BitAktiv, wenn in = 00
out1output1 BitAktiv, wenn in = 01
out2output1 BitAktiv, wenn in = 10
out3output1 BitAktiv, wenn in = 11

Deine Aufgabe besteht darin, das folgende Modul mithilfe einer case-Anweisung zu vervollständigen.

Aufgabe:

  1. Wenn in = 2'b00, out0 = 1, alle others 0
  2. Wenn in = 2'b01, out1 = 1, alle others 0
  3. Wenn in = 2'b10, out2 = 1, alle others 0
  4. Wenn in = 2'b11, out3 = 1, alle others 0

Probier es selbst

module decoder (
  input [1:0] in,
  output reg out0,
  output reg out1,
  output reg out2,
  output reg out3
);
  
  // TODO: Füge always @(*)-Block mit case (in) hinzu
  // 2'b00: out0=1, andere 0
  // 2'b01: out1=1, andere 0
  // 2'b10: out2=1, andere 0
  // 2'b11: out3=1, andere 0

endmodule

Alle Lektionen in Grundlagen

Übe selbstständig: Online-Verilog-Compiler