westerndigitalcorporation / swerv-ISS

Western Digital’s Open Source RISC-V SweRV Instruction Set Simulator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for running on 32-bit systems

raulbehl opened this issue · comments

Hi,

I tried building it on a 32-bit Ubuntu machines with 1.67 boost libs and gcc 7.4

After fixing the initial errors in Core.cpp related to the usage of __uint128_t datatypes, I was able to compile it successfully on my system.

But when running the simple test as per the readme, I see the following errors:

rahul@rahul:~/work/swerv-ISS$ ./whisper build/test
Unreasonably small memory size (less than 0x 1000) -- using 0x1000
End of ELF segment 0 (100c8) is beyond end of simulated memory (1000)
End of ELF segment 1 (110c8) is beyond end of simulated memory (1000)
No loadable segment in ELF file
rahul@rahul:~/work/swerv-ISS$

On running the attached .hex file in the simulator, I see segmentation fault when enabling --log mode but without that option it seems to work well:

rahul@rahul:~/work/swerv-ISS$ ./whisper --hex inst_hex.hex --startpc 0x00000000 --maxinst 28
Unreasonably small memory size (less than 0x 1000) -- using 0x1000
Stopped -- Reached instruction limit
Retired 1c instructions in 0.00s  692b1 inst/s
rahul@rahul:~/work/swerv-ISS$ 

Using --log option:

rahul@rahul:~/work/swerv-ISS$ ./whisper --hex inst_hex.hex --startpc 0x00000000 --maxinst 28 --log
Unreasonably small memory size (less than 0x 1000) -- using 0x1000
Segmentation fault (core dumped)
rahul@rahul:~/work/swerv-ISS$ 

Any ideas on how to proceed ahead?

Hi Joe,

Here are the required details:

NAME="Ubuntu"
VERSION="16.04.5 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.5 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
rahul@rahul:~$ free -m
              total        used        free      shared  buff/cache   available
Mem:           2913         779         417         245        1716        1574
Swap:           975           0         975
rahul@rahul:~$ df -h .
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       293G   19G  259G   7% /

Hi Joe,

Thank you so much for looking into it. I tried your fix on my machine but I still got the exact same error. I think there was a small typo in the following change you made:

 // Determine simulated memory size. Default to 4 gigs.
  // If running a 32-bit machine (pointer siz = 32 bits), try 2 gigs.
  size_t memorySize = size_t(1) << 32;  // 4 gigs
  if (memorySize == 0)
    memorySize = size_t(1) << 32;  // 2 gigs

Updating the 2 gigs case to use 31 instead of 32 seems to resolve the memory issue. But I still get the segmentation fault when enabling the --log option. Also, the simulator prints the following error message related to illegal instructions (I am using the simple to_host example C-code as per the GCC):

rahul@rahul:~/work/swerv-ISS/build$ ./whisper test2
Error: Failed stop: 64 consecutive illegal instructions
Retired 66 instructions in 0.00s  532258 inst/s

I'll open a pull request for the _uint128_t issue.

I think this is fixed. If not, please re-open.