Skip to content

Commit

Permalink
fix sram module name
Browse files Browse the repository at this point in the history
  • Loading branch information
unlsycn committed Dec 2, 2024
1 parent ab86b9a commit 67e4924
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 30 deletions.
25 changes: 10 additions & 15 deletions rocketv/src/SRAM.scala
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,12 @@ object SRAM {
val numReadPorts = readPortClocks.size
val numWritePorts = writePortClocks.size
val numReadwritePorts = readwritePortClocks.size
val isVecMem = evidenceOpt.isDefined
val enableMask = evidenceOpt.isDefined
val isValidSRAM = ((numReadPorts + numReadwritePorts) > 0) && ((numWritePorts + numReadwritePorts) > 0)
val maskGranularity = tpe match {
case vec: Vec[_] if enableMask => vec.sample_element.getWidth
case _ => 0
}

if (!isValidSRAM) {
val badMemory =
Expand All @@ -339,16 +343,13 @@ object SRAM {
val mem = Instantiate(
new SRAMBlackbox(
new CIRCTSRAMParameter(
s"sram_${size}x${tpe.getWidth}",
s"sram_${numReadPorts}R_${numWritePorts}W_${numReadwritePorts}RW_${maskGranularity}M_${size}x${tpe.getWidth}",
numReadPorts,
numWritePorts,
numReadwritePorts,
size.intValue,
tpe.getWidth,
tpe match {
case vec: Vec[_] if isVecMem => vec.sample_element.getWidth
case _ => 0
}
maskGranularity
)
)
)
Expand All @@ -360,7 +361,7 @@ object SRAM {
val includeMetadata = Builder.includeUtilMetadata

val out = Wire(
new SRAMInterface(size, tpe, numReadPorts, numWritePorts, numReadwritePorts, isVecMem, includeMetadata)
new SRAMInterface(size, tpe, numReadPorts, numWritePorts, numReadwritePorts, enableMask, includeMetadata)
)

out.readPorts.zip(sramReadPorts).zip(readPortClocks).map { case ((intfReadPort, sramReadPort), readClock) =>
Expand Down Expand Up @@ -397,17 +398,11 @@ object SRAM {
val descriptionInstance: Instance[SRAMDescription] = Instantiate(new SRAMDescription)
descriptionInstance.depthIn := Property(size)
descriptionInstance.widthIn := Property(tpe.getWidth)
descriptionInstance.maskedIn := Property(isVecMem)
descriptionInstance.maskedIn := Property(enableMask)
descriptionInstance.readIn := Property(numReadPorts)
descriptionInstance.writeIn := Property(numWritePorts)
descriptionInstance.readwriteIn := Property(numReadwritePorts)
descriptionInstance.maskGranularityIn := Property(
Option
.when(isVecMem)(tpe match {
case t: Vec[_] => t.sample_element.getWidth
})
.getOrElse(0)
)
descriptionInstance.maskGranularityIn := Property(maskGranularity)
descriptionInstance.hierarchyIn := Property(Path(mem.toTarget))
description := descriptionInstance.getPropertyReference
}
Expand Down
25 changes: 10 additions & 15 deletions t1/src/SRAM.scala
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,12 @@ object SRAM {
val numReadPorts = readPortClocks.size
val numWritePorts = writePortClocks.size
val numReadwritePorts = readwritePortClocks.size
val isVecMem = evidenceOpt.isDefined
val enableMask = evidenceOpt.isDefined
val isValidSRAM = ((numReadPorts + numReadwritePorts) > 0) && ((numWritePorts + numReadwritePorts) > 0)
val maskGranularity = tpe match {
case vec: Vec[_] if enableMask => vec.sample_element.getWidth
case _ => 0
}

if (!isValidSRAM) {
val badMemory =
Expand All @@ -339,16 +343,13 @@ object SRAM {
val mem = Instantiate(
new SRAMBlackbox(
new CIRCTSRAMParameter(
s"sram_${size}x${tpe.getWidth}",
s"sram_${numReadPorts}R_${numWritePorts}W_${numReadwritePorts}RW_${maskGranularity}M_${size}x${tpe.getWidth}",
numReadPorts,
numWritePorts,
numReadwritePorts,
size.intValue,
tpe.getWidth,
tpe match {
case vec: Vec[_] if isVecMem => vec.sample_element.getWidth
case _ => 0
}
maskGranularity
)
)
)
Expand All @@ -360,7 +361,7 @@ object SRAM {
val includeMetadata = Builder.includeUtilMetadata

val out = Wire(
new SRAMInterface(size, tpe, numReadPorts, numWritePorts, numReadwritePorts, isVecMem, includeMetadata)
new SRAMInterface(size, tpe, numReadPorts, numWritePorts, numReadwritePorts, enableMask, includeMetadata)
)

out.readPorts.zip(sramReadPorts).zip(readPortClocks).map { case ((intfReadPort, sramReadPort), readClock) =>
Expand Down Expand Up @@ -397,17 +398,11 @@ object SRAM {
val descriptionInstance: Instance[SRAMDescription] = Instantiate(new SRAMDescription)
descriptionInstance.depthIn := Property(size)
descriptionInstance.widthIn := Property(tpe.getWidth)
descriptionInstance.maskedIn := Property(isVecMem)
descriptionInstance.maskedIn := Property(enableMask)
descriptionInstance.readIn := Property(numReadPorts)
descriptionInstance.writeIn := Property(numWritePorts)
descriptionInstance.readwriteIn := Property(numReadwritePorts)
descriptionInstance.maskGranularityIn := Property(
Option
.when(isVecMem)(tpe match {
case t: Vec[_] => t.sample_element.getWidth
})
.getOrElse(0)
)
descriptionInstance.maskGranularityIn := Property(maskGranularity)
descriptionInstance.hierarchyIn := Property(Path(mem.toTarget))
description := descriptionInstance.getPropertyReference
}
Expand Down

0 comments on commit 67e4924

Please sign in to comment.