Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump difftest with standard Mem interfaces #127

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 13 additions & 24 deletions src/main/scala/device/AXI4RAM.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,7 @@ import chisel3.util.experimental.loadMemoryFromFile
import nutcore.HasNutCoreParameter
import bus.axi4._
import utils._

class RAMHelper(memByte: Int) extends BlackBox with HasNutCoreParameter {
val io = IO(new Bundle {
val clk = Input(Clock())
val rIdx = Input(UInt(DataBits.W))
val rdata = Output(UInt(DataBits.W))
val wIdx = Input(UInt(DataBits.W))
val wdata = Input(UInt(DataBits.W))
val wmask = Input(UInt(DataBits.W))
val wen = Input(Bool())
val en = Input(Bool())
}).suggestName("io")
}
import difftest.common.DifftestMem

class AXI4RAM[T <: AXI4Lite](_type: T = new AXI4, memByte: Int,
useBlackBox: Boolean = false) extends AXI4SlaveModule(_type) with HasNutCoreParameter {
Expand All @@ -50,23 +38,24 @@ class AXI4RAM[T <: AXI4Lite](_type: T = new AXI4, memByte: Int,
val wen = in.w.fire() && inRange(wIdx)

val rdata = if (useBlackBox) {
val mem = Module(new RAMHelper(memByte))
mem.io.clk := clock
mem.io.rIdx := rIdx
mem.io.wIdx := wIdx
mem.io.wdata := in.w.bits.data
mem.io.wmask := fullMask
mem.io.wen := wen
mem.io.en := true.B
mem.io.rdata
val mem = DifftestMem(memByte, 8)
when (wen) {
mem.write(
addr = wIdx,
data = in.w.bits.data.asTypeOf(Vec(DataBytes, UInt(8.W))),
mask = in.w.bits.strb.asBools
)
}
mem.readAndHold(rIdx, ren).asUInt
} else {
val mem = Mem(memByte / DataBytes, Vec(DataBytes, UInt(8.W)))

val wdata = VecInit.tabulate(DataBytes) { i => in.w.bits.data(8*(i+1)-1, 8*i) }
when (wen) { mem.write(wIdx, wdata, in.w.bits.strb.asBools) }

Cat(mem.read(rIdx).reverse)
RegEnable(Cat(mem.read(rIdx).reverse), ren)
}

in.r.bits.data := RegEnable(rdata, ren)
in.r.bits.data := rdata
}

41 changes: 0 additions & 41 deletions src/test/vsrc/ram.v

This file was deleted.

Loading