chipsalliance / chipsalliance/chisel

[Feature Request] Request MuxTLookup

Open
#4,066 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Scala
Stars
4.8k
Forks
658
Avg merge
18h 59m
Merged PRs (30d)
14

Description

**Type of issue**: Feature Request

**Is your feature request related to a problem? Please describe.**
I would like to extend the functionality of MuxLookup a bit like this:
```scala
val (test0,test1, test2) = MuxTLookup(in.foo, (1.U, 2.U, true.B),Seq(
1.U -> (2.U, 3.U, false.B),
2.U -> (3.U, 4.U, true.B),
3.U -> (4.U, 5.U, false.B),
))
```
Currently Chisel's MuxLookup API does not support this usage, Chisel compiler will report an error when we use it as in the above example:
```scala
[#6] [error] [S <: chisel3.EnumType, T <: chisel3.Data](key: S, default: T)(mapping: Seq[(S, T)]): T
[#6] [error] [T <: chisel3.Data](key: chisel3.UInt, default: T)(mapping: Seq[(chisel3.UInt, T)]): T
[#6] [error] cannot be applied to (chisel3.UInt, (chisel3.UInt, chisel3.UInt, chisel3.Bool))
[#6] [error] val (test0, test1, test2) = MuxLookup(in.foo, (1.U,2.U, true.B))(Seq(
[#6] [error] ^
[#6] [error] one error found
```

**Describe the solution you'd like**
I noticed that the rocket-chip has a MuxTLookup API with similar functionality:
https://github.com/chipsalliance/rocket-chip/blob/dbcb06afe1c76d1129cb6d264949322a34c37185/src/main/scala/util/Misc.scala#L45
I think this API can be handy in circuit design, Can we add the MuxTLookup API to Chisel?

Contributor guide

Open the contributing guide

Research direction

Start by locating Chisel's MuxLookup implementation and compare the requested API with rocket-chip's util/Misc.scala implementation linked in the issue. Confirm how tuple defaults and mappings should be handled, then verify that the example compiles and add coverage for the supported usage.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.