- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello every body;
I know that an 8 bits number defined as alt_u8, How can I define a 128 bits wide number, as I use in in my code. ThanksLink Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
NIOS is a 32-bit processor and the datatype sizes are described here:
http://www.altera.com/literature/hb/nios2/n2cpu_nii51016.pdf Similar to most other 32-bit processors, you will need additional (3rd party or your own) software libraries to perform 128-bit math.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Mr ted for ur attention;
but how can i deffine my own 128bit width type, i didnot want to use array n- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If this is for a homework problem, your professor probably wants you to use whatever language feature they most recently covered. e.g. struct or typedef.
If this is not for a homework problem, I suggest you start with this wiki page and read around and try to find the one that is going to be the best fit for you. http://en.wikipedia.org/wiki/arbitrary-precision_arithmetic- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks ted;
That is not a homework, that is a master degree preparation, and this code complete my whole hardware effort. Thanks for your attention.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Since you are not familiar with the C programming language, and just need the software to demonstrate the IP, my suggestion would be to find a computer science undergraduate to write it for you. This was first year material when I went through school.
Good luck.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Mr.ted;
Here; I need an "undergraduate "; I want to tell you that altera forum is not for "undergraduates" as you told me, but it for any one who don't know something or have a problems in finding materials a bout any thing related to its products. I ask u about things that i didnot understand, and this is an open forum you are free to reply or not. Thanks.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The Nios II compiler can only handle up to 64-bit data types (double, long long, unsigned long long). The processor is 32-bit so when it accesses 64-bit data in memory it can only do so 32 bits at a time and when it operates on 64-bit data it typically does so 32 bits at a time. In otherwords if you have to access 128-bit data in memory you will need to do so using the smaller C data types that are available to you. For example if I had to write 128 bits of data in the form of four 32-bit words (data0, data1, data2, and data3) to a location 0x1000 in my memory space I would do something like this:
IOWR_32DIRECT(0x1000, 0, data0); // bits 31 to 0 IOWR_32DIRECT(0x1000, 4, data1); // bits 63 to 32 IOWR_32DIRECT(0x1000, 8, data2); // bits 95 to 64 IOWR_32DIRECT(0x1000, 12, data3); // bits 127 to 96 The macros above are defined in io.h so you would have to include that file to use them. Those macros ensure that the Nios II data cache is bypassed, for more information what that's necessary I would google search "cache coherency".- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hmmm.... If the code is 'completing you hardware effort', I'm surprised this didn't come up during the initial design phase!
In any case it is simple 'schoolboy' coding.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- Here; I need an "undergraduate "; --- Quote End --- Sorry: I simply meant that if you do not know how to program in C because your background is electrical engineering / logic design, then I would grab a CS undergraduate to help with the software instead of trying to pick it up on the fly while trying to complete your FPGA IP project. It is different skill set, and this relationship was common when I was in school; many of the larger labs had undergrad CS work-study students hanging around simply to help the graduate students and professors with their experiments / projects that required small programs / scripts. From your other thread where you posted your code, if the only thing you want to accomplish is to avoid writing "alt_u8 array[4][4]" everywhere, you can use typedef and a struct or a union. Here is a union, which is convenient if you need to access the same data either 8 or 32 bits at a time.
typedef union {
alt_u8 u8 ; /** 8-bit access */
alt_u32 u32; /** 32-bit access */
} FOO128;
void main(void)
{
FOO128 x;
FOO128 result;
int i;
/* initialize the data byte-by-byte */
for(i=0; i < 16; i++) {
x.u8 = i;
}
/* write the data to the hardware block 32-bits at a time */
for(i=0; i < 4; i++) {
IOWR(base, i, x.u32);
}
/* read the data from the hardware block 32-bits at a time */
for(i=0; i < 4; i++) {
result.u32 = IORD(base, i);
}
}
On the other hand, if you are trying to construct a software validation of your FPGA IP and want to independently compute the various 128-bit math operations, you should look into getting that code from somewhere else like the wiki article I previously posted. Good luck.
![](/skins/images/C4F7392A5C68ACA60290C9576F107044/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page