-
Notifications
You must be signed in to change notification settings - Fork 609
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
Add decodeAs
API to output decoded signals directly to a Bundle
#2328
Conversation
decodeAs
API to output decoded signals directly to a Bundle
Thanks carlos! Could you add a example/test please? |
Sure, will add to the PR and below: class DecType extends Bundle {
val inst_type = UInt(InstructionType.getWidth.W)
val inst = UInt(Instruction.getWidth.W)
val to_alu = Bool()
val branch = Bool()
val use_imm = Bool()
val jump = Bool()
val is_load = Bool()
val is_store = Bool()
}
val signals = decode.decodeAs(
(new DecType),
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) ## BitPat(ADD) ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N() ## BitPat.N(),
BitPat("b?????????????????000?????0010011") -> BitPat(INST_I) ## BitPat(ADDI) ## BitPat.Y() ## BitPat.N() ## BitPat.Y() ## BitPat.N() ## BitPat.N() ## BitPat.N(),
), BitPat(IN_ERR) ## BitPat(ERR) ## BitPat.dontCare(6) // Default values
// format: on
)
) @ekiwi so per your comment on the other PR, having |
I'm trying to write a test case but it complains it's not in a Builder context: class DecoderSpec extends AnyFlatSpec {
"decoder" should "decodeAs to an existing bundle" in {
class OutputBundle extends Bundle {
val s1 = UInt(2.W)
val s2 = UInt(2.W)
val s3 = Bool()
}
val selector = "b001".U
val signals = decodeAs(
(new OutputBundle),
selector,
TruthTable(
Array(
BitPat("b001") -> BitPat(1.U(2.W)) ## BitPat(1.U(2.W)) ## BitPat.Y(),
BitPat("b?11") -> BitPat(2.U(2.W)) ## BitPat(2.U(2.W)) ## BitPat.N(),
), BitPat(0.U(2.W)) ## BitPat(0.U(2.W)) ## BitPat.dontCare(1) // Default values
)
)
assert(signals.s1 === true)
assert(signals.s2 === true)
assert(signals.s3 === true)
}
} Cc. @sequencer |
You need to put your code into a chisel Module. Unfortunately most chisel constructs are only supported in that context. |
Added a test spec for it! |
In cases where my Bundle has Enums, I'm getting a cast warning like I believe in the return of My Bundle: class DecType extends Bundle {
val inst_type = InstructionType()
val inst = Instruction()
val to_alu = Bool()
val branch = Bool()
val use_imm = Bool()
val jump = Bool()
val is_load = Bool()
val is_store = Bool()
} Where inst and inst_type are |
I'd like to have provide a |
I think this is the last missing piece to have a nice API for decode (1H enum + Mux1H + decodeAs + Bitpat accepting enums) :) |
I agree, Mux1H taking enum is a necessary feature that we have benign missing.
However the |
Happy new year, and hopefully resolved in #2924 |
Contributor Checklist
docs/src
?Type of Improvement
API Impact
This PR adds a new
decodeAs
function to decoder allowing the signal decode output to go directly to a Bundle.Backend Code Generation Impact
No Verilog output impact.
Desired Merge Strategy
Release Notes
Added a new
decodeAs
function to decoder allowing the signal decode output to go directly to a Bundle.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
?