目的:
verilog記述の基本構造を記す。基本構造:
module <モジュール名> (
ポートリスト
) ;
パラメータ宣言 (PARAMETER)
ネット宣言 (wire, reg)
論理記述
( assign, always, module接続, 等)
endmodule
1つのモジュール で 1つのファイル(*.v) とするのが良い様に思う。
例:
2つの入力信号 の AND を 2段の FF を通して出力。//
// Sample module
//
// Module Name : test
// Version : 0.00
//
module test( // Module name : test
rst, // port list
clk,
in1,
in2,
out
) ;
// port declaration ----------------
input rst ;
input clk ;
input in1 ;
input in2 ;
output out ;
// parameter declaration -----------
parameter DLY = 1 ;
// internal signal declaration -----
wire w_and ;
reg r_and_lt ;
reg r_and_lt2 ;
// logical description -------------
assign w_and = in1 & in2 ;
always @(posedge clk or posedge rst)
if (rst) begin
r_and_lt <= #DLY 1'b0 ;
r_and_lt2 <= #DLY 1'b0 ;
end
else begin
r_and_lt <= #DLY w_and ;
r_and_lt2 <= #DLY r_and_lt ;
end
assign out = r_and_lt ;
endmodule
0 件のコメント:
コメントを投稿