中村/第一回
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
[[中村/春プロジェクト]]
*第1回 2007年4月号 全加算器をHDLで設計してみよう [#x8749e93]
**概要 [#l91c0f76]
-Verilog HDLを用いて回路の作成(デザイン入力)から、シミュレーションまでの流れを理解する
-1bit adderの作成
**Verilog HDL記述の解説 [#l91c0f76]
***1bit adder [#sc9e89df]
-fa.v
1 module fa(a, b, cin, s , cout); //モジュール宣言
2
3 input a, b, cin;
4 output s, cout; //ポート宣言
5 wire a, b, cin, s, cout;
6
7 assign s = a ^ b ^ cin;
8 assign cout = (a & b) | (b & cin) | (cin & a);
9
10 endmodule // fa //モジュールの終り
|記号|`|&|l|^|`^|
|CENTER:説明|NOT|AND|OR|XOR|XNOR|
***テンスベンチ [#l28d0caf]
-fa_tb.v
1 `timescale 1ns / 1ps
2
3 // include needed module
4 `include "fa.v"
5
6 module fa_tb;
7
8 reg a, b, cin; //レジスタ宣言
9 wire s, cout;
10
11 fa fa0(.a(a), .b(b), .cin(cin), .s(s), .cout(cout)); //インスタンス宣言
12
13 initial begin
14 // output waveform
15 $dumpfile("fa_tb_wf.vcd"); // file name
16 $dumpvars(0, fa_tb); // starting time, test module name
17
18 // decide the input signals
19 a = 0; b = 0; cin = 0;
20 #100 a = 1; b = 0; cin = 0;
21 #100 a = 0; b = 1; cin = 0;
22 #100 a = 1; b = 1; cin = 0;
23 #100 a = 0; b = 0; cin = 1;
24 #100 a = 1; b = 0; cin = 1;
25 #100 a = 0; b = 1; cin = 1;
26 #100 a = 1; b = 1; cin = 1;
27 #100 a = 0; b = 0; cin = 0;
28 $finish;
29 end // initial begin
30 initial
31 $monitor($time, ,"a=%b, b=%b, cin=%b, s=%b, cout=%b",a,b,cin,s,cout);
32 endmodule // fa_tb
-1行目の`timescale 1ns/psは、シミュレーションの時間設定をしている。書式は-`timescale [単位時間] / [精度]~
-4行目の`include "fa.v"は、シミュレーションするファイルを読み込む~
-11行目は、インスタンス宣言をしている。インスタンス宣言の書式は[モジュール名] [インスタンス名](.[ポート名]([接続信号名]), …);~
-15行目の$dumpfile("fa_tb_wf.vcd");は、指定したファイルへダンプファイルを出力する~
-16行目の$dumpvars(0, fa_tb); は、指定したモジュールまたはインスタンスをダンプの対象とする~
-31行目の$monitorは、指定したオブジェクトの値が変わるたびに出力する
**シミュレーション [#ted2d979]
-simvisionでvcdファイルを開いて波形を確認する
-1bit adderは真理値表通りの結果が出た
**感想 [#q98482ab]
新しい言語を学ぶのは難しい
終了行:
[[中村/春プロジェクト]]
*第1回 2007年4月号 全加算器をHDLで設計してみよう [#x8749e93]
**概要 [#l91c0f76]
-Verilog HDLを用いて回路の作成(デザイン入力)から、シミュレーションまでの流れを理解する
-1bit adderの作成
**Verilog HDL記述の解説 [#l91c0f76]
***1bit adder [#sc9e89df]
-fa.v
1 module fa(a, b, cin, s , cout); //モジュール宣言
2
3 input a, b, cin;
4 output s, cout; //ポート宣言
5 wire a, b, cin, s, cout;
6
7 assign s = a ^ b ^ cin;
8 assign cout = (a & b) | (b & cin) | (cin & a);
9
10 endmodule // fa //モジュールの終り
|記号|`|&|l|^|`^|
|CENTER:説明|NOT|AND|OR|XOR|XNOR|
***テンスベンチ [#l28d0caf]
-fa_tb.v
1 `timescale 1ns / 1ps
2
3 // include needed module
4 `include "fa.v"
5
6 module fa_tb;
7
8 reg a, b, cin; //レジスタ宣言
9 wire s, cout;
10
11 fa fa0(.a(a), .b(b), .cin(cin), .s(s), .cout(cout)); //インスタンス宣言
12
13 initial begin
14 // output waveform
15 $dumpfile("fa_tb_wf.vcd"); // file name
16 $dumpvars(0, fa_tb); // starting time, test module name
17
18 // decide the input signals
19 a = 0; b = 0; cin = 0;
20 #100 a = 1; b = 0; cin = 0;
21 #100 a = 0; b = 1; cin = 0;
22 #100 a = 1; b = 1; cin = 0;
23 #100 a = 0; b = 0; cin = 1;
24 #100 a = 1; b = 0; cin = 1;
25 #100 a = 0; b = 1; cin = 1;
26 #100 a = 1; b = 1; cin = 1;
27 #100 a = 0; b = 0; cin = 0;
28 $finish;
29 end // initial begin
30 initial
31 $monitor($time, ,"a=%b, b=%b, cin=%b, s=%b, cout=%b",a,b,cin,s,cout);
32 endmodule // fa_tb
-1行目の`timescale 1ns/psは、シミュレーションの時間設定をしている。書式は-`timescale [単位時間] / [精度]~
-4行目の`include "fa.v"は、シミュレーションするファイルを読み込む~
-11行目は、インスタンス宣言をしている。インスタンス宣言の書式は[モジュール名] [インスタンス名](.[ポート名]([接続信号名]), …);~
-15行目の$dumpfile("fa_tb_wf.vcd");は、指定したファイルへダンプファイルを出力する~
-16行目の$dumpvars(0, fa_tb); は、指定したモジュールまたはインスタンスをダンプの対象とする~
-31行目の$monitorは、指定したオブジェクトの値が変わるたびに出力する
**シミュレーション [#ted2d979]
-simvisionでvcdファイルを開いて波形を確認する
-1bit adderは真理値表通りの結果が出た
**感想 [#q98482ab]
新しい言語を学ぶのは難しい
ページ名: