Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Accelerator Wrapper Tech
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SoCLabs
Accelerator Wrapper Tech
Commits
68b6dee6
Commit
68b6dee6
authored
2 years ago
by
David Mapstone
Browse files
Options
Downloads
Patches
Plain Diff
Generate FRI File from Python
parent
e0680b96
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
flow/stimgen.py
+45
-6
45 additions, 6 deletions
flow/stimgen.py
simulate/stimulus/ahb_input_hash_stim.fri
+25499
-0
25499 additions, 0 deletions
simulate/stimulus/ahb_input_hash_stim.fri
with
25544 additions
and
6 deletions
flow/stimgen.py
+
45
−
6
View file @
68b6dee6
import
csv
,
os
import
csv
,
os
,
tabulate
soclabs_header
=
"""
;#-----------------------------------------------------------------------------
;# SoC Labs Basic Hashing Accelerator Wrapper Input Stimulus File
;# A joint work commissioned on behalf of SoC Labs, under Arm Academic Access license.
;#
;# Contributors
;#
;# David Mapstone (d.a.mapstone@soton.ac.uk)
;#
;# Copyright 2023, SoC Labs (www.soclabs.org)
;#-----------------------------------------------------------------------------
"""
class
InputBlockStruct
:
class
InputBlockStruct
:
def
__init__
(
self
):
def
__init__
(
self
):
...
@@ -22,8 +33,32 @@ class WordStruct:
...
@@ -22,8 +33,32 @@ class WordStruct:
self
.
packet_num
=
packet_num
self
.
packet_num
=
packet_num
self
.
block_num
=
block_num
self
.
block_num
=
block_num
def
stimulus_generation
(
in_file
,
start_address
,
size
):
def
fri_output
(
out_file
,
word_list
):
"""
This function takes a list of 32 bit words and addresses and formats
the data into .fri format to be fed into fml2conv.pl script to stimulate
testbench
"""
# Column Names
col_names
=
[
"
Transaction
"
,
"
Address
"
,
"
Data
"
]
data
=
[]
for
word
in
word_list
:
data
.
append
([
str
(
word
.
trans
),
str
(
hex
(
word
.
addr
)),
str
(
hex
(
word
.
data
))])
table_str
=
tabulate
.
tabulate
(
data
,
headers
=
col_names
,
colalign
=
(
"
center
"
,),
tablefmt
=
"
plain
"
)
with
open
(
out_file
,
"
w
"
,
encoding
=
"
UTF8
"
,
newline
=
''
)
as
f
:
f
.
write
(
soclabs_header
+
"
\n
;
"
)
f
.
write
(
table_str
)
def
stimulus_generation
(
in_file
,
start_address
,
size
):
"""
This function takes 32 bit input stimulus file from accelerator model,
calculates write addresses for each word and generates a .fri file which
can be used to stimulate an AHB testbench
"""
# Calculate End Address
# Calculate End Address
end_address
=
start_address
+
size
-
0x4
end_address
=
start_address
+
size
-
0x4
# print(f"End Address is {hex(end_address)}")
# print(f"End Address is {hex(end_address)}")
...
@@ -76,7 +111,7 @@ def stimulus_generation(in_file, start_address, size):
...
@@ -76,7 +111,7 @@ def stimulus_generation(in_file, start_address, size):
# Increment Address
# Increment Address
write_addr
+=
0x4
write_addr
+=
0x4
#
for word in output_word_list:
#
Test Print Out
prev_block_num
=
0
prev_block_num
=
0
for
word
in
output_word_list
:
for
word
in
output_word_list
:
if
(
word
.
packet_num
>
0
):
if
(
word
.
packet_num
>
0
):
...
@@ -86,9 +121,13 @@ def stimulus_generation(in_file, start_address, size):
...
@@ -86,9 +121,13 @@ def stimulus_generation(in_file, start_address, size):
print
(
f
"
{
hex
(
word
.
addr
)
}
{
hex
(
word
.
data
)
}
{
word
.
trans
}
"
)
print
(
f
"
{
hex
(
word
.
addr
)
}
{
hex
(
word
.
data
)
}
{
word
.
trans
}
"
)
prev_block_num
=
word
.
block_num
prev_block_num
=
word
.
block_num
# Generate FRI File with Write Transactions
out_file
=
os
.
environ
[
"
WRAP_ACC_DIR
"
]
+
"
/simulate/stimulus/
"
+
"
ahb_input_hash_stim.fri
"
fri_output
(
out_file
,
output_word_list
)
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
accelerator_address
=
0x6001_0000
accelerator_
input_
address
=
0x6001_0000
accelerator_size
=
0x0000_8000
accelerator_
input_
size
=
0x0000_8000
in_file
=
os
.
environ
[
"
SHA_2_ACC_DIR
"
]
+
"
/simulate/stimulus/system/
"
+
"
input_data_32bit_stim.csv
"
in_file
=
os
.
environ
[
"
SHA_2_ACC_DIR
"
]
+
"
/simulate/stimulus/system/
"
+
"
input_data_32bit_stim.csv
"
stimulus_generation
(
in_file
,
accelerator_address
,
accelerator_size
)
stimulus_generation
(
in_file
,
accelerator_input_address
,
accelerator_input_size
)
\ No newline at end of file
\ No newline at end of file
This diff is collapsed.
Click to expand it.
simulate/stimulus/ahb_input_hash_stim.fri
0 → 100644
+
25499
−
0
View file @
68b6dee6
Source diff could not be displayed: it is too large. Options to address this:
view the blob
.
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