Industrielle Fertigung
Industrielles Internet der Dinge | Industrielle Materialien | Gerätewartung und Reparatur | Industrielle Programmierung |
home  MfgRobots >> Industrielle Fertigung >  >> Industrial programming >> Verilog

Gate-Level Modeling: Vom Hardware-Schaltplan zum Verilog-Code

Die meisten digitalen Designs werden auf einer höheren Abstraktionsebene wie RTL durchgeführt, obwohl es manchmal intuitiver ist, kleinere deterministische Schaltungen auf einer niedrigeren Ebene mit kombinatorischen Elementen wie and und or zu bauen. Modeling auf dieser Ebene wird normalerweise Gate-Level Modeling genannt, da es Gatter involviert und eine Eins-zu-Eins-Beziehung zwischen einem Hardware-Schaltplan und dem Verilog-Code hat.

Verilog unterstützt einige grundlegende Logikgatter, die als Primitives bekannt sind, da sie wie Module instanziiert werden können, da sie bereits vordefiniert sind.

And/Or/Xor-Gatter

Diese Primitives implementieren ein UND- und ein ODER-Gatter, das viele skalare Eingänge annimmt und einen einzelnen skalaren Ausgang liefert. Der erste Terminal in der Argumentliste dieser Primitives ist der Ausgang, der aktualisiert wird, wann immer sich einer der Eingänge ändert.

module gates (
  input a, b,
  output c, d, e
);
  and (c, a, b); // c ist der Ausgang, a und b sind Eingänge
  or (d, a, b);  // d ist der Ausgang, a und b sind Eingänge
  xor (e, a, b); // e ist der Ausgang, a und b sind Eingänge
endmodule
module tb;
  reg a, b;
  wire c, d, e;
  integer i;
  gates u0 (.a(a), .b(b), .c(c), .d(d), .e(e));
  initial begin
    {a, b} = 0;
    $monitor ("[T=%0t a=%0b b=%0b c(and)=%0b d(or)=%0b e(xor)=%0b", $time, a, b, c, d, e);
    for (i = 0; i < 10; i = i+1) begin
      #1 a <= $random; b <= $random;
    end
  end
endmodule

Simulationslog:

ncsim> run
[T=0 a=0 b=0 c(and)=0 d(or)=0 e(xor)=0
[T=1 a=0 b=1 c(and)=0 d(or)=1 e(xor)=1
[T=2 a=1 b=1 c(and)=1 d(or)=1 e(xor)=0
[T=4 a=1 b=0 c(and)=0 d(or)=1 e(xor)=1
[T=5 a=1 b=1 c(and)=1 d(or)=1 e(xor)=0
[T=6 a=0 b=1 c(and)=0 d(or)=1 e(xor)=1
[T=7 a=1 b=0 c(and)=0 d(or)=1 e(xor)=1
[T=10 a=1 b=1 c(and)=1 d(or)=1 e(xor)=0
ncsim: *W,RNQUIE: Simulation is complete.

Nand/Nor/Xnor-Gatter

Die Inversen all der oben genannten Gatter sind ebenfalls in Form von nand, nor und xnor verfügbar. Dasselbe Design wie oben wird wiederverwendet, mit der Ausnahme, dass die Primitives durch ihre inversen Versionen ersetzt werden.

module gates (
  input a, b,
  output c, d, e
);
  // nand, nor, xnor statt and, or und xor verwenden
  nand (c, a, b); // c ist der Ausgang, a und b sind Eingänge
  nor (d, a, b);  // d ist der Ausgang, a und b sind Eingänge
  xnor (e, a, b); // e ist der Ausgang, a und b sind Eingänge
endmodule
module tb;
  reg a, b;
  wire c, d, e;
  integer i;
  gates u0 (.a(a), .b(b), .c(c), .d(d), .e(e));
  initial begin
    {a, b} = 0;
    $monitor ("[T=%0t a=%0b b=%0b c(nand)=%0b d(nor)=%0b e(xnor)=%0b", $time, a, b, c, d, e);
    for (i = 0; i < 10; i = i+1) begin
      #1 a <= $random; b <= $random;
    end
  end
endmodule

Simulationslog:

ncsim> run
[T=0 a=0 b=0 c(nand)=1 d(nor)=1 e(xnor)=1
[T=1 a=0 b=1 c(nand)=1 d(nor)=0 e(xnor)=0
[T=2 a=1 b=1 c(nand)=0 d(nor)=0 e(xnor)=1
[T=4 a=1 b=0 c(nand)=1 d(nor)=0 e(xnor)=0
[T=5 a=1 b=1 c(nand)=0 d(nor)=0 e(xnor)=1
[T=6 a=0 b=1 c(nand)=1 d(nor)=0 e(xnor)=0
[T=7 a=1 b=0 c(nand)=1 d(nor)=0 e(xnor)=0
[T=10 a=1 b=1 c(nand)=0 d(nor)=0 e(xnor)=1
ncsim: *W,RNQUIE: Simulation is complete.

Diese Gatter können mehr als zwei Eingänge haben.

module gates (
  input a, b, c, d,
  output x, y, z
);
  and (x, a, b, c, d); // x ist der Ausgang, a, b, c, d sind Eingänge
  or (y, a, b, c, d);  // y ist der Ausgang, a, b, c, d sind Eingänge
  nor (z, a, b, c, d); // z ist der Ausgang, a, b, c, d sind Eingänge
endmodule
module tb;
  reg a, b, c, d;
  wire x, y, z;
  integer i;
  gates u0 (.a(a), .b(b), .c(c), .d(d), .x(x), .y(y), .z(z));
  initial begin
    {a, b, c, d} = 0;
    $monitor ("[T=%0t a=%0b b=%0b c=%0b d=%0b x=%0b y=%0b x=%0b", $time, a, b, c, d, x, y, z);
    for (i = 0; i < 10; i = i+1) begin
      #1 a <= $random; b <= $random; c <= $random; d <= $random;
    end
  end
endmodule

Simulationslog:

ncsim> run
[T=0 a=0 b=0 c=0 d=0 x=0 y=0 x=1
[T=1 a=0 b=1 c=1 d=1 x=0 y=1 x=0
[T=2 a=1 b=1 c=1 d=0 x=0 y=1 x=0
[T=3 a=1 b=1 c=0 d=1 x=0 y=1 x=0
[T=4 a=1 b=0 c=1 d=0 x=0 y=1 x=0
[T=5 a=1 b=0 c=1 d=1 x=0 y=1 x=0
[T=6 a=0 b=1 c=0 d=0 x=0 y=1 x=0
[T=7 a=0 b=1 c=0 d=1 x=0 y=1 x=0
[T=8 a=1 b=1 c=1 d=0 x=0 y=1 x=0
[T=9 a=0 b=0 c=0 d=1 x=0 y=1 x=0
[T=10 a=0 b=1 c=1 d=1 x=0 y=1 x=0
ncsim: *W,RNQUIE: Simulation is complete.

Buf/Not-Gatter

Diese Gatter haben nur einen skalaren Eingang und einen oder mehrere Ausgänge. buf steht für einen Puffer und überträgt den Wert einfach vom Eingang zum Ausgang ohne Änderung der Polarität. not steht für einen Inverter, der die Polarität des Signals an seinem Eingang invertiert. Eine 0 an seinem Eingang ergibt also eine 1 und umgekehrt.

module gates (
  input a,
  output c, d
);
  buf (c, a); // c ist der Ausgang, a ist Eingang
  not (d, a); // d ist der Ausgang, a ist Eingang
endmodule
module tb;
  reg a;
  wire c, d;
  integer i;
  gates u0 (.a(a), .c(c), .d(d));
  initial begin
    a = 0;
    $monitor ("[T=%0t a=%0b c(buf)=%0b d(not)=%0b", $time, a, c, d);
    for (i = 0; i < 10; i = i+1) begin
      #1 a <= $random;
    end
  end
endmodule

Simulationslog:

xcelium> run
[T=0 a=0 c(buf)=0 d(not)=1
[T=2 a=1 c(buf)=1 d(not)=0
[T=8 a=0 c(buf)=0 d(not)=1
[T=9 a=1 c(buf)=1 d(not)=0
xmsim: *W,RNQUIE: Simulation is complete.

Der letzte Terminal in der Port-Liste verbindet sich mit dem Eingang des Gatters und alle anderen Terminals verbinden sich mit dem Ausgangsport des Gatters. Hier ist ein Beispiel für einen Mehrfach-Ausgangs-Puffer, obwohl er selten verwendet wird.

module gates (
  input a,
  output c, d
);
  not (c, d, a); // c,d ist der Ausgang, a ist Eingang
endmodule

Simulationslog:

xcelium> run
[T=0 a=0 c=1 d=1
[T=2 a=1 c=0 d=0
[T=8 a=0 c=1 d=1
[T=9 a=1 c=0 d=0
xmsim: *W,RNQUIE: Simulation is complete.

Bufif/Notif

Puffer und Inverter mit einem zusätzlichen Steuersignal zum Aktivieren des Ausgangs sind über bufif- und notif-Primitives verfügbar. Diese Gatter haben nur dann einen gültigen Ausgang, wenn das Steuersignal aktiviert ist, andernfalls ist der Ausgang in High-Impedanz. Es gibt zwei Versionen davon: eine mit normaler Polarität des Steuersignals, angezeigt durch eine 1 wie bufif1 und notif1, und eine zweite mit invertierter Polarität des Steuersignals, angezeigt durch eine 0 wie bufif0 und notif0.

Verilog

  1. Einfaches NAND-Gatter mit dem 4011 IC entwerfen und verifizieren
  2. JFETs verstehen: Gate-Stromrichtung & N- vs. P-Kanal
  3. Integrierte Schaltungen: Grundlagen digitaler Logikgatter
  4. Variablengültigkeitsbereich in C# verstehen: Klassen-, Methoden- und Blockebene
  5. Design-Abstraktionsschichten: Klare Anleitung zur Chip-Architektur
  6. Praktisches Verilog Gate-Level Design: AND, OR, NOT Gatter & 2x1 Multiplexer
  7. Gate Delays in Verilog verstehen: Genaues Timing für zuverlässige Digitaldesigns
  8. Fortgeschrittenes Switch-Level Modeling in Verilog
  9. Nivellierlatten (Level Staffs): Definition, Einsatz und Typen
  10. Drehmaschine präzise ausrichten: Professionelle Anleitung zum Abrichten