Commit graph

33 commits

Author SHA1 Message Date
Greg Chadwick
a788593842 [cosim] Pass Ibex config through for verilator cosim 2022-09-30 09:41:07 +01:00
Greg Chadwick
70186c57ae [rtl] Add ic_scr_key_valid field to CPUCTRL (renamed CPUCTRLSTS)
The ic_scr_key_valid field indicates whether the ICache scrambling key
is valid.

CPUCTRL is also renamed CPUCTRLSTS as it contains both control and
status bits.
2022-09-22 16:17:31 +01:00
Greg Chadwick
7e9eef2cf9 [cosim] Pass PMP configuration through to spike 2022-08-11 17:43:34 +01:00
Canberk Topal
1e613cc7f4 [cosim,dv] Add support to set mcount registers
Extends RVFI connections further to include 30 mhpmcounterX registers.
Sets them up before every cosim step to let Spike know their real values.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-07-25 08:51:31 +01:00
Greg Chadwick
1ea89a423b [dv] Fix traps in simple system cosim
Previously any traps seen on RVFI were skipped over. This was old
behaviour. With the latest cosim setup traps must be passed to the
`step` function.
2022-07-19 16:44:53 +01:00
Rupert Swarbrick
42ce56b6b6 [dv] Simplify instructions for how to use Spike with cosim
This depends on Spike version ibex-cosim-v0.2 (which exposes the
various library headers with pkg-config, making configuration much
easier).
2022-04-29 11:13:21 +01:00
Canberk Topal
394a0d2160 Updating parameters for OpenTitan option
Updated the parameters with respect to top_earlgrey.hjson in OpenTitan
repository. For other builds, kept the previously undeclared parameters
as their default values.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-04-28 15:14:42 +01:00
Greg Chadwick
7508644c6e [simple_system_cosim] Switch to latest cosim version 2022-03-22 16:29:03 +00:00
Rupert Swarbrick
9f14922382 [dv] Construct ISA string from RTL parameters for cosim tests 2022-02-17 16:06:53 +00:00
Canberk Topal
187944c417 [icache] Add RAM Primitives for scrambling
This commit includes switching to a scrambling RAM primitive for
ICache data and tag RAMs. Also introduces minor changes to ICache
to handle scrambling key valid signal.

It also includes a minor bug fix regarding not initializing
`fill_way_q` signal without ResetAll parameter. When the parameter
is not set and we have our first hit right after ICache enables,
the signal hangs.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-01-19 14:59:43 +00:00
Greg Chadwick
84d2d6ad3f [cosim] Add Simple System with cosim 2021-11-12 09:39:38 +00:00
Rupert Swarbrick
6ebc6bcb9f [simple_system] Fix type for mhpmcounter_get
It's probably clearer if this 64-bit counter is treated as a uint64_t,
not an int64_t (the code using it downstream expects non-negative
values).
2021-02-25 15:34:02 +00:00
Rupert Swarbrick
33ad42debb Spelling fix: seperate -> separate 2020-06-05 11:37:37 +01:00
Philipp Wagner
3f4e706062 Move Verilator simutil upstream to OpenTitan
https://github.com/lowRISC/opentitan/pull/2311 added the Verilator
memutils to OpenTitan as upstream. This commit is the second part of the
story, removing the code from the Ibex repository, and vendoring it back
in from OpenTitan.

This also superseded #844, which has now been included through
OpenTitan.
2020-05-27 10:23:15 +01:00
Stefan Wallentowitz
8b8327d820 [dv] Change performance counter access to DPI
DPI access is suggested and more generic than Verilator direct signal
access. This changes the access to the performance counters from the
Verilator testbench to use DPI instead of directly accessing the
array.

Signed-off-by: Stefan Wallentowitz <stefan.wallentowitz@hm.edu>
2020-05-21 20:34:26 +01:00
Tom Roberts
dc8ba83de4 [memutils] Add support for > 32b memories
Pack > 32bit memory loads into wider RAM instances. Fixes #790

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-04-20 16:04:43 +01:00
Luís Marques
e9171001c3 [verilator] Fix --term-after-cycles
The option to limit the verilator simulation's maximum number of cycles was
implemented in terms of the `time_` variable, which counts half cycles. This
patch makes the limit respect the requested number of full cycles.

The patch divides `time_` by 2, instead of multiplying `term_after_cycles_`
by 2, as that better conveys the intended semantics, and slightly increases
the range of the limit. Related computations were modified for consistency.
2020-03-19 10:59:31 +00:00
Greg Chadwick
3927fd8d2a [rtl/sw] Add multiply and divide wait counters 2020-03-13 14:48:29 +00:00
Luís Marques
ed8bcc0d33 [verilator] Fix ELF loading
In `VerilatorMemUtil::WriteElfToMem`, the verilator memory is written
with the ELF segment data, 4 bytes at a time . If the segment size isn't
a multiple of 4 (e.g. when using the RISC-V C extension) the last word
wouldn't be written. This patch rounds the size up to a multiple of 4,
solving that issue.
2020-02-03 08:32:13 +00:00
Tobias Wölfel
17d69d1cd6 [DV] Continue argument parsing
In case one of the arguments is '-h' the parsing of the arguments is
aborted and only `PrintHelp()` of *verilator_sim_ctrl.cc* is executed.
Do not abort at this point in order to forward the arguments to the
registered extensions. This allows to execute the respective
`PrintHelp()` function and print the help message. For example
`VerilatorMemUtil` needs to parse the arguments in order to print the
help message.
The execution of the simulation is still terminated as `exit_app` is set
and then evaluated after parsing of the registered extensions.
2020-01-02 14:15:53 +01:00
Bryan Cantrill
6885c9e937 [verilator] Fix ELF processing
As described in https://github.com/lowRISC/opentitan/issues/1245,
the Ibex Verliator ELF processing does not exactly follow the algorithm
for the "binary" target of objcopy (which it is intended to mimic).
In particular, sections as denoted by program headers are laid down
strictly sequentially, ignoring their specified p_paddr -- and
resulting in a corrupted in-memory image for ELF images that have
unordered program headers.
2019-12-31 17:05:23 +01:00
Philipp Wagner
7fe01cc283 SimCtrlExtension: Add a default destructor
This base class needs a default destructor for potential future extensions.

Signed-off-by: Philipp Wagner <phw@lowrisc.org>
2019-12-24 10:08:59 +01:00
Tom Roberts
e45e314686 [verilator] Separate out memory loading utilities
- Split memory utils out of VerilatorSimCtrl
- Allows VerilatorSimCtrl to be used in systems not requiring memory loading
- Fixes #317
2019-12-23 21:35:30 +01:00
Tobias Wölfel
cd39a31498 [verilator] Clarify ELF BSS handling
Add a requirement for the software loaded by the simulator for zero-ing
the BSS section.

Fixes lowRISC/ibex#496
2019-12-04 19:42:11 -05:00
Philipp Wagner
82e0faf50b Make VerilatorSimCtrl class a singleton
The VerilatorSimCtrl class was always intended to be used only once in
an application, since it sets up a global signal handler and needs to be
accessible from DPI modules. This accessibility was achieved through a
global variable `simctrl`.

With this commit the VerilatorSimCtrl is switched to a singleton class.
The instance is accessible through `VerilatorSimCtrl::GetInstance()`.
The downside of that approach is that we loose the constructor
arguments, and need to deal with a class which potentially hasn't top or
the clock and reset signals set.
2019-12-02 10:57:24 +00:00
Philipp Wagner
71a635ec6b Reverse return code of simutil_verilator_set_mem()
All functions in simutil_verilator return booleans to indicate
success/failure, where 1 == true, and 0 == false.
simutil_verilator_set_mem() returns an int due to DPI interface
restrictions. Before, 0 meant success, and 1 meant error.

To keep things nice and consistent, turn things around and align with
the bool meaning.
2019-11-28 18:45:11 +00:00
Tobias Wölfel
ce7e38351e [DV] Add Verilator memory initialization from ELF
Support initialization of memory by loading content from ELF files.
All segments of the ELF file with the type `PT_LOAD` are merged into a
temporary buffer and then forwarded to a predefined memory.
This is an addition for setting the memories with VMEM files.

Memories must implement `simutil_verilator_set_mem` to support the
setting of values with a width of 32 bits. A return value of 0 must
indicate a successful operation and 1 an error.

Memories are defined by a call to `RegisterMemoryArea()` before the
execution of the simulation, at which point the arguments are parsed and
the initialization is started. The memories are identified by unique
name. The design specific location is used to set the SystemVerilog
scope.

Registered memories can be printed by using `-l list`. The unique name
is used for `-l name,file.elf` together with the file path.
An optional part of the argument is the type of the file, `elf` or
`vmem`, and if not provided it is attempted to detect the type by
looking at the file extension.
The memory specific arguments which already existed accept now also ELF
files. They use predefined names and are included to keep the interface
stable.

Contents of an ELF segment which has a bigger memory size than file size
are not set. This is typically required for BSS sections for zero-ing
the memory.
2019-11-27 11:35:07 +00:00
Greg Chadwick
5ce6351530 Add performance counter utils for verilator sims 2019-10-30 16:56:55 +00:00
Tom Roberts
70b53068db [DV] Add registers testbench
- Sample C++ unit testbench for system registers module
- Only tests a few PMP registers at the moment
2019-10-30 14:46:33 +00:00
Tobias Wölfel
0728fb7e9f [DV] Update simulation terminate argument
Add description to usage output.
Add short option '-c'.
2019-10-21 22:19:24 +02:00
Philipp Wagner
7a0614a1d0 simutil_verilator: Always produce toplevel class
Previously, verilated_toplevel.h contained a macro, VERILATED_TOPLEVEL()
to produce a class TOPLEVEL (whatever the toplevel happens to be). This
required all compilation units referring to that TOPLEVEL class to call
the macro.

After this change, the class is always generated in
verilated_toplevel.h. For that to work, a new define TOPLEVEL_NAME must
be globally set (e.g. passed to the compiler with -DTOPLEVEL_NAME=xxx).
2019-09-16 14:53:54 +01:00
Philipp Wagner
6b03bc6326 Run clang-format on all source files 2019-09-11 12:00:49 +01:00
Philipp Wagner
b72f5db6bd DV: Add verilator simulation utility 2019-08-05 15:49:15 +01:00