Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zero-RISCY PULP Architecture Toolchain

Zero-RISCY is the name of a small, efficient RISC-V core designed by the PULP project, optimized for minimal area and power in RV32 implementations.
REFER :- Toolchain


STEP-1 : Update Ubuntu (important)

sudo apt update && sudo apt upgrade -y 

STEP-2 : Install required dependencies (VERY IMPORTANT)

The toolchain will fail if even one dependency is missing.

sudo apt install -y \
autoconf \
automake \
autotools-dev \
curl \
python3 \
python3-pip \
libmpc-dev \
libmpfr-dev \
libgmp-dev \
gawk \
build-essential \
bison \
flex \
texinfo \
gperf \
libtool \
patchutils \
bc \
zlib1g-dev \
libexpat-dev \
ninja-build \
git \
cmake

STEP-3 : Create a workspace directory

mkdir RISC_V      
cd RISC_V

STEP-4 : Clone PULP RISC-V GNU toolchain

git clone https://github.com/pulp-platform/pulp-riscv-gnu-toolchain.git  

cd pulp-riscv-gnu-toolchain

STEP-5 : Configure for Zero-RISCY

./configure \
--prefix=$HOME/tools/pulp-riscv \
--with-arch=rv32imc \
--with-abi=ilp32

--prefix -> where toolchain will be installed
rv32imc -> Zero-RISCY ISA
ilp32 -> 32-bit ABI (Application Binary Interface)
ABI decides how binary code behaves, not how source code looks.
ISA : Instructions CPU supports.
ABI : How software uses CPU.

STEP-6 : Build the toolchain (long step)

make -j$(nproc)

Optional : If it shows Error 127

  1. Check if submodule directory exists

    ls riscv-binutils-gdb
    
  2. Check .gitmodules (sanity check)

    cat .gitmodules
    
  3. FORCE submodules to download (this is the key)

    git submodule sync
    git submodule update --init --recursive --force
    
  4. VERIFY submodule is now populated (VERY IMPORTANT)

    ls riscv-binutils-gdb
    

It will show like this : image

  1. Clean previous failed build (mandatory)

    rm -rf build-* stamps
    
  2. Re-configure (fresh)

    ./configure \
    --prefix=$HOME/tools/pulp-riscv \
    --with-arch=rv32imc \
    --with-abi=ilp32
    
  3. Build again

    make -j$(nproc)
    

STEP-7 : Add toolchain to PATH

nano ~/.bashrc   
export PATH=$HOME/tools/pulp-riscv/bin:$PATH  

CTRL + O -> Enter -> CTRL + X

source ~/.bashrc

STEP-8 : Verify installation

riscv32-unknown-elf-gcc --version

It will show as :

riscv32-unknown-elf-gcc (GCC) 7.1.1 20170509
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Compile your FIRST program (Zero-RISCY)


STEP-1 : Create a test file

mkdir tests     
cd tests    
nano add.c

STEP-2 : Simple Program

int main() 
{   
volatile int x = 10;    
volatile int y = 20;  
volatile int z = x + y;   
while (1); 
}      

STEP-3 : create build directory for .elf file

mkdir -p build

STEP-4 : Compile for Zero-RISCY

riscv32-unknown-elf-gcc \
-march=rv32imc \
-mabi=ilp32 \
-nostdlib \
-T linker.ld \
 add.c \
-o build/add.elf
Flag Reason
rv32imc Zero-RISCY ISA
ilp32 32-bit ABI
-nostdlib Bare-metal
-ffreestanding No OS
-O0 Readable assembly

Bare-metal = your program runs directly on the CPU hardware, with NO operating system.

STEP-5 : Inspect ELF

riscv32-unknown-elf-objdump -d build/add.elf    

Results : Assembly language
image

riscv32-unknown-elf-nm build/add.elf

Results : Address image

ELF = Executable and Linkable Format
This is the file format that quietly connects : C code -> compiler -> linker -> RTL -> silicon.
An ELF file is a container that holds:

  • your compiled machine code
  • Data
  • Addresses
  • Symbols
  • debug info

Verifying Zero Riscy implemantation

  1. create a file

    nano fpu.c
    

write the code for floating point

  void test_fpu() 
  {
       asm volatile ("fadd.s f0, f0, f0");
  }

Zero riscy doesn't support floating point implementation.
It will shows error as :
image


Setup PULPino


REFER :- PULPino

1. Update WSl

Open PowerShell

wsl --update
wsl --version

It should be :
image

Restart the PC

2. Install & Compile Python2

Open Ubuntu

Install build dependencies

sudo apt update
sudo apt install build-essential zlib1g-dev libssl-dev \
libbz2-dev libreadline-dev libsqlite3-dev curl llvm \
libncurses5-dev libncursesw5-dev xz-utils tk-dev \
libffi-dev liblzma-dev

Download Python 2.7.18
The PULpino setup requires python2 >= 2.6

wget https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz    
tar -xvf Python-2.7.18.tgz   
cd Python-2.7.18    
./configure --prefix=$HOME/python2 --enable-optimizations   
make -j$(nproc)      
make install

Verify the installation :

~/python2/bin/python2.7 --version
Screenshot 2026-03-10 160247

3. Python Virtual Enviroment Setup

Install pip for Python2

curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
~/python2/bin/python2.7 get-pip.py

If it shows error:
ERROR: Could not find a version that satisfies the requirement wheel (from versions: none)
ERROR: No matching distribution found for wheel

~/python2/bin/python2.7 ~/Python-2.7.18/get-pip.py "pip<21.0" "setuptools<45" --no-cache-dir  

verify

~/python2/bin/python2.7 -m pip --version
image

Install virtual enviroment using Python2

~/python2/bin/python2.7 -m pip install virtualenv

Create virtual environment

~/python2/bin/python2.7 -m virtualenv venv_pulp

Activate it

source ~/venv_pulp/bin/activate

For Deactivating the virtual enviroment

deactivate

Now all the setup will be done in virtual enviroment

4. Modelsim Setup

Go to : https://www.altera.com/downloads/simulation-tools/modelsim-fpgas-standard-edition-software-version-20-1-1

  • download for linux (size ~1.4GB version - 20.1.1)

  • from WSl goto [C:\Users\Admin\Downloads] copy the ModelSimSetup-20.1.1.720-linux.run file to the home directory

    cd /mnt/c/Users/Admin/Downloads 
    cp -r /mnt/c/Users/Admin/Downloads/ModelSimSetup-20.1.1.720-linux.run ~/amitvlsi01
    
  • make setup file executable

    chmod +x ModelSimSetup-20.1.1.720-linux.run
    
  • Installing Required 32-bit Dependencies. ModelSim 20.1 is a 32-bit application, so you must first enable i386 architecture before installing those libraries.

    sudo dpkg --add-architecture i386
    sudo apt update
    
  • This tells Ubuntu to allow installation of 32-bit packages.

    sudo apt install libncurses6:i386
    sudo apt install libc6:i386 libstdc++6:i386 \
    libxext6:i386 libxft2:i386 libxrender1:i386
    
  • Finally Run

    ./ModelSimSetup-20.1.1.720-linux.run
    
image

choose free license version then next
image

accept the agreement then next
image

image
  • Add ModelSim PATH to ~/.bashrc

    echo 'export PATH=$PATH:/home/amitvlsi01/intelFPGA/20.1/modelsim_ase/bin' >> ~/.bashrc
    source ~/.bashrc
    
  • Now create a directory to keep the ModelSim files

    mkdir model_sim
    
  • Now create a bashrc_pulpino.txt file in RISC_V directory and model_sim directory for the ModelSim path (VERY IMPORTANT)

     nano bashrc_pulpino.txt
     export PATH=/home/amitvlsi01/intelFPGA/20.1/modelsim_ase/bin:/home/amitvlsi01/tools/pulp-riscv/bin:$PATH
    
     source bashrc_pulpino.txt
    
  • verify the installation

     which vsim
    
image
  • launch ModelSim

    vsim
    
image
  • verify with verilog simulation
    In the model_sim directory create and.v file

    nano and.v
    

    write a small verilog program

    module and_gate (
        input  wire a,
        input  wire b,
        output wire y );
    
        assign y = a & b;
    
     endmodule
    

write a testbench

  nano tb.v


`timescale 1ns/1ps

module tb;
// Testbench signals
reg  a;
reg  b;
wire y;
// Instantiate DUT (Design Under Test)
and_gate uut (.a(a), .b(b), .y(y) );
// Test sequence
initial begin
    $display("Time | a b | y");
    $display("----------------");
    a = 0; b = 0; #10;
    $display("%4t | %b %b | %b", $time, a, b, y);
    a = 0; b = 1; #10;
    $display("%4t | %b %b | %b", $time, a, b, y);
    a = 1; b = 0; #10;
    $display("%4t | %b %b | %b", $time, a, b, y);
    a = 1; b = 1; #10;
    $display("%4t | %b %b | %b", $time, a, b, y);
    $finish;
end
endmodule
  • compile the design and testbench

    vlog and.v tb.v
    vsim tb
    
image
  • now in the ModelSim transcript window type

    add wave *
    run 50ns
    
image

5. PULPino integration

  • Clone the PULPino repository & get the submodules

    cd 
    git clone https://github.com/pulp-platform/pulpino.git
    cd pulpino
    git submodule update --init --recursive
    export PULP_CORE=zeroriscy
    
  • Install .yml

    python2 -m pip install "pyyaml==5.3.1"
    sudo apt install python-pip
    pip2 install pyyaml
    
  • Run update-ips script

    ./update-ips.py
    
  • If it throws error : Updating ip 'adv_dbg_if'... error: pathspec 'pulpinov1' did not match any file(s) known to git ERROR: could not checkout ip 'adv_dbg_if' at pulpinov1.
    It means : The repo : adv_dbg_if
    does NOT have a branch or tag named pulpinov1.
    So update-ips.py keeps failing.

    cd ~/pulpino/ips/adv_dbg_if
    git checkout -b pulpinov1 master
    cd ~/pulpino
    ./update-ips.py
    
  • If it throws error :

image

It means : The branch pulpinov1 exists locally, but it is not tracking any remote branch.
So when update-ips.py runs git pull, Git doesn’t know what to pull from.

cd ~/pulpino/ips/adv_dbg_if
git branch --set-upstream-to=origin/master pulpinov1
cd ~/pulpino
./update-ips.py

6. CMake (3.5.1) Installation

sudo apt install build-essential libssl-dev
wget https://github.com/Kitware/CMake/releases/download/v3.5.1/cmake-3.5.1.tar.gz
tar -xvf cmake-3.5.1.tar.gz
cd cmake-3.5.1
./bootstrap --prefix=$HOME/cmake-351
make -j$(nproc)
make install

verify :

$HOME/cmake-351/bin/cmake --version
image

7. Configure Zero-Riscy script

cd/pulpino/sw
vim cmake_configure.zeroriscy.gcc.sh
  • Change : line 13 : remove -m32 (it should be TARGET_C_FLAGS="-O3 -g") line 31 : GCC_MARCH="rv32im" line 40 : $HOME/cmake-351/bin/cmake "$PULP_GIT_DIRECTORY"/sw/ \

  • Create a build directory

    cd sw
    mkdir build
    cd build
    
  • Add bashrc_pulpino.txt inside build

    nano bashrc_pulpino.txt
    export PATH=/home/amitvlsi01/intelFPGA/20.1/modelsim_ase/bin:/home/amitvlsi01/tools/pulp-riscv/bin:$PATH
    
    
    source bashrc_pulpino.txt
    
  • Run cmake_configure.zeroriscy.gcc.sh script

    cp /home/amitvlsi01/pulpino/sw/cmake_configure.zeroriscy.gcc.sh /home/amitvlsi01/pulpino/sw/build
    chmod +x cmake_configure.zeroriscy.gcc.sh
    ./cmake_configure.zeroriscy.gcc.sh
    

It will show this :

image
  • If there is a error like riscv.ld is not found then : manually copy the riscv.ld file from pulp-riscv-gnu-toolchain directory to pulpino->sw->build->CMakeFiles->CMakeTmp then inside build directory type :

    riscv32-unknown-elf-ld -verbose | head -n -1 | tail -n +7 | sed '168 a\\_fbss = .;' | sed '169 a \\ . = .;' > /home/dev65/pulpino/sw/build/CMakeFiles/CMakeTmp/riscv.ld
    
  • NOTE : It might get automatically deleted from the destination folder but you have to copy the folder again and again run the above command make sure that you have open the folders in the background like this :

    Screenshot 2026-03-08 193722
  • Inside build :

    sudo ln -s /home/dev65/intelFPGA/20.1/modelsim_ase/linuxaloem linux_x86_64pe
    
  • Vcompile setup :

    sudo apt-get install tcsh
    sudo apt-get install csh
    sudo apt-get install gcc-multilib
    make vcompile
    make helloworld
    
  • here u will get error related to -m32

    find . -type f -exec sed -I 's/-m32//g' {} +
    

also inside sw directory : vim CMakeLists.txt remove -m32 from line 54

  • now from build directory :

    make helloworld.vsim
    
  • inside modelsim transcript type :

    run -all
    
  • or if you want to see the result in terminal

    make helloworld.vsimc
    

About

Build and install a PULP Zero-RISCY (RV32IMC) RISC-V GCC toolchain for bare-metal development.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages