First of all, the concept of address alignment I do not detail, you can refer to this article: Avalon Bus Address alignment: Dynamic addressing and native addressing.
Suppose we customize a peripheral with a data width of 32 bits and an address of 2 bits. If we want the address line to do something else rather than address it, for example:
1 if (cs&WR) 2 begin 3 Case (addr) 4 2 ' b00: //Custom 5 2 ' B01: //Custom 6endcase7End
In Nios eds, how to Determine addr? In other words, when we use Iowr_32direct (BASE, offset, DATA), how do we determine OFFSET?
I believe you have already thought the answer, the answer is actually very simple: offset for 0x00 addr for 2 ' B00,offset for 0x04 addr for 2 ' B01,offset for 0x08 corresponding addr for 2 ' B10, Offset for 0x0c corresponds to addr of 2 ' B11.
Other data widths are the same, assuming that the data width is 8 bits, the address is 2 bits, Iowr_32direct (base, 0x00, data) is the corresponding addr 2 ' B00,iowr_32direct (base, 0x01, data) is the corresponding addr 2 ' B01, the rest of the analogy.
There is also an article you can refer to: Understanding the Avalon Bus Static address alignment and dynamic address alignment.
Address alignment and Nios programming for Avalon Bus