Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
14 years ago

IOWR and IORD with PIOs

I have a basic question concerning PIOs. Currently, I am sending 4 8-bit integers over 4 ouput PIOs from NIOS to hardware to do a calculation on them and return another 8-bit integer value. This is achieved as below.


alt_u8 val_1 = 10;
alt_u8 val_2 = 15;
alt_u8 val_3 = 20;
alt_u8 val_4 = 25;
alt_u8 result_val;
 
IOWR_ALTERA_AVALON_PIO_DATA(DATA_OUT1_BASE , val_1);
.
.
IOWR_ALTERA_AVALON_PIO_DATA(DATA_OUT4_BASE , val_4);
 
result_val = IORD_ALTERA_AVALON_PIO_DATA(RESULT_IN0_BASE,0);

Now instead of using 4 PIOs of width 8, I want to use 1 PIO of width 32 to send my four integer values. What are the IOWR commands that I should write assuming my new 32-bit PIO base address is DATA_OUT_32_BASE?

Also on the hardware side where the calculation is done, the input port will now be a 32-bit input, i.e. [31:0] data_32_in;. How do I separate that input signal into its 4 component integers to use in the calculation?

15 Replies