OpenCores
no use no use 1/2 Next Last
initialize memory for openrisc
by system2 on Nov 24, 2009
system2
Posts: 11
Joined: Oct 13, 2009
Last seen: Apr 20, 2010
I want to implement the OpenRISC on an Altera FPGA. I downloaded the OpenRISC and installed the toolchain.
I wrote a simple application in c and I have compiled with the command or32-elf-gcc-code.c o code.o.
Then, with quartus, I create a project containing the OpenRISC, memory, file mapping processor and memory and a testbench file.
My problem is that when I initiate the memory with the contents of the output file of the compilation, the Quartus does not accept this file.The quartus accept only .hex or .mif files.
when I open this file I don't found binary or hexadecimal character.
Please have you an idea about this.
You find attached the result file of compilation.
a.out (144 kb)
RE: initialize memory for openrisc
by julius on Nov 24, 2009
julius
Posts: 363
Joined: Jul 1, 2008
Last seen: May 17, 2021
You've posted a statically linked OR32 ELF, not an object file like your compilation command suggests.

If this is meant to run as a standalone application (ie. without an operating system like Linux or eCos) you should consider using the newlib toolchain instead. The newlib gcc is specifically for easier generation of so-called "bare-metal" applications, which sounds like what you want. Or look at the software in ORPSoC for examples of building little stand-alone apps based on the uClibc compiler (the one which is installed by the toolchain installation script.)

Once you have an ELF which is properly linked (reset vector at 0x100, etc.) you can convert it to whatever you like using or32-elf-objcopy. The way hexadecimal value files are created in ORPSoCv2 is by converting the ELF to binary (or32-elf-objcopy -O binary myelf myelf.bin) and then a little utility in ORPSoC's sw/utils directory called bin2hex converts this binary to human-readable hexadecimal values. Perhaps this can be of use when initialising the memories.

I'm not so familiar with Altera's memory initialisation methods, but I know Xilinx's memories can be loaded various ways, depending on your synthesis tool, and this sometimes uses a VMEM file, which can also be generated using tools in that directory I mentioned in ORPSoCv2.

Julius
RE: initialize memory for openrisc
by rfajardo on Nov 27, 2009
rfajardo
Posts: 306
Joined: Jun 12, 2008
Last seen: Jan 6, 2020
Hi system2,

I think you are ignoring quite some steps in your approach. I will try to give you some hints and ask some other things about you are doing. Furthermore I want to recommend to you to try:

http://www.opencores.org/project,minsoc

It is a complete project with explanation of how to do what you want. The documentation under "/doc/minsoc.pdf" explains to you, how you can either simulate the whole design using a program or how to load your program to the memory of FPGA with your generated design . It also explains how you should compile your own firmware.

Below I try to explain and ask what is going on.

I want to implement the OpenRISC on an Altera FPGA. I downloaded the OpenRISC and installed the toolchain.


I'd follow the guide written in the documentation I proposed.

I wrote a simple application in c and I have compiled with the command or32-elf-gcc-code.c o code.o.


Well, when you compile normally, you generate a binary file. The command to do so would be: or32-elf-gcc code.c -o code.or32
This way you will get out of your c file a binary file (code.or32). This binary file can generally be used by gdb to load the OpenRISC with the program in connection to a debugging unit attached to the OpenRISC system.

To store the program in a memory you'd need a hex file. A hex file is generated out of a binary file with a software, which is delivered together with the project I recommended to you. Actually this comes from the orpsocv2 project which also Julius recommended to you. The program is called bin2hex. These commands are used by a Makefile inside of the "/sw/" part of the project. Example: "/sw/uart/Makefile". When you call "make all" the commands "or32-elf-gcc uart.c -o uart-nocache.or32" and "bin2hex uart-nocache.or32 1 -sizeword > uart-nocache.hex" are processed generating first the binary and then the hex file.

Then, with quartus, I create a project containing the OpenRISC, memory, file mapping processor and memory and a testbench file.


Well, that seems very vague and probably incomplete to me. What do you mean with a file mapping processor? Also the testbench is not important if you are going to generate a bitfile for your FPGA only. But it might allow you to call the simulation from quartus.

Though I'd have to say that you might need more than that if you want to do something with your processor. You would need the debugging unit to be able to load different firmwares online to the memory for instance, which does not seem to be available on your configuration. You also need a bus in form of shared bus or switch (which I could think of to be your file mapping processor). To see if the processor is doing what it should you would also need some type of response from the processor which is why the uart module is generally also attached to the system.

My problem is that when I initiate the memory with the contents of the output file of the compilation, the Quartus does not accept this file.The quartus accept only .hex or .mif files.
when I open this file I don't found binary or hexadecimal character.


Well, you need that bin2hex program to generate a hex file out of a binary. But as I said before, I am not sure if your design is complete either so it might as well as just don't work.

Please have you an idea about this.
You find attached the result file of compilation.
a.out (144 kb)


I hope that helps you.

Best regards,
Raul
RE: initialize memory for openrisc
by s0parsaean on Oct 12, 2010
s0parsaean
Posts: 50
Joined: Nov 11, 2009
Last seen: Mar 10, 2012
Hello,

what's different between myprog.elf and myprog.or32 ?
RE: initialize memory for openrisc
by s0parsaean on Oct 12, 2010
s0parsaean
Posts: 50
Joined: Nov 11, 2009
Last seen: Mar 10, 2012
Hello,

what's different between myprog.elf and myprog.or32 ?
RE: initialize memory for openrisc
by s0parsaean on Oct 12, 2010
s0parsaean
Posts: 50
Joined: Nov 11, 2009
Last seen: Mar 10, 2012
I want generate uart-simple.or32 but I encountered these error,

shilan@shilan-laptop:~/openrisc/orpsocv2/sw/uart$ or32-elf-gcc uart-simple.c -o uart-simple.or32
uart-simple.c:10:24: error: or32-utils.h: No such file or directory
uart-simple.c:11:19: error: board.h: No such file or directory
uart-simple.c:12:18: error: uart.h: No such file or directory
uart-simple.c:13:20: error: printf.h: No such file or directory
uart-simple.c: In function �hello_from_uart�:
uart-simple.c:18: warning: incompatible implicit declaration of built-in function �printf�
uart-simple.c: In function �main�:
uart-simple.c:26: warning: incompatible implicit declaration of built-in function �exit�


I change the path but I encountered another problem...


shilan@shilan-laptop:~/openrisc/orpsocv2/sw/uart$ cd ..
shilan@shilan-laptop:~/openrisc/orpsocv2/sw$ cd include
shilan@shilan-laptop:~/openrisc/orpsocv2/sw/include$ or32-elf-gcc uart-simple.c -o uart-simple.or32
/tmp/cc6sbKnO.o: In function `_hello_from_uart':
uart-simple.c:(.text+0x18): undefined reference to `_uart_init'
uart-simple.c:(.text+0x44): undefined reference to `_printf_to_uart'
collect2: ld returned 1 exit status
shilan@shilan-laptop:~/openrisc/orpsocv2/sw/include$

what's the problem??
RE: initialize memory for openrisc
by jeremybennett on Oct 13, 2010
jeremybennett
Posts: 815
Joined: May 29, 2008
Last seen: Jun 13, 2019
Hello,

what's different between myprog.elf and myprog.or32 ?

Hi Shilan,

I don't know how you are creating myprog.elf, but from the command you gave below, myprog.or32 is an OpenRISC 1000 executable in ELF format.

HTH

Jeremy

RE: initialize memory for openrisc
by s0parsaean on Oct 13, 2010
s0parsaean
Posts: 50
Joined: Nov 11, 2009
Last seen: Mar 10, 2012
for example in sw/uart with this command:

make uart-simple.elf
RE: initialize memory for openrisc
by jeremybennett on Oct 13, 2010
jeremybennett
Posts: 815
Joined: May 29, 2008
Last seen: Jun 13, 2019

A quick look at the makefile indicates that .elf is also an OpenRISC 1000 executable in ELF format.

Jeremy

RE: initialize memory for openrisc
by s0parsaean on Oct 13, 2010
s0parsaean
Posts: 50
Joined: Nov 11, 2009
Last seen: Mar 10, 2012
Hello

for loading memory with hex file instead of .vmem file I run "make prepare-vlt" but I encountered this error :

shilan@shilan-laptop:~/openrisc/orpsocv2/sim/run$ make prepare-vlt

Compiling SystemC modules

make[1]: Entering directory `/home/shilan/openrisc/orpsocv2/bench/sysc/src'
g++ -DTARGET_BIG_ENDIAN -I/include -I../include -fprofile-use -Wcoverage-mismatch -O3 -c DebugUnitSC.cpp
In file included from DebugUnitSC.cpp:34:
../include/DebugUnitSC.h:38:19: error: systemc: No such file or directory
In file included from ../include/JtagSC_includes.h:32,
from ../include/DebugUnitSC.h:40,
from DebugUnitSC.cpp:34:
../include/JtagSC.h:73: error: expected class-name before �{� token
../include/JtagSC.h:78: error: ISO C++ forbids declaration of �sc_in� with no type
../include/JtagSC.h:78: error: invalid use of �::�
../include/JtagSC.h:78: error: expected �;� before �../include/JtagSC.h:80: error: ISO C++ forbids declaration of �sc_in� with no type
../include/JtagSC.h:80: error: invalid use of �::�
../include/JtagSC.h:80: error: expected �;� before �../include/JtagSC.h:81: error: ISO C++ forbids declaration of �sc_out� with no type
../include/JtagSC.h:81: error: invalid use of �::�
../include/JtagSC.h:81: error: expected �;� before �../include/JtagSC.h:82: error: ISO C++ forbids declaration of �sc_in� with no type
../include/JtagSC.h:82: error: invalid use of �::�
../include/JtagSC.h:82: error: expected �;� before �../include/JtagSC.h:83: error: ISO C++ forbids declaration of �sc_out� with no type
../include/JtagSC.h:83: error: invalid use of �::�
../include/JtagSC.h:83: error: expected �;� before �../include/JtagSC.h:84: error: ISO C++ forbids declaration of �sc_out� with no type
../include/JtagSC.h:84: error: invalid use of �::�
../include/JtagSC.h:84: error: expected �;� before �../include/JtagSC.h:87: error: ISO C++ forbids declaration of �sc_fifo� with no type
../include/JtagSC.h:87: error: invalid use of �::�
../include/JtagSC.h:87: error: expected �;� before �../include/JtagSC.h:90: error: expected �)� before �name�
In file included from DebugUnitSC.cpp:34:
../include/DebugUnitSC.h:57: error: expected class-name before �{� token
../include/DebugUnitSC.h:61: error: expected �)� before �name�
../include/DebugUnitSC.h:173: error: ISO C++ forbids declaration of �sc_fifo� with no type
../include/DebugUnitSC.h:173: error: invalid use of �::�
../include/DebugUnitSC.h:173: error: expected �;� before �DebugUnitSC.cpp:39: error: �sc_core::sc_fifo� has not been declared
DebugUnitSC.cpp:40: error: �sc_core::sc_module_name� has not been declared
DebugUnitSC.cpp:65: error: expected �)� before �name�
DebugUnitSC.cpp: In member function �void DebugUnitSC::resetDebugUnit()�:
DebugUnitSC.cpp:108: error: invalid use of incomplete type �struct sc_core::sc_event�
../include/TapAction.h:39: error: forward declaration of �struct sc_core::sc_event�
DebugUnitSC.cpp:113: error: �tapActionQueue� was not declared in this scope
DebugUnitSC.cpp:114: error: �wait� was not declared in this scope
DebugUnitSC.cpp:117: warning: possible problem detected in invocation of delete operator:
DebugUnitSC.cpp:108: warning: �done� has incomplete type
../include/TapAction.h:39: warning: forward declaration of �struct sc_core::sc_event�
DebugUnitSC.cpp:117: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined.
DebugUnitSC.cpp: In member function �uint32_t DebugUnitSC::readRiscop()�:
DebugUnitSC.cpp:528: error: invalid use of incomplete type �struct sc_core::sc_event�
../include/TapAction.h:39: error: forward declaration of �struct sc_core::sc_event�
DebugUnitSC.cpp:534: error: �tapActionQueue� was not declared in this scope
DebugUnitSC.cpp:535: error: �wait� was not declared in this scope
DebugUnitSC.cpp:549: warning: possible problem detected in invocation of delete operator:
DebugUnitSC.cpp:528: warning: �done� has incomplete type
../include/TapAction.h:39: warning: forward declaration of �struct sc_core::sc_event�
DebugUnitSC.cpp:549: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined.
DebugUnitSC.cpp: In member function �void DebugUnitSC::writeRiscop(uint32_t)�:
DebugUnitSC.cpp:588: error: invalid use of incomplete type �struct sc_core::sc_event�
../include/TapAction.h:39: error: forward declaration of �struct sc_core::sc_event�
DebugUnitSC.cpp:594: error: �tapActionQueue� was not declared in this scope
DebugUnitSC.cpp:595: error: �wait� was not declared in this scope
DebugUnitSC.cpp:606: warning: possible problem detected in invocation of delete operator:
DebugUnitSC.cpp:588: warning: �done� has incomplete type
../include/TapAction.h:39: warning: forward declaration of �struct sc_core::sc_event�
DebugUnitSC.cpp:606: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined.
DebugUnitSC.cpp: In member function �void DebugUnitSC::selectDebugModule(int)�:
DebugUnitSC.cpp:631: error: invalid use of incomplete type �struct sc_core::sc_event�
../include/TapAction.h:39: error: forward declaration of �struct sc_core::sc_event�
DebugUnitSC.cpp:637: error: �tapActionQueue� was not declared in this scope
DebugUnitSC.cpp:638: error: �wait� was not declared in this scope
DebugUnitSC.cpp:668: warning: possible problem detected in invocation of delete operator:
DebugUnitSC.cpp:631: warning: �done� has incomplete type
../include/TapAction.h:39: warning: forward declaration of �struct sc_core::sc_event�
DebugUnitSC.cpp:668: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined.
DebugUnitSC.cpp: In member function �uint32_t DebugUnitSC::readJtagReg(uint32_t)�:
DebugUnitSC.cpp:707: error: invalid use of incomplete type �struct sc_core::sc_event�
../include/TapAction.h:39: error: forward declaration of �struct sc_core::sc_event�
DebugUnitSC.cpp:713: error: �tapActionQueue� was not declared in this scope
DebugUnitSC.cpp:714: error: �wait� was not declared in this scope
DebugUnitSC.cpp:734: error: �tapActionQueue� was not declared in this scope
DebugUnitSC.cpp:735: error: �wait� was not declared in this scope
DebugUnitSC.cpp:741: error: �printf� was not declared in this scope
DebugUnitSC.cpp:756: warning: possible problem detected in invocation of delete operator:
DebugUnitSC.cpp:707: warning: �done� has incomplete type
../include/TapAction.h:39: warning: forward declaration of �struct sc_core::sc_event�
DebugUnitSC.cpp:756: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined.
DebugUnitSC.cpp: In member function �void DebugUnitSC::writeJtagReg(uint32_t, uint32_t)�:
DebugUnitSC.cpp:796: error: invalid use of incomplete type �struct sc_core::sc_event�
../include/TapAction.h:39: error: forward declaration of �struct sc_core::sc_event�
DebugUnitSC.cpp:802: error: �tapActionQueue� was not declared in this scope
DebugUnitSC.cpp:803: error: �wait� was not declared in this scope
DebugUnitSC.cpp:823: error: �tapActionQueue� was not declared in this scope
DebugUnitSC.cpp:824: error: �wait� was not declared in this scope
DebugUnitSC.cpp:835: warning: possible problem detected in invocation of delete operator:
DebugUnitSC.cpp:796: warning: �done� has incomplete type
../include/TapAction.h:39: warning: forward declaration of �struct sc_core::sc_event�
DebugUnitSC.cpp:835: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined.
DebugUnitSC.cpp: In member function �void DebugUnitSC::clearBits(uint64_t*, int)�:
DebugUnitSC.cpp:856: error: �memset� was not declared in this scope
make[1]: *** [DebugUnitSC.o] Error 1
make[1]: Leaving directory `/home/shilan/openrisc/orpsocv2/bench/sysc/src'
make: *** [/home/shilan/openrisc/orpsocv2/sim/run/../../bench/sysc/src/libmodules.a] Error 2

RE: initialize memory for openrisc
by jeremybennett on Oct 13, 2010
jeremybennett
Posts: 815
Joined: May 29, 2008
Last seen: Jun 13, 2019

Hi Shilan

Looks like you don't have SystemC installed, or you don't have SYSTEMC_HOME pointing to its installation location. The first error gives it away - it can't find systemc.h. Go to www.systemc.org to download.

HTH

Jeremy

RE: initialize memory for openrisc
by s0parsaean on Oct 14, 2010
s0parsaean
Posts: 50
Joined: Nov 11, 2009
Last seen: Mar 10, 2012
Thank you Jeremy. I try install new version of gcc and systemc, may be solve it.

I want add some instruction to myprog.vmem, then I think myprog.or32 is better choice than

myprog.vmem. I can't read myprog.or32 then I can't change it. I decided convert it to myprog.hex with

this command:

../bin2hex myprog.or32 1 -sizeword > myprog.hex

Now my question is, how can I use this in compiling verilog source code? only changing the file name

on $readmemh is enough ?
RE: initialize memory for openrisc
by jeremybennett on Oct 15, 2010
jeremybennett
Posts: 815
Joined: May 29, 2008
Last seen: Jun 13, 2019

I think just renaming the file in $readmemh should suffice.

Best wishes,

Jeremy

RE: initialize memory for openrisc
by s0parsaean on Oct 18, 2010
s0parsaean
Posts: 50
Joined: Nov 11, 2009
Last seen: Mar 10, 2012
I want to implement the OpenRISC on an Altera FPGA. I downloaded the OpenRISC and installed the toolchain.
I wrote a simple application in c and I have compiled with the command or32-elf-gcc-code.c o code.o.
Then, with quartus, I create a project containing the OpenRISC, memory, file mapping processor and memory and a testbench file.
My problem is that when I initiate the memory with the contents of the output file of the compilation, the Quartus does not accept this file.The quartus accept only .hex or .mif files.
when I open this file I don't found binary or hexadecimal character.
Please have you an idea about this.
You find attached the result file of compilation.
a.out (144 kb)


Hello,

I tryed "make rtl-tests TESTS=or1200-u" in sim/run path, any thing is ok, but it doesn't generate

"a.out", how can I generate it?
RE: initialize memory for openrisc
by s0parsaean on Nov 4, 2010
s0parsaean
Posts: 50
Joined: Nov 11, 2009
Last seen: Mar 10, 2012
Hello,

When I run a simple program(hello_world.c) in openrisc, it add a lot of jumps in

assembly(hello_world.S), for example "l.jr r9", in my project I should control this jump, I found

some of them in printf.S , uart.S and or32-utils.S, what about remainder? where can I find them?

For example what means this in assembly code : .global __divsf3

If anyone could steer me in the right direction, I appreciate it!
no use no use 1/2 Next Last
© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.