Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
12409 Discussions

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

Altera_Forum
Honored Contributor II
838 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
123 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]);
Altera_Forum
Honored Contributor II
123 Views

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

 

Thanks!
Reply