Skip to content

Addressable bytes wb#1144

Open
lmbollen wants to merge 8 commits intomainfrom
lucas/addressable-bytes-wb
Open

Addressable bytes wb#1144
lmbollen wants to merge 8 commits intomainfrom
lucas/addressable-bytes-wb

Conversation

@lmbollen
Copy link
Contributor

@lmbollen lmbollen commented Jan 15, 2026

What (what did you do)
This PR introduces a component addressableBytesWb that supports adding memory mapped memories such as blockRams

Why (context, issues, etc.)
To be able to more easily integrate blockRam based components in our clash-protocols-memmap infrastructure.

Dear reviewer (anything you'd like the reviewer to pay close attention to?)
Regarding the rust side I added a HAL that contains a reference of functionality that I would like to have. What was especially problematic was the alignment requirement for [u8], or any [[u8; N]] that we use to represent bitvectors. Their alignment requirement is 1 byte, where I require the slice to be 4 byte aligned for efficient copying. I tried to offer an interface to create word aligned byte slices with AlignedArray that would allow the CPU to perform word sized reads and writes, but am not sure if this is the way to go.

We faced a related challenge earlier in the axi module, but that was trivially fixed with align_to because it has a streaming interface (we always write to the same destination address).

AI disclaimer (heads-up for more than inline autocomplete)
The unit test was mostly written with AI.

TODO

Cross-out any that do not apply

  • Write (regression) test
  • Update documentation, including docs/
  • Link to existing issue

@lmbollen lmbollen force-pushed the lucas/addressable-bytes-wb branch 3 times, most recently from d5c1686 to 55d8d66 Compare January 15, 2026 12:14
@lmbollen lmbollen force-pushed the lucas/addressable-bytes-wb branch 4 times, most recently from cfd4330 to 13ed24c Compare February 9, 2026 13:37
@lmbollen lmbollen force-pushed the lucas/addressable-bytes-wb branch 3 times, most recently from 521a310 to 24d5edc Compare February 19, 2026 13:44
@lmbollen lmbollen changed the base branch from main to lucas/Df-utils February 19, 2026 13:46
@lmbollen lmbollen force-pushed the lucas/addressable-bytes-wb branch from 24d5edc to 3c9dd65 Compare February 19, 2026 13:52
@lmbollen lmbollen force-pushed the lucas/addressable-bytes-wb branch from cc9ba47 to 0d17f4c Compare February 19, 2026 14:48
@lmbollen lmbollen force-pushed the lucas/addressable-bytes-wb branch 3 times, most recently from cc9ba47 to cb13674 Compare February 19, 2026 15:56
@lmbollen lmbollen force-pushed the lucas/Df-utils branch 4 times, most recently from 3c7c2f2 to a841075 Compare February 20, 2026 11:13
@lmbollen lmbollen force-pushed the lucas/addressable-bytes-wb branch from cb13674 to 1d7def8 Compare February 20, 2026 12:36
Base automatically changed from lucas/Df-utils to main February 20, 2026 12:39
@lmbollen lmbollen force-pushed the lucas/addressable-bytes-wb branch from 1d7def8 to df5ae82 Compare February 20, 2026 12:44
@lmbollen lmbollen changed the base branch from main to lucas/ReqResp-utils February 20, 2026 12:46
@lmbollen lmbollen force-pushed the lucas/ReqResp-utils branch from 0705b6a to 157f8b7 Compare February 24, 2026 11:24
@lmbollen lmbollen force-pushed the lucas/addressable-bytes-wb branch from df5ae82 to a166636 Compare February 24, 2026 11:37
@lmbollen lmbollen force-pushed the lucas/addressable-bytes-wb branch from 6c820a4 to b043367 Compare March 2, 2026 10:52
@lmbollen lmbollen force-pushed the lucas/ReqResp-utils branch from ce0173b to 76ca439 Compare March 2, 2026 13:05
@lmbollen lmbollen force-pushed the lucas/addressable-bytes-wb branch from b043367 to 48dc51f Compare March 2, 2026 13:05
@lmbollen lmbollen force-pushed the lucas/ReqResp-utils branch from 76ca439 to e192099 Compare March 2, 2026 16:26
@lmbollen lmbollen force-pushed the lucas/addressable-bytes-wb branch from 3b469f4 to 59f362f Compare March 2, 2026 16:26
@lmbollen lmbollen force-pushed the lucas/ReqResp-utils branch 2 times, most recently from 0496b73 to 92729b5 Compare March 6, 2026 08:23
@lmbollen lmbollen force-pushed the lucas/addressable-bytes-wb branch from 59f362f to 3e8d89f Compare March 6, 2026 08:29
Base automatically changed from lucas/ReqResp-utils to main March 6, 2026 10:47
@lmbollen lmbollen force-pushed the lucas/addressable-bytes-wb branch 2 times, most recently from 3ea08c8 to 12b0ce1 Compare March 6, 2026 12:26
@lmbollen lmbollen removed the impeded label Mar 6, 2026
@lmbollen lmbollen force-pushed the lucas/addressable-bytes-wb branch 2 times, most recently from 1e426ce to 580376d Compare March 6, 2026 13:45
@lmbollen lmbollen marked this pull request as ready for review March 6, 2026 13:50
@lmbollen lmbollen force-pushed the lucas/addressable-bytes-wb branch from 580376d to 14583fb Compare March 9, 2026 08:25
Copy link
Contributor

@martijnbastiaan martijnbastiaan left a comment

Choose a reason for hiding this comment

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

Nice! My fingers are itching for a registerWb refactor, but that'll have to wait.

Comment on lines +361 to +363
( Either
(Index n)
(Index n, BitVector wordSize, Bytes wordSize) -- Write (index, mask, data)
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment on lines +425 to +429
| addrMaxInteger < indexMaxInteger =
clashCompileError
[I.__i| Address range (#{addrMaxInteger}) is too small to address all #{indexMaxInteger} words of the register.

Consider increasing the address width or reducing the number of words.|]
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! You don't have to change it for this PR, but we should move this check to the memory map verifier. I.e., store how many bits each has on its address bus and then compare it to its stated size. That would give us much better / quicker error messages.


-- Address calculation: compute index within addressable range
relativeAddress = wbM2S.addr - offset
inRange = relativeAddress <= resize (bitCoerce (maxBound :: Index n))
Copy link
Contributor

Choose a reason for hiding this comment

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

numConvert? It should bubble up the right constraints, which should also eliminate the clashCompileError AFAIK.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was a bit of a conscious decision to use clashCompileError instead of adding the constraints.
I was on the fence about whether I'd prefer having an extra constraint for each memory mapped component and I decided the pollution would be larger than the chance you actually deal with address spaces that are too small.

@lmbollen lmbollen force-pushed the lucas/addressable-bytes-wb branch 2 times, most recently from 4ccca10 to 447503c Compare March 12, 2026 10:06
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