-
Notifications
You must be signed in to change notification settings - Fork 631
Deprecate ListLookup. #2259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Deprecate ListLookup. #2259
Conversation
I believe we could have some syntactic sugar in chisel3.util.experimental.decode wrapping the functionality for an easy-to-approach way to define the decoder (as straightforward as in ListLookup). The process of having a bundle, assigning the outputs of the decoder to it and casting to the bundle uses a complex pattern. |
You are right, I think I can add a something like |
@sequencer added a nice example to my core on the use of decoder/TruthTable: carlosedp/chiselv#2 I think there are a couple of places it could be "nicer" :) val signals = decode
.decoder(
io.DecoderPort.op,
decode.TruthTable(
// format: off
Array(
/* inst_type, ## inst ## to_alu ## branch ## use_imm ## jump ## is_load ## is_store */
// Arithmetic
BitPat("b0000000??????????000?????0110011") -> BitPat(INST_R.litValue.U(InstructionType.getWidth.W)) ## BitPat(ADD.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(),
BitPat("b?????????????????000?????0010011") -> BitPat(INST_I.litValue.U(InstructionType.getWidth.W)) ## BitPat(ADDI.litValue.U(Instruction.getWidth.W)) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(),
Other than that, it even improved the clock and logic elements usage on my core. Thanks a lot @sequencer :D |
Addressed point 1 above with #2327 |
@sequencer I've implemented a object decodeAs {
/** Decode signals using a [[Bundle]] as the output
*
* @param b the output bundle to be used as the decoded signal
* @param input input signal that contains decode table input
* @param truthTable [[TruthTable]] to decode user input.
* @return bundle with the decode output.
*
* @note The bundle width must match the TruthTable width.
*/
def apply[T <: Bundle](b: T, input: UInt, truthTable: TruthTable): T =
decoder(input, truthTable).asTypeOf(b)
def apply[T <: Bundle](minimizer: Minimizer, b: T, input: UInt, truthTable: TruthTable): T =
decoder(minimizer, input, truthTable).asTypeOf(b)
} But this way, I have to call it as: val signals = decode.decoder.decodeAs(
(new DecType),
io.DecoderPort.op,
decode.TruthTable(
Array(
... How can I make it not require the FYI, opened #2328 to address this. |
|
I want to say that this whole decoder thing seems to have a significant disadvantage compared to the old list lookup, namely it looks like you have to concatenate together all outputs and then manually extract the bits again (or do an unsafe cast to a Bundle). I would love for there to be a better, more type safe API. Maybe something using Bundle Literals and making sure that the output can only be of the type that was used to create the decoder? |
Yes, APIs for decoder is pretty primitive, I have been thinking adding a new dataview based API to view instructions as decode result. I'll prototype it this weekend(Sorry I have been too busy recently.) |
Awesome! Do you think you could prototype it in the context of chiselv? This way carlos can give you direct feedback. |
Sounds good. I'll have a try in Carlos repo. |
Yep, I'm trying to piece together a good API thru the PRs below:
I got them together and published locally to try on my core and got some nice code as can be seen in https://github.com/carlosedp/chiselv/blob/d676295d9e6cc16d4df973f2ea13005a775130bb/src/main/scala/Decoder.scala |
The part that I thought was rather unfortunate is here: https://github.com/carlosedp/chiselv/blob/d676295d9e6cc16d4df973f2ea13005a775130bb/src/main/scala/Decoder.scala#L111 Having to bit-extract the result seems very error prone. Maybe the solution could be that the decoder accepts as |
Here is my plan:
Then a Bundle/Record can use this API to construct
With this API, Construction of |
Looks good to me. With one of @carlosedp's PRs, we could even simplify:
to
|
Yes I agree. |
Hi Kev, actually I don't bit-extract from the decoder over there (it's extracting the registers from origin op only)... what I do is casting back to the Bundle here https://github.com/carlosedp/chiselv/blob/d676295d9e6cc16d4df973f2ea13005a775130bb/src/main/scala/Decoder.scala#L128-L134 using the decodeAs function I created at #2328 |
This API considers harmful and misleading to users.
Most of users use this API as decoder, however this is a sequentially cascaded Mux without logic minimization, synthesizer won't aware of the ME(mutually exclusive) from this API, which provides a bad PPA for hardware designing.
Real decoder should be a minimizer+PLA which has been implemented in chisel3.util.experimental.decode.
My proposal is:
Contributor Checklist
docs/src
?Type of Improvement
API Impact
deprecate chisel3.utils.ListLookup
Backend Code Generation Impact
None
Desired Merge Strategy
Release Notes
chisel3.util.ListLookup is replaced by chisel3.util.experimental.decode
Reviewer Checklist (only modified by reviewer)
3.3.x
, [small] API extension:3.4.x
, API modification or big change:3.5.0
)?Please Merge
?