Skip to content

Commit 0c86239

Browse files
committed
Merge remote-tracking branch 'origin/main' into update_monitor
2 parents a78da14 + 57b05e1 commit 0c86239

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+275
-647
lines changed

.github/workflows/test.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,22 @@ jobs:
2222
- name: Update Rust to ${{ matrix.toolchain }}
2323
run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
2424
- uses: actions/checkout@v4
25+
- uses: actions/setup-python@v4
26+
with:
27+
python-version: '3.13'
2528
- uses: YosysHQ/setup-oss-cad-suite@v3
2629
with:
2730
version: '2024-05-07'
2831
- name: Build
2932
run: cargo build --verbose
30-
- name: Run tests (Debug)
33+
- name: Run unit tests (Debug)
3134
run: cargo test --verbose
35+
- name: Install uv
36+
uses: astral-sh/setup-uv@v5
37+
- name: Install Turnt
38+
run: uv tool install turnt
39+
- name: Run Turnt snapshot tests
40+
run: turnt $(find . -type f -name '*.tx')
3241

3342
msrv:
3443
name: Check Minimum Rust Version for protocols library

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ A protocol is described using an `fn` definition containing a list of imperative
1313
- Note: this presumes you already have `uv` installed (if not, [follow these instructions](https://docs.astral.sh/uv/getting-started/installation/#pypi))
1414
- Run `cargo build` to build
1515
- Run `just test` to execute all unit tests (`cargo test`) + snapshot tests (via Turnt)
16+
- Run `just turnt` to only run Turnt snapshot tests
1617

1718
**CLI**:
1819
The interpreter has a CLI, which can be invoked as follows:

examples/picorv32/pcpi_mul.prot

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
struct picorv32 {
1+
struct picorv32_pcpi_mul {
2+
in resetn: u1,
23
in pcpi_insn: u32,
34
in pcpi_rs1: u32,
45
in pcpi_rs2: u32,
@@ -8,32 +9,47 @@ struct picorv32 {
89
out pcpi_rd: u32,
910
}
1011

11-
// Adapted from https://github.com/ekiwi/transactional-verification-with-protocols/blob/039fb8d5beafb3c4a464e5dac3dc8a3e00b69f04/picorv32/picorv32_pcpi_mul.py
12-
fn pcpi_mul<p: picorv32>(
12+
// Adapted from https://github.com/ekiwi/paso/blob/ad2bf83f420ca704ff0e76e7a583791a0e80a545/benchmarks/src/benchmarks/picorv32/PicoRV32Spec.scala#L27
13+
fn pcpi_mul<p: picorv32_pcpi_mul>(
1314
in rs1_data: u32,
1415
in rs2_data: u32,
1516
out rd_data: u32,
1617
in insn: u32,
1718
) {
19+
// TODO: can we decoupled this from the transaction?
20+
p.resetn := 1'b1;
21+
22+
23+
p.pcpi_valid := 1'b1;
24+
// HACK: pass multiplication instruction as input
1825
p.pcpi_insn := insn;
1926
// p.pcpi_insn := 33554483; // multiplication insn. TODO: allow binary values
27+
28+
2029
p.pcpi_rs1 := rs1_data;
2130
p.pcpi_rs2 := rs2_data;
2231

2332
assert_eq(p.pcpi_wr, 1'b0);
2433
assert_eq(p.pcpi_ready, 1'b0);
2534

26-
step();
35+
while (!(p.pcpi_ready == 1'b1)) {
36+
step();
37+
}
2738

2839
p.pcpi_valid := 1'b0;
2940
p.pcpi_insn := X;
3041
p.pcpi_rs1 := X;
3142
p.pcpi_rs2 := X;
3243

33-
while (!(p.pcpi_ready == 1'b1)) {
34-
step();
35-
}
3644

3745
assert_eq(p.pcpi_wr, 1'b1);
3846
assert_eq(p.pcpi_rd, rd_data);
47+
48+
// TODO: do we need/want this step?
49+
step();
3950
}
51+
52+
fn pcpi_mul_reset<p: picorv32_pcpi_mul>() {
53+
p.resetn := 1'b0;
54+
step();
55+
}

examples/picorv32/unsigned_mul.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Protocol executed successfully!

examples/picorv32/unsigned_mul.tx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// ARGS: --verilog picorv32/picorv32.v --protocol picorv32/pcpi_mul.prot --module picorv32_pcpi_mul
2+
pcpi_mul_reset();
3+
pcpi_mul(1, 1, 1, 0x2000033);
4+
pcpi_mul(1, 100, 100, 0x2000033);
5+
pcpi_mul(100, 1, 100, 0x2000033);
6+
pcpi_mul(33554483, 200, 2415929304, 0x2000033);

examples/serv/serv_regfile.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Protocol executed successfully!

examples/serv/serv_regfile.tx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// ARGS: --verilog serv/rtl/serv_regfile.v --protocol serv/serv_regfile.prot
2+
// Arguments to transaction are:
3+
// rs1_addr: u5
4+
// rs1_data: u32 (output)
5+
// rs2_data: u32 (output)
6+
// rs2_addr: u5
7+
// rd_enable: u1
8+
// rd_addr: u5
9+
// rd_data: u32
10+
read_write(0, 0, 0, 0, 1, 5, 0xdeadbeef);
11+
read_write(5, 0xdeadbeef, 0, 0, 0, 0, 0);

examples/tinyaes128/aes128.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Protocol executed successfully!

examples/tinyaes128/aes128.tx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// ARGS: --verilog tinyaes128/aes_128.v --protocol tinyaes128/aes128.prot --module aes_128
2+
// Arguments are key, state, expected output
3+
aes128(0x000102030405060708090a0b0c0d0e0f, 0x00112233445566778899aabbccddeeff, 0x69c4e0d86a7b0430d8cdb78070b4c55a);
4+
aes128(0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x66e94bd4ef8a2c3b884cfa59ca342b2e);

examples/turnt.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
command = "cargo run --package protocols-interp -- --color never --transactions {filename} {args}"

0 commit comments

Comments
 (0)