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

Verilog Ports verstehen: Inputs, Outputs und Modul-Kommunikation

Ports sind Signale, die als Inputs/Outputs eines Moduls fungieren – die primäre Kommunikationsschnittstelle. Analogie: Modul = fertiger Chip auf PCB, Ports = Pins, nur Weg zur Außenwelt.

Port-Typen

PortBeschreibung
InputModul empfängt Werte von außen
OutputModul sendet Werte nach außen
InoutBidirektional: Senden oder Empfangen
Ports sind standardmäßig Nets vom Typ wire.

Syntax

inout Ports können als Input und Output fungieren.

input  [net_type] [range] list_of_names;
inout  [net_type] [range] list_of_names;
output [net_type] [range] list_of_names;        // getrieben von wire
output [var_type] [range] list_of_names;        // getrieben von Variable

Beispiel

module my_design (
    input wire clk,
    input en,
    input rw,
    inout [15:0] data,
    output int
);
// Design-Verhalten
endmodule

Doppelter Port-Name ist illegal.

Signed Ports

signed Attribut an Port- oder Net/Reg-Deklaration. Implizite Nets = default unsigned.

module (input a, b, output c); // a,b,c default unsigned
endmodule

Wenn Net/Reg-Deklaration signed hat, gilt das auch für den Port.

module (input signed a, b, output c);
    wire a, b;      // signed durch Port-Deklaration
    reg signed c;   // signed durch Reg-Deklaration
endmodule

Port-Variationen nach Verilog-Version

Verilog 1995 (IEEE 1364-1995)

Modul-Deklaration listet nur Port-Namen in Klammern; Richtung/Typ im Modulkörper.

module test (a, b, c);
    input [7:0] a, b;   // a,b sind wires
    output [7:0] c;     // c default wire
    wire [7:0] a, b, c; // explizit als wire (optional)
endmodule

module test (a, b, c);
    input [7:0] a, b;
    output [7:0] c;
    reg [7:0] c;        // Port c zu reg ändern
endmodule

Verilog 2001+ (ANSI-C Style)

Typ/Direction direkt in Port-Liste (ANSI-C Stil).

module test (input [7:0] a, b, output [7:0] c);
// oder explizit:
module test (input wire [7:0] a, input wire [7:0] b, output reg [7:0] c);

Enthält Port-Deklaration Net/Variable-Type → Port vollständig deklariert. Redeclaration illegal.

module test (input [7:0] a, output reg [7:0] e);
    wire signed [7:0] a; // Illegal: a bereits vollständig deklariert
    wire [7:0] e;        // Illegal: e bereits vollständig deklariert
endmodule

Ohne Net/Variable-Type in Port-Deklaration → nachträgliche Deklaration erlaubt.

module test (input [7:0] a, output [7:0] e);
    reg [7:0] e; // OK: net_type war nicht vorher deklariert
endmodule

Verilog

  1. Verilog meistern: Komplettes Tutorial für digitales Schaltungsdesign
  2. Verilog Concatenation meistern: Praktischer Leitfaden
  3. Verilog Assignments verstehen: Typen, Syntax und Best Practices
  4. Verilog Blocking vs. Non-Blocking: Wichtige Unterschiede erklärt
  5. Verilog Functions meistern für effizientes RTL-Design
  6. Verilog Tasks verstehen: Functions vs. Tasks, Syntax und Verwendung
  7. Verilog Clock Generator: Design & Implementierungsleitfaden
  8. Verilog Math Functions meistern für effizientes Hardware-Design
  9. Verilog $timeformat meistern: Präzision und Anzeigesteuerung
  10. Verilog Timescales an jedem Scope verstehen und ausgeben