-
Notifications
You must be signed in to change notification settings - Fork 29
[Feature] Implement DMA support #293
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
Open
BenkangPeng
wants to merge
45
commits into
tancheng:master
Choose a base branch
from
BenkangPeng:dma-cgra
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
46e46a7
Add the DmaEngine implementation and the test.
BenkangPeng d64eded
[Test] Update the test of DmaEngine.
BenkangPeng f968239
Add DMA support to DataMemControllerRTL and implement corresponding t…
BenkangPeng 7bd704e
Add the dma ports into CgraTemplateRTL
BenkangPeng 72d9531
Wrap the Cgra and Dma into one single module.
BenkangPeng 46cfb8e
[Script] Add the local_CI script file
BenkangPeng 3d4ec4e
Update .gitignore to ignore the log file
BenkangPeng e90d45b
[Test] Add the test for CgraDmaRTL
BenkangPeng 8fe1e76
[Fix] Fix the bit mismatch error between dma_idx and num_xbar_in_ports.
BenkangPeng bf28acc
[Doc] Add some comments
BenkangPeng 8480563
[Fix] Fix the bit mismatch by type convertion
BenkangPeng 25c17cb
Move some constant into common header file
BenkangPeng e59d782
[Refactor] Wrap the signals between dma and dram with SendIfcRTL and …
BenkangPeng 4b994de
[Refactor] Update DMA command handling in CgraDmaRTL and CgraTemplate…
BenkangPeng 241bee7
[Refactor] Simplify DMA interface connections in CgraDmaRTL, CgraTemp…
BenkangPeng a125202
[Fix] Use Outport instead of Wire in DmaWireIfcRTL to avoid the RTLIR…
BenkangPeng 4112ec3
[CleanUp] Remove the unnecessary ports.
BenkangPeng 43da86d
[Feature] Introduce DMA data structure and DMA-to-DRAM write request …
BenkangPeng 6e647dd
[Refactor] Pass DmaCmdType and DmaDataType into DataMemController and…
BenkangPeng 78a1587
[Refactor] Update DmaEngineRTL to use DmaDramWrReqIfcRTL for DRAM wri…
BenkangPeng 6fb7e50
[Refactor] Enhance DMA integration in CgraTemplateRTL and ControllerR…
BenkangPeng a7618d8
[Refactor] Update CgraDmaRTL to utilize DmaDramWrReqIfcRTL for DRAM w…
BenkangPeng 1bf3b79
[Fix] Fix the bitwidth mismatch error between DataType and DmaSpmData…
BenkangPeng d4ce981
[CleanUp] Update DMA attribute references to use new constants for im…
BenkangPeng bca3100
[Rename][NFC] Rename some variables for clarity
BenkangPeng 075f63f
Add the assertion to ensure the number of tranfer data is the multipl…
BenkangPeng 628e2d3
Add assertions to ensure that the number of bytes transferred by DMA …
BenkangPeng 90023f2
[Refactor] Remove DmaWireIfcRTL and DmaSpmWireIfcRTL. Use ValRdyRecv/…
BenkangPeng 37a363e
Split the dma_spm_to_dram into 3 signals.
BenkangPeng af3c0a6
Deprecate the DmaSpmMasterRTL in DMA module
BenkangPeng 0fb1b5a
Refactor DataMemControllerRTL to replace DmaSpmMinionIfcRTL with ValR…
BenkangPeng 0bb2d9c
Refactor CgraDmaRTL and CgraTemplateRTL to replace DmaSpmMinionIfcRTL…
BenkangPeng 06eeec4
Add CgraDmaRTL wrapper integrating CGRA with DMA engine and correspon…
BenkangPeng 33622ea
Refactor CgraDmaRTL to replace DmaDramWrReqIfcRTL with new DMA DRAM w…
BenkangPeng 832f701
Refactor DMA signal handling across multiple components to improve cl…
BenkangPeng 94ca68a
[Fix] Precompute commonly used values in DmaEngineRTL to avoid PyMTL3…
BenkangPeng 282159d
Add Verilog generation functionality for the new wrapper.
BenkangPeng b772b7b
Enhance DMA documentation in messages.py and DmaEngineRTL.py by addin…
BenkangPeng 089e4ba
[Rename] Rename tag to dma_tag
BenkangPeng 0ed4b3c
[Rename] Update references from 'ctrl' to 'controller'. Enhance docum…
BenkangPeng 618d6e1
[Fix] Update dma_cmd string representation to use 'dma_tag' instead o…
BenkangPeng 04a2a4f
Add warning comment in ControllerRTL.py regarding potential conflict …
BenkangPeng 304ae24
[Fix] Update DmaEngineRTL to use dma_tag
BenkangPeng 85fcd19
[Fix] Update ControllerRTL and DmaEngineRTL to consistently use 'dma_…
BenkangPeng 559c419
Refactor DmaEngineRTL to simplify word calculation logic
BenkangPeng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,3 +2,4 @@ build | |
| __pycache__ | ||
| .hypothesis | ||
| .vscode | ||
| *.log | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,194 @@ | ||
| """ | ||
| ========================================================================= | ||
| IntegratedCgraWithDmaRTL.py | ||
| ========================================================================= | ||
|
|
||
| Wrapper that composes a CGRA template with a DMA engine attached to the | ||
| CGRA data SPM. | ||
| """ | ||
|
|
||
| from pymtl3 import * | ||
|
|
||
| from .CgraTemplateRTL import CgraTemplateRTL | ||
| from ..lib.basic.val_rdy.ifcs import ValRdyRecvIfcRTL as RecvIfcRTL | ||
| from ..lib.basic.val_rdy.ifcs import ValRdySendIfcRTL as SendIfcRTL | ||
| from ..lib.messages import * | ||
| from ..lib.util.data_struct_attr import * | ||
| from ..mem.dma.DmaEngineRTL import DmaEngineRTL | ||
|
|
||
|
|
||
| class IntegratedCgraWithDmaRTL( Component ): | ||
| """ | ||
| IntegratedCgraWithDmaRTL is a top-level wrapper that integrates a CGRA instance with a | ||
| DMA engine. | ||
|
|
||
| Architectural Design: | ||
| - It instantiates a standard CGRA template (`CgraTemplateRTL`) and a | ||
| DMA engine (`DmaEngineRTL`). | ||
| - CPU control packets are passed through to the CGRA's controller. | ||
| DMA commands are decoded there. | ||
| - The DMA engine accesses the CGRA's internal data SPM through controller- | ||
| forwarded ports; it is not connected directly to `DataMemControllerRTL`. | ||
| - External memory requests from the DMA engine are exposed at the top level | ||
| to be connected to a DRAM model or an AXI adapter. | ||
| - Boundary data ports for multi-CGRA configurations are also passed through | ||
| if enabled. | ||
| """ | ||
|
|
||
| def construct(s, CgraPayloadType, | ||
| multi_cgra_rows, | ||
| multi_cgra_columns, | ||
| per_cgra_rows, per_cgra_columns, | ||
| ctrl_mem_size, data_mem_size_global, | ||
| data_mem_size_per_bank, num_banks_per_cgra, | ||
| num_registers_per_reg_bank, num_ctrl, | ||
| total_steps, mem_access_is_combinational, | ||
| FunctionUnit, FuList, TileList, LinkList, | ||
| dataSPM, controller2addr_map, idTo2d_map, | ||
| is_multi_cgra = True, cgra_id = 0, | ||
| # For heterogeneous multi-cgra support.(maybe remove it in IntegratedCgraWithDmaRTL for simplicity?) | ||
| provided_max_per_cgra_rows = None, | ||
| provided_max_per_cgra_cols = None, | ||
| provided_max_num_rd_tiles = None, | ||
| provided_max_num_wr_tiles = None): | ||
|
|
||
| DataType = CgraPayloadType.get_field_type(kAttrData) | ||
| data_bitwidth = DataType.get_field_type(kAttrPayload).nbits | ||
| assert data_bitwidth == 32 | ||
|
|
||
| max_per_cgra_rows = provided_max_per_cgra_rows if provided_max_per_cgra_rows is not None else per_cgra_rows | ||
| max_per_cgra_cols = provided_max_per_cgra_cols if provided_max_per_cgra_cols is not None else per_cgra_columns | ||
| max_num_tiles = max_per_cgra_rows * max_per_cgra_cols | ||
| max_num_rd_tiles = provided_max_num_rd_tiles if provided_max_num_rd_tiles is not None else dataSPM.getNumOfValidReadPorts() | ||
|
|
||
| CtrlPktType = mk_intra_cgra_pkt(multi_cgra_columns, multi_cgra_rows, | ||
| max_num_tiles, CgraPayloadType) | ||
| NocPktType = mk_inter_cgra_pkt(multi_cgra_columns, multi_cgra_rows, | ||
| max_num_tiles, max_num_rd_tiles, | ||
| CgraPayloadType) | ||
|
|
||
| CgraIdType = mk_cgra_id_type(multi_cgra_columns, multi_cgra_rows) | ||
| DataAddrType = mk_bits(clog2(data_mem_size_global)) | ||
| DmaCmdType = mk_dma_cmd(dram_addr_nbits = 64, | ||
| spm_addr_nbits = 32, | ||
| bytes_nbits = 32, | ||
| tag_nbits = 8) | ||
|
|
||
| DmaDataType = mk_dma_data(dram_data_nbits = 128, | ||
| dram_mask_nbits = 16, | ||
| spm_data_nbits = 32) | ||
|
|
||
| DmaDramAddrType = DmaCmdType.get_field_type(kAttrDramAddr) | ||
| DmaMemDataType = DmaDataType.get_field_type(kAttrDramData) | ||
| DmaMemMaskType = DmaDataType.get_field_type(kAttrDramMask) | ||
| DmaDramWrReqType = mk_dma_dram_wr_req(DmaDramAddrType.nbits, DmaMemDataType.nbits, DmaMemMaskType.nbits) | ||
|
|
||
| # Existing CGRA-facing interfaces. | ||
| # CGRA <-> CPU | ||
| s.recv_from_cpu_pkt = RecvIfcRTL(CtrlPktType) | ||
| s.send_to_cpu_pkt = SendIfcRTL(CtrlPktType) | ||
|
|
||
| if is_multi_cgra: | ||
| s.recv_from_inter_cgra_noc = RecvIfcRTL(NocPktType) | ||
| s.send_to_inter_cgra_noc = SendIfcRTL(NocPktType) | ||
|
|
||
| s.recv_data_on_boundary_north = [RecvIfcRTL(DataType) for _ in range(max_per_cgra_cols)] | ||
| s.send_data_on_boundary_north = [SendIfcRTL(DataType) for _ in range(max_per_cgra_cols)] | ||
| s.recv_data_on_boundary_south = [RecvIfcRTL(DataType) for _ in range(max_per_cgra_cols)] | ||
| s.send_data_on_boundary_south = [SendIfcRTL(DataType) for _ in range(max_per_cgra_cols)] | ||
| s.recv_data_on_boundary_west = [RecvIfcRTL(DataType) for _ in range(max_per_cgra_rows)] | ||
| s.send_data_on_boundary_west = [SendIfcRTL(DataType) for _ in range(max_per_cgra_rows)] | ||
| s.recv_data_on_boundary_east = [RecvIfcRTL(DataType) for _ in range(max_per_cgra_rows)] | ||
| s.send_data_on_boundary_east = [SendIfcRTL(DataType) for _ in range(max_per_cgra_rows)] | ||
|
|
||
| s.cgra_id = InPort(CgraIdType) | ||
| # The local address range of current CGRA. | ||
| # Any address out of this range will be assumed as remote address. | ||
| s.address_lower = InPort(DataAddrType) | ||
| s.address_upper = InPort(DataAddrType) | ||
|
|
||
| # Abstract external dram memory interfaces for the internal DMA engine. | ||
|
|
||
| s.send_to_dram_rd_req = SendIfcRTL(DmaDramAddrType) | ||
| s.recv_from_dram_rd_resp = RecvIfcRTL(DmaMemDataType) | ||
|
|
||
| s.send_to_dram_wr_req = SendIfcRTL(DmaDramWrReqType) | ||
| s.recv_from_dram_wr_resp = RecvIfcRTL(mk_bits(1)) | ||
|
|
||
| # Components. | ||
|
|
||
| s.cgra = CgraTemplateRTL(CgraPayloadType, | ||
|
tancheng marked this conversation as resolved.
|
||
| multi_cgra_rows, | ||
| multi_cgra_columns, | ||
| per_cgra_rows, per_cgra_columns, | ||
| ctrl_mem_size, data_mem_size_global, | ||
| data_mem_size_per_bank, num_banks_per_cgra, | ||
| num_registers_per_reg_bank, num_ctrl, | ||
| total_steps, mem_access_is_combinational, | ||
| FunctionUnit, FuList, TileList, LinkList, | ||
| dataSPM, controller2addr_map, idTo2d_map, | ||
| is_multi_cgra, cgra_id, | ||
| provided_max_per_cgra_rows, | ||
| provided_max_per_cgra_cols, | ||
| provided_max_num_rd_tiles, | ||
| provided_max_num_wr_tiles, | ||
| has_dma_ports = True, | ||
| DmaDataType = DmaDataType, | ||
| DmaCmdType = DmaCmdType) | ||
|
|
||
| DmaSpmDataType = DmaDataType.get_field_type(kAttrSpmData) | ||
| DmaSpmAddrType = DmaCmdType.get_field_type(kAttrSpmAddr) | ||
| DmaBytesType = DmaCmdType.get_field_type(kAttrNBytes) | ||
| DmaTagType = DmaCmdType.get_field_type(kAttrDmaTag) | ||
| s.dma = DmaEngineRTL(spm_data_nbits = DmaSpmDataType.nbits, | ||
| dram_data_nbits = DmaMemDataType.nbits, | ||
| dram_addr_nbits = DmaDramAddrType.nbits, | ||
| spm_addr_nbits = DmaSpmAddrType.nbits, | ||
| bytes_nbits = DmaBytesType.nbits, | ||
| tag_nbits = DmaTagType.nbits) | ||
|
|
||
| # CGRA passthrough connections. | ||
|
|
||
| s.recv_from_cpu_pkt //= s.cgra.recv_from_cpu_pkt | ||
| s.send_to_cpu_pkt //= s.cgra.send_to_cpu_pkt | ||
|
|
||
| if is_multi_cgra: | ||
| s.recv_from_inter_cgra_noc //= s.cgra.recv_from_inter_cgra_noc | ||
| s.send_to_inter_cgra_noc //= s.cgra.send_to_inter_cgra_noc | ||
|
|
||
| for i in range(max_per_cgra_cols): | ||
| s.recv_data_on_boundary_north[i] //= s.cgra.recv_data_on_boundary_north[i] | ||
| s.send_data_on_boundary_north[i] //= s.cgra.send_data_on_boundary_north[i] | ||
| s.recv_data_on_boundary_south[i] //= s.cgra.recv_data_on_boundary_south[i] | ||
| s.send_data_on_boundary_south[i] //= s.cgra.send_data_on_boundary_south[i] | ||
|
|
||
| for i in range(max_per_cgra_rows): | ||
| s.recv_data_on_boundary_west[i] //= s.cgra.recv_data_on_boundary_west[i] | ||
| s.send_data_on_boundary_west[i] //= s.cgra.send_data_on_boundary_west[i] | ||
| s.recv_data_on_boundary_east[i] //= s.cgra.recv_data_on_boundary_east[i] | ||
| s.send_data_on_boundary_east[i] //= s.cgra.send_data_on_boundary_east[i] | ||
|
|
||
| s.cgra_id //= s.cgra.cgra_id | ||
| s.address_lower //= s.cgra.address_lower | ||
| s.address_upper //= s.cgra.address_upper | ||
|
|
||
|
|
||
| # Connections between CGRA and DMA engine. | ||
| # CGRA communicates with DMA engine through the controller. | ||
| s.cgra.dma_cmd //= s.dma.dma_cmd | ||
| s.dma.dma_done //= s.cgra.dma_done | ||
|
|
||
| s.send_to_dram_rd_req //= s.dma.send_to_dram_rd_req | ||
| s.recv_from_dram_rd_resp //= s.dma.recv_from_dram_rd_resp | ||
|
|
||
| s.send_to_dram_wr_req //= s.dma.send_to_dram_wr_req | ||
| s.recv_from_dram_wr_resp //= s.dma.recv_from_dram_wr_resp | ||
|
|
||
| # DMA to controller-forwarded SPM connections. | ||
|
|
||
| s.dma.send_to_spm_wr_req //= s.cgra.recv_from_dma_spm_wr_req | ||
| s.dma.send_to_spm_rd_req //= s.cgra.recv_from_dma_spm_rd_req | ||
| s.dma.recv_from_spm_rd_resp //= s.cgra.send_to_dma_spm_rd_resp | ||
|
|
||
| def line_trace(s): | ||
| return f"{s.dma.line_trace()} || {s.cgra.line_trace()}" | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.