OpenCores
no use no use 1/1 no use no use
openrisc instruction set
by technology on Feb 18, 2010
technology
Posts: 25
Joined: Dec 31, 2009
Last seen: May 8, 2010
Hello
I want to simulate a program that load two values stored in the memory in address 0x50 and 0x51 and make the addition of thesevalues so I write this code:
l.addi r1,r0,0;
l.addi r2, r0, 0;
l.lwz r1,0x50(r0);
l.lwz r2 ,0x51(r1);
l.add r2 , r1, r2;
when i simulate I note that the data at adress 50 and 51 are not read from memory and only the instruction to set to 0 the registers R1 and R2 are executed
Is that there are errors in my code???
RE: openrisc instruction set
by jeremybennett on Feb 18, 2010
jeremybennett
Posts: 689
Joined: May 29, 2008
Last seen: Feb 9, 2012

Hello

I want to simulate a program that load two values stored in the memory in address 0x50 and 0x51 and make the addition of thesevalues so I write this code:

l.addi r1,r0,0; 
l.addi r2, r0, 0;
 l.lwz r1,0x50(r0);
 l.lwz r2 ,0x51(r1);
 l.add r2 , r1, r2;

when i simulate I note that the data at adress 50 and 51 are not read from memory and only the instruction to set to 0 the registers R1 and R2 are executed

Is that there are errors in my code???

Hi Technology,

I notice that the two addresses you are using are only 1 byte apart, yet you are attempting to load word (32-bit) values.

I notice also that you are using r1 as the destination for your first load, and also as the base address for your second load.

How are you testing your code? How are you placing initial data in memory at 0x50 and 0x51? How are you determining which instructions are executed? It's quite likely your memory is empty, in which case 0x50 and 0x51 will contain zero and that is the value that will be found in r2 in the end.

Did you really mean something like:

    l.addi r1,r0,0; 
    l.addi r2,r0,0;
    l.lwz  r1,0x50(r0);
    l.lwz  r2,0x54(r0);
    l.add  r2,r1,r2;
    

You still need to initialize your data at 0x50 and 0x54. Perhaps a .word directive would help?

HTH

Jeremy

--
Tel: +44 (1590) 610184
Cell: +44 (7970) 676050
SkypeID: jeremybennett
Email: jeremy.bennett@embecosm.com
Web: www.embecosm.com

RE: openrisc instruction set
by technology on Feb 18, 2010
technology
Posts: 25
Joined: Dec 31, 2009
Last seen: May 8, 2010

Hello

I want to simulate a program that load two values stored in the memory in address 0x50 and 0x51 and make the addition of thesevalues so I write this code:

l.addi r1,r0,0; 
l.addi r2, r0, 0;
 l.lwz r1,0x50(r0);
 l.lwz r2 ,0x51(r1);
 l.add r2 , r1, r2;

when i simulate I note that the data at adress 50 and 51 are not read from memory and only the instruction to set to 0 the registers R1 and R2 are executed

Is that there are errors in my code???

Hi Technology,

I notice that the two addresses you are using are only 1 byte apart, yet you are attempting to load word (32-bit) values.

I notice also that you are using r1 as the destination for your first load, and also as the base address for your second load.

How are you testing your code? How are you placing initial data in memory at 0x50 and 0x51? How are you determining which instructions are executed? It's quite likely your memory is empty, in which case 0x50 and 0x51 will contain zero and that is the value that will be found in r2 in the end.

Did you really mean something like:

    l.addi r1,r0,0; 
    l.addi r2,r0,0;
    l.lwz  r1,0x50(r0);
    l.lwz  r2,0x54(r0);
    l.add  r2,r1,r2;
    

You still need to initialize your data at 0x50 and 0x54. Perhaps a .word directive would help?

HTH

Jeremy

--
Tel: +44 (1590) 610184
Cell: +44 (7970) 676050
SkypeID: jeremybennett
Email: jeremy.bennett@embecosm.com
Web: www.embecosm.com



i'm using the orpsoc and to have the hex i procede like this :
echo "l.addi r1,r0,0; l.addi r2,r0,0;l.lwz r1,0x50(r0);l.lwz r2,0x54(r0);l.add r2,r1,r2;"|or32-elf-as -o add.o

then
or32-elf-gcc -Ttext 0x100 nostdlib add.o add.or32
then
or32-elf-objcopy -0 binary add.or32 add.bin
then
../../sw/utils/bin2vmem/ add.bin> sram.vmem

and the hex code is in the sram.vmem .
So to place data @ adress 0x51 and 0x52 i just modify the sram.vmem at these adress

is it false to place data like this in the RAM??
RE: openrisc instruction set
by jeremybennett on Feb 24, 2010
jeremybennett
Posts: 689
Joined: May 29, 2008
Last seen: Feb 9, 2012

Hi Technology,

I don't know if this would work - it's not how I would do it.

I suggest you use GDB to load your programs into Or1ksim. Then you can use GDB's commands to set specific values at specific locations. You can also use GDB commands to verify that your program is loaded at the correct address, that your data is in the correct location, and to single step through the program.

HTH,

Jeremy

--
Tel: +44 (1590) 610184
Cell: +44 (7970) 676050
SkypeID: jeremybennett
Email: jeremy.bennett@embecosm.com
Web: www.embecosm.com

no use no use 1/1 no use no use
© copyright 1999-2012 OpenCores.org, equivalent to ORSoC AB, all rights reserved. OpenCores®, registered trademark.