Skip to content

Commit ac3d7e2

Browse files
mergify[bot]debs-sifivejackkoenig
authored
Remove extra bit from SRAMInterface address width (backport #3830) (#3839)
* Remove extra bit from `SRAMInterface` address width (#3830) (cherry picked from commit 4f1f4a7) # Conflicts: # src/test/scala/chiselTests/util/SRAMSpec.scala * Resolve backport conflicts --------- Co-authored-by: Deborah Soung <[email protected]> Co-authored-by: Jack Koenig <[email protected]>
1 parent b5f000f commit ac3d7e2

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/main/scala/chisel3/util/SRAM.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class SRAMInterface[T <: Data](
103103
s"SRAMInterface_${SRAM.portedness(numReadPorts, numWritePorts, numReadwritePorts)}${if (masked) "_masked"
104104
else ""}}_${tpe.typeName}"
105105

106-
val addrWidth = log2Up(memSize + 1)
106+
val addrWidth = log2Up(memSize)
107107

108108
val readPorts: Vec[MemoryReadPort[T]] = Vec(numReadPorts, new MemoryReadPort(tpe, addrWidth))
109109
val writePorts: Vec[MemoryWritePort[T]] = Vec(numWritePorts, new MemoryWritePort(tpe, addrWidth, masked))

src/test/scala/chiselTests/Mem.scala

+5-5
Original file line numberDiff line numberDiff line change
@@ -529,10 +529,10 @@ class SRAMSpec extends ChiselFunSpec {
529529
val chirrtl = ChiselStage.emitCHIRRTL(new TestModule(1, 1), args = Array("--full-stacktrace"))
530530

531531
chirrtl should include(
532-
"writePorts : { flip address : UInt<6>, flip enable : UInt<1>, flip data : UInt<8>[3], flip mask : UInt<1>[3]}[1]"
532+
"writePorts : { flip address : UInt<5>, flip enable : UInt<1>, flip data : UInt<8>[3], flip mask : UInt<1>[3]}[1]"
533533
)
534534
chirrtl should include(
535-
"readwritePorts : { flip address : UInt<6>, flip enable : UInt<1>, flip isWrite : UInt<1>, readData : UInt<8>[3], flip writeData : UInt<8>[3], flip mask : UInt<1>[3]}[1]"
535+
"readwritePorts : { flip address : UInt<5>, flip enable : UInt<1>, flip isWrite : UInt<1>, readData : UInt<8>[3], flip writeData : UInt<8>[3], flip mask : UInt<1>[3]}[1]"
536536
)
537537

538538
for (i <- 0 until 3) {
@@ -576,13 +576,13 @@ class SRAMSpec extends ChiselFunSpec {
576576
val wrIndexSuffix = if (i == 0) "" else s"_$i"
577577

578578
chirrtl should include(
579-
s"read mport mem_out_readPorts_${i}_data_MPORT = mem_mem[_mem_out_readPorts_${i}_data_T], readClocks[${i}]"
579+
s"read mport mem_out_readPorts_${i}_data_MPORT = mem_mem[_mem_out_readPorts_${i}_data_WIRE], readClocks[${i}]"
580580
)
581581
chirrtl should include(
582-
s"write mport mem_MPORT${wrIndexSuffix} = mem_mem[_mem_T${wrIndexSuffix}], writeClocks[${i}]"
582+
s"write mport mem_MPORT${wrIndexSuffix} = mem_mem[mem.writePorts[${i}].address], writeClocks[${i}]"
583583
)
584584
chirrtl should include(
585-
s"rdwr mport mem_out_readwritePorts_${i}_readData_MPORT = mem_mem[_mem_out_readwritePorts_${i}_readData_T], readwriteClocks[${i}]"
585+
s"rdwr mport mem_out_readwritePorts_${i}_readData_MPORT = mem_mem[_mem_out_readwritePorts_${i}_readData_WIRE], readwriteClocks[${i}]"
586586
)
587587
}
588588
}

0 commit comments

Comments
 (0)