Skip to content
This repository has been archived by the owner on May 28, 2024. It is now read-only.

Commit

Permalink
change direction of BRAM
Browse files Browse the repository at this point in the history
  • Loading branch information
SinaKarvandi committed Apr 5, 2024
1 parent 11f3eda commit 4e77060
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 37 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ThisBuild / scalaVersion := "2.13.12"
ThisBuild / version := "0.1.0"
ThisBuild / organization := "org.hyperdbg"

val chiselVersion = "6.0.0"
val chiselVersion = "6.2.0"

lazy val root = (project in file("."))
.settings(
Expand Down
38 changes: 19 additions & 19 deletions src/main/scala/hwdbg/main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,10 @@ class DebuggerMain(
//
// BRAM (Block RAM) ports
//
val rdAddr = Input(UInt(bramAddrWidth.W)) // read address
val rdData = Output(UInt(bramDataWidth.W)) // read data
val wrAddr = Input(UInt(bramAddrWidth.W)) // write address
val wrEna = Input(Bool()) // enable writing
val wrData = Input(UInt(bramDataWidth.W)) // write data
val rdWrAddr = Output(UInt(bramAddrWidth.W)) // read/write address
val rdData = Input(UInt(bramDataWidth.W)) // read data
val wrEna = Output(Bool()) // enable writing
val wrData = Output(UInt(bramDataWidth.W)) // write data

})

Expand All @@ -65,7 +64,9 @@ class DebuggerMain(
}

io.psOutInterrupt := false.B
io.rdData := 0.U
io.rdWrAddr := 0.U
io.wrEna := false.B
io.wrData := 0.U
}

object DebuggerMain {
Expand All @@ -79,12 +80,9 @@ object DebuggerMain {
)(
en: Bool,
inputPin: Vec[UInt],
psOutInterrupt: Bool,
rdAddr: UInt,
wrAddr: UInt,
wrEna: Bool,
wrData: UInt
): (Vec[UInt], Bool, UInt) = {
plInSignal: Bool,
rdData: UInt
): (Vec[UInt], Bool, UInt, Bool, UInt) = {

val debuggerMainModule = Module(
new DebuggerMain(
Expand All @@ -98,28 +96,30 @@ object DebuggerMain {

val outputPin = Wire(Vec(numberOfOutputPins, UInt((1.W))))
val psOutInterrupt = Wire(Bool())
val rdData = Wire(UInt(bramDataWidth.W))
val rdWrAddr = Wire(UInt(bramAddrWidth.W))
val wrEna = Wire(Bool())
val wrData = Wire(UInt(bramDataWidth.W))

//
// Configure the input signals
//
debuggerMainModule.io.en := en
debuggerMainModule.io.inputPin := inputPin
debuggerMainModule.io.rdAddr := rdAddr
debuggerMainModule.io.wrAddr := wrAddr
debuggerMainModule.io.wrEna := wrEna
debuggerMainModule.io.wrData := wrData
debuggerMainModule.io.plInSignal := plInSignal
debuggerMainModule.io.rdData := rdData

//
// Configure the input signals
//
outputPin := debuggerMainModule.io.outputPin
psOutInterrupt := debuggerMainModule.io.psOutInterrupt
rdData := debuggerMainModule.io.rdData
rdWrAddr := debuggerMainModule.io.rdWrAddr
wrEna := debuggerMainModule.io.wrEna
wrData := debuggerMainModule.io.wrData

//
// Return the output result
//
(outputPin, psOutInterrupt, rdData)
(outputPin, psOutInterrupt, rdWrAddr, wrEna, wrData)
}
}
20 changes: 9 additions & 11 deletions src/main/scala/top.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,17 @@ class DebuggerModule(
//
// BRAM (Block RAM) ports
//
val rdAddr = Input(UInt(bramAddrWidth.W)) // read address
val rdData = Output(UInt(bramDataWidth.W)) // read data
val wrAddr = Input(UInt(bramAddrWidth.W)) // write address
val wrEna = Input(Bool()) // enable writing
val wrData = Input(UInt(bramDataWidth.W)) // write data
val rdWrAddr = Output(UInt(bramAddrWidth.W)) // read/write address
val rdData = Input(UInt(bramDataWidth.W)) // read data
val wrEna = Output(Bool()) // enable writing
val wrData = Output(UInt(bramDataWidth.W)) // write data

})

//
// Instantiate the debugger's main module
//
val (outputPin, psOutInterrupt, rdData) =
val (outputPin, psOutInterrupt, rdWrAddr, wrEna, wrData) =
DebuggerMain(
debug,
numberOfInputPins,
Expand All @@ -70,15 +69,14 @@ class DebuggerModule(
io.en,
io.inputPin,
io.plInSignal,
io.rdAddr,
io.wrAddr,
io.wrEna,
io.wrData
io.rdData
)

io.outputPin := outputPin
io.psOutInterrupt := psOutInterrupt
io.rdData := rdData
io.rdWrAddr := rdWrAddr
io.wrEna := wrEna
io.wrData := wrData

}

Expand Down
48 changes: 42 additions & 6 deletions src/main/scala/top_test.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class DebuggerModuleTestingBRAM(
val bramAddr = WireInit(0.U(bramAddrWidth.W))
val bramDataIn = WireInit(0.U(bramDataWidth.W))

val bramDataOut = WireInit(0.U(bramDataWidth.W))

//
// Instantiate the BRAM memory initializer module
//
Expand All @@ -74,10 +76,12 @@ class DebuggerModuleTestingBRAM(
bramDataIn
)

bramDataOut := dataOut

//
// Instantiate the debugger's main module
//
val (outputPin, psOutInterrupt, rdData) =
val (outputPin, psOutInterrupt, rdWrAddr, wrEna, wrData) =
DebuggerMain(
debug,
numberOfInputPins,
Expand All @@ -88,14 +92,46 @@ class DebuggerModuleTestingBRAM(
io.en,
io.inputPin,
io.plInSignal,
bramAddr,
bramAddr,
bramEn,
dataOut
bramDataOut
)

//
// Connect BRAM Pins
//
bramEn := io.en // enable BRAM when the main chip enabled
bramAddr := rdWrAddr
bramWrite := wrEna
bramDataIn := wrData

//
// Connect I/O pins
//
io.outputPin := outputPin
io.psOutInterrupt := psOutInterrupt
bramDataIn := rdData

}

object MainWithInitializedBRAM extends App {

//
// Generate hwdbg verilog files
//
println(
ChiselStage.emitSystemVerilog(
new DebuggerModuleTestingBRAM(
DebuggerConfigurations.ENABLE_DEBUG,
DebuggerConfigurations.NUMBER_OF_INPUT_PINS,
DebuggerConfigurations.NUMBER_OF_OUTPUT_PINS,
DebuggerConfigurations.BLOCK_RAM_ADDR_WIDTH,
DebuggerConfigurations.BLOCK_RAM_DATA_WIDTH
),
firtoolOpts = Array(
"-disable-all-randomization",
"-strip-debug-info",
"--split-verilog", // The intention for this argument (and next argument) is to separate generated files.
"-o",
"generated/"
)
)
)
}

0 comments on commit 4e77060

Please sign in to comment.