- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I have a strange problem about reading the readdata.
I designed a user logic and wrote a C code corresponding to it. I hope use this circuit to do caculations twice. And I get right result at the fisrt time reading the readdata signal. However, when I want to get the second result, the result is still the value which is gotten at the first time. Therefore, I use the Modelsim to check the corresponding signal. I find that the chipselect signal just arise once. That means the chipselect signal does not arise at the second time when I want to retrieve the second result. Does anyone have the same experience ?? Following is my C code : # include<stdio.h># include "excalibur.h" float x,y,z,result; float a,b,c,result_1; float cmp = 4.0; int main(void) { float *p; printf("========startCompute======== \n"); x = 1.5; // I have three float-point operands y = 2.0; z = 0.5; printf("x is %f, y is %f, z is %f\n", x,y,z); p = 0x920800; // the starting address of the user logic *p = x; // write the first operand to the first register address *(p+1) = y; // write the second operand to the first register address *(p+2) = z; // write the third operand to the first register address *(p+3) = 2.0; // use to control the start signal. that means when write *(p+3), the circuit starts calculation while(((*(p+3))&& cmp)== 0) { printf("inwhile \n"); } result = *(p+4); // get the first result from the *(p+4) address. It is right. printf("result is = %f\n" ,result); //========================================================== *p = 0.0; // Clear all operands *(p+1) = 0.0; *(p+2) = 0.0; *(p+3) = 0.0; //========================================================== printf("===start second computation!!\n"); a = 1.2; // the three new operands b = 2.1; c = 3.4; printf("a is %f, b is %f, c is %f\n", a,b,c); *p = a; *(p+1) = b; *(p+2) = c; *(p+3) = 2.0; while(((*(p+3))&& cmp)== 0) { printf("inwhile \n"); } result_1 = *(p+4); // get the result from *(p+4) address. But the result is still the same with the fisrt one. Why???????????? printf("result_1 is = %f\n" ,result_1); return 0; } Does anybody can solve this problem ?? Thanks a lot.Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It could be that the compiler optimized your code or you have data cache turned on. To fix the compiler optimization issue you should make the value volatile and to fix the data cache issue you will need to bypass the cache on the read.
volatile float * p; p = (1<<31) | 0x920800;- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi pipiwau,
I don't know how to solve your problem but maybe you can help me. I'm looking for a simple example how to use the avalon bus (an example of using the chipselect, readdata and other avalon bus signals), see this topic (http://www.niosforum.com/forum/index.php?act=st&f=2&t=1351). Can you please post the source code of your user logic, so I can see how it works. Or some another example. You can send it to me as a PM if you don't want to post it here.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot.
I can get the second result now!!!! http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/biggrin.gif
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