Skip to content

Commit

Permalink
fix(countcomb): make module function correctly
Browse files Browse the repository at this point in the history
Makes the module not count duplicate consequtive bits.
  • Loading branch information
serjzimmerman committed Apr 17, 2024
1 parent 8e75611 commit 2faa19e
Showing 1 changed file with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,24 @@ class CountCombinations(numBits: Int) extends Module {
})

private val three = "b11".U

val areOnes =
VecInit
.tabulate(numBits - 1) { i =>
val currentBits = io.value(i + 1, i)
currentBits === three
};

val utilVec = VecInit(0.U(numBits.W).asBools)
for (i <- 0 until numBits - 1) {
utilVec(i) := (if (i == 0) { areOnes(i) }
else {
!utilVec(i - 1) && areOnes(i)
})
}

io.count :=
PopCount(
VecInit
.tabulate(numBits - 1) { i => (io.value(i + 1, i) === three) }
.asUInt
)
PopCount(utilVec.asUInt)
}

class CountCombinationsTopIO(numDigits: Int, numLeds: Int) extends Bundle {
Expand Down

0 comments on commit 2faa19e

Please sign in to comment.