LoginSignup
1
0

More than 5 years have passed since last update.

Python でFPGA/シミュレーションをしてみよう

Last updated at Posted at 2018-12-04

シミュレーションを実行してみる

実行に先立ってシミュレーション用のソフトをインストールしておきます。わたしは iverlog(Icuros Verilog) を使っています。Windows では"iverilog windows"のキーワードでインストール方法などが出てくるのでインストールしておきましょう

試してないけどここが有益そう → http://bleyer.org/icarus/

Linux なら簡単に simu.py を使える

polyphony のソースをダウンロード(git で clone して)、そこにある simu.py を使えば簡単にシミュレーションできます。simu.py は iverlog を呼ぶようにできているので iverlog はあらかじめインストールしておきましょう。

simu.py を実行してみる

shell$ ~1/simu.py blink.py
Compiling: [=========================] 100% ... printresouces
(38, 98, 3)
loop: 0
loop: 1
loop: 2
loop: 3
finished
350300:finish

Python で実行した時と同じ(ような)結果が出ます。

エラーです

polyphony がインストールされていないか PYTHONPATH が polyphony の clone に設定されていないと次のエラーがでます。

> ./simu.py blink.py
[COMPILE PYTHON] FAILED:blink.py
Traceback (most recent call last):
  File "./simu.py", line 60, in exec_compile
    compile_main(casefile_path, options)
  File "/cygdrive/i/Works/Polyphony-Works/venv/devel-test/polyphony/polyphony/compiler/__main__.py", line 789, in compile_main
    setup(src_file, options)
  File "/cygdrive/i/Works/Polyphony-Works/venv/devel-test/polyphony/polyphony/compiler/__main__.py", line 725, in setup
    if options.config:
AttributeError: 'types.SimpleNamespace' object has no attribute 'config'
'types.SimpleNamespace' object has no attribute 'config'

git clone して PYTHONPATH を設定すれば問題解決(するはず)。

$ git clone https://github.com/ktok07b6/polyphony
$ PYTOHNPATH=`pwd`/polyphony
$ polyphony/simu.py blink.py

Windows なら、、、

Polyphony がインストールされているはずなのでそのまま simu.py ”だけ"を git ハブからダウンロードします。(github から raw でダウンロード)

iverilog をインストールしていなかったのでエラー(FAILED)が出ましたが、cmd から実行できそうです(下の実行結果を参照)。

Windowsでsimu.py実行
>.\simu.py -h
usage: simu [-h] [-vd] [-vm] source

positional arguments:
  source                Python source file

optional arguments:
  -h, --help            show this help message and exit
  -vd, --verilog_dump   output vcd file in testbench
  -vm, --verilog_monitor
                        enable $monitor in testbench
>.\simu.py blink.py
Compiling: [=========================] 100% ... printresouces
(37, 98, 3)
[COMPILE HDL] FAILED:blink.py
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0