# neorv32

neorv32 with Makefiles compatible with MSYS2 64 on Windows(ONLY ASSEMBLY) and Linux(ASSEMBLY, C, and CPP).




## Windows Installation

You must download the latest RISCV precompiled binaries for your platform from: https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack/releases/

in this case the architecture x64 for windows binaries(https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack/releases/download/v13.2.0-2/xpack-riscv-none-elf-gcc-13.2.0-2-darwin-x64.tar.gz), then extract these under the folder C:\riscv_precompiled\
 <br>
    <img src="data:image/png;base64,[encoded data, 34476 characters]"
     style="float: left; margin-right: 10px;" />

1. clone or download this repository on your windows machine.
    ```
    $ git clone https://gitea.squirrelnut.synology.me:5001/FPGALover/neorv32
    ```
2. download and install MSYS2(msys2-x86_64-20240113.exe) --> https://www.msys2.org/
3. once MSYS2 is installed, run MSYS2, and run the command(pacman -S mingw-w64-ucrt-x86_64-gcc)
    ```
    $ pacman -S mingw-w64-ucrt-x86_64-gcc
    ```
4. Select ALL dependencies by pressing Enter and select Y[yes].
    ```
    resolving dependencies...
    looking for conflicting packages...

    Packages (15) mingw-w64-ucrt-x86_64-binutils-2.41-2
                mingw-w64-ucrt-x86_64-crt-git-11.0.0.r216.gffe883434-1
                mingw-w64-ucrt-x86_64-gcc-libs-13.2.0-2  mingw-w64-ucrt-x86_64-gmp-6.3.0-2
                mingw-w64-ucrt-x86_64-headers-git-11.0.0.r216.gffe883434-1
                mingw-w64-ucrt-x86_64-isl-0.26-1  mingw-w64-ucrt-x86_64-libiconv-1.17-3
                mingw-w64-ucrt-x86_64-libwinpthread-git-11.0.0.r216.gffe883434-1
                mingw-w64-ucrt-x86_64-mpc-1.3.1-2  mingw-w64-ucrt-x86_64-mpfr-4.2.1-2
                mingw-w64-ucrt-x86_64-windows-default-manifest-6.4-4
                mingw-w64-ucrt-x86_64-winpthreads-git-11.0.0.r216.gffe883434-1
                mingw-w64-ucrt-x86_64-zlib-1.3-1  mingw-w64-ucrt-x86_64-zstd-1.5.5-1
                mingw-w64-ucrt-x86_64-gcc-13.2.0-2

    Total Download Size:    49.38 MiB
    Total Installed Size:  418.82 MiB

    :: Proceed with installation? [Y/n]
    [... downloading and installation continues ...]
    ```
5. after the installation is completed, add the *Path* *"C:\msys64\ucrt64\bin"* under the enviroments variable on Windows.
    <br>
    <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAR0AAAA/CAYAAADdeRzyAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAq3SURBVHhe7Z39a1vXGce/DvsHluy3tHmbtOINEdLBQGYZg7CAjMMMo15ZmJv+Ii9jMAvmrluqdo2TZcM/SAzWYrWDRO26oaxgRpBgoyQhYP1UghGZ40lJnTRLQhLy8gfEd+c595x7z5WuHFsvx4r1fMKJztu997nH9z73eY7ueYSlpSXn/v37Xrp3755Md+/e9dKdO3ec27dvO7du3ZLpt+/8wXn06JHz8OFD58GDB4H+ut/Nmzed5eVl5/r1606tVnPoOFevXnWuXLniVCoVZ2Fhwbl8+bJz9uxZ5/Hjxx1Jx09lnVWpZpw4kk5RFRsoJh3EM05VFqpOJh53Mm5BUXSSMOvMsptPJuMO9DHk8SDKbkqaBzba4pnMqvspJv19wNuJOnbR3w81VTO0nd5vQHhF/TloGs/F6xM4Dz1+ND66Tp/bKmOWEWOr+gbkammMgm2+TKbca5WPsc0W8QfpL+KDiKrs6kQwmY6hcK6myo3UstPIxccwElEVKKMymIfjzCKBEiaiKcSKjiiLVM2gMjyErNxdsC2PAnJye425HyAxq/bhFJHMTat9EGWkpoE8tQnNlBsewLjYm+wryuXUjDhSGGK76AAGBtw0Ed5JQbIWMFZVMhSBaRKgNINUrKjkcjBLgjYdM3G8xdEQuVodoyYymaxLPsYmXVI65/Hmjh3YtWsX9uzZg0jkFZy5oZpwCe/GYti7dy/27duHEydOqHpLlBdRVdkGErNw5ifFpalIjCJWOIfgJerfsNFUDEWzP+IY0xqotoQKkhiVF7sgMol0so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bUv48zhYcwsAEdOFZA92uOrzIVS6GRoS3rPZW70GT/90g4dlrdjdEuuXj1fJpQuKp2f4hO5FfEqPvzvcXxXtrlJhre48RGOpf+NTy5eVP3a47kIbUEvJwrLKs+RApk+pW33ihQNmciNuOFKr127hmp1GvtFP0IrJ4kMV7rdzW966CtqciUKGOOQmkwfY39O51IeH3m/f/Ulqv/5n8pvdmgOhRQuh9Rk+pu23av6NrfOD1f62ot+lEBqf/r0At751s+6+hM0HK6UYXqXLikdP5mhSandLFPicKUM01+0rHRELzgrfj+5Df1T27pJ9Fd9AnVG+StbHBz/3VtyH+3CSodhep+WlI5OVK5vMz8phVk6Zvvy8jIOHTok99EurHQYpvexP5HMMExfw0qHYRirsNJhGMYqrHQYhrHKpptIZhimt9lUSodhmN6nJfeKlIZJfdmkfl1W+DothmH6BZ7TYRjGKqx0GIaxCisdhmGswkqHYRirsNJhGMYqrHQYhrEKKx2GYazCSodhGKuw0mEYxiqsdBiGscozlY5e4kCfegkDfep6XUdls6/OE836MAzTf7ClwzCMVVjpMAxjFVY6DMNYhZUOwzBWYaXDMIxVWOkwDGMVVjoMw1iFlQ7DMFZhpcMwjFVY6TAMYxVP6ay2LMFcxrAe9LIHvZ3eD2HmGYbpH9jSYRjGIsD/ASAs8oYBfBNBAAAAAElFTkSuQmCC"
     style="float: left; margin-right: 10px;" />

6. open a cmd and run the command (gcc --version)
    ```
    $ gcc --version
    gcc.exe (Rev2, Built by MSYS2 project) 13.2.0
    ```
7. go to the folder C:\msys64\ucrt64\bin make a copy of the file **mingw32-make.exe** and name it **make.exe**
     <br>
    <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQYAAABBCAYAAAAzHwpcAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAf6SURBVHhe7d1RaFvXGQfwv1bYHroW3Ic1eehoQcqD8UMf/JBJ2x4CGZXcFa8DQQPF0Ab5pSCNVIQGt6WdcFlF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rc/jarhZAwmGHiBwRQ5PpBt8HulC4brORTtrbvpFAJ34ShmNEmYK6CenpGa1utYLTY0XfDu7lVNtNskgJTj3hNGtYjc1MLwfyriNrAen4R5iNEApbHAJ1nGcg0VpHbWBsyCaLn740M7u7lXHxOENG0IZDd79qdxNJSM4dC2we+ZpsveM72mxXOSCfiPEiKqkUEmn//YIPV6WR4r2ulCbAMFk9ZrMQ/iJhg0N+qQQW27V3YteA4qmUcJOcR0zLkGprr8tCO55CK9ErOLhfL93BIk79/5LKEFy259HLNW4a2NJJEv1ZHyFx97GZPGxQC/Er2Ira3BtsGfmJhA/vyPsA2+puqxBhYGSfOJxtBY/Pl4/VFgql6C66/AE9G9jGhg0EXCGHL+s7ouqjFbIOoVN5whopCBFx+JaHQxMBBRCAMDEYUwMBBRCAMDEYUwMBBRCAMDEYUwMBBRCAMDEYUwMBBRCAMDEXUA/g+REJUismYM0gAAAABJRU5ErkJggg=="
     style="float: left; margin-right: 10px;" />
8. go to the directory where you cloned or donwloaded this repository to the directory **neorv32\sw\example\demo_blink_led_asm**
    ``` 
    $ cd neorv32\sw\example\demo_blink_led_asm
    ```
8. run the command **make all** (make sure all antivirus are disabled)
    ``` 
    $ make all
    "Memory utilization:"
    text    data     bss     dec     hex filename
        432       0       0     432     1b0 main.elf
    "Generationg APP BIN"
    "OK - APP BIN"
    "Generationg APP IMG VHD"
    "OK - APP IMG VHD"
    "Generationg RAW HEX"
    "OK - RAW HEX"
    "Generationg RAW BIN"
    "OK - RAW BIN"
    "Generationg BOOT IMG VHD"
    "OK - BOOT IMG VHD"
    "Memories Generated"    
    
    ```
9. list the generated files and you will see 

    ```
    $ ls -l
    -rw-rw-rw-  1 adriz 0 6781 2024-02-24 01:45 main.asm
    -rw-rw-rw-  1 adriz 0  432 2024-02-24 01:45 main.bin
    -rw-rw-rw-  1 adriz 0 8708 2024-02-24 01:45 main.elf
    -rw-rw-rw-  1 adriz 0 5456 2024-02-23 16:14 main.S
    -rw-rw-rw-  1 adriz 0 2764 2024-02-24 01:45 main.S.o
    -rw-rw-rw-  1 adriz 0  274 2024-02-24 01:16 makefile
    -rw-rw-rw-  1 adriz 0 1882 2024-02-24 01:45 neorv32_application_image.vhd
    -rw-rw-rw-  1 adriz 0 1878 2024-02-24 01:45 neorv32_bootloader_image.vhd
    -rw-rw-rw-  1 adriz 0  444 2024-02-24 01:45 neorv32_exe.bin
    -rw-rw-rw-  1 adriz 0  432 2024-02-24 01:45 neorv32_raw_exe.bin
    -rw-rw-rw-  1 adriz 0  972 2024-02-24 01:45 neorv32_raw_exe.hex
    ```    
10. you have been able to compiled assembly for the RISCV on windows.


## Linux Installation

1. Open shell and run:
     ``` 
    sudo apt-get update
    sudo apt-get install 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 libglib2.0-dev
    git clone https://github.com/riscv/riscv-gnu-toolchain
    cd riscv-gnu-toolchain/
    mkdir build/
    cd build
    sudo mkdir /opt/riscv32im
    sudo chown $USER /opt/riscv32im
    ./configure --with-arch=rv32im --prefix=/opt/riscv32im
    make -j$(nproc)
     ``` 
2. clone this repository.
3.  go to the directory where you cloned or donwloaded this repository to the directory **neorv32\sw\example\demo_blink_led_asm**
    ``` 
    $ cd neorv32\sw\example\demo_blink_led
    ```
4. run the command **make all** 
    ``` 
    $ make all
    Memory utilization:
    text    data     bss     dec     hex filename
    1012       0       0    1012     3f4 main.elf
    Executable (neorv32_exe.bin) size in bytes:
    1024
    Installing application image to ../../../rtl/core/neorv32_application_image.vhd

    ```
5. list the generated files and you will see 

    ```
    $ ls -l
    -rw-r--r-- 1 adrizcorp adrizcorp 18160 Feb 24 01:54 main.asm
    -rw-r--r-- 1 adrizcorp adrizcorp  1012 Feb 24 01:54 main.bin
    -rw-r--r-- 1 adrizcorp adrizcorp  4314 Feb 23 15:08 main.c
    -rw-r--r-- 1 adrizcorp adrizcorp  7696 Feb 24 01:54 main.c.o
    -rwxr-xr-x 1 adrizcorp adrizcorp 42856 Feb 24 01:54 main.elf
    -rw-r--r-- 1 adrizcorp adrizcorp   141 Feb 23 15:08 makefile
    -rw-r--r-- 1 adrizcorp adrizcorp  3704 Feb 24 01:54 neorv32_application_image.vhd
    -rw-r--r-- 1 adrizcorp adrizcorp  1024 Feb 24 01:54 neorv32_exe.bin
    -rw-r--r-- 1 adrizcorp adrizcorp  1012 Feb 24 01:54 neorv32_raw_exe.bin
    -rw-r--r-- 1 adrizcorp adrizcorp  2277 Feb 24 01:54 neorv32_raw_exe.hex
    ```    