Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
NanoSoC Tech
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SoCLabs
NanoSoC Tech
Commits
69bc0c7b
Commit
69bc0c7b
authored
2 years ago
by
dam1n19
Browse files
Options
Downloads
Patches
Plain Diff
Created Seperate Cocotb drivers file and added simple write test
parent
b3de40e5
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
flows/makefile.simulate
+3
-1
3 additions, 1 deletion
flows/makefile.simulate
verif/cocotb/adp_cocotb_driver.py
+65
-0
65 additions, 0 deletions
verif/cocotb/adp_cocotb_driver.py
verif/cocotb/test_adp.py
+18
-55
18 additions, 55 deletions
verif/cocotb/test_adp.py
with
86 additions
and
56 deletions
flows/makefile.simulate
+
3
−
1
View file @
69bc0c7b
...
@@ -55,6 +55,8 @@ COCOTB_SCRATCH_DIR := $(COCOTB_DIR)/scratch
...
@@ -55,6 +55,8 @@ COCOTB_SCRATCH_DIR := $(COCOTB_DIR)/scratch
# Filelist for Cocotb
# Filelist for Cocotb
MAKEFILE_FILELIST
:=
$(
COCOTB_DIR
)
/makefile.flist
MAKEFILE_FILELIST
:=
$(
COCOTB_DIR
)
/makefile.flist
MODULE
?=
test_adp
# Create a List of PHONY Targets
# Create a List of PHONY Targets
.PHONY
:
compile_$(SIMULATOR) run_$(SIMULATOR) sim_$(SIMULATOR)
.PHONY
:
compile_$(SIMULATOR) run_$(SIMULATOR) sim_$(SIMULATOR)
...
@@ -162,7 +164,7 @@ run_cocotb: DEFINES_VC += COCOTB_SIM
...
@@ -162,7 +164,7 @@ run_cocotb: DEFINES_VC += COCOTB_SIM
run_cocotb
:
flist_makefile_nanosoc
run_cocotb
:
flist_makefile_nanosoc
@
mkdir
-p
$(
SIM_DIR
)
@
mkdir
-p
$(
SIM_DIR
)
@
cd
$(
SIM_DIR
);
$(
MAKE
)
-C
$(
SOCLABS_NANOSOC_TECH_DIR
)
/verif/cocotb clean
SIM_BUILD
=
$(
COCOTB_SCRATCH_DIR
)
@
cd
$(
SIM_DIR
);
$(
MAKE
)
-C
$(
SOCLABS_NANOSOC_TECH_DIR
)
/verif/cocotb clean
SIM_BUILD
=
$(
COCOTB_SCRATCH_DIR
)
@
cd
$(
SIM_DIR
);
$(
MAKE
)
-C
$(
SOCLABS_NANOSOC_TECH_DIR
)
/verif/cocotb sim
SIM
=
$(
COCOTB_SIMULATOR
)
TESTCASE
=
$(
TESTNAME
)
GUI
=
$(
GUI
)
SIM_BUILD
=
$(
COCOTB_SCRATCH_DIR
)
ACCELERATOR
=
$(
ACCELERATOR
)
@
cd
$(
SIM_DIR
);
$(
MAKE
)
-C
$(
SOCLABS_NANOSOC_TECH_DIR
)
/verif/cocotb sim
MODULE
=
$(
MODULE
)
SIM
=
$(
COCOTB_SIMULATOR
)
TESTCASE
=
$(
TESTNAME
)
GUI
=
$(
GUI
)
SIM_BUILD
=
$(
COCOTB_SCRATCH_DIR
)
ACCELERATOR
=
$(
ACCELERATOR
)
sim_cocotb
:
GUI=1
sim_cocotb
:
GUI=1
sim_cocotb
:
run_cocotb
sim_cocotb
:
run_cocotb
This diff is collapsed.
Click to expand it.
verif/cocotb/adp_cocotb_driver.py
0 → 100644
+
65
−
0
View file @
69bc0c7b
#-----------------------------------------------------------------------------
# SoCLabs ADP Cocotb Drivers
# Contributors
#
# David Mapstone (d.a.mapstone@soton.ac.uk)
#
# Copyright 2021-3, SoC Labs (www.soclabs.org)
#-----------------------------------------------------------------------------
import
cocotb
# Class for ADP AXI Stream Interface
class
ADP
():
def
__init__
(
self
,
dut
,
send
,
recieve
):
self
.
dut
=
dut
# Send Stream to NanoSoC
self
.
send
=
send
# Send Recieve to NanoSoC
self
.
recieve
=
recieve
self
.
monitor_mode
=
False
# Read Block from ADP
@cocotb.coroutine
async
def
read
(
self
,
length
):
read_str
=
""
for
i
in
range
(
length
):
data
=
await
self
.
recieve
.
read
()
read_str
+=
chr
(
data
[
0
])
return
read_str
# Read ADP String
@cocotb.coroutine
async
def
readLine
(
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
.
strip
()
# Write ADP String
@cocotb.coroutine
async
def
write
(
self
,
string
):
for
i
in
string
:
await
self
.
send
.
write
([
ord
(
i
)])
await
self
.
send
.
write
([
0x0a
])
read_str
=
await
self
.
readLine
()
self
.
dut
.
log
.
info
(
read_str
)
# Enter Monitor Mode
@cocotb.coroutine
async
def
monitorModeEnter
(
self
):
self
.
dut
.
log
.
info
(
"
Entering ADP Monitor Mode
"
)
await
self
.
send
.
write
([
0x1b
])
self
.
monitor_mode
=
True
# Exit Monitor Mode
@cocotb.coroutine
async
def
monitorModeEnter
(
self
):
self
.
dut
.
log
.
info
(
"
Exiting ADP Monitor Mode
"
)
await
self
.
send
.
write
([
0x04
])
self
.
monitor_mode
=
False
\ No newline at end of file
This diff is collapsed.
Click to expand it.
verif/cocotb/test_adp.py
+
18
−
55
View file @
69bc0c7b
#-----------------------------------------------------------------------------
# SoCLabs Cocotb ADP Testcases
# Contributors
#
# David Mapstone (d.a.mapstone@soton.ac.uk)
#
# Copyright 2021-3, SoC Labs (www.soclabs.org)
#-----------------------------------------------------------------------------
from
random
import
randint
,
randrange
,
getrandbits
,
shuffle
from
random
import
randint
,
randrange
,
getrandbits
,
shuffle
from
collections.abc
import
Iterable
from
collections.abc
import
Iterable
...
@@ -9,52 +17,17 @@ from cocotb.result import TestFailure
...
@@ -9,52 +17,17 @@ from cocotb.result import TestFailure
from
cocotb.triggers
import
ClockCycles
,
Combine
,
Join
,
RisingEdge
from
cocotb.triggers
import
ClockCycles
,
Combine
,
Join
,
RisingEdge
from
cocotbext.axi
import
AxiStreamBus
,
AxiStreamSource
,
AxiStreamSink
,
AxiStreamMonitor
from
cocotbext.axi
import
AxiStreamBus
,
AxiStreamSource
,
AxiStreamSink
,
AxiStreamMonitor
from
adp_cocotb_driver
import
ADP
CLK_PERIOD
=
(
10
,
"
ns
"
)
CLK_PERIOD
=
(
10
,
"
ns
"
)
# Class for ADP AXI Stream Interface
class
ADPDriver
():
def
__init__
(
self
,
send
,
recieve
):
# Send Stream to NanoSoC
self
.
send
=
send
# Send Recieve to NanoSoC
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
)
logging
.
getLogger
(
"
cocotb.nanosoc_tb.rxd8
"
).
setLevel
(
logging
.
WARNING
)
driver
=
ADPDriver
(
adp_sender
,
adp_reciever
)
logging
.
getLogger
(
"
cocotb.nanosoc_tb.txd8
"
).
setLevel
(
logging
.
WARNING
)
driver
=
ADP
(
dut
,
adp_sender
,
adp_reciever
)
return
driver
return
driver
# Start Clocks and Reset System
# Start Clocks and Reset System
...
@@ -66,28 +39,12 @@ async def setup_dut(dut):
...
@@ -66,28 +39,12 @@ async def setup_dut(dut):
dut
.
NRST
.
value
=
1
dut
.
NRST
.
value
=
1
await
ClockCycles
(
dut
.
XTAL1
,
2
)
await
ClockCycles
(
dut
.
XTAL1
,
2
)
@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
@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
# Wait for bootcode to finish
@cocotb.coroutine
@cocotb.coroutine
async
def
wait_bootcode
(
dut
,
driver
):
async
def
wait_bootcode
(
dut
,
driver
):
bootcode_last
=
"
** Remap->IMEM0
"
bootcode_last
=
"
** Remap->IMEM0
"
while
True
:
while
True
:
read_str
=
await
driver
.
read
()
read_str
=
await
driver
.
read
Line
()
dut
.
log
.
info
(
read_str
)
dut
.
log
.
info
(
read_str
)
if
read_str
==
bootcode_last
:
if
read_str
==
bootcode_last
:
break
break
...
@@ -118,6 +75,12 @@ async def test_adp_write(dut):
...
@@ -118,6 +75,12 @@ async def test_adp_write(dut):
dut
.
log
.
info
(
"
Setup Complete
"
)
dut
.
log
.
info
(
"
Setup Complete
"
)
dut
.
log
.
info
(
"
Starting Test
"
)
dut
.
log
.
info
(
"
Starting Test
"
)
await
wait_bootcode
(
dut
,
adp_driver
)
await
wait_bootcode
(
dut
,
adp_driver
)
dut
.
log
.
info
(
"
Bootcode Finished
"
)
await
adp_driver
.
monitorModeEnter
()
await
adp_driver
.
write
(
'
A 0x10000000
\n
'
)
await
adp_driver
.
write
(
'
R 4
\n
'
)
for
i
in
range
(
4
):
dut
.
log
.
info
(
await
adp_driver
.
readLine
())
dut
.
log
.
info
(
"
ADP Write Test Complete
"
)
dut
.
log
.
info
(
"
ADP Write Test Complete
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment