Menu
Coddy logo textTech

AND OR NOT Gatter

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

Diese Lektion behandelt die drei grundlegendsten Logikgatter: AND, OR und NOT. Diese Gatter bilden die Grundlage des digitalen Logikentwurfs.

AND-Gatter

Das AND-Gatter gibt nur dann 1 aus, wenn alle Eingänge 1 sind.

Wahrheitstabelle (2 Eingänge):

about
000
010
100
111

Verilog-Gatter-Primitiv:

and(out, a, b);

Entsprechung als kontinuierliche Zuweisung:

assign out = a & b;

ODER-Gatter

Das ODER-Gatter gibt 1 aus, wenn mindestens ein Eingang 1 ist.

Wahrheitstabelle (2 Eingänge):

about
000
011
101
111

Verilog-Gatter-Primitiv:

or(out, a, b);

Äquivalent mit kontinuierlicher Zuweisung:

assign out = a | b;

NOT-Gatter

Das NOT-Gatter gibt das Gegenteil seines einzelnen Eingangs aus. Es wird auch als Inverter bezeichnet.

Wahrheitstabelle:

aout
01
10

Verilog-Gate-Primitiv:

not(out, a);

Äquivalent mit kontinuierlicher Zuweisung:

assign out = ~a;

Mehrere Eingänge

AND- und OR-Gatter können mehr als 2 Eingänge haben:

and(out, a, b, c);     // 3-Eingang-AND (out = a & b & c)
or(out, x, y, z, w);   // 4-Eingang-OR

NOT-Gatter haben immer genau 1 Eingang.

Code-Beispiel

module and_or_not (
  input a, b,
  output and_out,
  output or_out,
  output not_out
);
  and(and_out, a, b);   // AND-Gatter
  or(or_out, a, b);     // OR-Gatter
  not(not_out, a);      // NOT-Gatter (Inverter)
endmodule
challenge icon

Aufgabe

Fügen Sie die fehlenden Gate-Primitive basierend auf den Aufgaben hinzu.

Was zu tun ist:

  1. Erstellen Sie ein AND-Gate mit dem Ausgang and_result und den Eingängen p und q
  2. Erstellen Sie ein OR-Gate mit dem Ausgang or_result und den Eingängen p und q
  3. Erstellen Sie ein NOT-Gate mit dem Ausgang not_result und dem Eingang p

Spickzettel

Grundlegende Logikgatter in Verilog unter Verwendung von Gatter-Primitiven und kontinuierlicher Zuweisung:

GatterPrimitivZuweisungAusgang ist 1, wenn...
ANDand(out, a, b);assign out = a & b;Alle Eingänge 1 sind
ORor(out, a, b);assign out = a | b;Mindestens ein Eingang 1 ist
NOTnot(out, a);assign out = ~a;Der Eingang 0 ist

AND und OR unterstützen mehr als 2 Eingänge; NOT hat immer genau 1 Eingang:

and(out, a, b, c);   // 3-input AND
or(out, a, b, c, d); // 4-input OR
module example (input a, b, output and_out, or_out, not_out);
  and(and_out, a, b);
  or(or_out, a, b);
  not(not_out, a);
endmodule

Probier es selbst

module gates_challenge (
  input p,
  input q,
  output and_result,
  output or_result,
  output not_result
);
  
  // TODO: AND-Gatter hinzufügen (and_result = p & q)
  
  // TODO: OR-Gatter hinzufügen (or_result = p | q)
  
  // TODO: NOT-Gatter hinzufügen (not_result = ~p)

endmodule
quiz iconTeste dich selbst

Diese Lektion enthält ein kurzes Quiz. Starte die Lektion, um es zu beantworten und deinen Fortschritt zu speichern.

Alle Lektionen in Grundlagen