Commit Graph

6486 Commits

Author SHA1 Message Date
Yinan Xu bb8c2abf9d
Avoid warning messages when ccache does not exist (#369)
verilator.mk checks the existence of ccache and use it when possible.
However, on some OS platforms, such as CentOS, this checker may cause
warning messages if ccache does not exist. Since this checker is always
called even when the user is not building Verilator targets, the warning
message seems confused for users.

We avoid this message by redirecting the stderr to /dev/null.
2024-05-09 21:32:09 +08:00
Yinan Xu 5e13cd1be8
Makefile: set difftest_verilog the default target (#368)
This commit changes the default target of make to difftest_verilog.

The previous default target is emu. However, emu is for only the Verilator
target, one of the three supported simulation platforms.

To make the default target clearer, we change the default target to
difftest_verilog. It generates example difftest design-under-test
interfaces and C++ files. Using this main target, user may connect
their own design (maybe in Verilog) to difftest for simulation.
2024-05-09 21:29:02 +08:00
Yinan Xu a0d5e52f08
emu: update the stack size only for legacy Verilator (#367)
Verilator v5.026 comes with an automated stack resizer for various
verilated models. The stack size will be set implicitly in the
constructor of the verilated design based on an estimated stack size
requirement.

Thus, we comment out the `setrlimit` lines for newer version of
Verilator. They will use the estimated stack size instead of the
predetermined constant value.
2024-05-09 21:21:07 +08:00
Yinan Xu 957eae5391
CI: use the default NOOP_HOME for difftest_verilog (#366) 2024-05-08 10:59:16 +08:00
Jiuyue Ma b31c1b0c06 Makefile: NOOP_HOME should be exported for non-chisel design targets
For non-chisel design target `difftest_verilog`, the `NOOP_HOME` was set to
`$(abspath .)` as default by Makefile. But it was not exported.
This will cause `NOOP_HOME not found exception` when running `streamToFile()`
in difftest.test.runMain task.

Fix this by exporting NOOP_HOME in Makefile.

Signed-off-by: Jiuyue Ma <majiuyue@bosc.ac.cn>
2024-05-08 10:26:09 +08:00
Jiuyue Ma b445331789 compress: Fix compile error when disable zstd support
The `<fcntl.h>` header file was not included if difftest was compiled
without zstd support (a.k.a w/ `NO_ZSTD_COMPRESSION` defined), which
will cause `undefined symbol` compile errors for `open()` and `O_RDONLY`.

Move `fcntl.h` out of NO_ZSTD_COMPRESSION to make compiler happy.

This BUG was introduced by following commit:

```
compress: using magic number to determine the file type (#352)

 - commit: 57aa88a696
 - Date: Wed Apr 24 16:29:53 2024 +0800
```

Signed-off-by: Jiuyue Ma <majiuyue@bosc.ac.cn>
2024-05-08 10:26:09 +08:00
Kunlin You dd68cf2509
Makefile: check clang-format version (#362)
Add Version Checker and Install note into Makefile. So user should
ensure correct clang-format version for difftest.

* Add more 2> /dev/null to avoid unused warnings

---------

Co-authored-by: Yinan Xu <xuyinan@ict.ac.cn>
2024-04-29 11:34:20 +08:00
Yinan Xu 4aaf42c09b
Update README.md 2024-04-29 09:40:56 +08:00
Kamimiao 1ccb2b48e5
vcs: check max-instrs for every cpu core (#359)
When exiting the program using max_instrs, ensure that each core
runs to the corresponding number of instructions, and add the core
id when printing the IPC.
2024-04-26 19:27:35 +08:00
Kunlin You d7bed3cb0b
Squash: add SquashDependency for HCSR/VecCSR (#357)
In difftest, CSR is only valid and used when instrcommit or
exception. The value is invalid in other time, so we will only
squash HCSR/VecCSR when there is commit/event.
2024-04-25 17:00:52 +08:00
Yanqin Li 4a69fa8eb0
stack: enlarge the size (#355)
MultiCore test in XiangShan will failed with origin small stack size. This PR enlarges the stack size.
2024-04-25 15:42:58 +08:00
Luoshan Cai e634f341a5
Make: add support for compiling difftest as a lib.so (#353)
* This commit adds support for using difftest as a lib to simulate with XS.

* For now, it works both on VCS and Palladium.

* use "make difftest-so" to generate libdifftest.so and link it when compiling your design.

---------

Co-authored-by: Cai Luoshan <cailuoshan18@mails.ucas.ac.cn>
2024-04-24 20:12:12 +08:00
xyyy1420 57aa88a696
compress: using magic number to determine the file type (#352)
Signed-off-by: jiaxiaoyu <xyyy1420@gmail.com>
2024-04-24 16:29:53 +08:00
Kamimiao de2aa3412b
vcs: add the overwrite_nbytes argument (#351)
Since we have different sizes of gcpt that need to be replaced,
we add this feature to support it.
2024-04-22 17:08:16 +08:00
Kamimiao 98d13d0a58
vcs: fix the support for --max-instrs (#350) 2024-04-22 10:41:07 +08:00
Yinan Xu 57742e952b
Bump Chisel 6.3.0 (#348) 2024-04-20 09:35:33 +08:00
Yinan Xu ed6c82a441
Apply Clang format (#349)
Clang format seems to be updated last night and finds some missing
format issues.
2024-04-20 08:58:18 +08:00
Yinan Xu f1581ab672
emu: fix the missing `-F` option in help (#346)
`-F` is short for `--flash`.
2024-04-18 11:20:08 +08:00
huxuan0307 f3edf0a11a
LoadEvent: replace fuType with isAtomic and isLoad now (#344) 2024-04-16 13:24:15 +08:00
Kunlin You 92311228cb
vcs: remove bracket of $fatal (#342)
Palladium disallow empty argument for $fatal(). We remove bracket
and declare it as TB_IMPORT
2024-04-16 12:02:56 +08:00
Kunlin You e7e7560a12
vcs: call difftest_finish also when no-diff (#341)
This change is corresponding to difftest_init.
2024-04-12 17:25:24 +08:00
Yinan Xu fb7590bf8b
vcs: exit with $fatal for errors (#340)
When the simulation exits abnormally, we should let the user know
there're failures.

* Add the flag for completion of workload lists

We add a flag to indicate the completion of workload lists and let
the simulation exit normally at the end of the list.

Since this flag will be read only when simv_init fails, we expect
minor impact on the simulation performance.
2024-04-12 13:37:26 +08:00
Kunlin You d2e9e5ab65
Perf: report Simulation speed when finish (#339)
As test in Palladium, Simulation speed calculate by Time and CycleCnt is very
close to Palladium report. We add this platform-independent report
here.
2024-04-12 11:28:58 +08:00
Yinan Xu 5ae0ec15ec
vcs_main: avoid difftest functions when NO_DIFF (#338)
* CI: add a NO_DIFF test for VCS
2024-04-11 11:45:04 +08:00
Yinan Xu f58265171c
verilator: be quiet for stats (#337)
Verilator v5.024 introduces stats reports for both verilation and
simulation. These reports are never expected to be useful for normal
users but brings annoying prints. We are disabling them by default.

For advanced users, they should remove the `--quiet-stats` option
manually in the Makefile.
2024-04-11 10:41:53 +08:00
Kunlin You 52815ee1e5
Squash: use Queue to buffer unsquashed Bundle (#330)
We use Queue to buffer StoreEvent, avoid too many squash tick
caused by it. This bundle will only compare store actions betweens
DUT and REF, no other bundles depends on it, which enable us to buffer
it.

Another bundle causing many ticks is Sbuffer, for it will update
GoldenMem, and other bundle related will affected by it. Now buffering
of this bundle need Squash Flush Option, which means drop outdated 
bundles depending on GoldenMem.
2024-04-10 14:48:07 +08:00
Kunlin You 2e958c6620
Batch: pack DPIC with hybird parallel and pipeline (#331)
Previous we give each bundle a different delay to collect valid value by
Pipeline.

This change process bundles of same class in parallel, because offset
is easy to count, and it will reduce stages in pipeline to reduces regs.

We also sort bundles by width, giving larger bundle less delay for less
reg. And add `num` to info, which will reduce info costs with multiple
bundle of same class.
2024-04-10 14:45:42 +08:00
Xiaokun-Pei 644ce38a7c
Add support for RISC-V Hypervisor extension (#333)
This commit enhances difftest to include support for hypervisor extension,
including newly added CSR, extra checking logic for two-stage address
translation, and handlers of newly added exceptions.
2024-04-08 14:27:47 +08:00
Kunlin You ca81bef78a
Squash: tick squashed state independently between Groups (#320)
We seperate DiffTestBundles into REF/GoldenMem, tick of Bundle will
only affected by it's Group. Default Group is REF. Note some bundle
will have several Group, because it will affect both REF and GoldenMem
state. Bundles allowed to be dropped will ticked incidentially when
it's Group tick.

We also add built-in perf to count the tick cause of each Group.

We sperate squash of bundles with same CppName, which support we change
bundle num when squashing, preliminary support for later feature.Note
bundle num of replay and squash may be different.
2024-04-07 16:41:25 +08:00
Kamimiao a4e01f72c6
vcs: add finish_device for simv_finish (#324)
This change will clear device buffer, avoid potential affect between workloads.
2024-04-03 11:40:34 +08:00
Kamimiao 59b3e7ae7d
ram: add dpic ram read_addr check (#328)
Use PMEM_CHECK to enable checkers for read address.
2024-04-02 16:26:44 +08:00
Tang Haojin 24be047ba6
emu: increase reset cycles in verilator (#327) 2024-04-02 10:19:06 +08:00
Yinan Xu faa06977d0
Fix typo for privileged (#326) 2024-03-29 10:46:19 +08:00
Kunlin You 30bf8283ea
Replay: seperate from Squash (#325)
We seperate Replay feature for better structure. Signal `in_replay` will mark trace as replay or not, replayed trace will not be squashed. And we will record squashed range between `trace_head` and `trace_tail`, see detailed in squash function of `DiffTraceInfo`. In the future, Replay may support not only Squashed, but also Compress, etc.

This change also provides better flexibility for optimization. Now difftest will generated Cpp declaration depends on result of Gateway.
2024-03-28 16:29:51 +08:00
Kamimiao 3649000a75
vcs: fix the gcpt restore option (#323)
Should be performed before difftest is initialized, otherwise
the override cannot be synchronized to the dut.
2024-03-25 10:38:31 +08:00
Kamimiao b4cda2b692
ram: add gcpt-restore option for VCS (#322) 2024-03-22 20:08:36 +08:00
Kunlin You f8df21ae2a
Add built-in Perf for difftest (#315)
We will dump built-in Perf for difftest at the end of simulation. These printfs can be controled by difftest_perfCtrl_dump.

For emu, we call Emulator::trigger_stat_dump. For simv, we raise difftest_perfCtrl_dump when simv_result is not zero.

We also add system task decl $fwrite to Palladium scripts, otherwise it will be ignored by compiler.
2024-03-19 16:17:33 +08:00
Kunlin You 2766390a14
Fix extra space of Palladium CFLAGS for path parsing (#318)
Previous change #312 has an extra space, which cause error in path parsing, this change fixs it.
The usage of subst is $(subst <from>,<to>,<text>), redundant space is not allowed.
2024-03-19 14:52:47 +08:00
Yinan Xu 69506a365d
Remove MemRHelper/MemWHelper to avoid DPI-C conflicts (#313)
MemRWHelper imports the same DPI-C functions as MemRHelper and
MemWHelper. When they are instantiated at the same time, they will
bring duplicated DPI-C function imports in different design files.
The conflict DPI-C names will abort the RTL simulator.

We replace MemRHelper and MemWHelper with MemRWHelper. Read-only
or write-only memories should tie write/read off with zeros.
2024-03-19 14:40:27 +08:00
Yinan Xu bc6f2e0a2e
flash: add the read method (#319)
* also fix the address width
2024-03-18 18:28:00 +08:00
Yinan Xu 54cf0e2ee3
difftest: check every instruction commit slot (#317)
Previously the instruction commit checker loops over the commit slots
and breaks the loop at any invalid slot. This avoids checking further
slots and may have better performance.

However, if the design-under-test does not commit instructions one by
one, the checker may fail to locate the valid instructions.

This commit fixes it by checking every commit slot.
2024-03-15 20:24:06 +08:00
Kunlin You 695a71d062
ci: test simv simulation for SYNTHESIS and disable DPIC RAM/FLASH (#314) 2024-03-14 15:47:07 +08:00
Kamimiao 965fcd3e00
vcs: fix the support for DRAMsim3 (#302) 2024-03-13 21:02:35 +08:00
Kunlin You 0a21549d75
Fix Palladium CFLAGS for path parse (#312)
Previou for Verilator/VCS, SIM_CXXFLAGS will be passed twice, so
we use \\\" for path, make it visible as " inside the code.
For Palladium, we pass these CXX_FLAGS directly to gcc, so we should
replace \\\" with \", to make it treat correctly in compilation.
2024-03-13 21:01:12 +08:00
Kunlin You 561b7ae3e1
simv: add default /dev/zero for +workload (#310)
/dev/zero can be seen as a file with only NULL. This change enable us to use only +flash to set workload for bootrom(flash).
2024-03-13 10:20:29 +08:00
Yinan Xu fcfee4c764
Add the reflective DataMirror for future methods (#309)
This commit brings a DataMirror in the difftest.util package. It
now includes a method called isVisible which returns the visibility
of a Data object, which was originally brought into Chisel 6.1.0 for
the first time.

Since this method does not exist in older versions of Chisel, and
DiffTest must be compatible with legacy versions of Chisel, we use
Scala reflection features to load this method dynamically. If not
found, this method always returns false.
2024-03-12 18:30:49 +08:00
Kunlin You 27642615bb
emu: fix default return val of difftest_nstep (#311)
The default running status val is -1 for emu, 0 for simv. difftest_nstep perform n step comparison for emu, it should return STATE_RUNNING instead of 0 by defualt.

We fix the problem caused by PR#308(https://github.com/OpenXiangShan/difftest/pull/308)
2024-03-12 15:04:36 +08:00
Kunlin You bf55009287
simv, emu: set dut before checking difftest_state (#308)
In batch mode, dut may point to serveral posible position of diffstate_buffer. Trap check in difftest_state also relies on correct
dut position. So we should set dut before difftest_state.

Previosly we set dut only when difftest_step, however even without diff, we should also set correct dut. So we seperate the logic into difftest_set_dut, and difftest_step will call it.

This problem is hidden before, because trap may be check by next step of same batch can occasionally. But it fail when trap in right at last step of batch.

Also for emu, we apply zoneSwitch and setDut when no enable_diff.
2024-03-11 09:42:14 +08:00
Kunlin You cb97c84e92
palladium: fix scripts (#307)
We add exit at the end of run/debug scripts to make simualation exit automatically.
And we disable gui windows for debug by default.
2024-03-11 09:40:52 +08:00
Kunlin You f4ddea6041
flash: support synthesizable flash without SYNTHESIS (#303)
Previously we use synthesizable flash only when SYNTHESIS=1, now we support configuring synthesizable flash just like memory, so we can use it to run workload based on flash.
2024-03-11 09:23:07 +08:00