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
Empty file removed .github/workflows/.gitkeep
Empty file.
79 changes: 79 additions & 0 deletions .github/workflows/rtl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: RTL CI

on:
push:
paths:
- 'rtl/**'
- 'sim/**'
- '.github/workflows/rtl.yml'
pull_request:
paths:
- 'rtl/**'
- 'sim/**'
- '.github/workflows/rtl.yml'

jobs:
rtl-ci:
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v4

# cocotb 2.x requires Verilator >= 5.036; the ubuntu-24.04 apt package
# is only 5.020, so we build from source and cache by version tag.
- name: Cache Verilator build
id: cache-verilator
uses: actions/cache@v4
with:
path: ~/verilator-install
key: verilator-v5.036-ubuntu-24.04

- name: Build Verilator v5.036 from source
if: steps.cache-verilator.outputs.cache-hit != 'true'
run: |
sudo apt-get update -qq
sudo apt-get install -y autoconf flex bison libfl2 libfl-dev help2man perl
git clone --depth 1 --branch v5.036 https://github.com/verilator/verilator.git /tmp/verilator
cd /tmp/verilator
autoconf
./configure --prefix="$HOME/verilator-install"
make -j$(nproc)
make install

- name: Add Verilator to PATH
run: echo "$HOME/verilator-install/bin" >> $GITHUB_PATH

- uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install Python deps
run: pip install cocotb numpy pytest

- name: Lint RTL
run: verilator --lint-only -Wall rtl/*.sv

- name: Golden model tests
run: pytest sim/golden.py -q

# Each suite gets its own SIM_BUILD directory. cocotb does not detect a
# TOPLEVEL change across runs sharing the same sim_build/ — it reuses the
# previous binary, which causes "root handle not found" at runtime.
- name: cocotb — PE
working-directory: sim
run: make MODULE=test_pe TOPLEVEL=pe WAVES=0 SIM_BUILD=sim_build/pe

- name: cocotb — Systolic Array
working-directory: sim
run: |
make MODULE=test_systolic_array TOPLEVEL=systolic_array \
VERILOG_SOURCES="../rtl/pe.sv ../rtl/systolic_array.sv" \
WAVES=0 SIM_BUILD=sim_build/systolic_array

- name: cocotb — Top (full matmul vs golden)
working-directory: sim
run: |
make MODULE=test_top TOPLEVEL=tiny_tpu_top \
VERILOG_SOURCES="../rtl/pe.sv ../rtl/systolic_array.sv \
../rtl/controller.sv ../rtl/tiny_tpu_top.sv" \
WAVES=0 SIM_BUILD=sim_build/top
37 changes: 37 additions & 0 deletions .github/workflows/wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: WASM Build

on:
push:
paths:
- 'rtl/**'
- 'wasm/**'
- '.github/workflows/wasm.yml'
pull_request:
paths:
- 'rtl/**'
- 'wasm/**'
- '.github/workflows/wasm.yml'

jobs:
wasm-build:
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v4

- name: Install Verilator and build deps
run: |
sudo apt-get update
sudo apt-get install -y verilator build-essential

- name: Set up Emscripten
uses: mymindstorm/setup-emsdk@v14

- name: Build WASM
run: bash wasm/build.sh

- name: Assert artifacts produced
run: |
test -f web/public/tiny_tpu.mjs || (echo "ERROR: tiny_tpu.mjs not produced" && exit 1)
test -f web/public/tiny_tpu.wasm || (echo "ERROR: tiny_tpu.wasm not produced" && exit 1)
echo "WASM artifacts verified: $(du -sh web/public/tiny_tpu.wasm | cut -f1) wasm"
44 changes: 44 additions & 0 deletions .github/workflows/web.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Web CI

on:
push:
paths:
- 'web/**'
- '.github/workflows/web.yml'
pull_request:
paths:
- 'web/**'
- '.github/workflows/web.yml'

jobs:
web-ci:
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
with:
version: '11'

- uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'pnpm'
cache-dependency-path: web/pnpm-lock.yaml

- name: Install dependencies
working-directory: web
run: pnpm install --frozen-lockfile

- name: Lint
working-directory: web
run: pnpm lint

- name: Type check
working-directory: web
run: pnpm typecheck

- name: Build
working-directory: web
run: pnpm build
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
<img src="https://img.shields.io/badge/TypeScript-strict-3178c6?style=flat-square&logo=typescript&logoColor=white" alt="TypeScript strict" />
</p>

<p>
<a href="https://github.com/deaneeth/tiny-tpu/actions/workflows/rtl.yml"><img src="https://github.com/deaneeth/tiny-tpu/actions/workflows/rtl.yml/badge.svg" alt="RTL CI" /></a>
<a href="https://github.com/deaneeth/tiny-tpu/actions/workflows/web.yml"><img src="https://github.com/deaneeth/tiny-tpu/actions/workflows/web.yml/badge.svg" alt="Web CI" /></a>
<a href="https://github.com/deaneeth/tiny-tpu/actions/workflows/wasm.yml"><img src="https://github.com/deaneeth/tiny-tpu/actions/workflows/wasm.yml/badge.svg" alt="WASM Build" /></a>
</p>

<p>
<a href="https://tiny-tpu.vercel.app">
<img src="https://img.shields.io/badge/Open%20Live%20Visualizer-89dc52?style=for-the-badge&logoColor=black" alt="Open Live Visualizer" />
Expand Down
9 changes: 9 additions & 0 deletions web/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ export default [
react: { version: "detect" },
},
},
{
files: ["scripts/**/*.mjs", "scripts/**/*.js"],
languageOptions: {
globals: {
...globals.node,
...globals.es2022,
},
},
},
{
ignores: ["dist/", ".astro/", "node_modules/", "public/"],
},
Expand Down
5 changes: 0 additions & 5 deletions web/scripts/gen-og-image.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ function peCell(row, col) {
const y = GRID_Y + row * (CELL + CELL_GAP);
const isDiag = row === col;
const isLoading = row === col + 1;
const fill = isDiag
? `color-mix(in oklch, ${LIME} 9%, ${SURFACE})`
: isLoading
? SURFACE
: SURFACE;
const stroke = isDiag
? LIME
: isLoading
Expand Down
30 changes: 30 additions & 0 deletions web/vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"headers": [
{
"source": "/tiny_tpu.wasm",
"headers": [
{
"key": "Content-Type",
"value": "application/wasm"
},
{
"key": "Cache-Control",
"value": "public, max-age=31536000, immutable"
}
]
},
{
"source": "/tiny_tpu.mjs",
"headers": [
{
"key": "Content-Type",
"value": "application/javascript; charset=utf-8"
},
{
"key": "Cache-Control",
"value": "public, max-age=31536000, immutable"
}
]
}
]
}
Loading