Article #389

既に発行済みのブログであっても適宜修正・追加することがあります。
We may make changes and additions to blogs already published.
posted by sakurai on April 26, 2021 #389

Verilog階層生成

まずソースファイルをコンパイルしてverilogコードを生成します。

$ bsc -verilog testFSM.bsv
Verilog file created: testFSM.v

このようにtestFSM.vが生成されます。

次に最上位ファイルから正しくモジュールが呼び出されるように、最上位ファイルtop.vを修正します。emacsでtop.vを開き、C-c C-aをするだけで(過去記事参照)、自動的にインタフェースが生成されます。最上位には以下の2行を記述します。

  • /*AUTOREGINPUT*/及び/*AUTOWIRE*/

以下に最上位top.vにおいて、C-c C-a実行で変化する前とした後のコードを示します。

top.v(実行前)

module top();
   /*AUTOREGINPUT*/
   /*AUTOWIRE*/
   testFSM testFSM_inst(/*AUTOINST*/);
(以下略)

top.v(実行後)

module top();
   /*AUTOREGINPUT*/
   // Beginning of automatic reg inputs (for undeclared instantiated-module inputs)
   reg CLK; // To testFSM_inst of testFSM.v
   reg RST_N; // To testFSM_inst of testFSM.v
   // End of automatics
   /*AUTOWIRE*/
   // Beginning of automatic wires (for undeclared instantiated-module outputs)
   wire [2:0] read; // From testFSM_inst of testFSM.v
   // End of automatics
   testFSM testFSM_inst(/*AUTOINST*/
         // Outputs
         .read (read[2:0]),
         // Inputs
         .CLK (CLK),
         .RST_N (RST_N));
(以下略)

上記はコメントも含め全て、emacs verilog modeにより自動生成されたものです。


左矢前のブログ 次のブログ右矢

Leave a Comment

Your email address will not be published.

You may use Markdown syntax. If you include an ad such as http://, it will be invalidated by our AI system.

Please enter the numbers as they are shown in the image above.