Altera_Forum
Honored Contributor
15 years agoNIOS not reading the right FIFO value
Hello guys, i made a 32bits DCFIFO using the megawizard.
I made this wrapper to increment the fifo value by each second (my fifo is running at 50mhz)begin
contador <= contador +1;
valid <= 0;
wrclk <= 0;
if(usedw == 6'b100000)
begin
valid <= 1;
end
if(contador == 50000000)
begin
data_in <= data_in + 1;
wrclk <=1;
contador <= 0;
end
end
base fifo_inst (
.data ( data ),
.rdclk ( rdclk ),
.rdreq ( rdreq ),
.wrclk ( wrclk ),
.wrreq ( 1 ),
.q ( q ),
.wrusedw ( usedw )
); When my fifo is half full my valid goes to 1 and then i start to read from the fifo with this routine
printf("content of fifo\n");
for ( i=0;i<32;i++)
{
printf("%d: %x\n",i,IORD(FIFOWRAPPER_0_BASE,0));
} i should get the values 1,2,3,4,5,6,7,8,9,A etc.. However i am getthing this values: bash-3.1$ nios2-terminal
nios2-terminal: connected to hardware target using JTAG UART on cable
nios2-terminal: "USB-Blaster ", device 1, instance 0
nios2-terminal: (Use the IDE stop button or Ctrl-C to terminate)
loop start
waiting valid from fifo .................:
content of fifo:
0: 1
1: 3
2: 5
3: 7
4: 9
5: b
6: d
7: f
8: 11
9: 13
10: 15
11: 17
12: 19
13: 1b
14: 1d
15: 1f
16: 20
17: 20
18: 20
19: 20
20: 20
21: 20
22: 20
23: 20
24: 20
25: 20
26: 20
27: 20
28: 20
29: 20
30: 20
31: 20
END That's very weird. Can someone enlight me pleas?