Commit Graph

6486 Commits

Author SHA1 Message Date
Yinan Xu d9d86f454f
Bump Mill 0.11.7 (#305)
This version of Mill views `-t` as an internal argument. Thus, we
avoid using the shortened argument `-td` for `--target-dir`.
2024-03-08 09:35:48 +08:00
Yinan Xu be02e590bd
Bump Chisel 6.2.0 (#304) 2024-03-08 09:34:46 +08:00
Kunlin You 666a1ec8dd
Support parseArgs for GatewayConfig (#301)
We add an parseArgs interface of difftest for style and GatewayConfig.
User can pass DifftestArgs from top module which extends App trait, and
it will return filter args for subsequent parsing.

Now, we support use "--difftest-config ..." to specify GatewayConfig, each
letter represents an optimization measure. Corresponding change for NutShell/XiangShan will be added with next time bump difftest.
2024-03-06 13:18:02 +08:00
Kamimiao 1b3c3aa8e7
vcs: fix resources deallocation of simulation (#300)
When running with --workload-lilst, simv_init is reinitialized multiple times in a single launch, and the pointer from the last simv_init request needs to be destroyed before doing so. 

This commit fixed an issue with incomplete memory deallocation when exiting the program, and release the list file correctly when using the workload list
2024-03-05 15:31:57 +08:00
Kunlin You 260b9cdd24
Add TB_NO_DPIC/SYNTHESIS macros around all DPIC funcs (#298)
We add SYNTHESIS macros around generated DPIC funcs, and TB_NO_DPIC macros around DPIC funcs in fixed vsrc of TB.

With this change, difftest with non-default GatewayConfig can run in both SYNTHESIS or not.
2024-03-05 14:59:58 +08:00
Kunlin You bb991c9ee0
InternalStep: pack Data transmit and Step control (#294)
* Configurable batchByteLen:
For better performace without GFIFO. In palladium, we can pass maximum 4000 byte in Gfifo Func (enable isNonBlock), and 8000 byte in Other Func. With configurable byteLen, speed will increase from 70 K to 98 K without GFIFO.

* Interval step: pack Data transmit and Step control
Previous when batch is not supported, we use multiple DPIC func to transmit DiffState. Since the DPIC order in one beat is uncertain, we use the step to mark the transmission is finished.

With batch mode, data will be transmit at single func, so we can also pack step to reduce sync times. It can reduce DPIC calls to half. Speed will increase from 95 K to 98 K without GFIFO, 26 K to 27.5 K with GFIFO.

When IntervalStep is enable, step in TOP IO will be default 0. We hold this unused signal for fixed TOP IO interface.

By the way, when the feature is supported. DUT will only use a single port to interface with REF. This helps us to migrate Difftest for other platform.
2024-03-04 09:21:36 +08:00
Kamimiao 1a0a0a0bd0
vcs: add support for --workload-list option (#293)
Support --workload-list option for vcs simulation framework. By add running args like `--workload-list=<listfile_name>`,user can run several workload in a single launch on VCS or Palladium. This feature will greatly reduce time required to run many short workloads. Each line of list file should `workload-name max-instr-limit`.

To support this feature, we add workload-switch logic. When a workload is done (or exceed max-instr-limit),we will raise workload-switch signal according to simv_result. Then the reset signal will be set to high. Other logic will only rely on reset logic, so we can see each workload independently.

Note: Now DUT memory has two implementation schemes: load memory to Hardware memory when initial, or load memory in software, then read/write by DPIC. Currently the first scheme cannot support reload memory when reset again. So we must ensure using DPIC memory.

The whole progress of handling workload-list is like follows:
1. When initial, user pass workload-list.
2. When `reset` is set to high. User will trigger simv_init, it will get workload and max-instr from workload-list, just like only a workload is run. Software and DUT memory(DPIC) will be inited in this. 
3. When `simv_nstep` is ended successfully. `workload-switch` will set `reset` to high. Software should be free by difftest_finish. Then Back to Point 2.
4. When `simv_init` gets no more workload from list. The whole simulation is ended.
2024-03-01 13:46:26 +08:00
Kunlin You d19728839d
CI: add clang-format with Github Actions (#296)
* CI: add clang-format for github actions

We add clang-format to ensure consistent Cpp code style. When some code is no need to formatter, use clang-format off/on to control it.
Now our clang-format config is based on LLVM style, which can be checked by clang-format -style=LLVM --dump-config.
All possible options and their meanings can be searched in https://clang.llvm.org/docs/ClangFormatStyleOptions.html

After this PR, github actions will check format automatically. When the code need format, CI will fail, user need to make format manully and commit again.
2024-02-29 15:50:58 +08:00
Kunlin You 2f13b99b6b
Squash replay: optimized by store log (#288)
Previous we use naive memcpy for NEMU memory snapshot. Now we complete more efficient memory snapshot and recovery with store log.

Call ref_store_log_reset and set_store_log, then we can record origin data of every pmem_write for this execution. When REF and DUT comparation trigger error, call ref_store_log_restore, then memory will recover by origin data in reverse order. Note we restore REF and Golden Memory, not DUT memory.

ENABLE_STORE_LOG macro added to default config. This commit should be bumped with ready-to-run(latest NEMU and SPIKE so)
2024-02-28 17:02:45 +08:00
Kunlin You 3e6aa980e0
CI: git restore src after sed change (#297) 2024-02-28 16:31:36 +08:00
Yinan Xu 77e3f47618
Bump Mill 0.11.6 and Chisel 6.1.0 (#295) 2024-02-26 10:59:37 +08:00
Kamimiao b4d9e66fe3
vcs: add support for --max-instrs option (#290)
Support --max-instrs option for vcs, so workload can exit at desired max_instrs num. This change should help later checkpoint testing.
2024-02-21 16:23:41 +08:00
Yinan Xu ed5b6e979e
Update verilator.mk (#292)
* remove the unused `--stats-vars`
2024-02-21 11:16:54 +08:00
Kunlin You 27d0da69f6
Enable perfcnt for difftest (#289)
We add perfcnt to evalute the effects of different optimization of Gateway. Now we cnt Dpic calls, bytes, run time and failed cycle. Speed and Gates will be reported by Palladium.

Support display trap_PC and IPC for vcs
2024-02-21 11:14:04 +08:00
xyyy1420 0330732fcd
Decompress: support zstd algorithm (#291)
Signed-off-by: jiaxiaoyu <xyyy1420@gmail.com>
2024-02-20 16:16:19 +08:00
Kunlin You c87444e0df
Fix DPIC arg declaration (#287)
CI used to have a spelling mistake of diffStateSelect, which cause
sed incorrectly. Now we rename it to hasDutZone directly, means we
have different zones of DUT_buffer, each zone may have 1 or batchSize
space.

We clearify inherit and override of DPIC. DPIC/DPICBatch should override
modPorts corresponding to input format. CommonPorts(clock, enable) will
be filtered from DPICargs, other ports will be used in DPICAssigns
2024-02-19 16:25:58 +08:00
Kunlin You 74613abf27
palladium: add scripts (#286)
Now we release related palladium scripts and user should set PLDM_HOST
for internal information.

We use wildcard for boards occupation in compilerOptions.qel, it can
automatically choose approprate boards count. User can also set it
manully like {boards 0+1.1+1.2}, which means occupy 1 board and 2 extra
domains. It can be estimated by gate count in xe.msg.
2024-02-08 16:30:59 +08:00
Kunlin You 06622d0a0d
Batch: pack DPIC to reduce sync times (#281)
* Batch: pack DPIC to reduce sync times

We pack DPIC of DifftestBundles on Hardware and unpack it in Software. So tens of DPIC called times will be reduced to one, which reduce sync times in platform such as palladium.

It can speed up full-difftest of XiangShan from 0.23MHz to 0.29MHz with GlobalEnable,Squash and Gfifo(Non-block) in Palladium. Without Gfifo, it can speed up from 0.025 MHz to 0.11MHz.

Difftest cycle delayed for DifftestBundles to collect valid bundles in bundleNum cycles, which cause delayed comparision result.

BatchInterval and BatchFinish are appended to infoVec to seperate DPIC packed for different Cycle. Other elements contains BundleType and BundleLen to help unpack DataVec.

Now we set maximum data byte packed as 3900, and maximum info byte packed as 90, because Palladium limits total bytes of gfifo param should less than 4000.

We add --max-num-width verilator args to increase bit width limits. See related issue verilator/verilator#2082

For misalignment of struct member, we add packed attribute to struct declaration so all member will be aligned by byte, which helps use memcpy for DPIC.

Note: When run full-difftest in XiangShan with Batch mode, it is possible to contains only one cycle DPICs each time for larger possible maximum bytes each cycle. So diffStateSelect should also be open for VCS and Palladium.

We reshape GatewaySink for same control interface and different IO interface corresponding to DufftestBundle(single-pack) and batchIO(Batch). DPIC for different io interface should extend DPICBase for general methods.
2024-02-08 11:10:26 +08:00
Kunlin You 51f5f12d43
vcs: enable search for missing sv files (#285) 2024-02-07 10:25:17 +08:00
Yinan Xu bca49d2a80
Update README.md 2024-02-06 11:38:11 +08:00
Kunlin You ae9f7b2d83
Difftest: delay step for both emu and simv (#283)
For simv, we delay step to ensure DPIC_step behind DPIC_transfer.
For emu, when signal enable is high on current cycle, it will be read
by Software, however DPIC will be called next cycle because verilog
will use previous cycle signals as always block condition.

Such problem is not exposed when step size is fixed, so emu used to step
before DPIC. Now we move delay logic to Gateway, so it can be shared
by both emu and simv.
2024-02-04 21:48:57 +08:00
Kunlin You be428423ce
vcs: fix including generated vsrc (#282)
In vcs, -y only used for missing modules, +incdir is used for file
include. And +incdir is also support by verilator
2024-02-04 10:14:55 +08:00
Yinan Xu 05c0eebb74
emu: move IPC stats to difftest.display_stats() (#280) 2024-02-02 11:54:52 +08:00
Yinan Xu 5b798bc2a5
CI: update the fuzzing tests (#279)
* use rocket-chip to test the fuzzer (should have no bugs)
2024-01-31 23:12:53 +08:00
Yinan Xu 4c5b62807f
DPIC: reset diffstate_buffer to nullptr after free (#278)
DPI-C functions are using the diffstate_buffer to check whether
the corresponding data structures have been initialized. However,
we are not resetting it to nullptr after free. If the simulation
environment is reset manually and restarted, then this pointer
will be a dangling pointer and corrupt the next DPI-C calls.
2024-01-31 21:07:14 +08:00
Kunlin You 4d09d49575
DPIC: remove include DifftestMacros.v from generated RTL (#277)
For Param configuration in fixed code such as vcs/top.v, we include
DifftestMacros.v to contain macros corresponding to Param.
However, in generated RTL, we can add Macro directly in code generation.
And when pure verilog is generated, DifftestMacros may not be created,
which cuase syntax error.
2024-01-31 19:42:33 +08:00
Yinan Xu 0ea03160c3
Gateway: return GatewayResult in sink.collect (#276)
This allows the sink classes to decide their own results, and thus
the Gateway class can be simplified without worrying about the
details of sinks.
2024-01-30 14:07:37 +08:00
Yinan Xu 2fa10451a9
Update the scalafmt configuration (#275) 2024-01-30 12:09:54 +08:00
Kunlin You b757c3c7cf
Gateway: seperate functional components (#272)
* We seperate gateway mixed logic to PreProcess, Squash, Batch,
  GatewaySink and ZoneControl
* We add zone-related logic. DUT will write to different zones of
  State_Buffer at different clock. And REF will also read different
  zone at each nstep. It will help with async Read and Write. Also used
  when step at next cycle may be lag behind transfer.
* Each zone's len will be batchSize when isBatch, default is 1.
* Transfer Module such as DPIC should declare GatewayBundle for same IO
  interface. And batch will has specific Interface, declare
  GatewayBatchBundle.
2024-01-30 09:31:41 +08:00
Yinan Xu 9b66e4729b
coverage: fix the regex for module definition (#274)
* coverage: fix the regex for module definition

It now allows `module module_name (` as well.

We are not providing general-purpose Verilog parsing scripts. However,
we need to at lease support Chisel-generated sources using DiffTest.

* Disable Verilator coverage in LogPerfControl
2024-01-29 15:14:45 +08:00
Kunlin You b3f353bf81
CI: fix the sed changed by scalafmt (#273)
Indentation style of GatewayConfig param is changed by scalaFmt.
We modify sed to adapting that.
2024-01-29 13:55:59 +08:00
Yinan Xu e9b1748c6b
CI: separate fuzzing tests to speedup (#270)
* separate fuzzing tests
* add the dependency to check compiling errors first
* use -j2 to build emu
2024-01-28 17:30:21 +08:00
Yinan Xu b565245883
Add the Scala formatter with GitHub Actions (#269)
* Add the Scala formatter with GitHub Actions

It will automatically format the code on PRs to master using scalafmt.
2024-01-28 16:04:51 +08:00
Yinan Xu 703c705a1e
Gateway: wrap results in a case class (#268)
We wrap the gateway return values in a case class for better code
readability and code structure.

The results of the gateway consist of:
* C++ macros
* Verilog macros
* Extra difftest bundles
* DiffTest step
2024-01-28 13:16:19 +08:00
Yinan Xu 9ba8ed92fc
Bundles: allow comparison and indexing for ArchRegs (#267)
* Add apply, toSeq, and names methods to ArchInt/ArchFp/CSR State
* Add === and =/= to ArchInt/ArchFp/CSR State
* Add the default numPhyRegs value to InstrCommit
2024-01-28 11:02:12 +08:00
Yinan Xu 6ab8589a16
Add getValidOption method for DifftestBaseBundle (#266)
This allows using flatMap to get all valid bits of Seq[BaseBundle].
2024-01-28 10:49:43 +08:00
Yinan Xu 34903ba75e
Fix the data type T parameter of WiringControl (#265)
Should return the same data type as the input using polymorphic
methods.
2024-01-28 10:36:25 +08:00
Kunlin You f63f678641
palladium.mk: rename RELEASE_WITH_ASSERT to SYNTHESIS (#263)
We will generate same verilog code for both SYNTHESIS/no-SYNTHESIS
version. It should be more simple and clear.
2024-01-22 11:57:30 +08:00
Yinan Xu 09ad1b2d4d
Support needUpdate and defaultUpdate for DifftestBaseBundle (#262)
The valid bits are actually defined in the base bundle.
Thus, we move them from DifftestBundle to DifftestBaseBundle.
2024-01-20 18:57:02 +08:00
Yinan Xu 08260b420e
Allow LogPerfControl to be reused if necessary (#261)
Since https://github.com/chipsalliance/chisel/pull/3753, the users
are able to check whether a Data is visible in the current context.
To avoid a large number of duplicated LogPerfControl modules, we
allow it to be reused when some previous instance is still visible
to the current context.

Call `LogPerfControl.reuse(DataMirror.isVisible)` instead of pure
`apply()` to allow the reuse.

However, this is still a temporary workaround. In the future, we
need some clean methods to extract the simulation environment and
access these signals during simulation, possibly via XMR.
2024-01-20 13:12:06 +08:00
Yinan Xu ab7820f33c
Bump Chisel 6.0.0 (#260)
The official support for RC* and M* versions is removed.
2024-01-19 10:12:10 +08:00
Kunlin You 8673c659f5
Add macros to disable Mem and SimJTAG DPI-C functions (#259)
We add Macros to turn off DPIC on MemRWHelper and SimJTAG without
SYNTHESIS. That means we can reduce number of synchronizations if
needed. The new Macros is defined in palladium.mk by default.

To add build-in decleration of system task for Palladium, we need
to add $.

We declare fwrite in tb_top as Gfifo to reduce synchronizations and
speed up simulation.
2024-01-18 11:24:33 +08:00
Kunlin You b1ff1134d2
Use DPIC-function to return deferred result (#250)
Before this commit, we fetch simv_result at 5000 cycles. Only
when the result is not zero, it works and stop simulation.

Now we use DPIC function to implement the return of simv_result when not
zero, so only one DPIC function will be used to stop simulation.
That will reduce the cost of fetch and get result return faster.
2024-01-18 10:22:06 +08:00
Yinan Xu 207cceb65e
Bump Chisel 6.0.0-RC2 with stricter Scala linting (#257)
Deprecations are not checked because we need to maintain the
compatibility with several popular Chisel versions.
2024-01-17 12:50:42 +08:00
Kunlin You afabff248f
Gen C++ and Verilog macros by GatewayConfig (#251)
Currently all macros in Gateway can be decided by GatewayConfig,
we move macros inside Config for better comprehension.

Difftest-related macros in Verilog can be configured in generated
DifftestMacros.v, which should be included by all files use those macros.

Some redundant passing of config and return val of collect is removed.
Some macros are renamed for similar format.

Makefile and mk are changed to include generated/DifftestMacros.v
2024-01-17 11:57:36 +08:00
Kunlin You 1e94c8c5d8
Fix palladium.mk (#256)
We remove RANDOMIZE_GARBAGE_ASSIGN and RANDOMIZE_INVALID_ASSIGN
because it will cause many DPIC function to get $random, which slow
the simulation speed.

Move some display and delay declaration inside module, because some
module may sometimes not be used by DUT, declaration in command-line
will cause conflict.
2024-01-17 11:56:45 +08:00
Yinan Xu 9af8b1ed4b
CI: upgrade to actions/checkout@v4 (#255) 2024-01-16 17:25:45 +08:00
Yinan Xu 63b82f22b1
CI: enable -Werror for EMU build (#253) 2024-01-16 16:47:36 +08:00
Yinan Xu d97acf2187
coverage: add support for multiple design files (#254) 2024-01-16 16:47:26 +08:00
Yinan Xu 0a1f66607e
CI: switch to ubuntu-22.04 runners (#252) 2024-01-16 15:57:38 +08:00