This Repository Guides you to complete ASIC flow from scratch (GUIDE : Kunal Ghosh)
Update
sudo apt update
sudo apt upgrade
chmod +x run_ubuntu.sh
./run_ubuntu.sh
The installed contents will be available at ~/riscv_toolchain
- HLL -> High level language (c , c++)
- ALP -> Assembly level program
- HDL -> Hardware Description Language
- GDS -> Graphic Data System (layout)
The Hardware needs to understand what the Application software is saying it to do.This relation can be eshtablished by System Software
System Software
- OS : Operating System : Handles IO, memory allocation, Low level system function
- Compiler : Convert the input to hardware dependent instruction
- Assembler : Convert the instructions provided by compiler to Binary format
- HDL : A program that understands the Binary pattern and map it to a netlist
- GDS : Layout
DAY 1
Compile it using C compiler
gcc sum_1_to_N.c -o 1_to_N.o
./1_to_N.o
-o allows you to name your output file
compile using riscv compieler and view the output
riscv64-unknown-elf-gcc -O1 -mabi=lp64 -march=rv64i -o 1_to_N.o sum_1_to_N.c
spike pk 1_to_N.o
- -Onumber : level of optimisation required
- -mabi : specifies the ABI (Application Binary Interface) to be used during code generation according to the requirements
- -march : specifies target architecture
We can check the different options available for all these fields using the commands go to the directory where riscv64-unkonwn-elf is present
- -O1 :
riscv64-unkonwn-elf --help=optimizer
- -mabi :
riscv64-unknown-elf-gcc --target-help
- -march :
riscv64-unknown-elf-gcc --target-help
To view the disassembled ALP code
riscv64-unkonwn-elf-objdump -d 1_to_N.o
To debug the ALP generated by the compiler
spike -d pk 1_to_N.o
- press ENTER : shows the first line and successive ENTER shows successive lines
- reg 0 a2 : checks content of register a2 0th core
- q : quit the debug process
- use the command
riscv64-unknown-elf-objdump -d 1_to_N.o | less
- use
/instance
to search for an instance - press ENTER
- press
n
to search next occurance - press
N
to search for previous occurance. - use
esc :q
to quit
Contents of main when used -O1 optimizer
contents of main when used -Ofast optimizer
Range of Unsigned numbers : [0, (2^n)-1 ] Range of signed numbes : Positive : [0 , 2^(n-1)-1] Negative : [-1 to 2^(n-1)]
2. create a C program that shows the maximum and minimum values of 64bit unsigend and signed numbers
sign_unsign.c
![sign_snsign_compiled]
DAY 2
Instructions that act on signed or unsigned integers are called Base Integer Instructions There are 47 Base Integer Instructions present in RISC-V ISA
The instructions generated by compiler using a target ISA can be accessed by OS and User directly
- The parts of ISA accessible to User : User ISA
- The parts of ISA accessible to OS : system ISA The access is done using Sysytem calls with the help of ABI
==> If we want to access hardware resources of processor, it has to be done via registers using ABI
- Directly store in registers
- Store into registers from memory
To store 64 bits of data from mem to reg, we use 8*8bit stores ie., m[0],m[1]......m[7].
The load, add, store etc instructions have different representation formats
Pass The inputs to C program using Registers
The required program files are under day 2 folder
Here we can observe that at 5th line, inorder to comute the result ,its going to the "load" function