-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved HDL simulation flow for Questa #47
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has an informal first look at this proposal.
Thanks Niels! I like this a lot. This is much more flexible than our current solution. Please go ahead and let me know when this is ready to go.
0686160
to
33550a7
Compare
I will test it on Jenkins tomorrow and then we can merge it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is amazing, thanks!
I've got no useful comments on the code, it looks good to me. Maybe we can have @jf have a look from the software perspective.
I suggest that we test this for a day or two without merging, to see if we can think of anything else we'd like to add.
RULES/hdl/questa.go
Outdated
" -directive -cvg -codeAll -testname %s" + | ||
" -instance %s %s.ucdb\"", | ||
testcase, rule.Instance(), coverage_db)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Weird formatting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Is there a way to execute all testcases? And similarly, is there a way to execute whatever test-case (or all) using all parameter sets? |
has somebody been claiming "jf" here? The real "jf" is this guy, I'm sorry. |
The newest version now has the capability of simulating all parameter sets and testcases. The behavior is that if no testcase or parameter set is specified, then all will be simulated. It now also outputs |
Haha, sorry @jf. I meant @jfrohnhofen. :) Thanks, Niels. That's perfect. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only looked at the code from a DBT perspective, not from the perspective of a potential user.
- Two overall remoarks: The formatting seems to be off in a couple of places.
- Some functions in
questa.go
are only used inside his package and could be made private by giving them lowercase names.
RULES/hdl/utils.go
Outdated
return strings.HasSuffix(path, ".v") || strings.HasSuffix(path, ".sv") || strings.HasSuffix(path, ".vhd") | ||
return strings.HasSuffix(path, ".v") || | ||
strings.HasSuffix(path, ".sv") || | ||
strings.HasSuffix(path, ".vhd") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The formatting looks weird
RULES/hdl/utils.go
Outdated
|
||
func IsVhdl(path string) bool { | ||
return strings.HasSuffix(path, ".vhdl") || | ||
strings.HasSuffix(path, ".vhd") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting
cmd_preamble := "" | ||
|
||
// Default log file | ||
log_file_suffix := "vsim.log" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting
RULES/hdl/questa.go
Outdated
// Parse additional arguments | ||
for _, arg := range args { | ||
if strings.HasPrefix(arg, "-testcase=") && rule.TestCaseGenerator != nil { | ||
var testcase string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatting
I hope to have fixed the formatting and made the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I finally took this PR for a spin. I like the new capabilities, and the new UI very much, thanks a million for taking the initiative.
However, I have discovered some problems with the code so far.
It seems the parsing of the command line flags does not yet work propperly. More precisely, I've made the following observations:
- The argument for the verbosity flag is ignored. The simulation runs in silent mode no matter what.
- Arguments outside the allowed range {"none", "low", "medim", "high") are also ignored - i.e. they don't make the command crash, as thy should. The same goes for the
-params
argument. - Arguments to the
-params
flag are "somewhat ignored": it seems that a simulation for every parameter set is triggered every second time the command is issued. On the alternate invokation, a specific parameter set is simulated, but not always the rght one.
I'm appending a snipped from a couple of consecutive trials I did. I'll not post my full setup publicly, please ping me privately for that.
ddln-ng[code/exp-compute] $ ninja: build stopped: interrupted by user.
dbt test //exp-compute/vta/hw/dta_v1/sim/dma/DmaSimulation -v -seed=4199734666 -verbosity=hih -params=SramLatency1
[2/3] Created exp-compute/vta/hw/dta_v1/sim/dma/DmaSimulation:
BUILD/OUTPUT-069C378E/DMA/SramLatency10_vopt.log
BUILD/OUTPUT-069C378E/DMA/SramLatency1_vopt.log
BUILD/OUTPUT-069C378E/DMA/default_vopt.log
BUILD/OUTPUT-069C378E/DMA/exp-compute/vta/hw/dta_v1/sim/dma/tb.sv.log
[2/3] Testing exp-compute/vta/hw/dta_v1/sim/dma/DmaSimulation:
Testcase SramLatency10:^C
ddln-ng[code/exp-compute] $ ninja: build stopped: interrupted by user.
dbt test //exp-compute/vta/hw/dta_v1/sim/dma/DmaSimulation -v -seed=4199734666 -verbosity=hih -params=SramLatency1
[2/3] Created exp-compute/vta/hw/dta_v1/sim/dma/DmaSimulation:
BUILD/OUTPUT-069C378E/DMA/SramLatency10_vopt.log
BUILD/OUTPUT-069C378E/DMA/SramLatency1_vopt.log
BUILD/OUTPUT-069C378E/DMA/default_vopt.log
BUILD/OUTPUT-069C378E/DMA/exp-compute/vta/hw/dta_v1/sim/dma/tb.sv.log
[2/3] Testing exp-compute/vta/hw/dta_v1/sim/dma/DmaSimulation:
Testcase default:^C
ddln-ng[code/exp-compute] $ dbt test //exp-compute/vta/hw/dta_v1/sim/dma/DmaSimulation -v -seed=4199734666 -verbosity=high -params=SramLatency1
[2/3] Created exp-compute/vta/hw/dta_v1/sim/dma/DmaSimulation:
BUILD/OUTPUT-069C378E/DMA/SramLatency10_vopt.log
BUILD/OUTPUT-069C378E/DMA/SramLatency1_vopt.log
BUILD/OUTPUT-069C378E/DMA/default_vopt.log
BUILD/OUTPUT-069C378E/DMA/exp-compute/vta/hw/dta_v1/sim/dma/tb.sv.log
[2/3] Testing exp-compute/vta/hw/dta_v1/sim/dma/DmaSimulation:
Testcase default:^C
ddln-ng[code/exp-compute] $ ninja: build stopped: interrupted by user.
RULES/hdl/questa.go
Outdated
if rule.WaveformInit != nil { | ||
do_flags = append(do_flags, rule.WaveformInit.String()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we're at it: The WaveformInit rule parameter is somewhat superfluous: Can we work on the convention that waveformInit scripts are always called sth, (e.g. waves.do)? Then we could make do without that parameter. Just probe the source dir and if it exists, add the flag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrt. to your tests, keep in mind that runtime parameters should come after a ":" in the command line. For example:
❯ dbt test //exp-compute/vta/hw/dta_v1/sim/fetch/Simulation : -verbosity=foo
2022/01/10 10:49:48 invalid verbosity flag 'foo', only 'low', 'medium', 'high' or 'none' allowed!
exit status 1
Error: Failed to run generator: exit status 1.
A fatal error occured. Exiting...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with not having a WaveformInit rule is that probing the source directory from dbt
is a bit difficult. I will need to see what I can do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For your example, please use a simulation target like this:
var Simulation = hdl.Simulation{
Name: "dma",
Srcs: ins(
"tb.sv",
),
Ips: []hdl.Ip{
util.Logger,
dma.Dma,
interfaces.Stream,
DmaTest,
},
Params: hdl.ParamMap{
"default": {},
"SramLatency1": {"SramLatency": "1"},
"SramLatency10": {"SramLatency": "10"},
},
WaveformInit: in("waves.do"),
}
with a command line like this:
dbt test //exp-compute/vta/hw/dta_v1/sim/dma/Simulation : -seed=4199734666 -params=SramLatency1
you can then add -verbosity=high
too if you like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and make sure you do a dbt sync --update
too!
69a9002
to
b4b02f0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no relevant comments on the code. It looks good to me. I'll take this for a spin now. Will give more feedback later if I encounter any problems in practise, or approve if not.
Thanks a lot for your work. After about half a day of testing, I've got a few more comments. I've encountered three issues:
|
b4fe0da
to
da6abfc
Compare
Thanks for the clarifications. Works now like a charm. |
cmd := fmt.Sprintf("{ echo -n %s && xsim %s %s %s && "+ | ||
"{ { ! grep -q FAILURE %s; } && echo PASS; } }", | ||
cmd_echo, vsim_flags, rule.Name+params, cmd_devnull, log_file.String()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this only works reliably with our new testing environment. But that's not yet implemented consistently.
b4e9fe8
to
9f708cf
Compare
…agement instead of scripts.
… updated to merge coverage.
…overage database.
…gets are evaluated.
…s fail. Also made naming of directories a bit more sane.
…and params. Improved dbt build output to reflect command usage. Outputs coverage database location when enabled.
9f708cf
to
ad3a076
Compare
Overview
The purpose of the following PR is to provide an improved HDL simulation flow. The main changes are:
dbt run
anddbt test
in addition todbt build
dbt run
is used for starting the simulation in UI modedbt test
is used for running unit tests (i.e. batch mode)Simulation
target.How to use
Run the usual
dbt build
command to see a list of available build targets. Each target now has additional information as shown below:The additional information will be discussed in more detail below.
Test
Use the
dbt test
command to execute unit tests. The command will execute the simulator in batch mode and create code coverage if selected.Run
Use the
dbt run
command to execute tests in GUI mode. The simulator will open the UI and read in an optional waveform configuration file. Note that it will not automatically store code coverage data at the end of the simulation.Coverage
Code coverage may be generated using the
dbt test
with the flagquesta-coverage=true
. Code coverage will produce an HTML report of the entire design in theBUILD/OUTPUT-XXX
folder as well as a coverage database in UCDB format. The coverage database can be viewed using thevsim -viewcov <database>
command.Note that the tool will create a single coverage database for every simulation target, which merges the results of all simulation runs from e.g. multiple testcases and/or multiple parameter sets.
Params
The
Params
enables different named parameter sets to be defined. The option is useful for modules with parameters where a single top-level testbench may be used to verify different configurations of the modules. To add a parameter set use theParams
field of thehdl.Simulation
target like this:The
Params
field is a map with strings as keys. The key is the name of the parameter set. The content of each entry should themselves be a map from strings to strings. The key is the parameter name and the value is the parameter value. The parameters of a parameter set will be applied during thevopt
step using the-G
option, e.g.-G AxiDataWidth=64
.Parameters can be selected using the
-params
flag. For example, to selectRegisterCount16
as the parameter set one should execute e.g.Note that all parameter sets are always compiled, so make sure that they are syntactically correct. You can select multiple parameter sets to execute by specifying them as a comma separated list.
TestCases
Some testbenches require the use of an external test generator script for creating input data and expected output. The generator can be entered using the
TestCaseGenerator
andTestCasesDir
fields of thehdl.Simulator
target, like this:The
TestCasesDir
is optional. However, if defined, every file in the directory will be listed as an optional testcase. By default, ifTestCaseGenerator
is defined, the generator will always be executed. If no testcase is specifically selected on the command line andTestCasesDir
is defined, then the first file in the directory will be used as the default testcase.To execute a specific testcase do
Multiple testcases can be specified using a comma separated list, e.g. `-testcases=default.json,maxpool-10x10-16ch.json'.