OpenCores
no use no use 1/1 no use no use
Mor1kx 4.1 FPU simulation
by darkzihard on Jan 18, 2016
darkzihard
Posts: 15
Joined: May 26, 2014
Last seen: Mar 29, 2020
Hi all


I am trying to FPU simulation by using the mor1kx-4.1 in fusesoc.

I am using a variety of numbers in simulation

The use of a number such as 0.5 or 0.0, simulation is correctly.

However, in other numbers will be simulation suddenly end with a message that Closing RSP

server.

Please tell me about the causes and solutions of this problem.

Thanks
RE: Mor1kx 4.1 FPU simulation
by olof on Jan 23, 2016
olof
Posts: 218
Joined: Feb 10, 2010
Last seen: Dec 17, 2018
I'm not really sure what you mean here. Could you provide some more context? Where does your numbers come from? Are you sending a program with these numbers to FuseSoC? Which simulator?
RE: Mor1kx 4.1 FPU simulation
by darkzihard on Jan 24, 2016
darkzihard
Posts: 15
Joined: May 26, 2014
Last seen: Mar 29, 2020
i'm using ELF loader in fusesoc and icarus simulator i have make a C program #include #include int main() { float a,b,c,d,e,f; a = 4.5; b = 10.3; printf("start\n"); c = a + b; printf(" c = a + b = %f\n",c); d = a - b; printf(" d = a - b = %f\n",d); e = a / b; printf(" e = a / b = %f\n",e); f = a * b; printf(" f = a * b = %f\n",f); exit(0); } and i was compile with or1k-elf-gcc i ran the simulation in this command fusesoc sim --force mor1kx-generic --elf-load /root/file name as a result, Simulation is terminated with a masage Closing RSP server
RE: Mor1kx 4.1 FPU simulation
by olof on Jan 25, 2016
olof
Posts: 218
Joined: Feb 10, 2010
Last seen: Dec 17, 2018
Hi,

The mor1kx-generic system will always print out Closing RSP server before exiting. I thought I had fixed that, but apparently not. Anyway, it's not an error message, so you can ignore it.

I compiled and ran your program, and I get the following output (just before Closing RSP server)

start
c = a + b = 14.800000
d = a - b = -5.800000
e = a / b = 0.436893
f = a * b = 46.350002

Is this what you see as well?
RE: Mor1kx 4.1 FPU simulation
by darkzihard on Jan 26, 2016
darkzihard
Posts: 15
Joined: May 26, 2014
Last seen: Mar 29, 2020
thanks olof.

your answer is a big help for me
RE: Mor1kx 4.1 FPU simulation
by ontoshko on Aug 28, 2016
ontoshko
Posts: 1
Joined: Jun 30, 2010
Last seen: May 7, 2019
Hi, my app crashes at runtime when it execute FPU instruction. Can anybody help me?
My src very simple:

int main(){
float c = 0.0; //
c = c + 1.2; // (1) OK
c = c + 2.2; // (2) OK
c = c + 3.2; // (3) CRASH
return 0;
}

I use -lsingle-precision-constant and -mhart-float opts at compilation stage:

> or1k-elf-gcc -lsingle-precision-constant -mhard-float a.c -o a.elf

and have nice assembler code with FPU instructions (gcc -S), like that:

l.movhi r3,hi(.LC1) # movsi_high
l.ori r3,r3,lo(.LC1) # movsi_lo_sum
l.lwz r3,0(r3) # movsf
lf.add.s r3,r4,r3 # addsf3 (1)
l.sw -8(r2),r3 # movsf
l.lwz r4,-8(r2) # movsf
l.movhi r3,hi(.LC2) # movsi_high
l.ori r3,r3,lo(.LC2) # movsi_lo_sum
l.lwz r3,0(r3) # movsf
lf.add.s r3,r4,r3 # addsf3 (2)
l.sw -8(r2),r3 # movsf
l.lwz r4,-8(r2) # movsf
l.movhi r3,hi(.LC3) # movsi_high
l.ori r3,r3,lo(.LC3) # movsi_lo_sum
l.lwz r3,0(r3) # movsf
lf.add.s r3,r4,r3 # addsf3 (3)
l.sw -8(r2),r3 # movsf

I use fusesoc to simulate modificated mor1kx-generic (set mor1kx-4.1 instead mor1kx and enabled FEATURE_FPU) + iverilog

> fusesoc sim mor1kx-generic --elf-load=a.elf --vcd --trace_enable

Trace log:

S 000023b4: 8482fff8 l.lwz r4,0xfff8(r2) r4 = 007fdff8 flag: 0
S 000023b8: 18600000 l.movhi r3,0x0000 r3 = 00000000 flag: 0
S 000023bc: a8633a8c l.ori r3,r3,0x3a8c r3 = 00003a8c flag: 0
S 000023c0: 84630000 l.lwz r3,0x0000(r3) r3 = 00003a8c flag: 0
S 000023c4: c8641800 0.00 ns: Unknown opcode 0x32 flag: 0
S 000023c4: c8641800 0.00 ns: Unknown opcode 0x32 flag: 0
S 000023c8: d7e21ff8 l.sw 0xfff8(r2),r3 [007fdff8] = 3f99999a flag: 0 (1)
S 000023cc: 8482fff8 l.lwz r4,0xfff8(r2) r4 = 007fdff8 flag: 0
S 000023d0: 18600000 l.movhi r3,0x0000 r3 = 00000000 flag: 0
S 000023d4: a8633a90 l.ori r3,r3,0x3a90 r3 = 00003a90 flag: 0
S 000023d8: 84630000 l.lwz r3,0x0000(r3) r3 = 00003a90 flag: 0
S 000023dc: c8641800 0.00 ns: Unknown opcode 0x32 flag: 0
S 000023dc: c8641800 0.00 ns: Unknown opcode 0x32 flag: 0
S 000023e0: d7e21ff8 l.sw 0xfff8(r2),r3 [007fdff8] = 4059999a flag: 0 (2)
S 000023e4: 8482fff8 l.lwz r4,0xfff8(r2) r4 = 007fdff8 flag: 0
S 000023e8: 18600000 l.movhi r3,0x0000 r3 = 00000000 flag: 0
S 000023ec: a8633a94 l.ori r3,r3,0x3a94 r3 = 00003a94 flag: 0
S 000023f0: 84630000 l.lwz r3,0x0000(r3) r3 = 00003a94 flag: 0
S 000023f4: c8641800 0.00 ns: Unknown opcode 0x32 flag: 0
S 000023f4: c8641800 0.00 ns: Unknown opcode 0x32 flag: 0
S 00000d00: d4000804 l.sw 0x0004(r0),r1 [00000004] = 007fdff8 flag: 0

As you can see, expressions (1) and (2) are calculated correctly, but (3) is falling down.
I wonder why this is happening. How do I find out what happened?
RE: Mor1kx 4.1 FPU simulation
by wallento on Sep 1, 2016
wallento
Posts: 28
Joined: Jan 24, 2009
Last seen: Nov 8, 2018
Hi,

the cpu gets into the floating point exception. Can you please provide the generate vcd file?

Cheers,
Stefan
RE: Mor1kx 4.1 FPU simulation
by olof on Sep 2, 2016
olof
Posts: 218
Joined: Feb 10, 2010
Last seen: Dec 17, 2018
We got this worked out now. It turns out that there is an exception when the does a calculation where the result is not exact. We will change mor1kx to disable the FP exceptions by default, as we usually aren't interested in them and we have no software to take care of them yet.

In the meantime you can set iverilog_options = -DSIM -DOR1K_FPCSR_MASK_FLAGS in mor1kx-generic.core to disable this when running simulations with Icarus

//Olof
no use no use 1/1 no use no use
© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.