From 04b5c867420451fde5fcbff69da32519cb9b4e87 Mon Sep 17 00:00:00 2001 From: Sina Karvandi Date: Wed, 1 May 2024 13:30:09 +0900 Subject: [PATCH] add versioning info --- .../interpreter/interpreter.scala | 45 ++++++++++++++-- src/main/scala/hwdbg/configs/version.scala | 51 +++++++++++++++++++ src/main/scala/hwdbg/main.scala | 13 +++++ 3 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 src/main/scala/hwdbg/configs/version.scala diff --git a/src/main/scala/hwdbg/communication/interpreter/interpreter.scala b/src/main/scala/hwdbg/communication/interpreter/interpreter.scala index a646323..a107a6b 100644 --- a/src/main/scala/hwdbg/communication/interpreter/interpreter.scala +++ b/src/main/scala/hwdbg/communication/interpreter/interpreter.scala @@ -87,9 +87,10 @@ class DebuggerPacketInterpreter( val beginSendingBuffer = WireInit(false.B) val noNewDataSender = WireInit(false.B) val dataValidOutput = WireInit(false.B) - val requestedActionOfThePacketOutput = WireInit(0.U(new DebuggerRemotePacket().RequestedActionOfThePacket.getWidth.W)) val sendingData = WireInit(0.U(bramDataWidth.W)) + val regRequestedActionOfThePacketOutput = RegInit(0.U(new DebuggerRemotePacket().RequestedActionOfThePacket.getWidth.W)) + // // Apply the chip enable signal // @@ -121,8 +122,46 @@ class DebuggerPacketInterpreter( when(inputAction === HwdbgActionEnums.hwdbgActionSendVersion.id.U) { // - // Send version + // *** Send version *** + // + + // + // Set the packet type // + regRequestedActionOfThePacketOutput := 9999.U + + // + // Start sending the buffer + // + beginSendingBuffer := true.B + + // + // Wait until + // + when(io.sendWaitForBuffer === true.B) { + + // + // The sender is ready to send next buffer + // + sendingData := 1.U + + // + // Data is valid to send + // + dataValidOutput := true.B + + // + // Sending is finished at the next cycle + // + state := sDone + + }.otherwise { + + // + // Stay at the same state + // + state := sNewActionReceived + } }.elsewhen(inputAction === HwdbgActionEnums.hwdbgActionSendPinInformation.id.U) { @@ -170,7 +209,7 @@ class DebuggerPacketInterpreter( io.beginSendingBuffer := beginSendingBuffer io.noNewDataSender := noNewDataSender io.dataValidOutput := dataValidOutput - io.requestedActionOfThePacketOutput := requestedActionOfThePacketOutput + io.requestedActionOfThePacketOutput := regRequestedActionOfThePacketOutput io.sendingData := sendingData } diff --git a/src/main/scala/hwdbg/configs/version.scala b/src/main/scala/hwdbg/configs/version.scala new file mode 100644 index 0000000..d122b06 --- /dev/null +++ b/src/main/scala/hwdbg/configs/version.scala @@ -0,0 +1,51 @@ +/** + * @file + * version.scala + * @author + * Sina Karvandi (sina@hyperdbg.org) + * @brief + * Versioning details + * @details + * @version 0.1 + * @date + * 2024-05-01 + * + * @copyright + * This project is released under the GNU Public License v3. + */ +package hwdbg.version + +import chisel3._ +import chisel3.util._ + +/** + * @brief + * Version of hwdbg + * @warning + * will be checked with HyperDbg + */ +object Version { + + // + // Constant version info + // + val VERSION_MAJOR: Int = 0 + val VERSION_MINOR: Int = 1 + val VERSION_PATCH: Int = 0 + + def getEncodedVersion: Int = { + (VERSION_MAJOR << 16) | (VERSION_MINOR << 8) | VERSION_PATCH + } + + def extractMajor(encodedVersion: Int): Int = { + encodedVersion >> 16 + } + + def extractMinor(encodedVersion: Int): Int = { + (encodedVersion >> 8) & 0xff // Masking to get only the 8 bits + } + + def extractPatch(encodedVersion: Int): Int = { + encodedVersion & 0xff // Masking to get only the 8 bits + } +} diff --git a/src/main/scala/hwdbg/main.scala b/src/main/scala/hwdbg/main.scala index 65793ee..9feab2e 100644 --- a/src/main/scala/hwdbg/main.scala +++ b/src/main/scala/hwdbg/main.scala @@ -18,8 +18,10 @@ package hwdbg import chisel3._ import circt.stage.ChiselStage +import hwdbg.version._ import hwdbg.configs._ import hwdbg.types._ +import hwdbg.utils._ import hwdbg.communication._ import hwdbg.communication.interpreter._ @@ -78,6 +80,17 @@ class DebuggerMain( }) + // + // Printing the versioning info + // + val encodedVersion = Version.getEncodedVersion + LogInfo(true)("=======================================================================") + LogInfo(true)(s"Generating code for hwdbg v${Version.extractMajor(encodedVersion)}.${Version.extractMinor(encodedVersion)}.${Version + .extractPatch(encodedVersion)} ($encodedVersion)") + LogInfo(true)("Please visit https://hwdbg.hyperdbg.org/docs for more information...") + LogInfo(true)("hwdbg is released under the GNU Public License v3 (GPLv3).") + LogInfo(true)("=======================================================================") + // // Wire signals for the synchronizer //