{"id":26269669,"url":"https://github.com/artecs-group/percival","last_synced_at":"2025-04-30T21:55:03.856Z","repository":{"id":43750586,"uuid":"434856914","full_name":"artecs-group/PERCIVAL","owner":"artecs-group","description":"Open-Source Posit RISC-V Core with Quire Capability","archived":false,"fork":false,"pushed_at":"2025-01-31T09:31:12.000Z","size":35113,"stargazers_count":56,"open_issues_count":3,"forks_count":11,"subscribers_count":6,"default_branch":"big-percival-main","last_synced_at":"2025-04-30T21:54:55.055Z","etag":null,"topics":["arithmetic","floating-point","hardware","posit","posit-arithmetic","risc-v","riscv"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/artecs-group.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-04T09:20:05.000Z","updated_at":"2025-04-23T02:52:59.000Z","dependencies_parsed_at":"2025-01-31T10:24:51.353Z","dependency_job_id":"6c9782f8-fcf0-4023-a72c-3abf279474d1","html_url":"https://github.com/artecs-group/PERCIVAL","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artecs-group%2FPERCIVAL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artecs-group%2FPERCIVAL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artecs-group%2FPERCIVAL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artecs-group%2FPERCIVAL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/artecs-group","download_url":"https://codeload.github.com/artecs-group/PERCIVAL/tar.gz/refs/heads/big-percival-main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251789579,"owners_count":21644082,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arithmetic","floating-point","hardware","posit","posit-arithmetic","risc-v","riscv"],"created_at":"2025-03-14T05:15:43.694Z","updated_at":"2025-04-30T21:55:03.837Z","avatar_url":"https://github.com/artecs-group.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PERCIVAL: Open-Source Posit RISC-V Core with Quire Capability\n\nPERCIVAL is an application-level posit capable RISC-V core based on CVA6 that can execute all posit instructions, including the quire fused operations.\n\nYou can find the Xposit RISC-V custom extension for posit arithmetic used together with this repository here: \u003chttps://github.com/artecs-group/llvm-xposit\u003e\n\nYou can find the original CVA6 repo with additional documentation here: \u003chttps://github.com/openhwgroup/cva6\u003e\n\n## 64-bit version (Big-PERCIVAL)\n\nHere you can also find Big-PERCIVAL, an updated version of PERCIVAL which adds posit64 operations and increased flexibility in the PAU. You can read about it in our [paper](https://ieeexplore.ieee.org/document/10473215).\n\nFor the original PERCIVAL code switch to the `posit-master` branch. However, we recommend using the current default `big-percival-main` branch, as this also supports 32-bit posits.\n\n## Publication\n\nIf you use PERCIVAL in your academic work you can cite us:\n\n~~~bibtex\n@article{mallasen2022PERCIVAL,\n  title = {PERCIVAL: Open-Source Posit RISC-V Core With Quire Capability},\n  author = {Mallasén, David and Murillo, Raul and Del Barrio, Alberto A. and Botella, Guillermo and Piñuel, Luis and Prieto-Matias, Manuel},\n  year = {2022},\n  journal = {IEEE Transactions on Emerging Topics in Computing},\n  volume = {10},\n  number = {3},\n  pages = {1241-1252},\n  issn = {2168-6750},\n  doi = {10.1109/TETC.2022.3187199}\n}\n\n@article{mallasen2024BigPERCIVAL,\n  title = {Big-PERCIVAL: Exploring the Native Use of 64-Bit Posit Arithmetic in Scientific Computing},\n  author = {Mallas{\\'e}n, David and Del Barrio, Alberto A. and {Prieto-Matias}, Manuel},\n  year = {2024},\n  journal = {IEEE Transactions on Computers},\n  volume = {73},\n  number = {6},\n  pages = {1472--1485},\n  issn = {0018-9340, 1557-9956, 2326-3814},\n  doi = {10.1109/TC.2024.3377890}\n}\n~~~\n\n## Posit Arithmetic Unit (PAU)\n\nThe top-level module of the PAU can be found in `core/pau_top.sv`. The individual arithmetic modules are in `core/pau/`. You can configure the PAU changing the parameters in `core/include/ariane_pkg.sv`.\n\n![PAU diagram](docs/_static/pau_diagram.png)\n\n## Getting Started\n\nThe following instructions will get you a copy of the project up and running on your local machine and run the posit testsuite using the QuestaSim simulator. If you run into problems, look at the [troubleshooting](#troubleshooting-the-installation) section.\n\n### 1. Prerequisites\n\nThese instructions assume you have the [LLVM Xposit](https://github.com/artecs-group/llvm-xposit) compiler and the [QuestaSim](https://eda.sw.siemens.com/en-US/ic/questa/simulation/advanced-simulator/) simulator installed in your system. Also, on a fresh Ubuntu 22.04 installation you will need to install the following packages:\n\n~~~bash\nsudo apt install -y git curl gcc g++ make autoconf device-tree-compiler screen\n~~~\n\nMake sure you have the `$RISCV` environment variable pointing to the directory where you installed the RISC-V gcc toolchain. E.g. `export RISCV=\"/opt/riscv`. Consider adding this permanently in your `.bashrc` file.\n\n### 2. Checkout the repository\n\nTo set up the repository, run:\n\n~~~bash\ngit clone https://github.com/artecs-group/PERCIVAL.git\ncd PERCIVAL\ngit submodule update --init --recursive\nmkdir tmp\n./ci/install-riscvpk.sh\n~~~\n\n### 3. Compile the posit testsuite\n\nTo compile the posit64 testsuite, you must use the next command:\n\n~~~bash\nclang --target=riscv64 -march=rv64gcxposit posit64_testsuite_llvm.c -c -o posit64_testsuite_llvm.o\nriscv64-unknown-elf-gcc posit64_testsuite_llvm.o -o posit64_testsuite_llvm.elf\n~~~\n\n(Optional) Once the `.elf` executable has been generated, you can create visualize the generated assembly code with:\n\n~~~bash\nriscv64-unknown-elf-objdump -DC posit64_testsuite_llvm.elf \u003e posit64_testsuite_llvm.dump\n~~~\n\n### 4. Simulate the posit testsuite\n\nTo run the simulation, execute:\n\n~~~bash\nmake sim elf-bin=$RISCV/riscv64-unknown-elf/bin/pk target-options=posit64_testsuite_llvm.elf batch-mode=1\n~~~\n\nYou should see the following output at the end of the simulation:\n\n~~~text\nPADD test OK\nPSUB test OK\nPMUL test OK\nPDIV test OK\nPSQRT test OK\nPMIN test OK\nPMAX test OK\nQUIRE test OK\nPCVTWS test OK\nPCVTWUS test OK\nPCVTLS test OK\nPCVTLUS test OK\nPCVTSW test OK\nPCVTSWU test OK\nPCVTSL test OK\nPCVTSLU test OK\nPSGNJ test OK\nPSGNJN test OK\nPSGNJNX test OK\nPMVXW test OK\nPMVWX test OK\nPEQ test OK\nPLT test OK\nPLE test OK\n~~~\n\nNote: If you want to use the QuestaSim GUI, remove the `batch-mode=1` option from the `make sim` command.\n\n### 5. Running on FPGA\n\nPERCIVAL is designed to be used with the [Genesys II](https://digilent.com/reference/programmable-logic/genesys-2/start) board.\n\n#### 5.1 Generating the FPGA bitstream\n\n  To generate the FPGA bitstream of PERCIVAL run `make fpga`.\n  This will produce a bitstream file and memory configuration file in `corev_apu/fpga/work-fpga/`.\n\n#### 5.2 Programming the Memory Configuration File\n\n  1. Connect the FPGA to the PC using the **JTAG** port and turn it on.\n  2. Open Vivado.\n  3. Open the Hardware Manager.\n  4. Open the target board (Genesys II `xc7k325t`).\n  5. Tools -\u003e Add Configuration Memory Device -\u003e `xc7k325t`.\n  6. Select Configuration Memory Part -\u003e Spansion SPI flash `s25fl256sxxxxxx0`.\n  7. Program the configuration memory device with the configuration file `ariane_xilinx.mcs` generated in `corev_apu/fpga/work-fpga/`.\n  8. Press ok. Flashing will take a couple of minutes.\n  9. Exit Vivado and turn off the FPGA.\n\n#### 5.3 Creating a Linux SD image\n\n  1. Insert the SD card to the PC.\n  2. Clone the [cva6-sdk](https://github.com/openhwgroup/cva6-sdk/tree/176923f60efb9348dfa907412873dadbfd59319c) repository and follow the [Quickstart](https://github.com/openhwgroup/cva6-sdk/tree/176923f60efb9348dfa907412873dadbfd59319c?tab=readme-ov-file#quickstart).\n\n      ~~~bash\n      git clone https://github.com/openhwgroup/cva6-sdk.git\n      git checkout 176923f60efb9348dfa907412873dadbfd59319c\n      sudo apt-get install autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev libusb-1.0-0-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev device-tree-compiler pkg-config libexpat-dev\n      git submodule update --init --recursive\n      ~~~\n\n  3. Add the file `PERCIVAL/posit_testsuite_llvm.elf` to the `cva6-sdk/rootfs/` folder. All executables added here, will be built into the generated Linux image.\n  4. If you have created a previous Linux image, you must delete the `cva6-sdk/install64` folder, using:\n  \n      ~~~bash\n      rm -rf install64\n      ~~~\n\n  5. Create the Linux image (this can take a few minutes):\n  \n      ~~~bash\n      make images\n      ~~~\n\n  6. Get the ID of the SD device with `lsblk` or `fdisk -l`. E.g. **/dev/sdc**.\n  7. Flash the SD with the next command:\n\n      ~~~bash\n      sudo -E make flash-sdcard SDDEVICE=/dev/sdc\n      ~~~\n\n  8. Remove the SD card from the PC.\n\n#### 5.4 Connect a terminal to the FPGA and run PERCIVAL\n\n  1. Insert the flashed SD to the **Genesys II** FPGA.\n  2. Connect the FPGA to the PC using the **UART** port and turn the FPGA on.\n  3. You may have to configure the permissions to the device (normally uses **ttyUSB0**).\n  4. Configure a terminal connection with the FPGA specifying the baudrate to **115200**. For example:\n\n      ~~~bash\n      screen /dev/ttyUSB0 115200\n      ~~~\n\n      You can create a log file with the content of the session using `-L \"nameFile\"` the option.\n\n      ~~~bash\n      screen -L \"nameFile\" /dev/ttyUSB0 115200\n      ~~~\n\n  5. Now PERCIVAL is running and you should see the the booting process.\n  6. Once it finishes booting you should see the following:\n\n      ~~~text\n      Starting rpcbind: OK\n      [   33.124523] random: crng init done\n      [   33.124523] random: crng init done\n      Starting sshd: OK\n      NFS preparation skipped, OK\n      # \n      ~~~\n\n  7. Now, you can use the console to communicate with PERCIVAL. Try to rerun the `posit_testsuite_llvm`. The output should be the same than in the simulation.\n\n      ~~~bash\n      # ls\n      README.md                   opt\n      bin                         posit64_testsuite_llvm.elf\n      cachetest.elf               proc\n      dev                         root\n      etc                         run\n      init                        sbin\n      lib                         sys\n      lib64                       tetris\n      linuxrc                     tmp\n      media                       usr\n      mnt                         var\n      #\n      # ./posit64_testsuite_llvm.elf\n      .\n      .\n      .\n      ~~~\n\n  8. **Congratulations!** If you have arrived here, you have done everything well. Now, you can enjoy playing Tetris on the FPGA.\n\n      ~~~bash\n      ./tetris \n      ~~~\n\n  9. When you are finished, close the session using `ctrl-a` `k` `y`. You can also use detach using `ctrl-a` `d` and reattach with `screen -r PID` (`screen -ls` shows the active screens).\n\n## Troubleshooting the installation\n\n### QuestaSim does not find the `libfesvr.so`\n\nIf QuestaSim does not find the `libfesvr.so`, you can generate it by running the `./ci/install-fesvr.sh` script.\n\nIf it still doesn't generate the library, add the line `fesvr_install_shared_lib = yes` to the `./tmp/riscv-isa-sim/fesvr/fesvr.mk.in` file and follow the `./ci/install-fesvr.sh` script instructions manually in a console. Add `make libfesvr.so` and `cp libfesvr.so $RISCV/lib`.\n\n### QuestaSim returns the error: `Fatal: Unexpected signal: 11`\n\nIf QuestaSim fails with the following error: `Fatal: Unexpected signal: 11`, try running with:\n\n~~~bash\nmake sim elf-bin=posit64_testsuite_llvm.elf QUESTASIM_FLAGS=\"-novopt -suppress 12110\" batch-mode=1\n~~~\n\nThis fix follows the instructions [here](https://github.com/openhwgroup/cva6/issues/800#issuecomment-1081757665). It should be fixed with newer versions of QuestaSim (2022.4 or later).\n\n### QuestaSim doesn't find the `svdpi.h` file\n\nWhile simulating, QuestaSIM can return the next error:\n\n  ~~~text\n  *corev_apu/tb/dpi/elfloader.cc:4:10: fatal error: svdpi.h: No such file or directory*\n  ~~~\n\nTo fix this, you must add QuestaSIM's installation path to the `QUESTASIM_HOME` variable.\n\n### Error with the library `libstdc++.so`\n\nIf the `libstdc++.so.6` library shipped with questasim doesn't work, you must rename it so the system library is used instead.\n\n## Acknowledgments\n\nThis work was supported in part by the 2020 Leonardo Grant for Researchers and Cultural Creators, from BBVA Foundation under Grant PR2003_20/01, in part by the Spanish MINECO, the EU(FEDER), and Comunidad de Madrid under Grants RTI2018-093684-B-I00 and S2018/TCS-4423, and in part by grants PID2021-123041OB-I00 and PID2021-126576NB-I00 funded by MCIN/AEI/ 10.13039/501100011033 and by “ERDF A way of making Europe”.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartecs-group%2Fpercival","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fartecs-group%2Fpercival","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartecs-group%2Fpercival/lists"}