WRAP Address Calculation

AHB AXI WRAP Burst

A WRAP burst is similar to INCR burst. In WRAP the address will be incremented based the SiZE,
but on reaching the upper address limit address will wrap to lower address.

From the above statement, we could see  that there are two considerations during WRAP address calculation,

  1. Upper address limit to make WRAP
  2. Lower address to WRAP to

There are restrictions on WRAP bursts,

  • The start address must be aligned to the size of each transfer
  • The length of the burst must be 2, 4, 8, or 16 transfers

Equations for WRA Address Calculation

Below equations are used for WRAP address calculation,

  • Lower address to WRAP to

Wrap_Boundary = (INT(Start_Address/(Number_Bytes×Burst_Length)))×(Number_Bytes×Burst_Length)

  • Upper address limit to make WRAP

Address_N = Wrap_Boundary + (Number_Bytes × Burst_Length)

WRAP Address calculation examples

WRAP Example-1

AxADDR = 0x04,  AxLEN = 3, AxSIZE = 2, AxBURST = 3

Start_Address   = 0x04
Burst_Length    = 4
Number_Bytes  = 4

Wrap_Boundary = (INT(Start_Address/(Number_Bytes×Burst_Length)))×(Number_Bytes×Burst_Length)
= (0x04/(4×4)) x (4×4)
= 0

Address_N = Wrap_Boundary + (Number_Bytes × Burst_Length)
= 0 + (4 x 4)
= 16

As Burst_Length is 4, Burst consists of 4 Address,
Address_0
Address_1
Address_2
Address_3

Condition, If the Address_n == 16, Address_n = wrap_boundary = 0

Address_0 = 4
Address_1 = Address_0 + Number_Bytes =  4 + 4 = 8
Address_2 = Address_1 + Number_Bytes =  8 + 4 = 12
Address_3 = Address_2 + Number_Bytes = 12 + 4 = 16

As per condition, Address_3 == 16, so Address_3 = 0

Therefore, ADDRESSES are 4, 8, 12, 0.

WRAP Example-2

AxADDR = 0x38,  AxLEN = 3, AxSIZE = 2, AxBURST = 3

Start_Address   = 0x38
Burst_Length    = 4
Number_Bytes  = 4

Wrap_Boundary = (INT(Start_Address/(Number_Bytes×Burst_Length)))×(Number_Bytes×Burst_Length)
= (0x38/(4×4)) x (4×4)
= 0x30

Address_N = Wrap_Boundary + (Number_Bytes × Burst_Length)
= 0x30 + (4 x 4)
= 0x40

As Burst_Length is 4, Burst consists of 4 Address,
Address_0
Address_1
Address_2
Address_3

Condition, If the Address_n == 0x34, Address_n = wrap_boundary = 0x30

Address_0 = 0x38
Address_1 = Address_0 + Number_Bytes = 0x38 + 0x4 = 0x3C
Address_2 = Address_1 + Number_Bytes = 0x3C + 0x4 = 0x40

As per condition, Address_2 == 0x40, so Address_2 = 0x30

Address_3 = Address_2 + Number_Bytes = 0x30 + 0x4 = 0x34

Therefore, ADDRESSES are 0x38, 0x3C, 0x30, 0x34.

WRAP Example-3

Lets consider an example,
AxADDR = 0x34,  AxLEN = 7, AxSIZE = 2, AxBURST = 3

Start_Address = 0x34
Burst_Length  = 8
Number_Bytes  = 4

Wrap_Boundary = (INT(Start_Address/(Number_Bytes×Burst_Length)))×(Number_Bytes×Burst_Length)
= (0x34/(4×8)) x (4×8)
= 0x20

Address_N = Wrap_Boundary + (Number_Bytes × Burst_Length)
= 0x20 + (4 x 8)
= 0x40

As Burst_Length is 4, Burst consists of 4 Address,
Address_0
Address_1
Address_2
Address_3

Address_7

Condition, If the Address_n == 0x40, Address_n = wrap_boundary = 0x20

Address_0 = 0x34
Address_1 = Address_0 + Number_Bytes = 0x34 + 4 = 0x38
Address_2 = Address_1 + Number_Bytes = 0x38 + 4 = 0x3C
Address_3 = Address_2 + Number_Bytes = 0x3C + 4 = 0x40

As per condition, Address_3 == 0x40, so Address_3 = 0x20

Address_4 = Address_3 + Number_Bytes = 0x20 + 4 = 0x24
Address_5 = Address_4 + Number_Bytes = 0x24 + 4 = 0x28
Address_6 = Address_5 + Number_Bytes = 0x28 + 4 = 0x2C
Address_7 = Address_6 + Number_Bytes = 0x2C + 4 = 0x30

Therefore, ADDRESSES are 0x34, 0x38, 0x3C, 0x20, 0x24, 0x28, 0x2C, 0x30