chipsalliance / chipsalliance/chisel

"Default Block" / more than one match per line for switch statement

Open
#526 7 comments 1 reaction 2 assignees Claimed by @ducky64 View on GitHub
API Modification Challenge Issue Feature feature request
Dominant language
Scala
Stars
4.8k
Forks
658
Avg merge
18h 59m
Merged PRs (30d)
14

Description

Two separate feature requests

1. Have a default block available for switch statements (where if none of the is block match, it will execute the default block)
e.g.
```scala
switch(value) {
is(1) {
// do something
}
is(2) {
// do something
}
default {
error := true.B
assert(0)
}
}
```

2. Allow more than one matched value for each is block match.
e.g. (the first two cases are more useful, the subsequent examples have potential usages, but I haven't encountered it yet)
```scala
switch(value) {
is(1) {
// do something
}
is(2, 4) {
// do something
}
// we might need to figure out what it means if the user duplicate a value in this case (perhaps
execute both is blocks?) Or just error out and disallow it if it overlaps.
is(4, 6) {
}
// or maybe even more fancy, but can no longer check for non-overlapping matches if that's a requirement
is(>5) {
}
// Or even generalizing it by allowing a predicate function (Maybe this and the previous is too much, since if it gets that fancy, should probably just use when statement, and feature not in verilog anyway)
is( (v: Int):Bool => { v<7 }) {
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.