{"id":22201986,"url":"https://github.com/diohabara/chisel_riscv","last_synced_at":"2025-03-25T00:46:58.996Z","repository":{"id":192161311,"uuid":"403606359","full_name":"diohabara/chisel_riscv","owner":"diohabara","description":"RISC-V CPU Core","archived":false,"fork":false,"pushed_at":"2023-09-01T03:08:36.000Z","size":169,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-30T03:25:13.060Z","etag":null,"topics":["chisel3","cpu","riscv"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/diohabara.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-09-06T12:01:22.000Z","updated_at":"2023-09-02T00:26:13.000Z","dependencies_parsed_at":"2023-09-03T03:05:59.787Z","dependency_job_id":"f6d5c5be-9d9c-4ae1-b23a-fc995da085fe","html_url":"https://github.com/diohabara/chisel_riscv","commit_stats":null,"previous_names":["diohabara/chisel_riscv"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diohabara%2Fchisel_riscv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diohabara%2Fchisel_riscv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diohabara%2Fchisel_riscv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diohabara%2Fchisel_riscv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/diohabara","download_url":"https://codeload.github.com/diohabara/chisel_riscv/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245377955,"owners_count":20605375,"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":["chisel3","cpu","riscv"],"created_at":"2024-12-02T16:11:57.677Z","updated_at":"2025-03-25T00:46:58.967Z","avatar_url":"https://github.com/diohabara.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# chisel_riscv\n\n## Setup\n\n```bash\ndirenv allow .\n```\n\n## Build\n\nDevelop inside [Devcontainer](https://code.visualstudio.com/docs/devcontainers/containers)\n\nor\n\nuse Dockerfile\n\n```bash\ndocker build . -t riscv/mycpu\ndocker run -it -v $PWD/mycpu:/mycpu riscv/mycpu\n```\n\nor\n\nuse existing image\n\n```bash\ndocker pull yutaronishiyama/riscv-chisel-book\ndocker run -it -v $PWD/mycpu:/mycpu yutaronishiyama/riscv-chisel-book\n```\n\n## Format\n\n```bash\nscalafmt\n```\n\n## Test\n\nIn Docker\n\n### Basic test\n\nChange file path of Memory.scala\n\n```bash\ncd /mycpu\nsbt \"testOnly fetch.HexTest\"\nsbt \"testOnly decode.HexTest\"\nsbt \"testOnly lw.HexTest\"\nsbt \"testOnly sw.HexTest\"\n```\n\n### `riscv-tests`\n\nchange the starting address in `/opt/riscv/riscv-tests/env/p/link.ld`:\n\n```bash\nSECTIONS\n{\n  . = 0x00000000; // from 0x80000000\n  ...\n}\n```\n\nRun the following commands:\n\n```bash\ncd /opt/riscv/riscv-tests\nautoconf\n./configure --prefix=/src/target\nmake\nmake install\n```\n\nELF and dump files will be generated in `/src/target/share/riscv-tests/isa/`. We will be using\n\n- `rv32ui-p-` (for user-level instructions)\n- `rv32um-p-` (for machine-level instructions)\n\nConvert ELF file into BIN files:\n  \n```bash\nmkdir /mycpu/src/riscv\ncd /mycpu/src/riscv\nriscv64-unknown-elf-objcopy -O binary /src/target/share/riscv-tests/isa/rv32ui-p-add rv32ui-p-add.bin\nod -An -tx1 -w1 -v rv32ui-p-add.bin \u003e\u003e rv32ui-p-add.hex\n```\n\nRun\n\n```bash\nsbt \"testOnly riscvtests.RiscvTest\"\n```\n\nAutomate making `hex` files\n\n```bash\ncd /mycpu/src/shell\n./tohex.sh\n./riscv_tests.sh\n```\n\nThe results will be in `mycpu/results`\n\n### test with C\n\ncompile C code\n\n```bash\ncd /mycpu/src/c\nriscv64-unknown-elf-gcc \\\n  -march=rv32i \\ # specify ISA\n  -mabi=ilp32 \\ # specify ABI\n  -c \\ # compile only, not link\n  -o ctest.o ctest.c\n```\n\nlink it\n\n```bash\nriscv64-unknown-elf-ld -b elf32-littleriscv ctest.o -T link.ld -o ctest\nriscv64-unknown-elf-objcopy -O binary ctest ctest.bin\nod -An -tx1 -w1 -v ctest.bin \u003e ../hex/ctest.hex\nriscv64-unknown-elf-objdump -b elf32-littleriscv -D ctest \u003e ../dump/ctest.elf.dmp\n```\n\ntest it\n\n```bash\ncd /mycpu\nsbt \"testOnly ctest.HexTest\"\n```\n\n### Branch hazard\n\ncompile `br_hazard`\n\n```bash\ncd /mycpu/src/c\nmake br_hazard\n```\n\n```bash\ncd /mycpu\nsbt \"testOnly pipeline.HexTest\"\nsbt \"testOnly pipeline_brhazard.HexTest\"\n```\n\n### Data hazard\n\ncompile `hazard_wb`\n\n```bash\ncd /mycpu/src/c\nmake hazard_wb\n```\n\n```bash\ncd /mycpu\nsbt \"testOnly pipeline_datahazard.HexTest\"\n```\n\n### RISC-V tests\n\n```bash\ncd /mycpu/src/shell\n./riscv_tests.sh pipeline_datahazard 09_pipeline_datahazard\n```\n\n## References\n\n- \u003chttps://gihyo.jp/book/2021/978-4-297-12305-5\u003e\n- \u003chttps://github.com/chadyuu/riscv-chisel-book\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiohabara%2Fchisel_riscv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiohabara%2Fchisel_riscv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiohabara%2Fchisel_riscv/lists"}