{"id":19516910,"url":"https://github.com/yasnakateb/chipyardintegration","last_synced_at":"2026-02-06T02:32:19.805Z","repository":{"id":261255841,"uuid":"883761603","full_name":"yasnakateb/ChipyardIntegration","owner":"yasnakateb","description":"😱  RoCC Accelerator Integration with Chipyard","archived":false,"fork":false,"pushed_at":"2024-11-06T09:20:38.000Z","size":9,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T01:34:13.478Z","etag":null,"topics":["accelerators","chipyard","chisel","chisel3","computer-architecture","hardware","hardware-acceleration","integration","risc-v","rocc","rocket","rocket-chip","sbt","scala","simulation","verilator"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yasnakateb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-05T14:27:06.000Z","updated_at":"2024-12-22T15:54:35.000Z","dependencies_parsed_at":"2025-01-08T12:43:05.202Z","dependency_job_id":"f479b5c4-2eeb-422a-b13c-2fb8b474c33c","html_url":"https://github.com/yasnakateb/ChipyardIntegration","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"3b95ea66a312ae02e50f1e97892e9465cc094d3e"},"previous_names":["yasnakateb/chipyardintegration"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yasnakateb%2FChipyardIntegration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yasnakateb%2FChipyardIntegration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yasnakateb%2FChipyardIntegration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yasnakateb%2FChipyardIntegration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yasnakateb","download_url":"https://codeload.github.com/yasnakateb/ChipyardIntegration/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249155743,"owners_count":21221651,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["accelerators","chipyard","chisel","chisel3","computer-architecture","hardware","hardware-acceleration","integration","risc-v","rocc","rocket","rocket-chip","sbt","scala","simulation","verilator"],"created_at":"2024-11-11T00:01:02.275Z","updated_at":"2026-02-06T02:32:19.772Z","avatar_url":"https://github.com/yasnakateb.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Chipyard Integration\n \n\n## Integrating a RoCC Accelerator with Chipyard (a.k.a., the ultimate guide for the brave)\n\nIn this guide, I’ll take you through the (sometimes frustrating) journey of integrating a custom RoCC accelerator with Chipyard. Please make sure you’re referencing [Chipyard’s docs](https://chipyard.readthedocs.io/en/latest/) if you get stuck.\n\n**Warning:** Be mindful of your Chipyard version. I’m using **v1.10.0**—trust me, it matters. Plus I am using Ubuntu!\n\n---\n\n### The Step-by-Step guide\n\n#### 1. Install Anaconda (Your New Best Friend)\n\n1. Head over to the [Anaconda installer list](https://repo.anaconda.com/archive/) and grab the one that matches your OS.\n2. Open your terminal, and let’s run this:\n   ```bash\n   bash ~/Downloads/Anaconda3-\u003cINSTALLER_VERSION\u003e-Linux-x86_64.sh\n   ```\n3. Type \"yes\" as needed (agree to that license, get your Anaconda initialized, etc.). \n4. The default install location? Right here:\n   ```bash\n   PREFIX=/home/\u003cUSER\u003e/anaconda3\n   ```\n\n#### 2. Initialize Conda \n\n```bash\nsource \u003cPATH_TO_CONDA\u003e/bin/activate\nconda init\n```\n\n#### 3. Activate Anaconda \n\n```bash\nsource ~/.bashrc\n```\n\n*(By the way, still using `bashrc`? Not `zshrc`? Are you sure you don’t wanna move on? Just saying...🤣🤣🤣)*\n\n(Optional: Want your shell to auto-activate Anaconda every time it opens? Here you go:)\n```bash\nconda config --set auto_activate_base True\n```\n\n---\n\n#### 4. Install `libmamba` (Because faster solves = less hair-pulling)\n\n```bash\nconda install -n base conda-libmamba-solver\nconda config --set solver libmamba\nconda activate base\n```\n\n#### 5. Time to Set Up Chipyard (the real fun begins)\n\n1. Clone the Chipyard repo and check out the right version:\n   ```bash\n   git clone https://github.com/ucb-bar/chipyard.git\n   cd chipyard\n   git checkout 1.10.0\n   ```\n2. Run the setup script and skip the extras (because time is precious):\n   ```bash\n   ./build-setup.sh riscv-tools -s 6 -s 7 -s 8 -s 9\n   ```\n   - `-s 6`: Skips FireSim (only if you don’t need it)\n   - `-s 7`: Skips FireSim source pre-compilation (trust me, skip it)\n   - `-s 8`: Skips FireMarshal (Fire what?)\n   - `-s 9`: Skips FireMarshal Linux pre-compilation (we’ve got other things to do)\n\n3. After all that, source the environment script every time:\n   ```bash\n   source ./env.sh\n   ```\n\n   *(Pro tip: Save yourself the trouble by creating an alias in `.bashrc`, still using `bashrc`?)*\n\n   ```bash\n   alias chip=\"cd /home/USER/chipyard/ \u0026\u0026 source env.sh\"\n   ```\n\n---\n\n#### 6. Adding Your Custom Chisel Generator (I name it Takhol!)\n\n1. Structure your project directory like this:\n   ```\n   Takhol/\n       build.sbt\n       src/main/scala/Takhol.scala\n   ```\n\n2. Add the project settings to `build.sbt`:\n   ```sbt\n   organization := \"edu.berkeley.cs\"\n   version := \"1.0\"\n   name := \"Takhol\"\n   scalaVersion := \"2.12.13\"\n   ```\n\n3. Add Takhol to Chipyard’s `generators/` directory:\n   ```bash\n   cd generators/\n   git submodule add https://git-repository.com/Takhol.git\n   git submodule update --recursive generators/Takhol\n   ```\n\n4. Link Takhol to Chipyard’s top-level `build.sbt` file:\n   ```sbt\n   lazy val Takhol = (project in file(\"generators/Takhol\"))\n     .dependsOn(rocketchip)\n     .settings(libraryDependencies ++= rocketLibDeps.value)\n     .settings(commonSettings)\n   ```\n\n5. Add Takhol as a dependency in the sub-projects section:\n   ```sbt\n   lazy val chipyard = (project in file(\"generators/chipyard\"))\n       .dependsOn(testchipip, rocketchip, boom, hwacha, Takhol, ...)\n       .settings(libraryDependencies ++= rocketLibDeps.value)\n       .settings(\n           libraryDependencies ++= Seq(\n           \"org.reflections\" % \"reflections\" % \"0.10.2\"\n           )\n       )\n       .settings(commonSettings)\n   ```\n\n---\n\n#### 7. Build with `sbt`\n\n```bash\nsbt build\n```\n\n#### 8. Add Your Accelerator Config \n\nFind the `RocketConfigs.scala` file (maybe in `chipyard/generators/chipyard/src/main/scala/config/`) and add your custom config:\n```scala\nclass TakholRocketConfig extends Config (\n  new Takhol.WithTakhol ++\n  new freechips.rocketchip.subsystem.WithNBigCores(1) ++  // single rocket-core\n  new chipyard.config.AbstractConfig\n)\n```\n\n#### 9. Use Parameters in Takhol.scala \n\nIf the command above seems unclear, and you're unfamiliar with configuring settings in Chipyard or Chisel projects, let me provide a brief overview.\n\nImagine that in your Takhol.scala file, you define a set of parameters such as rows and columns. To manage these parameters more effectively, you can create a new file named config.scala. This file would look something like this:\n\n```scala\npackage Takhol\n\nimport org.chipsalliance.cde.config._\n\nclass WithTakhol extends Config((site, here, up) =\u003e {\n  case TakholKey =\u003e TakholParams(\n    rows  = 4,\n    columns = 4\n  )\n})\n\n```\n\nNow, you can use these parameters directly in your Takhol.scala file. Your Takhol.scala might look something like this:\n\n```scala\npackage Takhol\n\nimport chisel3._\nimport chisel3.util._\nimport org.chipsalliance.cde.config._\n\ncase class TakholParams(\n  rows: Int,\n  columns: Int)\n\ncase object TakholKey extends Field[TakholParams]\n\nabstract trait TakholParameters {\n  implicit val p: Parameters\n\n  val takholParams = p(TakholKey)\n\n  val rows = takholParams.rows\n  val columns = takholParams.columns\n  \n}\n\n```\n\nYou now have `rows` and `columns` in `Takhol.scala` that you can use them as you wish.\n\n---\n\n#### 10. Set Up RISC-V Simulation with Verilator (Hello, Debugging!)\n\n1. Inside `chipyard/sims/verilator`, create a folder for your program:\n   ```bash\n   mkdir src\n   cd src\n   touch hello_world.c\n   ```\n\n2. Write your first RISC-V program in `hello_world.c` (simple and classic):\n   ```c\n   #include \u003cstdio.h\u003e\n   \n   int main(void) {\n       printf(\"Hello, World!\\n\");\n       return 0;\n   }\n   ```\n\n3. Build the program: \n   ```\n   riscv64-unknown-elf-gcc -fno-common -fno-builtin-printf -specs=htif_nano.specs -c hello_world.c\n   riscv64-unknown-elf-gcc -static -specs=htif_nano.specs hello_world.o -o hello_world.riscv\n   spike hello_world.riscv\n   ```\n   If you are lazy like me, create a `run.sh` script to compile and test your code with all baremetal programs:\n   \n   ```bash\n   #!/bin/bash\n   \n   if [ -z \"$1\" ]; then\n     echo \"Usage: sh file.sh \u003cfilename.c\u003e\"\n     exit 1\n   fi\n   \n   filename=$(basename \"$1\" .c)\n   \n   echo \"riscv64-unknown-elf-gcc -fno-common -fno-builtin-printf -specs=htif_nano.specs -c $filename.c\"\n   riscv64-unknown-elf-gcc -fno-common -fno-builtin-printf -specs=htif_nano.specs -c \"$filename.c\" -o \"$filename.o\"\n   \n   echo \"riscv64-unknown-elf-gcc -static -specs=htif_nano.specs $filename.o -o $filename.riscv\"\n   riscv64-unknown-elf-gcc -static -specs=htif_nano.specs \"$filename.o\" -o \"$filename.riscv\"\n   \n   echo \"spike $filename.riscv\"\n   spike \"$filename.riscv\"\n   \n   \n   rm \"$filename.o\"%     \n      \n   ```\n   and then run it:\n   \n   ```\n   chmod +x run.sh\n   ./run.sh hello_world.c \n   ```\n\n\n   *(If you get an error about `htif_nano.specs`, you missed sourcing `env.sh` earlier. Go back, fix it, and try again!)*\n\n4. Run the simulation with VCD output (yes, you’ll want this):\n   ```bash\n   make CONFIG=TakholRocketConfig BINARY=src/hello_world.riscv run-binary-debug\n   ```\n\nCheck the output folder for simulation results, including the `.vcd` file. If you see “Hello, World!” on your terminal, rejoice—everything works. If not... well, you know where to look.\n\n---\n\n### Enjoy the Madness\n\nCongrats! You’re now fully set up to experiment and debug your custom accelerator in Chipyard. Enjoy the chaos and the code!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyasnakateb%2Fchipyardintegration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyasnakateb%2Fchipyardintegration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyasnakateb%2Fchipyardintegration/lists"}