Hardware interview practice
Constrain a size-aligned address
Randomize an address in 0x8000_0000 through 0x8000_FFFF with transfer size 1, 2, 4, or 8, aligned to that size.
Reviewed example
Work through one case
Input
randomize size from {1,2,4,8} and address in 0x8000_0000..0x8000_FFFFExpected output
One valid result: size=8, address=0x8000_0040The transfer size is legal, the address is inside the aperture, and 0x8000_0040 modulo 8 is zero. Other aligned pairs are valid.
What to cover
Requirements
- Choose only legal power-of-two transfer sizes.
- Keep the address inside the inclusive aperture.
- Require addr modulo size to equal zero.
