fix Mux1H for bundles
This commit is contained in:
parent
81dcb194d3
commit
6e2610b0ad
@ -158,18 +158,21 @@ class Mux1H [T <: Data](n: Int)(gen: => T) extends Component
|
|||||||
val out = gen.asOutput
|
val out = gen.asOutput
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n > 2) {
|
def buildMux(sel: Bits, in: Vec[T], i: Int, n: Int): T = {
|
||||||
var out = io.in(0).toBits & Fill(gen.getWidth, io.sel(0))
|
if (n == 1)
|
||||||
for (i <- 1 to n-1)
|
in(i)
|
||||||
out = out | (io.in(i).toBits & Fill(gen.getWidth, io.sel(i)))
|
else
|
||||||
io.out := out
|
{
|
||||||
} else if (n == 2) {
|
val half_n = (1 << log2up(n))/2
|
||||||
io.out := Mux(io.sel(1), io.in(1), io.in(0))
|
val left = buildMux(sel, in, i, half_n)
|
||||||
} else {
|
val right = buildMux(sel, in, i + half_n, n - half_n)
|
||||||
io.out := io.in(0)
|
Mux(sel(i+n-1,i+half_n).orR, right, left)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
io.out := buildMux(io.sel.toBits, io.in, 0, n)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class ioDecoupled[+T <: Data]()(data: => T) extends Bundle
|
class ioDecoupled[+T <: Data]()(data: => T) extends Bundle
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user