2011-10-26 08:02:47 +02:00
|
|
|
package Top
|
|
|
|
{
|
|
|
|
import Chisel._
|
|
|
|
import Node._;
|
|
|
|
import Constants._;
|
|
|
|
|
|
|
|
class ioCtrlSboard extends Bundle()
|
|
|
|
{
|
2012-01-18 19:28:48 +01:00
|
|
|
val clr = Bool(INPUT);
|
|
|
|
val clra = UFix(5, INPUT);
|
|
|
|
val set = Bool(INPUT);
|
|
|
|
val seta = UFix(5, INPUT);
|
|
|
|
val raddra = UFix(5, INPUT);
|
|
|
|
val raddrb = UFix(5, INPUT);
|
|
|
|
val raddrc = UFix(5, INPUT);
|
2012-02-08 08:54:25 +01:00
|
|
|
val raddrd = UFix(5, INPUT);
|
2012-01-18 19:28:48 +01:00
|
|
|
val stalla = Bool(OUTPUT);
|
|
|
|
val stallb = Bool(OUTPUT);
|
|
|
|
val stallc = Bool(OUTPUT);
|
2012-02-08 08:54:25 +01:00
|
|
|
val stalld = Bool(OUTPUT);
|
2011-10-26 08:02:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class rocketCtrlSboard extends Component
|
|
|
|
{
|
|
|
|
override val io = new ioCtrlSboard();
|
|
|
|
val reg_busy = Reg(width = 32, resetVal = Bits(0, 32));
|
|
|
|
|
2012-01-02 11:51:30 +01:00
|
|
|
val set_mask = io.set.toUFix << io.seta;
|
|
|
|
val clr_mask = ~(io.clr.toUFix << io.clra);
|
|
|
|
reg_busy <== (reg_busy | set_mask) & clr_mask
|
2011-10-26 08:02:47 +02:00
|
|
|
|
|
|
|
io.stalla := reg_busy(io.raddra).toBool;
|
|
|
|
io.stallb := reg_busy(io.raddrb).toBool;
|
|
|
|
io.stallc := reg_busy(io.raddrc).toBool;
|
2012-02-08 08:54:25 +01:00
|
|
|
io.stalld := reg_busy(io.raddrd).toBool;
|
2011-10-26 08:02:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class ioCtrlCnt extends Bundle()
|
|
|
|
{
|
2012-01-18 19:28:48 +01:00
|
|
|
val enq = Bool(INPUT);
|
|
|
|
val deq = Bool(INPUT);
|
|
|
|
val empty = Bool(OUTPUT);
|
|
|
|
val full = Bool(OUTPUT);
|
2011-10-26 08:02:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class rocketCtrlCnt(n_bits: Int, limit: Int) extends Component
|
|
|
|
{
|
|
|
|
override val io = new ioCtrlCnt();
|
|
|
|
val counter = Reg(width = n_bits, resetVal = UFix(0, n_bits));
|
|
|
|
when (io.enq && !io.deq) {
|
|
|
|
counter <== counter + UFix(1, n_bits);
|
|
|
|
}
|
|
|
|
when (!io.enq && io.deq) {
|
|
|
|
counter <== counter - UFix(1, n_bits);
|
|
|
|
}
|
|
|
|
io.empty := counter === UFix(0, n_bits);
|
|
|
|
io.full := counter === UFix(limit, n_bits);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|