Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ __pycache__
*.swp
*.swo
*~
build/
target/
out/
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
# Keep the GitHub Actions used by the workflows current
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
# Keep the base image of the Dockerfile current
- package-ecosystem: docker
directory: /
schedule:
interval: weekly
38 changes: 28 additions & 10 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,52 @@ concurrency:
jobs:
docker:
name: Build Docker Image and Publish (only on push)
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
permissions:
contents: read
actions: write

steps:
- name: Check out the repo
uses: actions/checkout@v4
uses: actions/checkout@v7

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
uses: docker/setup-qemu-action@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v4

- name: Login to Docker Hub
if: github.event_name == 'push'
uses: docker/login-action@v3
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}

- name: Build image for the smoke test (amd64)
uses: docker/build-push-action@v7
with:
context: .
platforms: linux/amd64
load: true
tags: chisel-bootcamp:test
cache-from: type=gha,scope=build
cache-to: type=gha,mode=max,scope=build

- name: Run notebooks (smoke test, offline)
# The image bundles every dependency, so no network is needed.
run: |
docker run --rm --network none chisel-bootcamp:test \
python3 runtest.py 0_demo.ipynb 2.1_first_module.ipynb 2.6_chiselsim.ipynb 4.1_firrtl_ast.ipynb
docker run --rm --network none chisel-bootcamp:test python3 tests/test_visualizer.py

- name: Build and push
uses: docker/build-push-action@v6
if: github.event_name == 'push'
uses: docker/build-push-action@v7
with:
context: .
platforms: ${{ github.event_name == 'push' && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
push: ${{ github.event_name == 'push' }}
platforms: linux/amd64,linux/arm64
push: true
tags: sysprog21/chisel-bootcamp:latest
cache-from: type=gha
cache-to: type=gha,mode=max
cache-from: type=gha,scope=build
cache-to: type=gha,mode=max,scope=build
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@
# Jupyter-scala scripts
coursier
almond
/build
*.sv
9 changes: 4 additions & 5 deletions 0_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
},
"outputs": [],
"source": [
"val path = System.getProperty(\"user.dir\") + \"/source/load-ivy.sc\"\n",
"interp.load.module(ammonite.ops.Path(java.nio.file.FileSystems.getDefault().getPath(path)))"
"interp.load.module(os.pwd / \"source\" / \"load-ivy.sc\")"
]
},
{
Expand All @@ -47,8 +46,8 @@
"outputs": [],
"source": [
"import chisel3._\n",
"import chisel3.util._\n",
"import chisel3.iotesters.{ChiselFlatSpec, Driver, PeekPokeTester}"
"import chisel3.Input // avoid a name clash with almond.input.Input\n",
"import chisel3.util._\n"
]
},
{
Expand Down Expand Up @@ -222,7 +221,7 @@
"mimetype": "text/x-scala",
"name": "scala",
"nbconvert_exporter": "script",
"version": "2.12.8"
"version": "2.13.18"
}
},
"nbformat": 4,
Expand Down
10 changes: 6 additions & 4 deletions 1_intro_to_scala.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,9 @@
"\n",
"```scala\n",
"import chisel3._\n",
"import chisel3.iotesters.{ChiselFlatSpec, Driver, PeekPokeTester}\n",
"import chisel3.util.{Counter, Queue}\n",
"```\n",
"The first imports all the classes and methods in the chisel3 package; the underscore here works as a wildcard. The second imports specific classes from the chisel3.iotesters package."
"The first imports all the classes and methods in the chisel3 package; the underscore here works as a wildcard. The second imports specific classes (here `Counter` and `Queue`) from the chisel3.util package."
]
},
{
Expand Down Expand Up @@ -538,7 +538,9 @@
" println(\"counter is about to wrap\")\n",
"}\n",
"\n",
"x inc() // Scala allows the dots to be omitted; this can be useful for making embedded DSL's look more natural"
"// Scala allows the dot and parentheses to be omitted when a method takes exactly one argument;\n",
"// this can be useful for making embedded DSL's look more natural\n",
"println(x.counter max 3) // same as x.counter.max(3); a method without arguments, like inc(), still needs `x.inc()`"
]
},
{
Expand Down Expand Up @@ -651,7 +653,7 @@
"mimetype": "text/x-scala",
"name": "scala",
"nbconvert_exporter": "script",
"version": "2.12.8"
"version": "2.13.18"
}
},
"nbformat": 4,
Expand Down
24 changes: 14 additions & 10 deletions 2.1_first_module.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
"metadata": {},
"outputs": [],
"source": [
"val path = System.getProperty(\"user.dir\") + \"/source/load-ivy.sc\"\n",
"interp.load.module(ammonite.ops.Path(java.nio.file.FileSystems.getDefault().getPath(path)))"
"interp.load.module(os.pwd / \"source\" / \"load-ivy.sc\")"
]
},
{
Expand All @@ -51,7 +50,12 @@
"execution_count": null,
"metadata": {},
"outputs": [],
"source": "import chisel3._\nimport chisel3.util._\nimport chiseltest._\nimport chiseltest.RawTester.test"
"source": [
"import chisel3._\n",
"import chisel3.Input // avoid a name clash with almond.input.Input\n",
"import chisel3.util._\n",
"import chisel3.simulator.PeekPokeAPI._"
]
},
{
"cell_type": "markdown",
Expand Down Expand Up @@ -190,7 +194,7 @@
"// Scala Code: `test` runs the unit test. \n",
"// test takes a user Module and has a code block that applies pokes and expects to the \n",
"// circuit under test (c)\n",
"test(new Passthrough()) { c =>\n",
"simulate(new Passthrough()) { c =>\n",
" c.io.in.poke(0.U) // Set our input to value 0\n",
" c.io.out.expect(0.U) // Assert that the output correctly has 0\n",
" c.io.in.poke(1.U) // Set our input to value 1\n",
Expand Down Expand Up @@ -230,13 +234,13 @@
"source": [
"// Test with width 10\n",
"\n",
"test(???) { c =>\n",
"simulate(???) { c =>\n",
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved
" ???\n",
"}\n",
"\n",
"// Test with width 20\n",
"\n",
"test(???) { c =>\n",
"simulate(???) { c =>\n",
" ???\n",
"}\n",
"\n",
Expand All @@ -252,14 +256,14 @@
"<label for=\"check-1\"><strong>Solution</strong> (click to toggle displaying it)</label>\n",
"<article>\n",
"<pre style=\"background-color:#f7f7f7\">\n",
"test(new PassthroughGenerator(10)) { c =>\n",
"simulate(new PassthroughGenerator(10)) { c =>\n",
" c.io.in.poke(0.U)\n",
" c.io.out.expect(0.U)\n",
" c.io.in.poke(1023.U)\n",
" c.io.out.expect(1023.U)\n",
"}\n",
"\n",
"test(new PassthroughGenerator(20)) { c =>\n",
"simulate(new PassthroughGenerator(20)) { c =>\n",
" c.io.in.poke(0.U)\n",
" c.io.out.expect(0.U)\n",
" c.io.in.poke(1048575.U)\n",
Expand Down Expand Up @@ -349,7 +353,7 @@
" println(s\"Print during generation: Input is ${io.in}\")\n",
"}\n",
"\n",
"test(new PrintingModule ) { c =>\n",
"simulate(new PrintingModule ) { c =>\n",
" c.io.in.poke(3.U)\n",
" c.clock.step(5) // circuit will print\n",
" \n",
Expand All @@ -371,7 +375,7 @@
"mimetype": "text/x-scala",
"name": "scala",
"nbconvert_exporter": "script",
"version": "2.12.10"
"version": "2.13.18"
}
},
"nbformat": 4,
Expand Down
21 changes: 10 additions & 11 deletions 2.2_comb_logic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
"metadata": {},
"outputs": [],
"source": [
"val path = System.getProperty(\"user.dir\") + \"/source/load-ivy.sc\"\n",
"interp.load.module(ammonite.ops.Path(java.nio.file.FileSystems.getDefault().getPath(path)))"
"interp.load.module(os.pwd / \"source\" / \"load-ivy.sc\")"
]
},
{
Expand All @@ -44,9 +43,9 @@
"outputs": [],
"source": [
"import chisel3._\n",
"import chisel3.Input // avoid a name clash with almond.input.Input\n",
"import chisel3.util._\n",
"import chiseltest._\n",
"import chiseltest.RawTester.test"
"import chisel3.simulator.PeekPokeAPI._"
]
},
{
Expand Down Expand Up @@ -108,7 +107,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We create two `val`s. The first adds two Scala `Int`s, so `println` prints out the integer 2. The second `val` adds two *Chisel* `UInt`s together, so `println` sees this as a hardware node and prints out the type name and pointer (`chisel3.core.UInt@d`). Note that `1.U` is a type cast from a Scala `Int` (1) to a Chisel `UInt` literal.\n",
"We create two `val`s. The first adds two Scala `Int`s, so `println` prints out the integer 2. The second `val` adds two *Chisel* `UInt`s together, so `println` sees this as a hardware node and prints out a description of the node (its type and an internal name, not a number). Note that `1.U` is a type cast from a Scala `Int` (1) to a Chisel `UInt` literal.\n",
"\n",
"We need to drive the output to something, so we just connect it to the input for now, as with the passthrough module in the previous tutorial.\n",
"\n",
Expand Down Expand Up @@ -180,7 +179,7 @@
"metadata": {},
"outputs": [],
"source": [
"test(new MyOperators) {c =>\n",
"simulate(new MyOperators) {c =>\n",
" c.io.out_add.expect(5.U)\n",
" c.io.out_sub.expect(1.U)\n",
" c.io.out_mul.expect(8.U)\n",
Expand Down Expand Up @@ -216,7 +215,7 @@
"\n",
"println(getVerilog(new MyOperatorsTwo))\n",
"\n",
"test(new MyOperatorsTwo) { c =>\n",
"simulate(new MyOperatorsTwo) { c =>\n",
" c.io.out_mux.expect(3.U)\n",
" c.io.out_cat.expect(5.U)\n",
"}\n",
Expand Down Expand Up @@ -268,7 +267,7 @@
" ???\n",
"}\n",
"\n",
"test(new MAC) { c =>\n",
"simulate(new MAC) { c =>\n",
" val cycles = 100\n",
" import scala.util.Random\n",
" for (i <- 0 until cycles) {\n",
Expand Down Expand Up @@ -345,7 +344,7 @@
" ???\n",
"}\n",
"\n",
"test(new Arbiter) { c =>\n",
"simulate(new Arbiter) { c =>\n",
" import scala.util.Random\n",
" val data = Random.nextInt(65536)\n",
" c.io.fifo_data.poke(data.U)\n",
Expand Down Expand Up @@ -427,7 +426,7 @@
"}\n",
"\n",
"for (saturate <- Seq(true, false)) {\n",
" test(new ParameterizedAdder(saturate)) { c =>\n",
" simulate(new ParameterizedAdder(saturate)) { c =>\n",
" // 100 random tests\n",
" val cycles = 100\n",
" import scala.util.Random\n",
Expand Down Expand Up @@ -498,7 +497,7 @@
"mimetype": "text/x-scala",
"name": "scala",
"nbconvert_exporter": "script",
"version": "2.12.10"
"version": "2.13.18"
}
},
"nbformat": 4,
Expand Down
Loading