Skip to content

Commit 02c1976

Browse files
committed
doc: toolchains/scala/README.md, chisel/README.md
1 parent 3a96177 commit 02c1976

File tree

2 files changed

+24
-80
lines changed

2 files changed

+24
-80
lines changed

chisel/README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,9 @@ Create a Chisel test bench module that has one `done` top level output signal to
1616

1717
See BUILD file in this folder and read the test.bzl on how to set up chisel_bench_test().
1818

19-
Unfortunately, there isn't enough disk space in CI to have LLVM + verilator toolchains enabled, so it has been temporarily disabled. To enable, revert the disabling:
19+
Run the test:
2020

21-
git revert 60f0a5e5335feca1b0c9a4b8ae087d23a5fb99b2
22-
23-
Now run the test:
24-
25-
bazelisk test :life_test
21+
bazel test :life_test
2622

2723
Output:
2824

toolchains/scala/README.md

Lines changed: 22 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ This directory contains Bazel rule wrappers for Chisel hardware design, built on
44

55
## Architecture
66

7-
The project uses **BCR rules_scala 7.1.5** from Bazel Central Registry as the underlying Scala toolchain. The Chisel wrappers (`chisel_binary`, `chisel_library`, `chisel_test`) provide a convenient API that:
7+
The project uses **BCR rules_scala 7.1.5 or newer** (as per `MODULE.bazel`) from Bazel Central Registry as the underlying Scala toolchain. The Chisel wrappers (`chisel_binary`, `chisel_library`, `chisel_test`) provide a convenient API that:
88

9-
- Automatically includes Chisel 7.2.0 and its dependencies
10-
- Pre-configures Scala compiler options for Chisel
11-
- Sets up Verilator and firtool for hardware simulation (tests only)
9+
* Automatically includes Chisel and its dependencies
10+
* Pre-configures Scala compiler options for Chisel
11+
* Sets up Verilator and firtool for hardware simulation (tests only)
1212

1313
## Usage
1414

15+
For another minimal working example, please refer to [bazel-chisel-verilator-openroad-demo](https://github.com/MrAMS/bazel-chisel-verilator-openroad-demo).
16+
1517
### chisel_library
1618

1719
Use for Chisel library targets:
@@ -24,6 +26,7 @@ chisel_library(
2426
srcs = ["MyModule.scala"],
2527
visibility = ["//visibility:public"],
2628
)
29+
2730
```
2831

2932
### chisel_binary
@@ -39,6 +42,7 @@ chisel_binary(
3942
main_class = "myproject.Generate",
4043
deps = [":mylib"],
4144
)
45+
4246
```
4347

4448
### chisel_test
@@ -53,23 +57,8 @@ chisel_test(
5357
srcs = ["MyModuleTest.scala"],
5458
deps = [":mylib"],
5559
)
56-
```
57-
58-
**Note**: Tests run locally (`tags = ["local"]`) to allow Verilator to generate files during simulation.
5960

60-
## Dependencies
61-
62-
The following dependencies are automatically included:
63-
64-
- Chisel 7.2.0 (`org.chipsalliance.chisel`)
65-
- Chisel plugin for Scala 2.13.17
66-
- Circe (JSON library)
67-
- Shapeless (generic programming)
68-
- Cats (functional programming)
69-
70-
For tests, additional tools are provided:
71-
- Verilator 5.036 (from BCR)
72-
- firtool from CIRCT
61+
```
7362

7463
## Verilator Integration
7564

@@ -81,69 +70,28 @@ The `chisel_test` rule includes workarounds for BCR verilator compatibility:
8170

8271
## IDE Support with Bazel BSP
8372

84-
This project uses [Bazel BSP](https://github.com/JetBrains/bazel-bsp) (Build Server Protocol) for IDE integration with Metals.
73+
This project uses [Bazel BSP](https://github.com/JetBrains/bazel-bsp) (Build Server Protocol) for IDE integration. Modern editors like **Zed**, **VS Code**, and **IntelliJ IDEA** can automatically detect and initialize the BSP server via Metals or their respective plugins without manual installation.
8574

8675
### Quick Setup
8776

88-
1. **Install Bazel BSP**:
89-
```bash
90-
cs install bsp
91-
```
77+
1. **Configure targets** (`.bazelproject` in project root):
78+
Ensure your `.bazelproject` lists the targets you want to index. You check this [doc](https://ij.bazel.build/docs/project-views.html) more information.
9279

93-
2. **Initialize BSP**:
94-
```bash
95-
cd /path/to/bazel-orfs-local
96-
bsp
97-
```
98-
99-
3. **Configure targets** (`.bazelproject` in project root):
100-
```
101-
targets:
102-
//:blooplib
103-
//chisel:all
104-
//sby:all
105-
106-
allow_manual_targets_sync: false
107-
derive_targets_from_directories: false
108-
109-
enabled_rules:
110-
rules_scala
111-
rules_java
112-
rules_jvm
113-
```
114-
115-
4. **Build project first**:
116-
```bash
117-
bazel build //chisel:codegenlib //chisel:applicationlib
118-
```
119-
120-
5. **Open in VSCode** and Metals will auto-connect to BSP
80+
2. **Open in Editor**:
81+
Open the project directory in your preferred editor (VS Code, Zed, etc.). The editor (via Metals) will detect the `.bazelproject` file and automatically initialize the Bazel BSP connection.
12182

12283
### Troubleshooting
12384

12485
**No targets found**:
125-
- Verify `.bazelproject` exists in project root
126-
- Check targets: `bazel query "//chisel:all"`
127-
- Rebuild BSP index: VSCode → "Metals: Import Build"
12886

129-
**Metals doesn't connect**:
130-
- Ensure `bsp` is in PATH: `which bsp`
131-
- Check `.bsp/bazelbsp.json` exists
132-
- Restart: VSCode → "Metals: Restart Build Server"
87+
* Verify `.bazelproject` exists in project root
88+
* Check targets validity: `bazel query "//chisel:all"`
89+
* Re-import build:
90+
* **VS Code**: "Metals: Import Build"
91+
* **Zed**: Trigger a build server reconnect or restart the editor
13392

13493
**No IntelliSense**:
135-
- Wait for initial indexing (check status bar)
136-
- Verify build succeeds: `bazel build //chisel:codegenlib`
137-
- Check logs: VSCode → Output → Metals
138-
139-
### Resources
140-
141-
- [Metals Bazel Documentation](http://scalameta.org/metals/docs/build-tools/bazel/)
142-
- [Bazel BSP Server](https://github.com/JetBrains/bazel-bsp)
143-
- [BSP Protocol Specification](https://build-server-protocol.github.io/)
144-
145-
## See Also
14694

147-
- [rules_scala documentation](https://github.com/bazelbuild/rules_scala)
148-
- [Chisel documentation](https://www.chisel-lang.org/)
149-
- [Verilator documentation](https://verilator.org/)
95+
* Wait for initial indexing (check status bar)
96+
* Verify build succeeds via command line
97+
* Check logs: Editor Output -> Metals

0 commit comments

Comments
 (0)