Use a generic UInt for TileLink op sizes, rather than MT_xx enum
This commit is contained in:
@ -7,17 +7,6 @@ import Chisel._
|
||||
|
||||
object MemoryOpConstants extends MemoryOpConstants
|
||||
trait MemoryOpConstants {
|
||||
val MT_SZ = 3
|
||||
val MT_X = BitPat("b???")
|
||||
val MT_B = UInt("b000")
|
||||
val MT_H = UInt("b001")
|
||||
val MT_W = UInt("b010")
|
||||
val MT_D = UInt("b011")
|
||||
val MT_BU = UInt("b100")
|
||||
val MT_HU = UInt("b101")
|
||||
val MT_WU = UInt("b110")
|
||||
val MT_Q = UInt("b111")
|
||||
|
||||
val NUM_XA_OPS = 9
|
||||
val M_SZ = 5
|
||||
val M_X = BitPat("b?????");
|
||||
|
@ -73,16 +73,6 @@ class NastiIOTileLinkIOConverter(implicit p: Parameters) extends TLModule()(p)
|
||||
val nasti = new NastiIO
|
||||
}
|
||||
|
||||
private def opSizeToXSize(ops: UInt) = MuxLookup(ops, UInt("b111"), Seq(
|
||||
MT_B -> UInt(0),
|
||||
MT_BU -> UInt(0),
|
||||
MT_H -> UInt(1),
|
||||
MT_HU -> UInt(1),
|
||||
MT_W -> UInt(2),
|
||||
MT_WU -> UInt(2),
|
||||
MT_D -> UInt(3),
|
||||
MT_Q -> UInt(log2Up(tlDataBytes))))
|
||||
|
||||
val dataBits = tlDataBits*tlDataBeats
|
||||
require(tlDataBits == nastiXDataBits, "Data sizes between LLC and MC don't agree") // TODO: remove this restriction
|
||||
require(tlDataBeats < (1 << nastiXLenBits), "Can't have that many beats")
|
||||
@ -155,7 +145,7 @@ class NastiIOTileLinkIOConverter(implicit p: Parameters) extends TLModule()(p)
|
||||
id = get_id_mapper.io.req.out_id,
|
||||
addr = io.tl.acquire.bits.full_addr(),
|
||||
size = Mux(is_subblock,
|
||||
opSizeToXSize(io.tl.acquire.bits.op_size()),
|
||||
io.tl.acquire.bits.op_size(),
|
||||
UInt(log2Ceil(tlDataBytes))),
|
||||
len = Mux(is_subblock, UInt(0), UInt(tlDataBeats - 1)))
|
||||
|
||||
@ -276,13 +266,6 @@ class TileLinkIONastiIOConverter(implicit p: Parameters) extends TLModule()(p)
|
||||
def nasti_addr_byte(chan: NastiAddressChannel): UInt =
|
||||
chan.addr(tlByteAddrBits - 1, 0)
|
||||
|
||||
def nasti_operand_size(chan: NastiAddressChannel): UInt =
|
||||
MuxLookup(chan.size, MT_Q, Seq(
|
||||
UInt(0) -> MT_BU,
|
||||
UInt(1) -> MT_HU,
|
||||
UInt(2) -> MT_WU,
|
||||
UInt(3) -> MT_D))
|
||||
|
||||
def size_mask(size: UInt): UInt =
|
||||
(UInt(1) << (UInt(1) << size)) - UInt(1)
|
||||
|
||||
@ -333,7 +316,7 @@ class TileLinkIONastiIOConverter(implicit p: Parameters) extends TLModule()(p)
|
||||
addr_block = nasti_addr_block(io.nasti.ar.bits),
|
||||
addr_beat = nasti_addr_beat(io.nasti.ar.bits),
|
||||
addr_byte = nasti_addr_byte(io.nasti.ar.bits),
|
||||
operand_size = nasti_operand_size(io.nasti.ar.bits),
|
||||
operand_size = io.nasti.ar.bits.size,
|
||||
alloc = Bool(false)))
|
||||
|
||||
val put_acquire = Mux(is_multibeat(aw_req),
|
||||
|
@ -91,8 +91,7 @@ class ClientTileLinkIOUnwrapper(implicit p: Parameters) extends TLModule()(p) {
|
||||
addr_block = iacq.addr_block,
|
||||
addr_beat = iacq.addr_beat,
|
||||
data = iacq.data,
|
||||
union = Mux(iacq.isBuiltInType(),
|
||||
iacq.union, Cat(MT_Q, M_XRD, Bool(true))))
|
||||
union = iacq.union)
|
||||
io.in.acquire.ready := acq_helper.fire(io.in.acquire.valid)
|
||||
|
||||
relRoq.io.enq.valid := rel_helper.fire(rel_roq_ready, rel_roq_enq)
|
||||
@ -418,16 +417,7 @@ class TileLinkIONarrower(innerTLId: String, outerTLId: String)
|
||||
assert(!io.in.acquire.valid || !smallput || PopCount(beat_sel) <= UInt(1),
|
||||
"Can't perform Put wider than outer width")
|
||||
|
||||
val read_size_ok = MuxLookup(iacq.op_size(), Bool(false), Seq(
|
||||
MT_B -> Bool(true),
|
||||
MT_BU -> Bool(true),
|
||||
MT_H -> Bool(outerDataBits >= 16),
|
||||
MT_HU -> Bool(outerDataBits >= 16),
|
||||
MT_W -> Bool(outerDataBits >= 32),
|
||||
MT_WU -> Bool(outerDataBits >= 32),
|
||||
MT_D -> Bool(outerDataBits >= 64),
|
||||
MT_Q -> Bool(false)))
|
||||
|
||||
val read_size_ok = iacq.op_size() <= UInt(log2Ceil(outerDataBits / 8))
|
||||
assert(!io.in.acquire.valid || !smallget || read_size_ok,
|
||||
"Can't perform Get wider than outer width")
|
||||
|
||||
|
@ -59,8 +59,7 @@ class NastiROM(contents: Seq[Byte])(implicit p: Parameters) extends Module {
|
||||
val slice = contents.slice(i*byteWidth, (i+1)*byteWidth)
|
||||
UInt(slice.foldRight(BigInt(0)) { case (x,y) => (y << 8) + (x.toInt & 0xFF) }, byteWidth*8)
|
||||
}
|
||||
val rdata_word = rom(if (rows == 1) UInt(0) else ar.bits.addr(log2Up(contents.size)-1,log2Up(byteWidth)))
|
||||
val rdata = new LoadGen(Cat(UInt(1), ar.bits.size), ar.bits.addr, rdata_word, Bool(false), byteWidth).data
|
||||
val rdata = rom(if (rows == 1) UInt(0) else ar.bits.addr(log2Up(contents.size)-1,log2Up(byteWidth)))
|
||||
|
||||
io.r <> ar
|
||||
io.r.bits := NastiReadDataChannel(ar.bits.id, rdata)
|
||||
|
@ -72,7 +72,7 @@ trait HasTileLinkParameters {
|
||||
val tlBeatAddrBits = log2Up(tlDataBeats)
|
||||
val tlByteAddrBits = log2Up(tlWriteMaskBits)
|
||||
val tlMemoryOpcodeBits = M_SZ
|
||||
val tlMemoryOperandSizeBits = MT_SZ
|
||||
val tlMemoryOperandSizeBits = log2Ceil(log2Ceil(tlWriteMaskBits) + 1)
|
||||
val tlAcquireTypeBits = max(log2Up(Acquire.nBuiltInTypes),
|
||||
tlCoh.acquireTypeWidth)
|
||||
val tlAcquireUnionBits = max(tlWriteMaskBits,
|
||||
@ -380,10 +380,11 @@ object Acquire {
|
||||
val tlExternal = p(TLKey(p(TLId)))
|
||||
val tlWriteMaskBits = tlExternal.writeMaskBits
|
||||
val tlByteAddrBits = log2Up(tlWriteMaskBits)
|
||||
val tlMemoryOperandSizeBits = log2Ceil(log2Ceil(tlWriteMaskBits) + 1)
|
||||
|
||||
// These had better be the right size when we cat them together!
|
||||
val my_addr_byte = (UInt(0, tlByteAddrBits) | addr_byte)(tlByteAddrBits-1, 0)
|
||||
val my_operand_size = (UInt(0, MT_SZ) | operand_size)(MT_SZ-1, 0)
|
||||
val my_operand_size = (UInt(0, tlMemoryOperandSizeBits) | operand_size)(tlMemoryOperandSizeBits-1, 0)
|
||||
val my_opcode = (UInt(0, M_SZ) | opcode)(M_SZ-1, 0)
|
||||
val my_wmask = (UInt(0, tlWriteMaskBits) | wmask)(tlWriteMaskBits-1, 0)
|
||||
|
||||
@ -436,7 +437,7 @@ object BuiltInAcquireBuilder {
|
||||
addr_beat: UInt = UInt(0),
|
||||
data: UInt = UInt(0),
|
||||
addr_byte: UInt = UInt(0),
|
||||
operand_size: UInt = MT_Q,
|
||||
operand_size: UInt = UInt(0),
|
||||
opcode: UInt = UInt(0),
|
||||
wmask: UInt = UInt(0),
|
||||
alloc: Bool = Bool(true))
|
||||
|
@ -22,13 +22,11 @@ class GetMultiWidthDriver(implicit p: Parameters) extends Driver()(p) {
|
||||
val s_start :: s_send :: s_recv :: s_done :: Nil = Enum(Bits(), 4)
|
||||
val state = Reg(init = s_start)
|
||||
|
||||
val size = Reg(UInt(width = MT_SZ))
|
||||
val ref = Reg(UInt(width = 64))
|
||||
val bytemask = MuxLookup(size, UInt(0), Seq(
|
||||
MT_D -> UInt("hff"),
|
||||
MT_W -> UInt("h0f"),
|
||||
MT_H -> UInt("h03"),
|
||||
MT_B -> UInt("h01")))
|
||||
val w = 64
|
||||
val initialSize = UInt(log2Ceil(w/8))
|
||||
val size = Reg(UInt(width = log2Ceil(log2Ceil(w/8)+1)))
|
||||
val ref = Reg(UInt(width = w))
|
||||
val bytemask = (UInt(1) << (UInt(1) << size)) - UInt(1)
|
||||
val bitmask = FillInterleaved(8, bytemask)
|
||||
|
||||
io.mem.acquire.valid := (state === s_send)
|
||||
@ -42,20 +40,20 @@ class GetMultiWidthDriver(implicit p: Parameters) extends Driver()(p) {
|
||||
io.mem.grant.ready := (state === s_recv)
|
||||
|
||||
when (state === s_start && io.start) {
|
||||
size := MT_D
|
||||
size := initialSize
|
||||
state := s_send
|
||||
}
|
||||
|
||||
when (io.mem.acquire.fire()) { state := s_recv }
|
||||
when (io.mem.grant.fire()) {
|
||||
when (size === MT_D) { ref := io.mem.grant.bits.data }
|
||||
when (size === initialSize) { ref := io.mem.grant.bits.data }
|
||||
size := size - UInt(1)
|
||||
state := Mux(size === MT_B, s_done, s_send)
|
||||
state := Mux(size === UInt(0), s_done, s_send)
|
||||
}
|
||||
|
||||
io.finished := state === s_done
|
||||
|
||||
assert(!io.mem.grant.valid || size === MT_D ||
|
||||
assert(!io.mem.grant.valid || size === initialSize ||
|
||||
(io.mem.grant.bits.data & bitmask) === (ref & bitmask),
|
||||
"GetMultiWidth: smaller get does not match larger get")
|
||||
}
|
||||
@ -325,7 +323,7 @@ class PutAtomicDriver(implicit p: Parameters) extends Driver()(p) {
|
||||
addr_beat = UInt(0),
|
||||
addr_byte = UInt(2),
|
||||
atomic_opcode = M_XA_ADD,
|
||||
operand_size = MT_H,
|
||||
operand_size = UInt(log2Ceil(16 / 8)),
|
||||
data = UInt(3 << 16))
|
||||
|
||||
val get_acquire = Get(
|
||||
|
@ -34,9 +34,8 @@ class StoreGenAligned(typ: UInt, addr: UInt, dat: UInt, maxSize: Int) extends St
|
||||
override def genData(i: Int) = dat
|
||||
}
|
||||
|
||||
class LoadGen(typ: UInt, addr: UInt, dat: UInt, zero: Bool, maxSize: Int) {
|
||||
private val t = new StoreGen(typ, addr, dat, maxSize)
|
||||
private val signed = typ.asSInt >= SInt(0)
|
||||
class LoadGen(typ: UInt, signed: Bool, addr: UInt, dat: UInt, zero: Bool, maxSize: Int) {
|
||||
private val size = new StoreGen(typ, addr, dat, maxSize).size
|
||||
|
||||
private def genData(logMinSize: Int): UInt = {
|
||||
var res = dat
|
||||
@ -45,7 +44,7 @@ class LoadGen(typ: UInt, addr: UInt, dat: UInt, zero: Bool, maxSize: Int) {
|
||||
val shifted = Mux(addr(i), res(2*pos-1,pos), res(pos-1,0))
|
||||
val doZero = Bool(i == 0) && zero
|
||||
val zeroed = Mux(doZero, UInt(0), shifted)
|
||||
res = Cat(Mux(t.size === UInt(i) || doZero, Fill(8*maxSize-pos, signed && zeroed(pos-1)), res(8*maxSize-1,pos)), zeroed)
|
||||
res = Cat(Mux(size === UInt(i) || doZero, Fill(8*maxSize-pos, signed && zeroed(pos-1)), res(8*maxSize-1,pos)), zeroed)
|
||||
}
|
||||
res
|
||||
}
|
||||
@ -61,7 +60,7 @@ class AMOALU(rhsIsAligned: Boolean = false)(implicit p: Parameters) extends Modu
|
||||
val io = new Bundle {
|
||||
val addr = Bits(INPUT, blockOffBits)
|
||||
val cmd = Bits(INPUT, M_SZ)
|
||||
val typ = Bits(INPUT, MT_SZ)
|
||||
val typ = Bits(INPUT, log2Ceil(log2Ceil(operandBits/8) + 1))
|
||||
val lhs = Bits(INPUT, operandBits)
|
||||
val rhs = Bits(INPUT, operandBits)
|
||||
val out = Bits(OUTPUT, operandBits)
|
||||
@ -75,8 +74,6 @@ class AMOALU(rhsIsAligned: Boolean = false)(implicit p: Parameters) extends Modu
|
||||
val sgned = io.cmd === M_XA_MIN || io.cmd === M_XA_MAX
|
||||
val max = io.cmd === M_XA_MAX || io.cmd === M_XA_MAXU
|
||||
val min = io.cmd === M_XA_MIN || io.cmd === M_XA_MINU
|
||||
val word = io.typ === MT_W || io.typ === MT_WU || // Logic minimization:
|
||||
io.typ === MT_B || io.typ === MT_BU
|
||||
|
||||
val adder_out =
|
||||
if (operandBits == 32) io.lhs + rhs
|
||||
@ -88,6 +85,7 @@ class AMOALU(rhsIsAligned: Boolean = false)(implicit p: Parameters) extends Modu
|
||||
val less =
|
||||
if (operandBits == 32) Mux(io.lhs(31) === rhs(31), io.lhs < rhs, Mux(sgned, io.lhs(31), io.rhs(31)))
|
||||
else {
|
||||
val word = !io.typ(0)
|
||||
val cmp_lhs = Mux(word && !io.addr(2), io.lhs(31), io.lhs(63))
|
||||
val cmp_rhs = Mux(word && !io.addr(2), rhs(31), rhs(63))
|
||||
val lt_lo = io.lhs(31,0) < rhs(31,0)
|
||||
|
Reference in New Issue
Block a user