Skip to content

Commit e7ff788

Browse files
Cleanup hardware modules
1 parent 8f3c335 commit e7ff788

File tree

9 files changed

+7
-145
lines changed

9 files changed

+7
-145
lines changed

src/main/scala/caches/hardware/pipelined/MemoryInterface.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ class MemoryInterface(nCores: Int, nWays: Int, nHalfMissCmds: Int, reqIdWidth: I
9999
val missFifoPop = WireDefault(false.B)
100100
val updateLogicValid = WireDefault(false.B)
101101
val updateLogicValidCmd = WireDefault(false.B)
102-
val cacheRData = WireDefault(0.U(blockWidth.W))
103-
val cacheRespStatus = WireDefault(0.U(1.W))
104102

105103
switch(stateReg) {
106104
is(sIdle) {

src/main/scala/caches/hardware/pipelined/RejectionQueue.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ class RejectionQueue(nCores: Int, addrWidth: Int, dataWidth: Int, reqIdWidth: In
4141
io.popCoreId := popData(coreIdWidth - 1 + reqIdWidth + addrWidth + (dataWidth / 8) + dataWidth + 1, reqIdWidth + addrWidth + (dataWidth / 8) + dataWidth + 1)
4242

4343
io.full := !rejectQueue.io.enq.ready
44-
io.popEntry.reqId.valid := rejectQueue.io.deq.valid // && popCountReg =/= 0.U
44+
io.popEntry.reqId.valid := rejectQueue.io.deq.valid
4545
}

src/main/scala/caches/hardware/pipelined/SharedPipelinedCacheTestTop.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package caches.hardware.pipelined
33
import chisel3._
44
import chisel3.util._
55
import caches.hardware.reppol._
6+
import caches.hardware.util.DummyDRAM
67

78
class SharedCachePort(nCores: Int, reqIdWidth: Int, addrWidth: Int, dataWidth: Int) extends Bundle {
89
val cores = Vec(nCores, new CacheCorePortIO(addrWidth, dataWidth, reqIdWidth))
@@ -53,7 +54,7 @@ class SharedPipelinedCacheTestTop(
5354
})
5455

5556
// The dummy memory is sub-block addressable
56-
val memory = Module(new DummyMemory(addressWidth - log2Ceil(memBeatSize), bytesPerBlock * 8, memBeatSize, memBurstLen, dataFile))
57+
val memory = Module(new DummyDRAM(addressWidth - log2Ceil(memBeatSize), bytesPerBlock * 8, memBeatSize, memBurstLen, dataFile))
5758

5859
for (coreIdx <- 0 until nCores) {
5960
arbiter.io.ports(coreIdx).reqId <> io.requests.cores(coreIdx).req.reqId

src/main/scala/caches/hardware/reppol/ContentionReplacementPolicy.scala

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package caches.hardware.reppol
33
import chisel3._
44
import chisel3.util._
55
import caches.hardware.util.Constants.CONTENTION_LIMIT_WIDTH
6-
import caches.hardware.util.{MemBlock, PipelineReg, UpdateSingleVecElem}
6+
import caches.hardware.util.{MemBlock, PipelineReg}
77

88
class LineAssignmentsArray(nWays: Int, nSets: Int, nCores: Int) extends Module() {
99
val io = IO(new Bundle {
@@ -188,26 +188,4 @@ class ContentionReplacementPolicy(
188188
io.control.replacementSet := VecInit(Seq.fill(nWays)(0.U(log2Up(nWays).W)))
189189
io.control.updateCoreReachedLimit := coreTable.io.rCritCores(io.control.updateCoreId) && (coreTable.io.rLimits(io.control.updateCoreId) === 0.U)
190190
io.control.updateCoreIsCrit := coreTable.io.rCritCores(io.control.updateCoreId)
191-
}
192-
193-
object ContentionReplacementPolicy extends App {
194-
// val l2Size = 262144 // 256 KiB
195-
// val l2Size = 16384 // 16 KiB
196-
val l2Size = 131072 // 128 KiB
197-
val l2Ways = 8
198-
val nCores = 4
199-
val l2BytesPerBlock = 64
200-
val l2nSets = l2Size / (l2Ways * l2BytesPerBlock)
201-
202-
val plruL2RepPolicy = () => new BitPlruReplacementPolicy(l2Ways, l2nSets, nCores)
203-
204-
(new chisel3.stage.ChiselStage).emitVerilog(
205-
new ContentionReplacementPolicy(
206-
l2Ways,
207-
l2nSets,
208-
nCores,
209-
plruL2RepPolicy
210-
),
211-
Array("--target-dir", "generated")
212-
)
213191
}

src/main/scala/caches/hardware/util/Constants.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package caches.hardware.util
22

33
object Constants {
4-
val ADDRESS_WIDTH = 32
5-
64
val CONTENTION_LIMIT_WIDTH = 11 // If the maximum limit is 100k and assuming a single L2 cache miss latency is 60 cc, then we need only 11 bits to represent the maximum contention limit count
75

86
val TIMEOUT_LIMIT_WIDTH = 16 // Assuming one sets timers are ticked down each cycle, and default size includes 512 sets, each timer is decremented every 512 cycles, giving a max timer at 500k using 10 bits

src/main/scala/caches/hardware/pipelined/DummyMemory.scala renamed to src/main/scala/caches/hardware/util/DummyDRAM.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
package caches.hardware.pipelined
1+
package caches.hardware.util
22

3-
import caches.hardware.util.MemBlock
3+
import caches.hardware.pipelined.CacheMemoryControllerIO
44
import chisel3._
55
import chisel3.util._
66

7-
class DummyMemory(addrWidth: Int, blockWidth: Int, beatSize: Int, burstLen: Int, dataFile: Option[String] = None) extends Module {
7+
class DummyDRAM(addrWidth: Int, blockWidth: Int, beatSize: Int, burstLen: Int, dataFile: Option[String] = None) extends Module {
88
require((blockWidth * 8) > beatSize, "Block width must be greater than beat size.")
99

1010
val io = IO(Flipped(new CacheMemoryControllerIO(addrWidth, beatSize)))

src/main/scala/caches/hardware/util/MemBlock.scala

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,6 @@ class TwoReadMemBlockIO(depth: Int, width: Int) extends Bundle {
2424
val readData2 = Output(UInt(width.W))
2525
}
2626

27-
class MaskedMemBlockIO(depth: Int, width: Int, maskElemWidth: Int) extends Bundle {
28-
val readAddr = Input(UInt(log2Up(depth).W))
29-
val writeAddr = Input(UInt(log2Up(depth).W))
30-
val writeData = Input(UInt(width.W))
31-
val wrEn = Input(Bool())
32-
val byteEn = Input(Vec(width / maskElemWidth, Bool()))
33-
val readData = Output(UInt(width.W))
34-
}
35-
3627
/**
3728
* General purpose synchronous memory block.
3829
*
@@ -86,63 +77,6 @@ class MemBlock(depth: Int, width: Int, forward: Boolean = true, stallReg: Boolea
8677
}
8778
}
8879

89-
/**
90-
* General purpose synchronous memory block with mask.
91-
*
92-
* @param depth Number of memory entries
93-
* @param width Memory entry width in bits
94-
* @param maskElemWidth Width of bits that a single mask bool value covers in the input data
95-
* @param forward Whether to include forwarding registers or not
96-
* @param dataFile Hex datafile for initializing the memory block
97-
*/
98-
class MaskedMemBlock(depth: Int, width: Int, maskElemWidth: Int, forward: Boolean = true, dataFile: Option[String] = None) extends Module {
99-
val io = IO(new MaskedMemBlockIO(depth, width, maskElemWidth))
100-
101-
val mem = SyncReadMem(depth, Vec(width / maskElemWidth, UInt(maskElemWidth.W)), SyncReadMem.ReadFirst)
102-
103-
// Initialize memory block from a file
104-
if (dataFile.isDefined) {
105-
val file = dataFile.get
106-
107-
if (file.trim().nonEmpty) { // If not empty path
108-
loadMemoryFromFileInline(mem, file)
109-
} else {
110-
println(s"Warning: The provided initialization file path is incorrect: $file")
111-
}
112-
}
113-
114-
val writeDataAsVec = UIntToVec(io.writeData, width, maskElemWidth)
115-
116-
// Write
117-
when(io.wrEn) {
118-
mem.write(io.writeAddr, writeDataAsVec, io.byteEn)
119-
}
120-
121-
// Read
122-
val readDataAsVec = mem.read(io.readAddr)
123-
124-
if (forward) {
125-
val writeByteMaskReg = RegNext(io.byteEn)
126-
val writeDataReg = RegNext(writeDataAsVec)
127-
val forwardSelReg = RegNext((io.writeAddr === io.readAddr) && io.wrEn)
128-
129-
// If forwarding then we need to combine the old data with the write data using the byte mask
130-
val forwardDataAsVec = VecInit(Seq.fill(width / 8)(0.U(8.W)))
131-
for (i <- 0 until forwardDataAsVec.length) {
132-
when(writeByteMaskReg(i)) {
133-
forwardDataAsVec(i) := writeDataReg(i)
134-
} .otherwise {
135-
forwardDataAsVec(i) := readDataAsVec(i)
136-
}
137-
}
138-
139-
io.readData := Mux(forwardSelReg, writeDataAsVec.asUInt, readDataAsVec.asUInt)
140-
} else {
141-
// No forwarding, just output the read data
142-
io.readData := readDataAsVec.asUInt
143-
}
144-
}
145-
14680
/**
14781
* General purpose synchronous memory block with two read ports.
14882
*

src/main/scala/caches/hardware/util/UIntToVec.scala

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/main/scala/caches/hardware/util/UpdateSingleVecElem.scala

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)