Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12585 Discussions

Display Mif / Hex file in dual port ram on Nios II stdout

Altera_Forum
Honored Contributor II
1,117 Views

I'm trying to fill a dual port ram (framebuffer) with a Mif File and then print it out with NIOS II and its C-Code programming. 

 

The Mif File (converted to Hex) and loaded into the dual port ram looks like this:  

 

-- quartus prime generated memory initialization file (.mif) 

 

width=8; 

depth=12; 

 

address_radix=hex; 

data_radix=hex; 

 

content begin 

0 : ab; 

1 : cd; 

2 : ef; 

3 : 12; 

4 : 34; 

5 : 56; 

6 : 78; 

7 : 9a; 

8 : bc; 

9 : de; 

a : f1; 

b : 23; 

end; 

 

The c-code for the NIOS II looks like this (and does not work): 

# include <stdio.h># include <stddef.h># include <stdint.h># include "system.h" 

 

int main(void) 

int MEMORY_FB; 

MEMORY_FB = 0x5000; 

volatile char *mem_fb = (volatile char*) MEMORY_FB; 

int i; 

for (i=0;i<13;i++){ 

printf("%x\n", mem_fb); 

return 0; 

 

[/I]It prints out: 

 

ffffffab 

ffffffcd 

ff 

 

How can I fix this to get "ABCDEF123456789ABCDEF123" as an output? 

 

This is only a test for image data a camera will collect later on.
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
402 Views

if the RAM is connected as 8Bit addressable memory: 

printf("%x", 0xff & mem_fb[i]); 

 

if the RAM is connected on a 32Bit bus teh upper bits may filled up with 0: 

printf("%x", 0xff & mem_fb[4*i]);
0 Kudos
Altera_Forum
Honored Contributor II
402 Views

printf("%x", 0xff & mem_fb[i]); - worked! 

 

Thanks!
0 Kudos
Reply