[lang] the case for allowing arguments to appear in control flow conditions
- Dominant language
- Rust
- Stars
- 15
- Forks
- 0
- Avg merge
- 6h 20m
- Merged PRs (30d)
- 15
Description
I am currently looking a bit into Wishbone and there appears to be a case for allowing control flow to depend on protocol arguments: **byte masking**.
When some bytes are masked out, then their value does not matter and thus we want to apply `X` selectively when writing and `assert_eq` selectively when reading:
```prot
prot write(mask: u4, addr: u30, data: u32) {
// ....
self.wishbone_sel := mask;
self.wishbone_dat_w := data;
// the following is currently not supported:
if !mask[0] { wishbone_dat_w[ 7: 0] := X; }
if !mask[1] { wishbone_dat_w[15: 8] := X; }
if !mask[2] { wishbone_dat_w[23:16] := X; }
if !mask[3] { wishbone_dat_w[31:24] := X; }
// ...
}
prot read(mask: u4, addr: u30, data: u32) {
// ...
self.wishbone_sel := mask;
self.wishbone_dat_w := X;
// ...
// the following is currently not supported:
if mask[0] { assert_eq(self.wishbone_dat_r[ 7: 0], data[ 7: 0]); }
if mask[1] { assert_eq(self.wishbone_dat_r[15: 8], data[15: 8]); }
if mask[2] { assert_eq(self.wishbone_dat_r[23:16], data[23:16]); }
if mask[3] { assert_eq(self.wishbone_dat_r[31:24], data[31:24]); }
// ...
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.