chipsalliance / VeeR-ISS

Apache License 2.0
114 stars 33 forks source link

FP instruction doesn't work #24

Closed 0x1ab closed 2 years ago

0x1ab commented 2 years ago

with the last commit 68d4634

I ran a simple fp program

volatile unsigned int tohost = 0;

int main(int argc, char** argv)
{
        float a = 1.0f;
        float b = 3.2f;
        float c = a * b;
        return 1;
}

void _start()
{
        tohost = main(0, 0);
}

compiler command:

riscv64-linux-gnu-gcc -mabi=ilp32f -march=rv32imfc -nostdlib -g -o test main.c

The output from the whisper:

#1 0 0000021a     1141 r 02         fffffff0  c.addi   x2, -0x10
#2 0 0000021c     c606 m fffffffc   00000000  c.swsp   x1, 0xc
#3 0 0000021e     c422 m fffffff8   00000000  c.swsp   x8, 0x8
#4 0 00000220     0800 r 08         00000000  c.addi4spn  x8, 0x4
#5 0 00000222     4581 r 0b         00000000  c.li     x11, 0x0
#6 0 00000224     4501 r 0a         00000000  c.li     x10, 0x0
#7 0 00000226     3f45 r 01         00000228  c.jal    . - 0x50
#8 0 000001d6     7179 r 02         ffffffc0  c.addi16sp -0x3
#9 0 000001d8     d622 m ffffffec   00000000  c.swsp   x8, 0x2c
#10 0 000001da     1800 r 08         fffffff0  c.addi4spn  x8, 0xc
#11 0 000001dc fca42e23 m ffffffcc   00000000  sw       x10, -0x24(x8)
#12 0 000001e0 fcb42c23 m ffffffc8   00000000  sw       x11, -0x28(x8)
#13 0 000001e4 00000797 r 0f         000001e4  auipc    x15, 0x0
#14 0 000001e8 05c78793 r 0f         00000240  addi     x15, x15, 92
#15 0 000001ec     639c c 0300       00001800  c.flw    x15, 0x0(x15)  +
#15 0 000001ec     639c c 0341       000001ec  c.flw    x15, 0x0(x15)  +
#15 0 000001ec     639c c 0342       00000002  c.flw    x15, 0x0(x15)  +
#15 0 000001ec     639c c 0343       0000639c  c.flw    x15, 0x0(x15)
#16 0 00000000 464c457f c 0300       00001800  illegal  +
#16 0 00000000 464c457f c 0341       00000000  illegal  +

It ended with illegal instruction when it met the first fp instruction.

0x1ab commented 2 years ago

Sorry, I didn't pass --linux as input. With --linux it works. Close this issue.