Skip to content
Snippets Groups Projects
Commit b3de40e5 authored by dam1n19's avatar dam1n19
Browse files

Refactored ADP Cocotb driver

parent e5d443b8
Branches
Tags
No related merge requests found
...@@ -20,10 +20,40 @@ class ADPDriver (): ...@@ -20,10 +20,40 @@ class ADPDriver ():
# Send Recieve to NanoSoC # Send Recieve to NanoSoC
self.recieve = recieve self.recieve = recieve
# Read ADP String
@cocotb.coroutine
async def read(self):
read_str = ""
while True:
# Read Bytes from ADP AXI Stream
data = await self.recieve.read()
curr_char = chr(data[0])
# Combine Bytes into String
if (curr_char != '\n'):
read_str += curr_char
else:
return read_str
# Write ADP String
# @cocotb.coroutine
# async def read(self):
# read_str = ""
# while True:
# # Read Bytes from ADP AXI Stream
# data = await self.recieve.read()
# curr_char = chr(data[0])
# # Combine Bytes into String
# if (curr_char != '\n'):
# read_str += curr_char
# else:
# return read_str
# Control ADP AXI Stream bus and create ADP Driver Object # Control ADP AXI Stream bus and create ADP Driver Object
def setup_adp(dut): def setup_adp(dut):
adp_sender = AxiStreamSource(AxiStreamBus.from_prefix(dut, "txd8"), dut.XTAL1, dut.NRST) adp_sender = AxiStreamSource(AxiStreamBus.from_prefix(dut, "txd8"), dut.XTAL1, dut.NRST)
adp_reciever = AxiStreamSink(AxiStreamBus.from_prefix(dut, "rxd8"), dut.XTAL1, dut.NRST) adp_reciever = AxiStreamSink(AxiStreamBus.from_prefix(dut, "rxd8"), dut.XTAL1, dut.NRST)
logging.getLogger("cocotb.nanosoc_tb.rxd8").setLevel(logging.WARNING)
driver = ADPDriver(adp_sender, adp_reciever) driver = ADPDriver(adp_sender, adp_reciever)
return driver return driver
...@@ -44,6 +74,24 @@ async def write(driver, buf): ...@@ -44,6 +74,24 @@ async def write(driver, buf):
await driver.tx.send(str(ord(i))) await driver.tx.send(str(ord(i)))
return wr_count return wr_count
@cocotb.coroutine
async def write(driver, buf):
wr_count = 0
for i in buf:
print(i)
await driver.tx.send(str(ord(i)))
return wr_count
# Wait for bootcode to finish
@cocotb.coroutine
async def wait_bootcode(dut, driver):
bootcode_last = "** Remap->IMEM0"
while True:
read_str = await driver.read()
dut.log.info(read_str)
if read_str == bootcode_last:
break
# Basic Test Clocks Test # Basic Test Clocks Test
@cocotb.test() @cocotb.test()
async def test_clocks(dut): async def test_clocks(dut):
...@@ -54,26 +102,23 @@ async def test_clocks(dut): ...@@ -54,26 +102,23 @@ async def test_clocks(dut):
# Basic Test Reading from ADP # Basic Test Reading from ADP
@cocotb.test() @cocotb.test()
async def test_driver(dut): async def test_adp_read(dut):
"""Tests ADP Driver"""
log = logging.getLogger(f"cocotb.test")
await setup_dut(dut) await setup_dut(dut)
adp_driver = setup_adp(dut) adp_driver = setup_adp(dut)
logging.getLogger("cocotb.nanosoc_tb.rxd8").setLevel(logging.WARNING) dut.log.info("Setup Complete")
log.info("Setup Complete") dut.log.info("Starting Test")
log.info("Starting Test") await wait_bootcode(dut, adp_driver)
temp_str = "" dut.log.info("ADP Read Test Complete")
while True:
# Read Bytes from ADP AXI Stream # Basic Test Write to ADP
data = await adp_driver.recieve.read() @cocotb.test()
curr_char = chr(data[0]) async def test_adp_write(dut):
# Combine Bytes into Strings and Print Out await setup_dut(dut)
if (curr_char == '\n'): adp_driver = setup_adp(dut)
log.info(temp_str) dut.log.info("Setup Complete")
# Exit Test on Last String dut.log.info("Starting Test")
if temp_str == "** Remap->IMEM0": await wait_bootcode(dut, adp_driver)
break dut.log.info("ADP Write Test Complete")
temp_str = ""
else:
temp_str += curr_char
log.info("Driver Test Complete")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment