Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CTU CAN FD IP Core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
16
Issues
16
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
canbus
CTU CAN FD IP Core
Commits
f72362d6
Commit
f72362d6
authored
Mar 22, 2019
by
Martin Jeřábek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testfw: generate and use wave-opt file for ghdl
Addresses
#284
parent
07b97930
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
4 deletions
+19
-4
test/testfw/gtkwave.py
test/testfw/gtkwave.py
+13
-2
test/testfw/test_common.py
test/testfw/test_common.py
+6
-2
No files found.
test/testfw/gtkwave.py
View file @
f72362d6
from
vcd.gtkw
import
GTKWSave
import
tkinter
from
typing
import
List
from
typing
import
List
,
Set
import
logging
import
traceback
import
functools
...
...
@@ -25,6 +25,7 @@ def logexc(f):
class
TclFuncs
:
def
__init__
(
self
,
gtkw
:
str
,
hierarchy
):
self
.
gtkw
=
gtkw
self
.
used_signals
=
set
()
# type: Set[str]
self
.
hierarchy
=
hierarchy
# set up TCL
...
...
@@ -65,6 +66,13 @@ class TclFuncs:
fqn
=
'top.'
+
fqn
return
fqn
.
replace
(
'('
,
'['
).
replace
(
')'
,
']'
).
lower
()
def
convsig_wave_opt
(
self
,
sig
:
str
)
->
str
:
sig
=
re
.
sub
(
r
'__([0-9]+)'
,
r
'(\1)'
,
sig
)
sig
=
re
.
sub
(
r
'\([^)]+\)'
,
''
,
sig
)
if
sig
[
0
]
!=
'/'
:
sig
=
'/'
+
sig
return
sig
def
_add_trace
(
self
,
signal
,
type
,
*
,
label
:
str
,
datafmt
:
str
,
expand
:
bool
,
**
kwds
):
if
ghw_parse
.
is_record
(
type
):
with
self
.
gtkw
.
group
(
label
,
closed
=
not
expand
):
...
...
@@ -72,6 +80,7 @@ class TclFuncs:
# do not pass label
self
.
_add_trace
(
signal
+
'/'
+
iname
,
itype
,
datafmt
=
datafmt
,
expand
=
False
,
label
=
None
,
**
kwds
)
else
:
self
.
used_signals
.
add
(
self
.
convsig_wave_opt
(
signal
))
signal
=
self
.
convsig
(
signal
)
self
.
gtkw
.
trace
(
signal
,
alias
=
label
,
datafmt
=
datafmt
,
**
kwds
)
...
...
@@ -170,7 +179,7 @@ class TclFuncs:
self
.
gtkw
.
end_group
(
o
.
group
)
def
tcl2gtkw
(
tcl_wave
,
tcl_init_files
:
List
[
str
],
gtkw
,
ghw
:
Path
):
def
tcl2gtkw
(
tcl_wave
,
tcl_init_files
:
List
[
str
],
gtkw
,
ghw
:
Path
)
->
List
[
str
]
:
hierarchy
=
ghw_parse
.
parse
(
ghw
)
with
open
(
gtkw
,
'wt'
)
as
f
:
gtkw
=
GTKWSave
(
f
)
...
...
@@ -183,3 +192,5 @@ def tcl2gtkw(tcl_wave, tcl_init_files: List[str], gtkw, ghw: Path):
c
.
tcl
.
createcommand
(
'run_simulation'
,
lambda
:
None
)
c
.
source
(
tcl_wave
)
c
.
finalize
()
used_signals
=
sorted
(
c
.
used_signals
)
return
used_signals
test/testfw/test_common.py
View file @
f72362d6
...
...
@@ -122,6 +122,7 @@ class TestsBase:
gtkw
=
tcl
.
with_suffix
(
'.gtkw'
)
tclfname
=
tcl
.
relative_to
(
self
.
base
)
ghw_file
=
self
.
build
/
(
tb
.
name
+
'.elab.ghw'
)
wave_opt_file
=
tcl
.
with_suffix
(
'.wevaopt.txt'
)
# We need the GHW file for TCL -> GTKW conversion. If we are
# generating them, there is no sense in actually doing
# the conversion now.
...
...
@@ -136,8 +137,11 @@ class TestsBase:
gtkw
=
None
else
:
log
.
info
(
'Converting wave file {} to gtkw ...'
.
format
(
tclfname
))
tcl2gtkw
(
str
(
tcl
),
tcl_init_files
,
str
(
gtkw
),
ghw_file
)
used_signals
=
tcl2gtkw
(
str
(
tcl
),
tcl_init_files
,
str
(
gtkw
),
ghw_file
)
with
wave_opt_file
.
open
(
'wt'
)
as
f
:
f
.
write
(
'$ version 1.1
\n
'
)
f
.
writelines
(
'
\n
'
.
join
(
used_signals
))
sim_options
[
'ghdl.sim_flags'
]
+=
[
'--read-wave-opt='
+
str
(
wave_opt_file
)]
if
gtkw
:
try
:
tb
.
set_sim_option
(
"ghdl.gtkwave_flags"
,
[])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment