RISC-VをRTLで提供しているところがいくつかある。
手っ取り早くRISC-VをFPGAに組み込んでみようと思う。
もっとも一般的なRICS-V実装でChiselで実装されている。
ZCaleは32bitでパイプライン段数が短く、面積重視のコアだね。
一方、ZScaleのVerilog HDL版といったところですが若干、未実装な部分があったりしてソースコードがあるという程度に留めておくほうが良いようだ。
SIFiveがFreedom Everwhere 310(FE310)で製品化しているRISC-Vがオープンソースで公開されている。
Xilinx社のVC707(Virtex-7評価ボード)及びDigilent社のArty(Artix-7評価ボード)に実装できるプロジェクトが公開されている。
http://store.digilentinc.com/arty-artix-7-fpga-development-board-for-makers-and-hobbyists/ Digilent社から$99で、秋月電子で16,000円で販売されている。
今回はFreedomをArtyに実装してみる。
次のようにFreedomをダウンロードしてきて、makeする
$ git clone git://github.com/sifive/freedom.git
$ cd fpga/e300artydevkit/
$ source /opt/Xilinx/Vivado/2016.4/settings64.sh
$ make
実行すると次のようなエラーが発生する。
ERROR: [Board 49-71] The board_part definition was not found for digilentinc.com:arty:part0:1.1. The project's board_part property was not set, but the project's part property was set to xc7a35ticsg324-1L. Valid board_part values can be retrieved with the 'get_board_parts' Tcl command. Check if board.repoPaths parameter is set and the board_part is installed from the tcl app store.
これはVivadoにArtyのボード定義ファイルが入っていないために発生するエラーだ。
そこで次のWebページからArtyのボード定義ファイルをダウンロードして、Vivadoに追加する。
https://reference.digilentinc.com/reference/software/vivado/board-files?redirect=1
$ unzip vivado-boards-master.zip
$ cd vivado-boards-master/new/board_files
$ sudo cp -R arty /opt/Xilinx/Vivado/2016.4/data/boards/board_files
ボード定義ファイルを追加してからmakeを実行すると次のようなエラーが発生する。
ERROR: [Vivado 12-385] Illegal file or directory name ''
なにやら、script/prologue.tclの$vsrc_topに何も入っていないことからエラーが発生している。
rocket-chip、sifive-blocksに何もファイルが存在していない。
このfreedomリポジトリはrocket-chip、sifive-blocksのフォルダをsubmoduleとして呼び出す。
次のコマンドを実行してsubmoduleをダウンロードしておく必要がある。
$ git submodule update --init
次にrochek-chipのフォルダ内も同じようにsubmoduleをupdateする。
$ cd rocket-chip
$ git submodule update --init
どうも、makeの手順が間違っていたようだ。
本当は次のようにmakeするようだ。
$ make -f Makefile.e300artydevkit
結局、次のエラーが発生する。
/home/h-ishihara/workspace/freedom/freedom/rocket-chip/firrtl/utils/bin/firrtl.jar
javacが無いんだって・・・
$ sudo apt install default-jdk
総括するとこういうことになる。
$ git clone git://github.com/sifive/freedom.git
$ cd freedom/
$ source /opt/Xilinx/Vivado/2016.4/settings64.sh
$ git submodule update --init
$ cd rocket-chip/
$ git submodule update --init
$ cd ..
$ make -f Makefile.e300artydevkit verilog
$ cp rocket-chip/vsrc/AsyncResetReg.v fpga/e300artydevkit/src/
$ cp rocket-chip/vsrc/DebugTransportModuleJtag.v fpga/e300artydevkit/src
$ cp sifive-blocks/vsrc/SRLatch.v fpga/e300artydevkit/src
$ cd fpga/e300artydevkit
$ VSRC_TOP=../../builds/e300artydevkit make
ビルドが完了するとobjの下にsystem.bitが生成されている。