2012-02-26 02:09:26 +01:00
|
|
|
package rocket
|
2012-02-12 02:20:33 +01:00
|
|
|
|
2011-10-26 08:02:47 +02:00
|
|
|
import Chisel._
|
|
|
|
import Node._;
|
|
|
|
|
2012-02-14 03:12:23 +01:00
|
|
|
class rocketCtrlSboard(entries: Int, nread: Int, nwrite: Int) extends Component
|
2011-10-26 08:02:47 +02:00
|
|
|
{
|
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)
|
|
|
|
}
|
2011-10-26 08:02:47 +02:00
|
|
|
|
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
|
2011-10-26 08:02:47 +02:00
|
|
|
}
|