工業製造
産業用モノのインターネット | 工業材料 | 機器のメンテナンスと修理 | 産業プログラミング |
home  MfgRobots >> 工業製造 >  >> Industrial programming >> Verilog

Verilog ポート

ポートは、特定のモジュールへの入力および出力として機能する一連の信号であり、モジュールと通信する主要な方法です。モジュールを PCB に配置された加工済みチップと考えると、チップと通信する唯一の方法がそのピンを介することであることが明らかになります。ポートはピンのようなもので、外部からの信号を送受信するために設計によって使用されます。

港の種類

ポート 説明
入力 設計モジュールは、input を使用して外部からのみ値を受け取ることができます ポート
出力 設計モジュールは、output を使用して外部に値を送信することしかできません。 ポート
インアウト 設計モジュールは、inout を使用して値を送信または受信できます。 ポート

ポートはデフォルトでタイプ wire のネットと見なされます .

構文

inout として宣言されたポート 入力と出力の両方として機能できます。

  
  
	input  [net_type] [range] list_of_names; 	// Input port
	inout  [net_type] [range] list_of_names; 	// Input & Output port
	output [net_type] [range] list_of_names; 	// Output port driven by a wire
	output [var_type] [range] list_of_names; 	// Output port driven by a variable

  

以下に示すコードでは、3 つの input があります。 ポート、1 つの output ポートと 1 つの inout ポート。

  
  
module  my_design ( input wire			clk,
                    input 					en,
                    input 					rw,
                    inout [15:0]	  data,
                    output 					int );
                    
	// Design behavior as Verilog code
	
endmodule

  

同じ名前を使用することは違法です 複数のポート用。

  
  
	input  aport;         // First declaration - valid
	input  aport;         // Error - already declared
	output aport;         // Error - already declared

  

署名付きポート

signed 属性は、ポート宣言または net/reg 宣言、またはその両方に添付できます。暗黙的なネットはデフォルトで 符号なし です .

  
  
module ( input      a, 
                    b,
         output     c);
		 
	// ports a, b, and c are by default unsigned
endmodule

  

net/reg 宣言のいずれかに signed がある場合 属性の場合、もう一方も署名済みと見なされます。

  
  
	module ( input signed a, b,
	         output c);
		wire a, b;          // a, b are signed from port declaration
		reg signed c;       // c is signed from reg declaration
	endmodule

  

港のバリエーション

Verilog 1995

Verilog にはいくつかの改訂が加えられており、1995 年のオリジナルの IEEE バージョンでは、ポート宣言に次の方法がありました。ここで、モジュール宣言は、最初に角括弧内にポートの名前をリストし、次にモジュールの本体内で後で定義されたポートの方向をリストする必要がありました.

  
  	
module test (a, b, c);
	
	input 	[7:0] a;            // inputs "a" and "b" are wires
	input 	[7:0] b;  
	output 	[7:0] c; 			// output "c" by default is a wire
	
	// Still, you can declare them again as wires to avoid confusion
	wire 	[7:0] a;
	wire 	[7:0] b;
	wire 	[7:0] c;
endmodule
	
	
module test (a, b, c);
	
	input  [7:0] a, b;
	output [7:0] c;           // By default c is of type wire
	
	// port "c" is changed to a reg type
	reg    [7:0] c;           
endmodule
  

Verilog 2001 以降

ANSI-C スタイルのポート命名は 2001 年に導入され、ポート リスト内でタイプを指定できるようになりました。

  
  
module test ( input [7:0]	a,
                            b, 		// "b" is considered an 8-bit input
              output [7:0]  c);
			  
	// Design content			  
endmodule

module test ( input wire [7:0]	a, 	
              input wire [7:0]  b, 		
              output reg [7:0]  c);
			  
	// Design content
endmodule

  

ポート宣言にネットまたは変数タイプが含まれている場合、そのポートは完全に宣言されていると見なされます。ネットまたは変数の型宣言で同じポートを再宣言することは違法です。

  
  
module test ( input      [7:0] a,       // a, e are implicitly declared of type wire
	          output reg [7:0] e );

   wire signed [7:0] a;     // illegal - declaration of a is already complete -> simulator dependent
   wire        [7:0] e;     // illegal - declaration of e is already complete
   
   // Rest of the design code
endmodule

  

ポート宣言にネットまたは変数タイプが含まれていない場合、ポートはネットまたは変数タイプ宣言で再度宣言できます。

  
  
module test ( input      [7:0] a,
              output     [7:0] e);
	              
     reg [7:0] e;              // Okay - net_type was not declared before
     
     // Rest of the design code
endmodule

  

Verilog

  1. Verilog チュートリアル
  2. Verilog 連結
  3. Verilog 割り当て
  4. Verilog ブロッキング &ノンブロッキング
  5. Verilog 関数
  6. Verilog タスク
  7. Verilog クロック ジェネレーター
  8. Verilog 数学関数
  9. Verilog タイムフォーマット
  10. Verilog タイムスケール スコープ
  11. Verilog ファイルの IO 操作