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
| Port | Beschreibung |
|---|---|
| Input | Modul empfängt Werte von außen |
| Output | Modul sendet Werte nach außen |
| Inout | Bidirektional: Senden oder Empfangen |
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
- Verilog meistern: Komplettes Tutorial für digitales Schaltungsdesign
- Verilog Concatenation meistern: Praktischer Leitfaden
- Verilog Assignments verstehen: Typen, Syntax und Best Practices
- Verilog Blocking vs. Non-Blocking: Wichtige Unterschiede erklärt
- Verilog Functions meistern für effizientes RTL-Design
- Verilog Tasks verstehen: Functions vs. Tasks, Syntax und Verwendung
- Verilog Clock Generator: Design & Implementierungsleitfaden
- Verilog Math Functions meistern für effizientes Hardware-Design
- Verilog $timeformat meistern: Präzision und Anzeigesteuerung
- Verilog Timescales an jedem Scope verstehen und ausgeben