Skip to content
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

add smart-peripheral if, im2col acc, and Verifheep flow #581

Merged
merged 243 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
243 commits
Select commit Hold shift + click to select a range
bedfda5
2D DMA with strides & without padding
Apr 22, 2024
518cc70
DMA stride computation fixes
Apr 23, 2024
e17d809
Started padding support, added output strides
Apr 24, 2024
2a88ec2
Added padding support & performance estimation
Apr 29, 2024
89dd815
First stable point: padding & performance estimation working
Apr 30, 2024
ab70937
Started development DMA HAL
May 1, 2024
0d696e2
Optimized register sizes & continued development of DMA HALs
May 2, 2024
72b2334
Development of DMA HALs & new example_2d_dma
May 6, 2024
fecb4a0
Added LLs example in example_2d_dma
May 6, 2024
671b775
Fixed non-word padding issue caused by read_ptr_valid logic
May 8, 2024
505fa38
Merge remote-tracking branch 'origin/main' into DMA_2D_smart
May 8, 2024
10c6635
Added out of bounds check 2D
May 8, 2024
1b6daba
Clean up for PR review
May 15, 2024
8b539bb
Merge branch 'main' into DMA_2D_smart
May 15, 2024
69f03a7
Added transposition & final cleanup
May 17, 2024
89689ac
First commit. core_v_mini_mcu_pkg.sv.tpl modificaitons
May 17, 2024
78ba652
Reduce test data size
May 21, 2024
48e4b81
Clean up
TommiTerza May 21, 2024
aa7cc98
Developed dma subsystem sv, HALs & example
May 21, 2024
b48afe5
Mini clean up
TommiTerza May 22, 2024
4bb0c19
second mini clean up
TommiTerza May 22, 2024
96ad87b
Added multichannel interrupt handling & new test on 4 channels
May 22, 2024
d552130
Merge branch 'esl-epfl:main' into DMA_multiCH
TommiTerza May 23, 2024
eafd82c
Merge branch 'DMA_2D_smart' into DMA_multiCH
May 23, 2024
9800b63
First development of the smart DMA
May 23, 2024
bcbf6a1
Small example_DMA fix
May 23, 2024
754af46
to squash
May 23, 2024
b20b6d0
Fixes
May 23, 2024
a1d863e
to be squashed
May 23, 2024
bd12dba
PR fixes
May 23, 2024
e42ecf4
fixes
May 23, 2024
06d0c56
Started doc
May 23, 2024
a1ae48e
Merge branch 'DMA_multiCH' into DMA_smart
May 23, 2024
86b5900
Started development of AOPB
May 23, 2024
322d2b9
Modified .tpl to expose external AOPB ports
May 24, 2024
b23586c
Fixes on example_2d
May 24, 2024
a75f5bc
Fixes example_2d
May 24, 2024
fd42174
Development AOPB FIFOs
May 24, 2024
2e56402
Fixed ao_peripheral sv & started development im2col in C using 2D DMA
May 29, 2024
f2b1a93
Added pseudo-rvalid logic to avoid mem accesses during padding, fixed…
May 31, 2024
b1abf01
Added pseudo-rvalid logic to avoid mem accesses during padding, fixed…
May 31, 2024
dc83d37
Fixed example_spi_write
Jun 3, 2024
66cad90
Merge branch 'DMA_2D_smart' into DMA_multiCH
Jun 3, 2024
0b54737
Development new test spi
Jun 3, 2024
6a9d8d2
Merge remote-tracking branch 'origin/main' into DMA_multiCH
Jun 3, 2024
aaa47e6
Fixed test spi & multich
Jun 4, 2024
f47a270
Merge branch 'main' into DMA_multiCH
Jun 4, 2024
d994571
small fixes
Jun 4, 2024
2c851c9
small fix
Jun 4, 2024
846afa7
fixes
Jun 4, 2024
eda0189
Modified dma gen
Jun 4, 2024
77a4306
fixes
Jun 5, 2024
795c787
Merge branch 'DMA_multiCH' into DMA_smart
Jun 5, 2024
e8e0703
Developed im2col w/ 2d DMA & fixes DMA HALs
Jun 5, 2024
25d4e21
Small fixes
Jun 5, 2024
de95b9c
Merge branch 'DMA_multiCH' into DMA_smart
Jun 5, 2024
9c3c0d9
small fix
Jun 5, 2024
119f0b2
Modified example & added window_ifr
Jun 6, 2024
c1278ef
Added window int case in example_dma_multichannel & DMA HAL fix
Jun 6, 2024
c48c2cc
fixes
Jun 6, 2024
c02f279
Fixes
Jun 6, 2024
ab761e7
Fixes
Jun 6, 2024
8015bbe
1 channel case fixes
Jun 7, 2024
72bf347
Work in progress optimized im2col
Jun 7, 2024
f1d271f
Work in progress optimized im2col 2
Jun 7, 2024
126ed5d
Started SV development of im2col_spc, added dma queue for multichanne…
Jun 10, 2024
e1e7bed
Added FSMs for parameter computations & loading transactions
Jun 11, 2024
f5e6dd2
Merge branch 'DMA_multiCH' into DMA_smart
Jun 12, 2024
268e65d
Started development im2col spc test in example_im2col
Jun 12, 2024
ee93bba
Continued dev
Jun 13, 2024
159407e
Fixes
Jun 13, 2024
b86f4c1
Cont'd
Jun 14, 2024
2dffbf3
Added optional priority interrupt mechanism
Jun 14, 2024
4164200
Cont'd
Jun 14, 2024
46bde0d
cont'd
Jun 18, 2024
5acf9dd
Merge branch 'DMA_multiCH' into DMA_smart
Jun 18, 2024
77bdf89
First stable point
Jun 19, 2024
3913b31
Fixed ch > 1 case, performance evaluation
Jun 19, 2024
cdb1d8c
Turned NUM_CH_SPC into register & fixes
Jun 20, 2024
7e42a41
Added verifHEEP.py script
Jun 20, 2024
d37ee68
Finished ver script & started im2col driver
Jun 21, 2024
0612ab9
Started HAL development
Jun 24, 2024
7b9388a
Started HAL development
Jun 24, 2024
9b94127
continued
Jun 24, 2024
ab01194
Modified contacts
Jun 25, 2024
f9dac3a
Merge branch 'main' into DMA_multiCH
Jun 25, 2024
f5e236d
Finished merging
Jun 25, 2024
28a440c
Fixes
Jun 25, 2024
98a52d7
Fixes
Jun 25, 2024
b588e08
Added plotter script for perf comparison
Jun 25, 2024
6d2974b
Development multimaster DMA subsystem
Jun 26, 2024
df6b367
Trying to fix freertos
Jun 27, 2024
c32b237
Trying to fix freertos 2
Jun 27, 2024
19c7b9e
Added multimaster xbar in dma subsystem
Jun 27, 2024
c6a134a
Merge branch 'main' into DMA_multiCH
Jun 28, 2024
0fd12a1
Fix w25q
Jun 28, 2024
c7470db
Fixed dma multichannel example
Jun 28, 2024
6f48ef5
added channel masks
Jun 28, 2024
2927feb
Added 4 channels in CI
Jun 28, 2024
027cc74
Fixed DMA SDK
Jul 1, 2024
4bdacd5
Merge branch 'main' into DMA_multiCH
Jul 1, 2024
af40dfb
Fixed power manager
Jul 1, 2024
21b3d97
Fixed channel masks system
Jul 1, 2024
0991d0f
Added individual DMA CH FIFO size control
Jul 1, 2024
277f9d9
Fixing examples for OpenHW compiler, to be continued
Jul 1, 2024
58786c5
Optimizing register sizes
Jul 2, 2024
06d3f94
Fixing example_dma...
Jul 2, 2024
0228462
Fixed example_dma
Jul 3, 2024
b7ef064
Optimizing
Jul 3, 2024
af958cb
Fixing multimaster configurations
Jul 5, 2024
a6d2780
Fixing
Jul 5, 2024
da28ee6
Fixes
TommiTerza Jul 8, 2024
7264e94
Merge branch 'main' into DMA_multiCH
TommiTerza Jul 8, 2024
18b656b
Added PLIC interrupt
TommiTerza Jul 9, 2024
b4249d3
Cleanup for merging
TommiTerza Jul 9, 2024
c615cb0
Cleanup for merging 2
TommiTerza Jul 9, 2024
dc7789a
Fixes
TommiTerza Jul 9, 2024
e878330
Removed useless files
TommiTerza Jul 9, 2024
9677de2
Decommented custom fifo sizes
TommiTerza Jul 9, 2024
7ba3556
fixes
TommiTerza Jul 9, 2024
b562b8a
Fixed a bug in the spc and improved verifHEEP.py
TommiTerza Jul 9, 2024
4866175
Merge remote-tracking branch 'origin/main' into DMA_multiCH
TommiTerza Jul 10, 2024
354e38b
Test changes
TommiTerza Jul 10, 2024
21946cc
Added individual external triggers for DMA channels & external dma_stop
TommiTerza Jul 10, 2024
c9a469d
Merge branch 'DMA_multiCH' of https://github.com/TommiTerza/x-heep in…
TommiTerza Jul 10, 2024
1ee6f80
Added OPT flag to test_all.sh to run questasim-sim-opt
TommiTerza Jul 10, 2024
c46a758
fix
TommiTerza Jul 10, 2024
d64cb31
fix
TommiTerza Jul 10, 2024
5ab018f
fix
TommiTerza Jul 10, 2024
e7be889
fix
TommiTerza Jul 10, 2024
b6c1013
fix
TommiTerza Jul 10, 2024
82e2ce1
Fixed trigger system for multiple channels
TommiTerza Jul 11, 2024
fcb8a82
fix
TommiTerza Jul 11, 2024
a9a7b39
Converted AOPB to reginterface
TommiTerza Jul 11, 2024
ba33d3f
Merge branch 'DMA_smart' of https://github.com/TommiTerza/x-heep into…
TommiTerza Jul 11, 2024
f8a39d3
mods
TommiTerza Jul 12, 2024
c575aa4
Fixes
TommiTerza Jul 12, 2024
a53a798
ext_dma_stop signal name update
TommiTerza Jul 12, 2024
d7bef7f
started dev verifHEEP.py on pynq-z2
TommiTerza Jul 12, 2024
7c83098
Merge branch 'DMA_multiCH' into DMA_smart
TommiTerza Jul 12, 2024
9ee10b1
Finalized merging & development verifHEEP_pynqz2.py
TommiTerza Jul 12, 2024
e8a3548
Added im2col spc support to xilinx_core_v_mini_mcu_wrapper
TommiTerza Jul 15, 2024
79c21d1
Fixes
TommiTerza Jul 15, 2024
3edfa4b
Fixes
TommiTerza Jul 15, 2024
d4467d9
Converted AOPB to reginterface
TommiTerza Jul 15, 2024
df96995
Fixing fpga testbench
TommiTerza Jul 16, 2024
c3d1089
Fixing timing issues with im2col spc
TommiTerza Jul 17, 2024
ec6dff0
Trying to reduce CP...
TommiTerza Jul 18, 2024
81a02dd
Still fixing...
TommiTerza Jul 18, 2024
7a257fc
Added pipeline registers is parameter computation
TommiTerza Jul 19, 2024
bb89fe7
fixes
TommiTerza Jul 22, 2024
f903e67
Optimizations
TommiTerza Jul 22, 2024
7efb3a4
Fixes to im2col fsm param logic
TommiTerza Jul 23, 2024
0b85027
Fixes
TommiTerza Jul 23, 2024
5246d50
fixes
TommiTerza Jul 23, 2024
09575e7
Fixed multiple im2col spc calls errors
TommiTerza Jul 25, 2024
1915536
Fixed multiple im2col spc calls errors
TommiTerza Jul 25, 2024
7c42e26
fixes
TommiTerza Jul 25, 2024
7d7b1ad
First stable version of verifHEEP!
TommiTerza Jul 26, 2024
780e0fc
Fix DMA padding
TommiTerza Jul 26, 2024
351889e
Merge branch 'main' into DMA_smart
TommiTerza Aug 6, 2024
b2fd280
mods
TommiTerza Aug 6, 2024
307d2c5
Merge branch 'DMA_smart' of https://github.com/TommiTerza/x-heep into…
TommiTerza Aug 6, 2024
5871b95
completed merging
TommiTerza Aug 6, 2024
88e8cbe
Rework of the DMA structure
TommiTerza Aug 8, 2024
64166fe
fixes
TommiTerza Aug 8, 2024
e03487d
fix
TommiTerza Aug 9, 2024
8d4f10d
gen new test for questasim sim
TommiTerza Aug 9, 2024
fb0b1e1
fix
TommiTerza Aug 9, 2024
5fe694d
Verifheep update
TommiTerza Aug 13, 2024
9df7d2d
Verifheep update 2
TommiTerza Aug 13, 2024
ff6385c
doc update
TommiTerza Aug 13, 2024
cf3dc9f
Merge branch 'main' into DMA_smart
TommiTerza Aug 13, 2024
1c1ce8c
Fix dma counters, removed byte units
TommiTerza Aug 14, 2024
1254394
Reorganized verifheep
TommiTerza Aug 19, 2024
7c58eb2
Forgot to add
TommiTerza Aug 19, 2024
589d4bd
fix
TommiTerza Aug 19, 2024
7a7a176
fix
TommiTerza Aug 19, 2024
8075143
fix
TommiTerza Aug 19, 2024
a465e2f
Added clock gating
TommiTerza Aug 20, 2024
3e37ea4
fix
TommiTerza Aug 21, 2024
bfc1b7e
fix
TommiTerza Aug 21, 2024
1ea0a69
Reran mcu-gen
TommiTerza Aug 21, 2024
688a94a
PR fix
TommiTerza Aug 25, 2024
4893ac9
fix
TommiTerza Aug 25, 2024
575ffde
fix
TommiTerza Aug 25, 2024
e9ebb52
fix
TommiTerza Aug 26, 2024
7227d53
fix
TommiTerza Aug 26, 2024
a2d4899
mcu gen small fix
TommiTerza Aug 26, 2024
13646ba
Trying to fix vendor
TommiTerza Aug 26, 2024
04627b5
Solved lintoff bug
TommiTerza Aug 26, 2024
1722ea3
Added chw - hwc conversion example
TommiTerza Aug 27, 2024
ca6cb09
Modified AO_SPC parameter
TommiTerza Sep 2, 2024
490a402
fix
TommiTerza Sep 2, 2024
8884fbf
Added im2col spc HAL & fixes
TommiTerza Sep 5, 2024
e5f7101
fix
TommiTerza Sep 5, 2024
e4ac6f1
fix
TommiTerza Sep 5, 2024
bfa8137
Merge branch 'esl-epfl:main' into DMA_smart
TommiTerza Sep 5, 2024
84b01b6
fix
TommiTerza Sep 6, 2024
a3b660d
Merge branch 'DMA_smart' of https://github.com/TommiTerza/x-heep into…
TommiTerza Sep 6, 2024
c6d2edc
Merge branch 'esl-epfl:main' into DMA_smart
TommiTerza Sep 9, 2024
e89f742
Use arrays
LuigiGiuffrida98 Sep 9, 2024
22064a9
Fix typo
LuigiGiuffrida98 Sep 9, 2024
11f3e91
Removed im2col spc dependencies from rtl-fpga target
TommiTerza Sep 9, 2024
527438a
v1 modifications to im2col
TommiTerza Sep 9, 2024
f2bf5bd
Fixes
TommiTerza Sep 9, 2024
86a5ad4
Fixes
TommiTerza Sep 10, 2024
cf4b81e
fix
TommiTerza Sep 10, 2024
e4ba80e
Updated the im2col verification scritp
TommiTerza Sep 10, 2024
a7e17bd
fix
TommiTerza Sep 11, 2024
a3803fe
Solved bug in dma padding fsm
TommiTerza Sep 11, 2024
f13b1d9
reduced im2col test lenght for CI
TommiTerza Sep 11, 2024
cec7445
im2col spc bugs fixes
TommiTerza Sep 16, 2024
a9365c8
fixes
TommiTerza Sep 16, 2024
a5dba92
added multi datatyep im2col
TommiTerza Sep 17, 2024
5441884
fix
TommiTerza Sep 17, 2024
cde62c0
fix
TommiTerza Sep 18, 2024
f40754e
fix
TommiTerza Sep 18, 2024
fb9fa99
fix
TommiTerza Sep 18, 2024
f969630
Merge branch 'DMA_smart' of https://github.com/TommiTerza/x-heep into…
TommiTerza Sep 18, 2024
091a55d
fix
TommiTerza Sep 18, 2024
fff2aac
fix
TommiTerza Sep 20, 2024
708d732
Merge remote-tracking branch 'origin/main' into DMA_smart
TommiTerza Sep 20, 2024
b8402e1
fix
TommiTerza Sep 20, 2024
019800a
fix
TommiTerza Sep 20, 2024
0bc9487
fix power manager CI
TommiTerza Sep 23, 2024
a28ff8c
fix
TommiTerza Sep 23, 2024
2021d4b
final fixes
TommiTerza Sep 24, 2024
0160d48
doc fix
TommiTerza Sep 27, 2024
2ecdc63
doc fix
TommiTerza Sep 27, 2024
fccb2b0
Merge branch 'esl-epfl:main' into DMA_smart
TommiTerza Sep 27, 2024
93ad3a8
fix
TommiTerza Sep 27, 2024
b196ec0
fix
TommiTerza Sep 27, 2024
cb13cc3
fix
TommiTerza Sep 27, 2024
1412a12
fix
TommiTerza Sep 27, 2024
0f66fba
fix
TommiTerza Sep 27, 2024
ee42b13
Merge branch 'esl-epfl:main' into DMA_smart
TommiTerza Sep 27, 2024
7cef8a0
fix
TommiTerza Sep 27, 2024
fb41c1b
Merge branch 'DMA_smart' of https://github.com/TommiTerza/x-heep into…
TommiTerza Sep 27, 2024
31d4eb0
fix
TommiTerza Sep 28, 2024
bbef477
fix
TommiTerza Sep 30, 2024
f0cce86
fix
TommiTerza Oct 1, 2024
581b35b
Fix typo
LuigiGiuffrida98 Oct 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix DMA padding
  • Loading branch information
TommiTerza committed Jul 26, 2024
commit 780e0fce5f1b2fa03c5184a6cd2c2dce6087eac0
105 changes: 101 additions & 4 deletions docs/source/Peripherals/DMA.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ It can be configured to perform *1D* or *2D* transactions and it can apply **zer

The DMA **Hardware Abstraction Layer (HAL)** facilitates the configuration of transactions from the users application. Furthermore, it adds an additional layer of safety checks to reduce the risk of faulty memory accesses, data override or infinite loops.
<br>

## Structural description

INSERIRE SCHEMATICO DMA
Expand Down Expand Up @@ -42,6 +43,7 @@ While the 1st solution is a general purpose, balanced configuration, the 2nd sol

This mechanism guarantees maximum flexibility, enabling the user to adapt the DMA subsystem to its requirements, both in terms of area and performance.
<br>

#### Data FIFOs configuration

Each DMA channel uses a FIFO to buffer the data to be written, which is crucial for mitigating the combined delays from the system bus and the DMA subsystem bus.
Expand All @@ -58,6 +60,7 @@ These are the steps to follow to take advantage this feature:
- Adjust the parameters _L_, _M_ and _S_. They define the size of a large, medium and small FIFO.
- Modify the parameter `typedef enum {L, M, S} fifo_ch_size_t;` to assign individual sizes to the FIFOs. The number of elements must reflect the number of DMA channels.
<br>

#### Triggers

In the case of memory-peripheral operations, it is common for the peripheral to have a reaction time that cannot match the system clock. For example, the SPI trasmits data with a period of circa 30 clock cycles.
Expand All @@ -67,6 +70,7 @@ This difference in response times creates the need for a communication channel b
They can be used both when the peripheral writes data using the DMA and when the DMA reads data from the peripheral.
The DMA can be configured to respond to triggers by enabling the appropriate _slot_ via software, using the DMA HAL. [INSERIRE LINK A ESEMPIO SPI SLOT DMA MULTICHANNEL]
<br>

#### Tips for DMA-based accelerator developers

The DMA subsystem has been developed with specific features to facilitate the creation of custom accelerators that can leverage it to improve memory-intense applications.
Expand All @@ -81,6 +85,7 @@ Check out the _im2col SPC_ in the `\ip_examples` folder for a detailed example a
- **Stop signal**: it can terminate a DMA transaction at any moment. It's particularly useful for accelerators that produce a large quantity of data, but with a variable trasfer size that cannot be known or computed.
A good example of such an accelerator is a level crossing subsampler, which writes sampled data only when they cross a specific threshold.
<br>

- **VerifHEEP**: it's a python library that has been developed to test computational units and accelerators developed on X-Heep.
It has been deployed succesfully to validate the _im2col SPC_ as it is expecially useful for data-intense accelerators.
[LINK ALLA DOCUMENTAZIONE DI VERIFHEEP]
Expand All @@ -90,6 +95,7 @@ It includes methods to:
- Compile, program & launch applications on FPGA targets for a tenfold reduction in test & verification times
- Analyze the performance of the tests and plot the results.
<br>

### Registers description

This section will describe every register of a DMA channel and their function.
Expand Down Expand Up @@ -140,7 +146,7 @@ The previous parameters, including the register offsets, can be found at `sw/dev

- **SIZE_D1**
- _SW access_: rw
- _Description_: number of bytes to be copied by the DMA channel along the first dimension, i.e. using the first counter. As soon as this register is written, the transaction starts.
- _Description_: number of bytes to be copied by the DMA channel along the first dimension, i.e. using the first counter. As soon as this register is written, the **transaction starts**.


<hr>
Expand Down Expand Up @@ -681,13 +687,104 @@ The same result from this example could have been achieved by setting the transa

This use case is very impractical as it doubles the memory usage. It is intended to be used along In-Memory-Computing architectures and algorithms.

## Software stack: HAL and SDK

Like every other computational unit in X-Heep, a DMA transaction can be set up and launched using direct register writes. This method achieves minimal overhead and optimal performance, as thoroughly documented in sw/applications/example_dma_2d and sw/applications/example_dma_multichannel.

## Usa cases and examples
However, it carries significant risks. For instance, the transaction starts immediately after writing to the size register, so the order of register writes must be strictly followed. If the code is compiled with aggressive optimization flags, these write operations might be reordered, potentially compromising DMA functionality. Additionally, errors in setting the transaction size or increments can lead to memory corruption.

In this section, several usecases are going to be studied and explained in detail, to give the users a better understanding on how the DMA subsystem works and how to exploit it to improve the performance of their application.
Given the criticality of DMA operations and the potential for destructive errors, direct register writes should be approached with utmost _caution_. To mitigate these risks, two software stacks have been developed:

- **HAL**: Provides functions for initializing DMA channels, validating and correcting issues within the targets, loading and launching transactions.
- **SDK**: Employs the HAL to offer user-friendly functions for basic but essential memcpy and fill operations.

### DMA HAL

This section will include a brief overview of the functionalities offered by the DMA HAL. For more practical example, please refer to the next chapter, _"Usecases and examples"_.

Let's start with the structures that enable users to define a DMA transaction and its targets, defined in `dma.h`:


#### <i> dma_target_t </i>

The dma_target_t structure represents a target for a DMA transaction, either as a source or a destination. It encapsulates the parameters required to define a memory region or a peripheral for DMA operations. Furthermore, control parameters can be added to prevent the DMA from reading/writing outside the boundaries of the target.

#### <i> dma_trans_t </i>

The dma_trans_t structure defines a DMA transaction, encapsulating all the necessary parameters and configurations required to perform a DMA operation. Each member of the structure is carefully designed to handle specific aspects of the transaction, from source and destination targets to increment sizes, data types, and operational modes.

Once these structures are defined, there are three main functions to be called in order to correctly perform a DMa transaction.

#### <i> dma_init() </i>

*Purpose*:
The dma_init function initializes the DMA subsystem by cresetting transaction structures and clearing DMA registers of each channel.

*Parameters*:
- dma *dma_peri: Pointer to the DMA peripheral. If this pointer is provided, it uses the given DMA peripheral; otherwise (NULL), it uses the integrated DMA peripheral.

#### <i> dma_validate_transaction() </i>

_Purpose_:
The dma_validate_transaction function ensures the configuration of a DMA transaction is correct,checking for potential issues that could prevent the transaction from executing properly. It performs sanity checks, verifies target configurations, and addresses any alignment, increment, padding, trigger, and mode inconsistencies.

_Parameters_:
- dma_trans_t *p_trans: Pointer to the DMA transaction structure that contains the transaction configuration.
- dma_en_realign_t p_enRealign: Flag indicating whether realignment is enabled.
- dma_perf_checks_t p_check: Flag indicating whether integrity checks should be performed.

_Return Values_:
- dma_config_flags_t: Configuration flags indicating the status of the transaction validation. They provide information about the validity of the transaction and any detected errors or warnings.

#### <i> dma_load_transaction() </i>

_Purpose_:
The dma_load_transaction function configures and loads a DMA transaction into a DMA channel. It checks for critical errors defined by the validation function, ensures no other transaction is running, and sets various parameters such as interrupts, pointers, increments, padding, and operation modes by writing in the correct registers. The only register that is not written is the
SIZE_D1 register so it doesn't launch the transaction.

_Parameters_:
- dma_trans_t *p_trans: Pointer to the DMA transaction structure that contains the configuration for the transaction.

_Return Values_:
- DMA_CONFIG_OK: Indicates that the transaction was successfully loaded.
- DMA_CONFIG_CRITICAL_ERROR: Indicates that the transaction contains a critical error and cannot be loaded.
- DMA_CONFIG_TRANS_OVERRIDE: Indicates that another transaction is currently running and cannot be overridden.

#### <i> dma_launch_transaction() </i>

_Purpose_:
The dma_launch function initiates a DMA transaction that has been previously configured and loaded into a DMA channel. It ensures the transaction is valid, checks for any ongoing transactions, and then starts the new transaction. If the end event is set to wait for an interrupt, the function will block until the interrupt is received.

_Parameters_:
- dma_trans_t *p_trans: Pointer to the DMA transaction structure that contains the configuration for the transaction.

_Return Values_:

- DMA_CONFIG_OK: Indicates that the transaction was successfully launched.
- DMA_CONFIG_CRITICAL_ERROR: Indicates that the transaction could not be launched due to a critical error.
- DMA_CONFIG_TRANS_OVERRIDE: Indicates that another transaction is currently running and cannot be overridden.

## Usacases and examples

This section will examine and explain several use cases in detail to provide users with a comprehensive understanding of the DMA subsystem and how to leverage it to enhance their application's performance.

Here is a brief overview of the examples:

1) Simple mem2mem transaction, i.e., 1D memcpy
2) 2D mem2mem transaction, i.e., 2D memcpy
3) Matrix transposition
4) Matrix padding
5) Multichannel mem2mem transaction, focusing on the IRQ handler
6) Multichannel flash2mem transaction using the SPI SDK
7) BONUS: Minimizing overhead by using register writes instead of HALs

The complete code for these examples can be found in `sw/applications/example_dma`, `sw/applications/example_dma_2d`, `sw/applications/example_dma_multichannel` and `sw/applications/example_dma_sdk`. These applications offer both verification and performance estimation modes, enabling users to verify the DMA and measure the application's execution time.


### 1. Simple mem2mem transaction

The goal of this example is to develop a function that



#### Basic application

Expand Down
5 changes: 4 additions & 1 deletion hw/ip/dma/rtl/dma.sv
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,10 @@ module dma #(
pad_state_q <= PAD_IDLE;
pad_state_x <= PAD_IDLE;
end else if (dma_conf_2d == 1'b1) begin
if (dma_start == 1'b1 && |reg2hw.pad_top.q == 1'b1) begin
if (dma_done == 1'b1) begin
pad_state_q <= PAD_IDLE;
pad_state_x <= PAD_IDLE;
end else if (dma_start == 1'b1 && |reg2hw.pad_top.q == 1'b1) begin
pad_state_q <= TOP_PAD_EXEC;
pad_state_x <= TOP_PAD_EXEC;
end else if (dma_start == 1'b1 && |reg2hw.pad_left.q == 1'b1) begin
Expand Down
24 changes: 11 additions & 13 deletions hw/ip_examples/im2col_spc/rtl/im2col_spc.sv
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,15 @@ module im2col_spc

/* Register interface control FSM */
im2col_spc_regintfc_controller im2col_spc_regintfc_controller_i (
.clk_i,
.rst_ni,
.addr_i(dma_addr),
.wdata_i(dma_wdata),
.start_i(dma_regintfc_start),
.aopb_resp_i(aopb2im2col_resp_i),
.aopb_req_o(im2col2aopb_req_o),
.done_o(dma_regintfc_done)
);
.clk_i,
.rst_ni,
.addr_i(dma_addr),
.wdata_i(dma_wdata),
.start_i(dma_regintfc_start),
.aopb_resp_i(aopb2im2col_resp_i),
.aopb_req_o(im2col2aopb_req_o),
.done_o(dma_regintfc_done)
);

/*_________________________________________________________________________________________________________________________________ */

Expand Down Expand Up @@ -418,7 +418,7 @@ module im2col_spc
default: begin
dma_if_cu_load_q = IDLE_IF_LOAD;
end

endcase
end

Expand All @@ -440,9 +440,7 @@ module im2col_spc
end

WRITE_SLOTS: begin
dma_wdata = {
reg2hw.slot.tx_trigger_slot.q, reg2hw.slot.rx_trigger_slot.q
};
dma_wdata = {reg2hw.slot.tx_trigger_slot.q, reg2hw.slot.rx_trigger_slot.q};
dma_addr = core_v_mini_mcu_pkg::DMA_START_ADDRESS +
dma_trans_free_channel * core_v_mini_mcu_pkg::DMA_CH_SIZE +
DMA_SLOTS_OFFSET;
Expand Down
24 changes: 12 additions & 12 deletions hw/ip_examples/im2col_spc/rtl/im2col_spc_param_fsm.sv
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ module im2col_spc_param_fsm
zeros_phase2_en = 1'b0;
zeros_rst = 1'b0;
output_data_ptr_rst = 1'b0;

unique case (param_state_d)

IDLE: begin
Expand Down Expand Up @@ -191,17 +191,17 @@ module im2col_spc_param_fsm

N_ZEROS_COMP_1: begin
zeros_phase1_en = 1'b1;
param_state_q = N_ZEROS_COMP_2;
param_state_q = N_ZEROS_COMP_2;
end

N_ZEROS_COMP_2: begin
zeros_phase2_en = 1'b1;
param_state_q = N_ZEROS_COMP_3;
param_state_q = N_ZEROS_COMP_3;
end

N_ZEROS_COMP_3: begin
zeros_phase2_en = 1'b1;
param_state_q = INDEX_COMP_1;
param_state_q = INDEX_COMP_1;
end

INDEX_COMP_1: begin
Expand Down Expand Up @@ -422,7 +422,7 @@ module im2col_spc_param_fsm
.WIDTH(8)
) pipe_reg_left_zeros (
.clk_i,
.rst_ni(pipe_rst),
.rst_ni (pipe_rst),
.data_in (n_zeros_left_comp1_n),
.data_out(n_zeros_left_comp1)
);
Expand All @@ -431,7 +431,7 @@ module im2col_spc_param_fsm
.WIDTH(8)
) pipe_reg_top_zeros (
.clk_i,
.rst_ni(pipe_rst),
.rst_ni (pipe_rst),
.data_in (n_zeros_top_comp1_n),
.data_out(n_zeros_top_comp1)
);
Expand All @@ -440,7 +440,7 @@ module im2col_spc_param_fsm
.WIDTH(8)
) pipe_reg_right_zeros (
.clk_i,
.rst_ni(pipe_rst),
.rst_ni (pipe_rst),
.data_in (n_zeros_right_comp1_n),
.data_out(n_zeros_right_comp1)
);
Expand All @@ -449,7 +449,7 @@ module im2col_spc_param_fsm
.WIDTH(8)
) pipe_reg_bottom_zeros (
.clk_i,
.rst_ni(pipe_rst),
.rst_ni (pipe_rst),
.data_in (n_zeros_bottom_comp1_n),
.data_out(n_zeros_bottom_comp1)
);
Expand All @@ -458,7 +458,7 @@ module im2col_spc_param_fsm
.WIDTH(32)
) pipe_reg_index_comp1 (
.clk_i,
.rst_ni(pipe_rst),
.rst_ni (pipe_rst),
.data_in (index_comp1_n),
.data_out(index_comp1)
);
Expand All @@ -467,7 +467,7 @@ module im2col_spc_param_fsm
.WIDTH(32)
) pipe_reg_index_comp2 (
.clk_i,
.rst_ni(pipe_rst),
.rst_ni (pipe_rst),
.data_in (index_comp2_n),
.data_out(index_comp2)
);
Expand All @@ -476,7 +476,7 @@ module im2col_spc_param_fsm
.WIDTH(32)
) pipe_reg_index_comp3 (
.clk_i,
.rst_ni(pipe_rst),
.rst_ni (pipe_rst),
.data_in (index_comp3_n),
.data_out(index_comp3)
);
Expand All @@ -485,7 +485,7 @@ module im2col_spc_param_fsm
.WIDTH(32)
) pipe_reg_index_comp4 (
.clk_i,
.rst_ni(pipe_rst),
.rst_ni (pipe_rst),
.data_in (index_comp4_n),
.data_out(index_comp4)
);
Expand Down
15 changes: 8 additions & 7 deletions hw/ip_examples/im2col_spc/rtl/im2col_spc_regintfc_controller.sv
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ module im2col_spc_regintfc_controller
output reg_req_t aopb_req_o,
output logic done_o
);

/* General status signal */
enum {
IDLE,
WAITING_READY,
SENDING,
DONE
} im2col_status_q, im2col_status_d;
}
im2col_status_q, im2col_status_d;

always_comb begin
unique case (im2col_status_d)
Expand All @@ -42,7 +43,7 @@ module im2col_spc_regintfc_controller

SENDING: begin
im2col_status_q = WAITING_READY;
end
end

WAITING_READY: begin
if (aopb_resp_i.ready == 1'b1) begin
Expand All @@ -52,9 +53,9 @@ module im2col_spc_regintfc_controller
end
end

DONE: begin
DONE: begin
im2col_status_q = IDLE;
end
end
endcase
end

Expand All @@ -71,14 +72,14 @@ module im2col_spc_regintfc_controller
aopb_req_o.valid <= 1'b0;
aopb_req_o.write <= 1'b0;
aopb_req_o.wstrb <= 4'b1111;
aopb_req_o.addr <= '0;
aopb_req_o.addr <= '0;
aopb_req_o.wdata <= '0;
end else begin
if (im2col_status_d == SENDING) begin
aopb_req_o.valid <= 1'b1;
aopb_req_o.write <= 1'b1;
aopb_req_o.wstrb <= 4'b1111;
aopb_req_o.addr <= addr_i;
aopb_req_o.addr <= addr_i;
aopb_req_o.wdata <= wdata_i;
end else begin
aopb_req_o.valid <= 1'b0;
Expand Down
Binary file removed plot.png
Binary file not shown.
Loading