Commit ac9984b9 authored by Yuxiao Mao's avatar Yuxiao Mao
Browse files

RegmapUtil: fix decrement bug

parent ab0288cd
...@@ -19,7 +19,7 @@ class RegmapUtilCountEvent(regName: String)(implicit mp: MatanaParams) { ...@@ -19,7 +19,7 @@ class RegmapUtilCountEvent(regName: String)(implicit mp: MatanaParams) {
when (in.event && !in.decrement) { // Only inc when (in.event && !in.decrement) { // Only inc
countEvent := countEvent + 1.U // TODO? increment should not overflow countEvent := countEvent + 1.U // TODO? increment should not overflow
} .elsewhen (!in.event && in.decrement) { // Only dec } .elsewhen (!in.event && in.decrement) { // Only dec
countEvent := Mux(countEvent >= 1.U, countEvent - in.event, 0.U), // decrement should not below 0 countEvent := Mux(countEvent >= 1.U, countEvent - 1.U, 0.U), // decrement should not below 0
} // Else if inc and dec OR no inc no dec, should remain old value } // Else if inc and dec OR no inc no dec, should remain old value
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment