- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello as i know integer can hold 2^16 data
but
typedef struct flash_region
{
int offset;/* Offset of this region from start of the flash */
int region_size;/* Size of this erase region */
int number_of_blocks;/* Number of blocks in this region */
int block_size;/* Size of each block in this erase region */
}flash_region;
the value if offset is larger than 2^16 - 1, how does NIOS II handle this ???? can someone clarify this for me....
- Tags:
- Include
Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
An integer is stored as 32 bits (cf Table 7–1 of the Nios II Processor Reference Handbook). And now this is true for all the machine I think, it is not particular to the Nios II. Jérôme- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You could use 'alt_u32' data type including library '#include <alt_types.h>'. It is of 32 bits and can serve your purpose
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Indeed you can use also these types, but actually there are the same. If you looked at alt_types.h you have :
typedef signed char alt_8;
typedef unsigned char alt_u8;
typedef signed short alt_16;
typedef unsigned short alt_u16;
typedef signed long alt_32;
typedef unsigned long alt_u32;
typedef long long alt_64;
typedef unsigned long long alt_u64;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Actually by using alt_u32 you will be sure that you have a 32-bit integer.
The C standard doesn't define the size of the int type, and depending on the compiler or architecture, "int" can mean 16, 32 or 64 bits. It has always been a problem with C and that's why each HAL redefines its own integer types.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
But I face a problem of defining a 128bit type< how can I solve this?
Thanks- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- But I face a problem of defining a 128bit type< how can I solve this? Thanks --- Quote End --- Probably the best way is to use an array of some defined types. For example: int32_t My128bitArray[4]; int16_t My128bitArray[8]; int8_t My128bitArray[16]; By the way you should choose the type your array on the basis of what you have to do with it. If you have to write 32bit registers BadOmen gives you the answer: http://www.alteraforum.com/forum/showthread.php?t=44527 If you have to send 1 byte on a SPI you should go with an 8 bit array etc etc.. What are you supposed to do with a 128 bit var ? If we can know..
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page