Skip to content

idma: Streamline TCDM connection, enable multi-channel operation - #330

Open
gbellocchi wants to merge 100 commits into
pulp-platform:mainfrom
gbellocchi:gb/idma_tcdm_multich_develop
Open

gbellocchi wants to merge 100 commits into
pulp-platform:mainfrom
gbellocchi:gb/idma_tcdm_multich_develop

Conversation

@gbellocchi

@gbellocchi gbellocchi commented Aug 4, 2026

Copy link
Copy Markdown

Description

This PR updates the iDMA integration within the Snitch cluster, as shown in Figures 1 and 2.
It is a refreshed version of PR #238 , which had fallen behind the main snitch cluster branch due to being open for a long period, and a continuation of PR #322.

New features include:

  • The wide SoC port directly connects to the TCDM subsystem, allowing external data access while DMA transfers run.
  • The wide DMA XBAR has been simplified.
  • The DMA uses the OBI protocol to connect to the TCDM subsystem.
  • Arbitration between the channels, the superbanks, and the SoC port happens now in TCDM, increasing flexibility and throughput. With minimal changes, it is possible to have multiple DMA cores in the cluster.
  • Add DMINIT support in Snitch cluster.
  • Add support for OBI events and performance counters.
  • Add L1-to-L1 and TLS tests to investigate TCDM deadlock.
  • Support iDMA after common-cells-v2 update.

Tasks

I have collected the tasks and reviewer comments/suggestions of PR #88:

  • Apply modifications of PR idma: Streamline TCDM connection, enable multi-channel operation #238 to the most recent version of the snitch_cluster.
  • Merge the corresponding idma branch into devel (PR #88).
  • Update custom_instructions.md.
  • Cut wide_in by default.
  • Fix failing Snitch CI tests.
  • Test iDMA after common-cells-v2 update.
  • Fix linting issues.
  • Fix Spyglass violation in common_cells.
  • Fix Spyglass violation in idma.
  • Finalizing idma PR #222.
  • Complete PR review.
  • Check for (performance) regressions.
  • Check TCDM interconnect area utilization.
snitch_cluster_idma_pr_pre

Figure 1: Old integration of `idma`. The wide AXI4 XBAR interconnect is used for: (i) DMA interfaces to TCDM and SoC; (ii) NoC wide in/out; (iii) I$; (iv) Zero memory; and (v) BootROM.
snitch_cluster_idma_pr_post

Figure 2: New integration of `idma`. The wide AXI4 XBAR interconnect is simplified: (i) DMA interfaces to TCDM via OBI and wide AXI4 requests are transmitted to other clusters via the AXI4 XBAR (NoC wide out); (ii) Remove AXI4 TCDM port and directly interface the NoC wide inputs of external DMAs to the TCDM subsystem (bypassing the XBAR); (iii) Remove zero memory as the iDMA now supports memset initialization of TCDM.

gbellocchi and others added 30 commits June 2, 2026 23:12
* `axi_zero_mem` is removed because the idma can now initialize the memory to a desired value.
* Modify the wide cluster xbar address map based on the removal of the zero memory and the new idma-tcdm integration.
* Update the cluster and dma enums in the `snitch_pkg`.
The wide `soc_in_axi_req` is directly interfaced with the tcdm subsystem and bypasses the wide axi cluster xbar.
* `snitch_cluster`: Add memory and obi typedefs.
* `snitch_cluster`: Add obi-to-tcdm protocol conversion for dma requests toward the tcdm subsystem.
* `snitch_cluster`: Update interface of `snitch_cc` instance.
* `snitch_cc`: Instantiate `idma` with obi interfaces.
idma: Fix dminit opcode encoding and add TCDM tests
* Avoid the flattening of arrays in the tcdm dma interconnect.
* Fix deadlock in tcdm-to-tcdm idma transfers, which originates from the absence of p_valid for write transactions.

* Add write pipeline shift register (mirroring id_pipeline) for tracking whether an in-flight slot is a write.
* Add GUI version of `vsim` among the `run.py` simulators.

* Add `wave-file` argument to specify a corresponding wave file to automatically source when launching the `vsim-gui` simulator.

* Add support for wave argument in the generated `snitch_cluster.vsim.gui` script.
* Tie off the `obi_dma_req_o` when no DMA is instantiated in the `snitch_cc`.
* Tie off undriven signals to avoid having undefined behaviors.

* Add documentation for the obi-to-tcdm bridge.
* hw: Update hw configuration files and templates.

* hw: Remove commented lines in `snitch_cluster.sv` for address remapping after zeromem removal.

* sw: Update experiment json configuration files.
* Remove hardcoded reference to DM core as core 8.

* Update dma wait api.
* Map arrays to l1 in order to test l1-to-l1 dma transfers. To this end, use `snrt_l1_alloc()` to initialize `src` and `dst` arrays.

* Extend the range of traffic sizes to trigger the l1-to-l1 deadlock experienced with other kernels (exp).
* This test assesses proper tls initialization at runtime (sanity check) and modification at application-time (core isolation).
* This test concerns the traffic patterns used in `snrt_init_tls` at runtime.

* Parameters are currently tuned on the specific case of the `exp` kernel.
DanielKellerM added a commit to DanielKellerM/snitch_cluster that referenced this pull request Sep 1, 2026
The pinned ref __deploy__9785d30__common-cells-v2 was the deploy branch of
the old common_cells v2 PR head. That PR was squash-merged as 14dcdf1a and
the deploy branch was deleted, so bender could not resolve it. Point at
__deploy__ba01de2__devel instead, the deploy branch of the current iDMA
devel tip and the one snitch_cluster PR pulp-platform#330 uses.

snitch_cc.sv includes obi/typedef.svh but obi was never declared here, so
its export_include_dirs never reached the compile line and vcs failed with
"Source file obi/typedef.svh cannot be opened".
DanielKellerM added a commit to pulp-platform/gwaihir that referenced this pull request Sep 1, 2026
Bender.yml iDMA -> 0.7.0 (the release carries the merged MX quant/dequant
compute, the single-sourced compute_op encoding, and common_cells v2, matching
main's common_cells v2 base). The MX tests and compute helpers move to the
per-tile macro idiom of the reshaped heterogeneous-tile address map
(GW_L2_SPM_*(i), 4 KiB DMA window); the backend instantiation drops testmode_i
(cc-v2 iDMA removed the test-mode ports); snitch_cluster is pinned to
dk/idma070 (DanielKellerM fork), which threads the obi/init type parameters
iDMA 0.7.0 added to idma_inst64_top - an interim shim converging with
pulp-platform/snitch_cluster#330, to be dropped when it merges.
Comment thread hw/snitch_cc/src/snitch_cc.sv Outdated
Comment on lines +601 to +602
.TCDMAliasEnable (TCDMAliasEnable),
.DMATracing (1),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this needed for?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @DanielKellerM is a better catch for this question. :)

@DanielKellerM DanielKellerM Sep 17, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. .TCDMAliasEnable required for the new address decoder to map OBI / TCDM requests. I would leave this for now like this, but its a bit unnecessary since its the point of this PR to decouple TCDM port from the xbar.
  2. .DMATracing this was already here, so nothing new. I have a improvement to remove the hardcoded 1 and use the debug flag #329

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still not clear why 1 is needed. Isn't passing the addrmap sufficient?

@DanielKellerM DanielKellerM Sep 21, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it is. This can be removed indeed

Comment thread hw/snitch_cluster/src/snitch_cluster_pkg.sv Outdated
Comment thread hw/snitch_cluster/src/snitch_cluster.sv Outdated
Comment thread hw/snitch_cluster/src/snitch_cluster.sv Outdated
Comment thread hw/snitch_cluster/src/snitch_cluster.sv Outdated
Comment thread .gitlab-ci.yml Outdated
Comment thread .gitlab-ci.yml Outdated
Comment thread Bender.yml Outdated
Comment thread Bender.yml
Comment on lines +52 to +54
register_interface:
git: https://github.com/pulp-platform/register_interface.git
rev: common-cells-v2

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this needed?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dependency was resolved through idma. However, this was dropped at a certain point, thus breaking some Snitch components. At that time, snitch_ssr tests were the first to break. Hence, I expressed the dependency directly in the cluster.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we can keep it, but its not required in the iDMA anymore

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by the snitch_ssr tests would break? What exactly would break and how?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am referring to hw/snitch_ssr/test/fixture_ssr.sv, which breaks at vsim build time because of the missing reg_test defined in register_interface.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To this end, I removed register_interface from the dependency list, rebuilt the HW, and this is the resulting error log for reference:

# ** Error: hw/snitch_ssr/test/fixture_ssr.sv(216): (vlog-2164) Class or package 'reg_test' not found.
# ** Error: (vlog-13069) hw/snitch_ssr/test/fixture_ssr.sv(216): near "::": syntax error, unexpected ::.
# ** Error: hw/snitch_ssr/test/fixture_ssr.sv(216): (vlog-13205) Syntax error found in the scope following 'reg_test'. Is there a missing '::'?
# ** Error: hw/snitch_ssr/test/fixture_ssr_streamer.sv(284): (vlog-2164) Class or package 'reg_test' not found.
# ** Error: (vlog-13069) hw/snitch_ssr/test/fixture_ssr_streamer.sv(284): near "::": syntax error, unexpected ::.
# ** Error: hw/snitch_ssr/test/fixture_ssr_streamer.sv(284): (vlog-13205) Syntax error found in the scope following 'reg_test'. Is there a missing '::'?

Comment thread util/sim/sim_utils.py
Comment on lines +121 to +136
parser.add_argument(
'--wave-file',
default=None,
metavar='WAVE_DO',
help='Path to a QuestaSim waveform .do file to load at startup (vsim-gui only)')
return parser


def apply_wave_file(args):
"""Export QUESTA_WAVE_DO so the vsim-gui binary picks it up.

Nothings happen when --wave-file is not passed or the simulator is not vsim-gui.
"""
if getattr(args, 'wave_file', None) is not None:
os.environ['QUESTA_WAVE_DO'] = str(Path(args.wave_file).resolve())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be reverted? I don't see the QUESTA_WAVE_DO variable used anywhere.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was supported via a mk target that was then removed here. I generally like loading custom wave files in RTL simulation, hence why I added support for this at a certain point. Anyway, it is no critical feature.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh okay I see. I'm not exactly sure how this is intended to be used though. In general, it might be a valuable addition, but maybe we can move it to a separate PR, where it can be better documented. Otherwise, I would revert it here.

Comment thread sw/deps/riscv-opcodes
The associated offset parameters become useless after the recent modification to
the wide XBAR and additional support for multiple `idma` channels. `ICache` is not
used and would break with the use of >1 `idma` channel since its offset is fixed.
Thus, the only useful parameter is `SDMAMst` that is now directly handled in the
`snitch_cluster` based on the value of `DMANumChannels`.
Remove `zero_mem` dependency from the `snitch_cluster` address map.
This leaves 64kB unmapped between `cluster_periph` and `ext_mem`.
Make this aligned with other cluster signal namings.
The `xdma_mask` is removed and substituted with `supports_xdma`, which mirrors the functionality of `supports_xpulp`.
`xdma_mask`. The cluster body is then modified accordingly.
Remove 64kB unmapped address region between `cluster_periph` and `ext_mem`. These are now contiguous.
Move the `obi_to_tcdm` converter inside the `snitch_cc` and directly expose the TCDM interface.
The previous function was initializing a 2D array, but `snrt_dma_memset` cannot do this. So loop over rows with it.
Brings the INIT channel and DMA event typedef macros, and the inst64 buffer-stall
event fix dropped by iDMA pulp-platform#187.
iDMA owns these types since pulp-platform/iDMA#229. The event struct loses
aw_bw, ar_bw and w_bw, which nothing reads; the peripheral derives those
counters from aw_len/aw_size, ar_len/ar_size and num_bytes_written.
The branch had fallen 3 commits behind. None of them touch
extensions/unratified/rv_xdma, and hw/snitch/src/snitch_riscv_instr.sv is
byte-identical to main, so no instruction encoding changes.

@colluca colluca left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're almost there 😁

Comment on lines +30 to 34
typedef enum logic {
TcdmDma = 0,
ToSoc = 1
} dma_e;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember if we discussed this anymore now, but ToSoc seems to not be used anywhere. I don't see a value in having this enumeration; the name doesn't have any meaning either.

We can just hardcode 0 in the DMA addrmap, where TcdmDma is used. If we wanted to do this properly, the iDMA should probably define such a type:

typedef enum logic {
    DmaObi = 0,
    DmaAxi = 1
} dma_path_e;

Comment thread sw/kernels/blas/gemm/src/gemm.h Outdated
Comment thread sw/runtime/src/dma.h
Comment on lines +442 to 446
* @note The function passes the @p channel argument as an immediate,
* thus this must be known at compile time. As a consequence, the
* function must always be inlined. This is true also for all functions
* invoking this function, and passing down an argument to @p channel.
*/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This used to be the way channel was handled in most functions, e.g. the dma_start_1d function. But now we are no longer passing channel as an immediate, which is not very robust.

Can you align the new functions you added to this behaviour?

Comment thread test/frep_xs.yaml Outdated
Comment thread .gitlab-ci.yml Outdated
Comment thread Bender.yml
Comment on lines +52 to +54
register_interface:
git: https://github.com/pulp-platform/register_interface.git
rev: common-cells-v2

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by the snitch_ssr tests would break? What exactly would break and how?

Comment thread util/sim/sim_utils.py
Comment on lines +121 to +136
parser.add_argument(
'--wave-file',
default=None,
metavar='WAVE_DO',
help='Path to a QuestaSim waveform .do file to load at startup (vsim-gui only)')
return parser


def apply_wave_file(args):
"""Export QUESTA_WAVE_DO so the vsim-gui binary picks it up.

Nothings happen when --wave-file is not passed or the simulator is not vsim-gui.
"""
if getattr(args, 'wave_file', None) is not None:
os.environ['QUESTA_WAVE_DO'] = str(Path(args.wave_file).resolve())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh okay I see. I'm not exactly sure how this is intended to be used though. In general, it might be a valuable addition, but maybe we can move it to a separate PR, where it can be better documented. Otherwise, I would revert it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants