## Rocket Chip Verilog 編譯流程紀錄 0. **前置作業:** 須完成[官方Chisel環境建置](https://www.chisel-lang.org/docs/installation),包括 `mill,verilator`,或者參考[建構Chisel環境使用VSCode](https://hackmd.io/wcXabDrsQzebdk9qq8ho9A)。 2. **下載 Rocket Chip 程式碼:** 首先,從 GitHub 儲存庫克隆 Rocket Chip 的程式碼: ```bash git clone https://github.com/chipsalliance/rocket-chip.git cd rocket-chip git submodule update --init ``` 下載主要的 Rocket Chip 程式碼並初始化所有子模組。 2. **下載並建置 Rocket Tools:** Rocket Tools 提供了支援 Rocket Chip 的必要工具,如 GNU 工具鏈和 ISA 模擬器。 按照以下步驟下載並建置: ```bash git clone https://github.com/chipsalliance/rocket-tools.git cd rocket-tools git submodule update --init --recursive # 設定環境變量 export RISCV=/path/to/install/riscv/toolchain 或者 # 1. 編輯 .bashrc nano ~/.bashrc # 2. 在檔案結尾加入 export RISCV=/home/ethan2339/riscv/toolchain # 3. 重新載入 .bashrc 使變更生效 source ~/.bashrc # 4.執行 build.sh ./build.sh ``` 將 `/path/to/install/riscv/toolchain` 替換為安裝工具鏈的路徑。 這些步驟為下載並建置支援 Rocket Chip 的工具。 3. **安裝必要的相關套件:** 作業系統《Ubuntu》,需要安裝一些額外的套件。 使用以下命令安裝所需的套件。[更詳細的請參閱官方網站](https://github.com/chipsalliance/rocket-tools/blob/master/README.md)。 ```bash cd rocket-chip sudo apt-get install autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev libusb-1.0-0-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev device-tree-compiler pkg-config libexpat-dev libfl-dev ``` 4. **安裝Firtool:** 目前 `1.42版本` 測試成功,[下載網址。](https://github.com/llvm/circt/releases/tag/firtool-1.42.0) ```bash wget https://github.com/llvm/circt/releases/download/firtool-1.42.0/firrtl-bin-ubuntu-20.04.tar.gz ``` ```bash tar -xvf firrtl-bin-ubuntu-20.04.tar.gz sudo mv firtool /usr/local/bin/ sudo chmod +x /usr/local/bin/firtool ``` <span style="color:#B22222">註</span>:firtool位置在解壓縮後檔案的 `bin` 裡,或者在目前目錄樹中搜尋 firtool。 ```bash find . -name firtool ``` **驗證安裝** ```bash firtool --version ``` 6. **安裝 nix :** - 步驟一,首先進入 rocket-chip 目錄: ```bash cd ~/projects/rocket-chip ``` - 步驟二,安裝 nix: ```bash curl -L https://nixos.org/nix/install | sh ``` - 步驟三,重新加載 shell 或重啟終端,然後執行: ```bash . ~/.nix-profile/etc/profile.d/nix.sh ``` - 步驟四,在 rocket-chip 目錄中生成 BSP 配置: ```bash mill mill.bsp.BSP/install ``` - 步驟五,修改 BSP 配置文件: ```bash #如果找不到.bsp再創建檔案 mkdir -p .bsp echo '{ "name": "mill-bsp", "argv": ["/usr/bin/nix", "develop", "-c", "mill", "--bsp", "--disable-ticker=false"] }' > .bsp/mill-bsp.json ``` 6. **建置 Rocket Chip 專案:** 安裝完所有依賴項並建置 Rocket Tools 後,回到 Rocket Chip 目錄生成 Verilog: ```bash cd rocket-chip make verilog ``` 為特定的配置生成 Verilog: ```bash make verilog CONFIG=DefaultSmallConfig ``` 7. **完成後檢查檔案是否成功生成** ```bash = cd out/emulator/freechips.rocketchip.system.TestHarness/freechips.rocketchip.system.DefaultConfig/mfccompiler/compile.dest/ ls ``` 結果:  如需更多詳細資訊,請參閱 [Rocket Chip 的 README 文件](https://github.com/chipsalliance/rocket-chip/blob/master/README.md) 和 [Rocket Tools 的 README 文件](https://github.com/chipsalliance/rocket-tools/blob/master/README.md)。 --- ### 版本紀錄 1. Ubuntu 24.04  3. Java 11 or 17  1. Mill 0.11.12,Millw (wrapper) [下載網址](https://github.com/lefou/millw/releases/tag/0.4.12)。  1. Firtool 1.42.0  1. Verilator 5.0.20  1. Scala : VSCode Metal --- **Mill 注意事項&備忘** 安裝: ```bash curl -L https://raw.githubusercontent.com/com-lihaoyi/mill/master/mill > mill && chmod +x mill chmod +x mill sudo mv mill /usr/local/bin/ ``` 第一次安裝使用 `mill version`,然後創建 `.mill version`指定版本(或使用預設版本)。 --- 其他注意事項 :Scala語言須要在程式最後一行 空一行空白行,否則會出錯。 實用指令:find。 ```bash #在目前目錄及子目錄找檔名 find . -name "檔案名稱" #在特定目錄找檔名 find /home/user -name "檔案名稱" #使用萬用字元 find . -name "*.c" # 找所有 .c 檔案 find . -name "test*" # 找所有以 test 開頭的檔案 #只找目錄 find . -type d -name "目錄名稱" #只找檔案 find . -type f -name "檔案名稱" ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up