Skip to content

[DRAFT] Dynamic allocation scheme #126

Open
bowwwang wants to merge 61 commits intomainfrom
asap25-release/das
Open

[DRAFT] Dynamic allocation scheme #126
bowwwang wants to merge 61 commits intomainfrom
asap25-release/das

Conversation

@bowwwang
Copy link
Copy Markdown
Collaborator

@bowwwang bowwwang commented Jul 1, 2025

This PR enabled TeraPool with a dynamic allocation scheme with support for the DMA engine.

  • TODO: Adapt to the latest system CSR
  • FIX: the maximum number of memory rows per DAS scrambling is fixed to the number of tiles in the system.
  • FIX: the allocation can only start at specific addresses in memory. The only requirement should be that the address is aligned to the memory row. This has to be changed in the address_scrambler and in the software for allocation.
  • FIX: keep only the fastest DMA transfer option.
  • FIX: keep only the necessary defines in the mempool_pkg.sv.
  • CHANGE: change the naming of DAS registers ex. tiles_das, start_das, rows_das, and make it consistent across all the files.
  • VERIFY: that all the changes do not conflict with the parametrization on main.

Changelog

Added

Changed

  • address_scrambler.sv for dynamic address mapping
  • idma_midend_distributor.sv and idma_midend_splitter.sv for augmented transaction split
  • mempool_tile.sv, mempool_sub_group.sv, mempool_group.sv, and mempool_cluster.sv for passing scrambling configuration

Fixed

(Reference to issues, labels, and related merge requests)

Checklist

  • Automated tests pass
  • Changelog updated
  • Code style guideline is observed

Please check our contributing guidelines before opening a Pull Request.

@mbertuletti mbertuletti force-pushed the asap25-release/das branch 5 times, most recently from 08a9bb1 to 6eef71c Compare October 23, 2025 09:11
[software] Add DMA with DAS test
@bowwwang bowwwang force-pushed the asap25-release/das branch from d70ea47 to 0a7a90c Compare April 13, 2026 08:24
@bowwwang bowwwang marked this pull request as ready for review April 13, 2026 10:21
Copy link
Copy Markdown
Collaborator

@mbertuletti mbertuletti left a comment

Choose a reason for hiding this comment

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

Thank you for your work,

  • Please keep naming scheme consistent between hardware and software. Add explanatory comments where needed to clarify the use of some signals. In particular the group_factor was replaced by tiles_das.
  • Please remove unused or commented out code blocks and format the .sv files.
  • Please verify the critical path of the design.

Comment thread software/runtime/control_registers.h Outdated
#define CONTROL_REGISTERS_PARAM_MAX_NUMGROUPS 8

// Supported number of DAS partitions
#define CONTROL_REGISTERS_PARAM_NUM_D_A_S_PARTITIONS 4
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.

Please use consistent naming, you use "DAS" for other defines.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Register naming has been changed from D_A_S to DAS

Comment thread software/runtime/control_registers.h Outdated
// Wake Up Offst Register
#define CONTROL_REGISTERS_WAKE_UP_OFFST_REG_OFFSET 0x30

// Tile grouping for DAS partition (common parameters)
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.

These registers shift the address of other previously existing registers. Couldn't you place them at address 0x64 and following?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I placed DAS related registers to the end of the existing regs

Comment thread software/runtime/control_registers.h Outdated
// Wake Up Offst Register
#define CONTROL_REGISTERS_WAKE_UP_OFFST_REG_OFFSET 0x30

// Tile grouping for DAS partition (common parameters)
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.

Please add a Comment on what the DAS addresses are used for. The difference between the "TILES_DAS" and "START_DAS" registers is not clear.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Desc for the DAS related regs has been addded

Comment thread CHANGELOG.md Outdated
## Unreleased

### Added
- Add Dynamic Address Scrambling (DAS) support with configurable partitioning, hardware address scrambler, and software runtime for dynamic heap allocation
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.

Please move this to the bottom of the list.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Moved to the end of the list

Comment thread README.md Outdated
[![ci](https://github.com/pulp-platform/mempool/actions/workflows/ci.yml/badge.svg)](https://github.com/pulp-platform/mempool/actions/workflows/ci.yml)
[![lint](https://github.com/pulp-platform/mempool/actions/workflows/lint.yml/badge.svg)](https://github.com/pulp-platform/mempool/actions/workflows/lint.yml)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
# MemPool Dynamic Allocation Scheme
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.

Please add this to the bottom of ./config/README.md and provide more information about how the DAS registers should be configured.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This part has been moved to config/README.md

Comment thread hardware/src/mempool_cluster.sv Outdated
.tcdm_slave_resp_valid_o (tcdm_slave_resp_valid[g] ),
.tcdm_slave_resp_ready_i (tcdm_slave_resp_ready[g] ),
`ifdef DAS
.tiles_das_i (tiles_das_i ),
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.

FOrmat misaligned parentheses.

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.

Please confirm that this solution does not compromise the timing of the cores to L1 connection.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I narrowed the add/sub datapath from 32-bit to 8-bit.
I will schedule a backend run asap

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.

Can the address scrambler of the mempool/hw/src/ be reused? In this case the naming of the input signals is possibly wrong and the group_factor_i should be replaced by the more intuitive das_tile_i.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch, i have aligned the naming accordingly.
However, the scrambler in DMA is not the same as the one in the Tile, because DAS does not consider the logic for the stack region. Therefore, the logic related to the stack region has been stripped.
I would keep these two module apart.

end
end

// ------ Considering Partition Scheme ------ //
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.

Can you add a comment on what shift_index, partition_mask, masked_start_addr, shift_index_sc, shift_row, shift_partition, masked_shift_row are used for? The naming is not very clear and should be possibly improved.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

You are very right, it was very confusing. i hope now it is clearer

logic [AddrWidth-1:0] partition_mask;
addr_t masked_start_addr;

always_comb begin
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.

Similar case blocks were replaced by lzcs in the address scramblers. I believe such implementation and a consistent name replacement for group_factor would improve clarity.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thank you for the advice, this has been adapted

// L2 --> L1
if (burst_req_i.num_bytes<=DmaRegionWidth )begin
burst_req_o[i].src = burst_req_i.src+i*rows_das_i*DmaRegionWidth;
end else if (i==2) begin
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

need to change

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.

2 participants