Skip to content
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

Converted Vec to UInt #2597

Merged
merged 5 commits into from
Aug 21, 2020
Merged

Conversation

MathewTG
Copy link
Contributor

@MathewTG MathewTG commented Aug 8, 2020

Converted Vec to UInt to resolve verilog elaboration issue - freechipsproject/chisel3 Issue #1456

*Enhancement to devices/debug/Debug.scala to resolve verilog elaboration issue.
Changes incorporated as mentioned in freechipsproject/chisel3 - Issue 1456(Not in chipalliance/rocket-chip)

Comment on lines 900 to 903
}.elsewhen (hartIsInResetSync.reduce(_ | _)) {
haveResetBitRegs := haveResetBitRegs | hartIsInResetSync.asUInt
}.elsewhen (io.innerCtrl.fire() && io.innerCtrl.bits.ackhavereset) {
haveResetBitRegs := haveResetBitRegs & (~(hamaskWrSel.asUInt))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is not the same as the original. Suppose hart 23 is always in reset (maybe it is waiting for hart 0 to enable it). The second clause will always take effect, preventing the third clause from handling ackhavereset for other harts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
Thank you for the inputs.
I wrongly assumed only 1 hart would be in 1 state at a time. I'm looking into correcting this error.

Comment on lines 1202 to 1205
when (hartIsInResetSync.reduce(_ | _)) {
haltedBitRegs := haltedBitRegs & ~(hartIsInResetSync.asUInt)
resumeReqRegs := resumeReqRegs & ~(hartIsInResetSync.asUInt)
}.elsewhen (hartHaltedWrEn) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment - this code is not functionally equivalent. You must allow for some harts to be in reset while others are not.

Copy link
Contributor

@ernie-sifive ernie-sifive left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is much closer, but it still doesn't quite have the same behavior it used to. When there are multiple active assignments to one Reg, the last one takes effect and all others are ignored. In other words, you need to handle setting some bits of haltedBitRegs and haveResetBitRegs and clearing others in the same expression.

val a = RegInit(0.U(8.W))
a := a | 1.U
a := a | 2.U

results in a=2, not a=3. Only the second assignment occurs.

Also, please convert all the tab characters in the file to spaces.

Comment on lines 1205 to 1212
val hartHaltedIdIndex = UIntToOH(hartSelFuncs.hartIdToHartSel(hartHaltedId))
val hartResumingIdIndex = UIntToOH(hartSelFuncs.hartIdToHartSel(hartResumingId))
val hartselIndex = UIntToOH(io.innerCtrl.bits.hartsel)
when (hartHaltedWrEn) {
haltedBitRegs := haltedBitRegs | hartHaltedIdIndex
}.elsewhen (hartResumingWrEn) {
when (hartSelFuncs.hartIdToHartSel(hartResumingId) === component.U) {
haltedBitRegs(component) := false.B
}
haltedBitRegs := haltedBitRegs & ~(hartResumingIdIndex)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fail if one hart's hartIsInResetSync is 1 in the same cycle that another hart is doing hartHaltedWrEn. I suggest combining everything into one expression, like this:

        when (hartHaltedWrEn) {
          haltedBitRegs := (haltedBitRegs | hartHaltedIdIndex) & ~(hartIsInResetSync.asUInt)
        }.elsewhen (hartResumingWrEn) {
          haltedBitRegs := haltedBitRegs & ~(hartResumingIdIndex) & ~(hartIsInResetSync.asUInt)
        }.otherwise {
          haltedBitRegs := haltedBitRegs & ~(hartIsInResetSync.asUInt)
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this out, but the asm-tests run indefinitely in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correction.
It was when I tried applying the same transformation to resumeReqRegs that the asm-tests run indefintely.
For now pulling only haltedBitRegs

src/main/scala/devices/debug/Debug.scala Outdated Show resolved Hide resolved
MathewTG and others added 3 commits August 18, 2020 13:48
Co-authored-by: Ernie Edgar <43148441+ernie-sifive@users.noreply.github.com>
Copy link
Contributor

@ernie-sifive ernie-sifive left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@jackkoenig
Copy link
Contributor

I'm running some additional tests, will merge assuming they come back green.

Copy link
Contributor

@jackkoenig jackkoenig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately there appears to be some functional issue. I'll try to distill it to a simple example when I get a chance.

@jackkoenig
Copy link
Contributor

Turns out my tests were flakey, thanks a lot @MathewTG!

@jackkoenig jackkoenig dismissed their stale review August 21, 2020 21:17

Testers were flakey

@jackkoenig jackkoenig merged commit 375045a into chipsalliance:master Aug 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants