diff --git a/src/main/scala/devices/spi/SPIFIFO.scala b/src/main/scala/devices/spi/SPIFIFO.scala index a322a1b..5bc6e82 100644 --- a/src/main/scala/devices/spi/SPIFIFO.scala +++ b/src/main/scala/devices/spi/SPIFIFO.scala @@ -41,7 +41,7 @@ class SPIFIFO(c: SPIParamsBase) extends Module { val proto = SPIProtocol.decode(io.link.fmt.proto).zipWithIndex val cnt_quot = Mux1H(proto.map { case (s, i) => s -> (io.ctrl.fmt.len >> i) }) - val cnt_rmdr = Mux1H(proto.map { case (s, i) => s -> (io.ctrl.fmt.len(i, 0).orR) }) + val cnt_rmdr = Mux1H(proto.map { case (s, i) => s -> (if (i > 0) io.ctrl.fmt.len(i-1, 0).orR else UInt(0)) }) io.link.fmt <> io.ctrl.fmt io.link.cnt := cnt_quot + cnt_rmdr