Closed fatalfeel closed 3 years ago
Hi,
Instead of modifying those files, i would say create a additional plugin to add the instruction.
See one example here : https://github.com/SpinalHDL/VexRiscv#add-a-custom-instruction-to-the-cpu-via-the-plugin-system
thanks man done from ur example. i wrote full step here https://fatalfeel.blogspot.com/2013/12/risc-v-on-arty-a7-35t.html
////////////////////////////successful and share code here///////////////////////////
//by dolu asm(".set abiname_zero, 0"); asm(".set abiname_ra , 1"); asm(".set abiname_sp , 2"); asm(".set abiname_gp , 3"); asm(".set abiname_tp , 4"); asm(".set abiname_t0 , 5"); asm(".set abiname_t1 , 6"); asm(".set abiname_t2 , 7"); asm(".set abiname_s0 , 8"); asm(".set abiname_s1 , 9"); asm(".set abiname_a0 , 10"); asm(".set abiname_a1 , 11"); asm(".set abiname_a2 , 12"); asm(".set abiname_a3 , 13"); asm(".set abiname_a4 , 14"); asm(".set abiname_a5 , 15"); asm(".set abiname_a6 , 16"); asm(".set abiname_a7 , 17"); asm(".set abiname_s2 , 18"); asm(".set abiname_s3 , 19"); asm(".set abiname_s4 , 20"); asm(".set abiname_s5 , 21"); asm(".set abiname_s6 , 22"); asm(".set abiname_s7 , 23"); asm(".set abiname_s8 , 24"); asm(".set abiname_s9 , 25"); asm(".set abiname_s10 , 26"); asm(".set abiname_s11 , 27"); asm(".set abiname_t3 , 28"); asm(".set abiname_t4 , 29"); asm(".set abiname_t5 , 30"); asm(".set abiname_t6 , 31"); //word func7 rs2 rs1 func3 rd opc
asm volatile \ ( \ ".word ((0b0000000 << 25) | (abiname%2 << 20) | (abiname%1 << 15) | (0b000 << 12) | (abiname_%0 << 7) | 0b0110011) \n\t" \ : "=r"(result) \ : "r" (src1), "r" (src2) \ )
//word func7 rs2 rs1 func3 rd opc
asm volatile \ ( \ ".word ((0b0000011 << 25) | (abiname%2 << 20) | (abiname%1 << 15) | (0b000 << 12) | (abiname_%0 << 7) | 0b0110011) \n\t" \ : "=r"(result) \ : "r" (src1), "r" (src2) \ )
void print(const charstr){ while(str){ uart_write(UART,*str); str++; } }
void hello_print(const char*str){ print(str); uart_write(UART,'\r'); uart_write(UART,'\n'); }
void delay(uint32_t loops){ for(int i=0;i<loops;i++){ int tmp = GPIO_A->OUTPUT; } }
void main() { const int nleds = 4; const int nloops = 2000000;
unsigned int src1 = 0x11111111;
unsigned int src2 = 0x22222222;
unsigned int outputa= 0xEEEEEEEE;
unsigned int outputb= 0xFFFFFFFF;
hello_print("hello world arty-a7 35t");
GPIO_A->OUTPUT_ENABLE = 0x0000000F;
GPIO_A->OUTPUT = 0x00000001;
while(1){
for(unsigned int i=0;i<nleds-1;i++){
GPIO_A->OUTPUT = 1<<i;
delay(nloops);
}
hello_print("hello led loop section 1");
RISC_ADD(src1, src2, outputa);
SIMD_ADD(src1, src2, outputb);
if( outputa == outputb )
hello_print("outputa == outputb");
else
hello_print("outputa != outputb");
for(unsigned int i=0;i<nleds-1;i++){
GPIO_A->OUTPUT = (1<<(nleds-1))>>i;
delay(nloops);
}
hello_print("hello led loop section 2");
RISC_ADD(src1, src2, outputa);
SIMD_ADD(src1, src2, outputb);
if( outputa == outputb )
hello_print("outputa == outputb");
else
hello_print("outputa != outputb");
}
}
void irqCallback(){ }
Cool thanks ^^
If i want to add a new instruction EX: "ADDOR"
A+B = C C = A | C return C
/root/riscv_cpu/VexRiscv/src/main/scala/vexriscv/Riscv.scala /root/riscv_cpu/VexRiscv/src/main/scala/vexriscv/plugin/IntAluPlugin.scala
I need modify the two files right? Do I need modify another files?