This repository has been archived by the owner on May 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e77060
commit 54bce68
Showing
6 changed files
with
194 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
/** @file | ||
* interpreter.scala | ||
* @author | ||
* Sina Karvandi ([email protected]) | ||
* @brief | ||
* Remote debugger packet interpreter module | ||
* @details | ||
* @version 0.1 | ||
* @date | ||
* 2024-04-08 | ||
* | ||
* @copyright | ||
* This project is released under the GNU Public License v3. | ||
*/ | ||
package hwdbg.interpreter | ||
|
||
import chisel3._ | ||
import circt.stage.ChiselStage | ||
|
||
import hwdbg.configs._ | ||
import hwdbg.types._ | ||
|
||
class DebuggerPacketInterpreter( | ||
debug: Boolean = DebuggerConfigurations.ENABLE_DEBUG, | ||
numberOfInputPins: Int = DebuggerConfigurations.NUMBER_OF_INPUT_PINS, | ||
numberOfOutputPins: Int = DebuggerConfigurations.NUMBER_OF_OUTPUT_PINS, | ||
bramAddrWidth: Int = DebuggerConfigurations.BLOCK_RAM_ADDR_WIDTH, | ||
bramDataWidth: Int = DebuggerConfigurations.BLOCK_RAM_DATA_WIDTH | ||
) extends Module { | ||
val io = IO(new Bundle { | ||
|
||
// | ||
// Chip signals | ||
// | ||
val en = Input(Bool()) // chip enable signal | ||
|
||
// | ||
// Input/Output signals | ||
// | ||
val inputPin = Input(Vec(numberOfInputPins, UInt((1.W)))) // input pins | ||
val outputPin = Output(Vec(numberOfOutputPins, UInt((1.W)))) // output pins | ||
|
||
// | ||
// Interrupt signals (lines) | ||
// | ||
val plInSignal = Input(Bool()) // PS to PL signal | ||
val psOutInterrupt = Output(Bool()) // PL to PS interrupt | ||
|
||
// | ||
// BRAM (Block RAM) ports | ||
// | ||
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 | ||
|
||
// | ||
// Interpretation signals | ||
// | ||
val interpretationDone = Output(Bool()) // interpretation done or not? | ||
val foundValidPacket = Output(Bool()) // packet was valid or not | ||
val requestedActionOfThePacket = Output(UInt(32.W)) // the requested action | ||
|
||
}) | ||
|
||
/* | ||
val receivedPacketBuffer = Wire(new DebuggerRemotePacket()) | ||
receivedPacketBuffer.key := io.key | ||
receivedPacketBuffer.value := io.value | ||
io.struct_key := ms.key | ||
io.struct_value := ms.value | ||
*/ | ||
|
||
} | ||
|
||
object DebuggerPacketInterpreter { | ||
|
||
def apply( | ||
debug: Boolean = DebuggerConfigurations.ENABLE_DEBUG, | ||
numberOfInputPins: Int = DebuggerConfigurations.NUMBER_OF_INPUT_PINS, | ||
numberOfOutputPins: Int = DebuggerConfigurations.NUMBER_OF_OUTPUT_PINS, | ||
bramAddrWidth: Int = DebuggerConfigurations.BLOCK_RAM_ADDR_WIDTH, | ||
bramDataWidth: Int = DebuggerConfigurations.BLOCK_RAM_DATA_WIDTH | ||
)( | ||
en: Bool, | ||
inputPin: Vec[UInt], | ||
plInSignal: Bool, | ||
rdData: UInt | ||
): (Vec[UInt], Bool, UInt, Bool, UInt, Bool, Bool, UInt) = { | ||
|
||
val debuggerPacketInterpreter = Module( | ||
new DebuggerPacketInterpreter( | ||
debug, | ||
numberOfInputPins, | ||
numberOfOutputPins, | ||
bramAddrWidth, | ||
bramDataWidth | ||
) | ||
) | ||
|
||
val outputPin = Wire(Vec(numberOfOutputPins, UInt((1.W)))) | ||
val psOutInterrupt = Wire(Bool()) | ||
val rdWrAddr = Wire(UInt(bramAddrWidth.W)) | ||
val wrEna = Wire(Bool()) | ||
val wrData = Wire(UInt(bramDataWidth.W)) | ||
val interpretationDone = Wire(Bool()) | ||
val foundValidPacket = Wire(Bool()) | ||
val requestedActionOfThePacket = Wire(UInt(32.W)) | ||
|
||
// | ||
// Configure the input signals | ||
// | ||
debuggerPacketInterpreter.io.en := en | ||
debuggerPacketInterpreter.io.inputPin := inputPin | ||
debuggerPacketInterpreter.io.plInSignal := plInSignal | ||
debuggerPacketInterpreter.io.rdData := rdData | ||
|
||
// | ||
// Configure the output signals | ||
// | ||
outputPin := debuggerPacketInterpreter.io.outputPin | ||
psOutInterrupt := debuggerPacketInterpreter.io.psOutInterrupt | ||
rdWrAddr := debuggerPacketInterpreter.io.rdWrAddr | ||
wrEna := debuggerPacketInterpreter.io.wrEna | ||
wrData := debuggerPacketInterpreter.io.wrData | ||
|
||
// | ||
// Configure the output signals related to interpreted packets | ||
// | ||
interpretationDone := debuggerPacketInterpreter.io.interpretationDone | ||
foundValidPacket := debuggerPacketInterpreter.io.foundValidPacket | ||
requestedActionOfThePacket := debuggerPacketInterpreter.io.requestedActionOfThePacket | ||
|
||
// | ||
// Return the output result | ||
// | ||
( | ||
outputPin, | ||
psOutInterrupt, | ||
rdWrAddr, | ||
wrEna, | ||
wrData, | ||
interpretationDone, | ||
foundValidPacket, | ||
requestedActionOfThePacket | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** @file | ||
* communication.scala | ||
* @author | ||
* Sina Karvandi ([email protected]) | ||
* @brief | ||
* Data types for the communication | ||
* @details | ||
* @version 0.1 | ||
* @date | ||
* 2024-04-08 | ||
* | ||
* @copyright | ||
* This project is released under the GNU Public License v3. | ||
*/ | ||
package hwdbg.types | ||
|
||
import chisel3._ | ||
|
||
/* | ||
Structure in C: | ||
typedef struct _DEBUGGER_REMOTE_PACKET | ||
{ | ||
BYTE Checksum; | ||
UINT64 Indicator; /* Shows the type of the packet */ | ||
DEBUGGER_REMOTE_PACKET_TYPE TypeOfThePacket; | ||
DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION RequestedActionOfThePacket; | ||
} DEBUGGER_REMOTE_PACKET, *PDEBUGGER_REMOTE_PACKET; | ||
*/ | ||
|
||
/** @brief | ||
* The packet used for communication with the remote debugger | ||
*/ | ||
class DebuggerRemotePacket() extends Bundle { | ||
val Checksum = UInt(8.W) // 1 bytes | ||
val Alignment0 = UInt((64 - 8).W) // 7 bytes | ||
val Indicator = UInt(64.W) // 8 bytes | ||
val TypeOfThePacket = UInt(32.W) // 4 bytes | ||
val RequestedActionOfThePacket = UInt(32.W) // 4 bytes | ||
} | ||
|
||
// ----------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters