Skip to content

Commit

Permalink
[RsTb] Add core_clk and axis_core to the testbench.
Browse files Browse the repository at this point in the history
  • Loading branch information
egorman44 committed Aug 18, 2024
1 parent 759dc9e commit 48d02b1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
11 changes: 10 additions & 1 deletion coco_sim/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,21 @@ def read_json(file_path):
POLY = ip_params['POLY']
ENCODE_MSG_DURATION = math.ceil(N_LEN/BUS_WIDTH)
FCR = ip_params['FCR']

AXIS_CLOCK = ip_params['AXIS_CLOCK']
CORE_CLOCK = ip_params['CORE_CLOCK']
if AXIS_CLOCK/CORE_CLOCK == 1.0:
SINGLE_CLOCK = True
else:
SINGLE_CLOCK = False

print(f"PRJ_DIR : {PRJ_DIR}")
print("\n")
print("================")
print("RS CONFIGURATION")
print("================")
print(f"\t AXIS_CLOCK = {AXIS_CLOCK}")
print(f"\t CORE_CLOCK = {CORE_CLOCK}")
print(f"\t SINGLE_CLOCK = {SINGLE_CLOCK}")
print(f"\t POLY = {POLY}")
print(f"\t N_LEN = {N_LEN}")
print(f"\t K_LEN = {K_LEN}")
Expand Down
19 changes: 13 additions & 6 deletions coco_sim/rs_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
from axis import AxisMonitor

from config import ENCODE_MSG_DURATION
from config import SINGLE_CLOCK
from config import AXIS_CLOCK
from config import CORE_CLOCK

class RsEnv():

Expand Down Expand Up @@ -42,9 +45,14 @@ def build_env(self, s_if_containers, m_if_containers):

async def run(self):
await cocotb.start(reset_dut(self.dut.reset,200,1))
await Timer(50, units = "ns")

await cocotb.start(custom_clock(self.dut.clock, 10))
if not SINGLE_CLOCK:
await cocotb.start(reset_dut(self.dut.io_coreRst,200,1))

await Timer(50, units = "ns")
await cocotb.start(custom_clock(self.dut.clock, 1000/AXIS_CLOCK))
if not SINGLE_CLOCK:
await cocotb.start(custom_clock(self.dut.io_coreClock, 1000/CORE_CLOCK))

for m_mon in self.m_monitors:
await cocotb.start(m_mon.mon_if())

Expand All @@ -59,10 +67,9 @@ async def run(self):
s_coroutings.append(cocotb.start_soon(with_timeout(self.s_drivers[i].send_pkt(self.s_if_containers[i].if_packets[pkt_num]), 10_000, 'us')))
for corouting in s_coroutings:
await Join(corouting)
for i in range(ENCODE_MSG_DURATION):
await RisingEdge(self.dut.clock)

for i in range(ENCODE_MSG_DURATION+100):
# TODO: add delay based on latency
for i in range(ENCODE_MSG_DURATION+400):
await RisingEdge(self.dut.clock)

#await watchdog_set(self.dut.clock, self.comparators)
Expand Down

0 comments on commit 48d02b1

Please sign in to comment.