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

Commit

Permalink
add sending port information at interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
SinaKarvandi committed May 6, 2024
1 parent 4922da1 commit 44a0631
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 28 deletions.
2 changes: 1 addition & 1 deletion sim/hwdbg/DebuggerModuleTestingBRAM/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ VERILOG_SOURCES += $(shell pwd)/../../../generated/InterpreterPortInformation.sv
TOPLEVEL = DebuggerModuleTestingBRAM
MODULE = test_DebuggerModuleTestingBRAM

include $(shell cocotb-config --makefiles)/Makefile.sim
include $(shell cocotb-config --makefiles)/Makefile.sim
2 changes: 1 addition & 1 deletion sim/hwdbg/DebuggerModuleTestingBRAM/test.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
make SIM=verilator WAVES=1
make SIM=icarus WAVES=1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import cocotb
from cocotb.clock import Clock
from cocotb.triggers import RisingEdge
from cocotb.triggers import RisingEdge, Timer
from cocotb.types import LogicArray

maximum_number_of_clock_cycles = 1000
Expand Down Expand Up @@ -265,9 +265,9 @@ async def DebuggerModuleTestingBRAM_test(dut):
# assert LogicArray(dut.io_outputPin_31.value) == LogicArray("Z")

#
# Create a 10ns period clock on port clock
# Create a 1ns period clock on port clock
#
clock = Clock(dut.clock, 10, units="ns")
clock = Clock(dut.clock, 1, units="ns")

#
# Start the clock. Start it low to avoid issues on the first RisingEdge
Expand All @@ -287,7 +287,8 @@ async def DebuggerModuleTestingBRAM_test(dut):
#
dut.reset.value = 1
for _ in range(10):
await RisingEdge(dut.clock)
# await RisingEdge(dut.clock)
await Timer(1, units="ns")
dut.reset.value = 0

dut._log.info("Enabling an interrupting chip to receive commands from BRAM")
Expand Down Expand Up @@ -337,13 +338,13 @@ async def DebuggerModuleTestingBRAM_test(dut):
# Tell the hwdbg to receive BRAM results
#
dut.io_plInSignal.value = 1
await RisingEdge(dut.clock)
await Timer(1, units="ns")
dut.io_plInSignal.value = 0

#
# Synchronize with the clock. This will regisiter the initial `inputPinX` value
#
await RisingEdge(dut.clock)
await Timer(1, units="ns")

#
# Wait until the debuggee sends an interrupt to debugger
Expand All @@ -359,7 +360,7 @@ async def DebuggerModuleTestingBRAM_test(dut):
print("Number of clock cycles spent in debuggee (PL): " + str(clock_counter))

clock_counter = clock_counter + 1
await RisingEdge(dut.clock)
await Timer(1, units="ns")

#
# Apply a limitation to the number of clock cycles that
Expand All @@ -381,7 +382,7 @@ async def DebuggerModuleTestingBRAM_test(dut):
#
# Run one more clock cycle to apply the latest BRAM modifications
#
await RisingEdge(dut.clock)
await Timer(1, units="ns")

#
# Print contents of BRAM
Expand All @@ -393,4 +394,4 @@ async def DebuggerModuleTestingBRAM_test(dut):
# of more clock cycles
#
for _ in range(10):
await RisingEdge(dut.clock)
await Timer(1, units="ns")
1 change: 1 addition & 0 deletions src/main/scala/hwdbg/communication/interpreter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ class DebuggerPacketInterpreter(
//
// Instantiate the port information module
//

val (
noNewDataSenderModule,
dataValidOutputModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,22 @@ class InterpreterPortInformation(
val state = RegInit(sIdle)

//
// Convert input port pins into vector
// Get number of input/output ports
//
val inputPinsVec = VecInit(inputPortsConfiguration.values.toSeq.map(_.U))
val numberOfInputPorts = inputPortsConfiguration.size
val numberOfOutputPorts = outputPortsConfiguration.size

//
// Convert output port pins into vector
// Convert input port pins into vector
//
val outputPinsVec = VecInit(outputPortsConfiguration.values.toSeq.map(_.U))
// val inputPinsVec = VecInit(inputPortsConfiguration.values.toSeq.map(_.U))
val inputPinsVec = RegInit(VecInit(Seq.fill(numberOfInputPorts)(0.U(bramDataWidth.W))))

//
// Get number of input/output ports
// Convert output port pins into vector
//
val numberOfInputPorts = inputPortsConfiguration.size
val numberOfOutputPorts = outputPortsConfiguration.size
// val outputPinsVec = VecInit(outputPortsConfiguration.values.toSeq.map(_.U))
val outputPinsVec = RegInit(VecInit(Seq.fill(numberOfOutputPorts)(0.U(bramDataWidth.W))))

//
// Determine the width for numberOfSentPins based on conditions
Expand Down Expand Up @@ -124,6 +126,16 @@ class InterpreterPortInformation(
//
dataValidOutput := true.B

//
// Fill the port info
//
LogInfo(debug)("Iterating over input pins:")

inputPortsConfiguration.foreach { case (port, pins) =>
LogInfo(debug)(s"Port $port has $pins pins")
inputPinsVec(port) := pins.U
}

//
// Going to the next state (sending count of input ports)
//
Expand All @@ -144,6 +156,16 @@ class InterpreterPortInformation(
//
dataValidOutput := true.B

//
// Fill the port info
//
LogInfo(debug)("Iterating over output pins:")

outputPortsConfiguration.foreach { case (port, pins) =>
LogInfo(debug)(s"Port $port has $pins pins")
outputPinsVec(port) := pins.U
}

//
// Next, we gonna send each ports' information ()
//
Expand All @@ -155,11 +177,6 @@ class InterpreterPortInformation(
//
// Send input port items
//
LogInfo(debug)("Iterating over input pins:")

inputPortsConfiguration.foreach { case (port, pins) =>
LogInfo(debug)(s"Port $port has $pins pins")
}

//
// Adjust data
Expand Down Expand Up @@ -199,11 +216,6 @@ class InterpreterPortInformation(
//
// Send output port items
//
LogInfo(debug)("Iterating over output pins:")

outputPortsConfiguration.foreach { case (port, pins) =>
LogInfo(debug)(s"Port $port has $pins pins")
}

//
// Adjust data
Expand Down

0 comments on commit 44a0631

Please sign in to comment.