1
0
rocket-chip/rocket/src/main/scala/ctrl_util.scala

33 lines
782 B
Scala
Raw Normal View History

package rocket
2012-02-12 02:20:33 +01:00
import Chisel._
import Node._;
2012-02-14 03:12:23 +01:00
class rocketCtrlSboard(entries: Int, nread: Int, nwrite: Int) extends Component
{
2012-02-14 03:12:23 +01:00
class read_port extends Bundle {
val addr = UFix(log2up(entries), INPUT)
val data = Bool(OUTPUT)
}
class write_port extends Bundle {
val en = Bool(INPUT)
val addr = UFix(log2up(entries), INPUT)
val data = Bool(INPUT)
}
2012-02-14 03:12:23 +01:00
val io = new Bundle {
val r = Vec(nread) { new read_port() }
val w = Vec(nwrite) { new write_port() }
}
val busybits = Reg(resetVal = Bits(0, entries));
for (i <- 0 until nread)
io.r(i).data := busybits(io.r(i).addr)
var wdata = busybits
for (i <- 0 until nwrite)
wdata = wdata.bitSet(io.w(i).addr, Mux(io.w(i).en, io.w(i).data, wdata(io.w(i).addr)))
busybits := wdata
}