OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

dita-sidsc message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: IP-XACT <dim>


Hi All,

I think having an integer is better since it aligns with IP-XACT and is easier to parse. From a register addressing perspective, I imagine it would work as illustrated by the following C program.

//============================================================================
// Name        : SidscArray.cpp
// Author      : Jeremy Ralph
// Description : Clarifying example to show how an array is defined using in
//               IP-XACT div tags:
//                 <dim>2</dim>
//                 <dim>4</dim>
//                 <dim>8</dim>
//
//============================================================================

#include <stdio.h>
#include <stdlib.h>

#define I 2
#define J 4
#define K 8

int main(void) {

	unsigned int array3d[I][J][K];
	unsigned int i, j, k;
	unsigned int base_addr = (unsigned int)&array3d;
	unsigned int elem_addr, offset;

	printf("offset\tarray index\n");
	for (i=0; i<I; i++) {
		for (j=0; j<J; j++) {
			for (k=0; k<K; k++) {
				elem_addr = (unsigned int)(&(array3d[i][j][k]));
				offset=elem_addr-base_addr;
				printf("0x%02x\t[%u][%u][%u]\n", offset, i, j, k );
			}
		}
	}

	return EXIT_SUCCESS;
}
//============================================================================

The output for this program looks as follows:

offset	array index
0x00	[0][0][0]
0x04	[0][0][1]
0x08	[0][0][2]
0x0c	[0][0][3]
0x10	[0][0][4]
0x14	[0][0][5]
0x18	[0][0][6]
0x1c	[0][0][7]
0x20	[0][1][0]
0x24	[0][1][1]
0x28	[0][1][2]
0x2c	[0][1][3]
0x30	[0][1][4]
0x34	[0][1][5]
0x38	[0][1][6]
0x3c	[0][1][7]
0x40	[0][2][0]
0x44	[0][2][1]
0x48	[0][2][2]
0x4c	[0][2][3]
0x50	[0][2][4]
0x54	[0][2][5]
0x58	[0][2][6]
0x5c	[0][2][7]
0x60	[0][3][0]
0x64	[0][3][1]
0x68	[0][3][2]
0x6c	[0][3][3]
0x70	[0][3][4]
0x74	[0][3][5]
0x78	[0][3][6]
0x7c	[0][3][7]
0x80	[1][0][0]
0x84	[1][0][1]
0x88	[1][0][2]
0x8c	[1][0][3]
0x90	[1][0][4]
0x94	[1][0][5]
0x98	[1][0][6]
0x9c	[1][0][7]
0xa0	[1][1][0]
0xa4	[1][1][1]
0xa8	[1][1][2]
0xac	[1][1][3]
0xb0	[1][1][4]
0xb4	[1][1][5]
0xb8	[1][1][6]
0xbc	[1][1][7]
0xc0	[1][2][0]
0xc4	[1][2][1]
0xc8	[1][2][2]
0xcc	[1][2][3]
0xd0	[1][2][4]
0xd4	[1][2][5]
0xd8	[1][2][6]
0xdc	[1][2][7]
0xe0	[1][3][0]
0xe4	[1][3][1]
0xe8	[1][3][2]
0xec	[1][3][3]
0xf0	[1][3][4]
0xf4	[1][3][5]
0xf8	[1][3][6]
0xfc	[1][3][7]

Comments?

Cheers,

--
Jeremy Ralph, PDTi
Free trial of http://SpectaReg.com for register automation!


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]