For the first time in a while, I am connecting my own CPU core to LiteX and running simulations. The FPGA environment is coming together somehow, so I figure that if I can confirm the BIOS runs in simulation, things will be more or less fine for now.
There are a lot of things that need to be changed, and I am checking them while looking at waveforms. The LiteX execution environment itself has to include my own CPU's environment as a sub-repository. Keeping the repositories in sync every time is a hassle.
With the command below, I set things up so that I can capture waveforms up to a certain point.
litex_sim --cpu-type=scariv --trace --trace-fst --trace-start 0 --trace-end 1000000000000
[clocker] sys_clk: freq_hz=1000000, phase_deg=0
------------------------------------------------------------
,------. ,--. ,--.
| .--. ' ,---. ,--,--. | | ,---. ,---. `--' ,---.
| '--'.'| .-. |' ,-. | | | | .-. | .-. |,--.| .--'
| |\ \ ' '-' '\ '-' | | '--.' '-' ' '-' || |\ `--.
`--' '--' `---' `--`--' `-----' `---' `- /`--' `---'
`---'
RISC-V Platform Level Interrupt Controller
- Configuration Report -------------------------------------
Sources | Targets | Priority-lvl | Threshold? | Event-Cnt
8 | 1 | 8 | YES | 8
- Register Map ---------------------------------------------
Address Function Mapping
0x00000000 Interrupt Priority 96'h0,1'b0,P[7][2:0],1'b0,P[6][2:0],1'b0,P[5][2:0],1'b0,P[4][2:0],1'b0,P[3][2:0],1'b0,P[2][2:0],1'b0,P[1][2:0],1'b0,P[0][2:0]
0x00000010 ID 124'h0, ID[1][3:0]
0x00000020 ID 124'h0, ID[2][3:0]
0x00000030 ID 124'h0, ID[3][3:0]
0x00000040 ID 124'h0, ID[4][3:0]
- End Configuration Report ---------------------------------
<DUMP ON><CLOSED OFF>%
It stops at the point above, and the instruction log stops at the following place.
2754626000000 ( 8, 2) PC=0x0000002dc6: 0107a023 sw a6, 0(a5) 2754627000000 ( 9, 1) PC=0x0000002dca: 0000a029 c.j pc + 10 GPR[ 0](00) <= 0000000000000000 2754628000000 (10, 1) PC=0x0000002dd4: 00008082 ret GPR[ 0](00) <= 0000000000000000 2754641000000 (11, 1) PC=0x000000062e: 00000405 c.addi s0, 1 GPR[ 8](02) <= 0000000000002ff1 2754653000000 (12, 1) PC=0x0000000630: 0000bf61 c.j pc - 104 GPR[ 0](00) <= 0000000000000000 2754691000000 (13, 1) PC=0x00000005c8: 00044503 lbu a0, 0(s0) GPR[10](24) <= 000000000000004c 2754691000000 (13, 2) PC=0x00000005cc: 0000ed39 c.bnez a0, pc + 94 2754692000000 (14, 1) PC=0x000000062a: 738020ef jal pc + 0x2738 GPR[ 1](08) <= 000000000000062e 2754693000000 (15, 1) PC=0x0000002d62: 20000637 lui a2, 0x20000 GPR[12](2d) <= 0000000020000000 2754693000000 (15, 2) PC=0x0000002d66: 22062783 lw a5, 544(a2) GPR[15](19) <= 0000000000000000 2754694000000 ( 0, 1) PC=0x0000002d6a: 00002785 c.addiw a5, 1 GPR[15](0b) <= 0000000000000001 2754695000000 ( 1, 1) PC=0x0000002d6c: 07f7f793 andi a5, a5, 127 GPR[15](1c) <= 0000000000000001 2754701000000 ( 2, 1) PC=0x0000002d70: 30002773 csrr a4, mstatus GPR[14](28) <= 0000000a00000008 2754726000000 (10, 1) PC=0x0000002d74: 00008b21 c.andi a4, 8 GPR[14](0b) <= 0000000000000008 2754728000000 (11, 1) PC=0x0000002d76: 200006b7 lui a3, 0x20000 GPR[13](0c) <= 0000000020000000 2754728000000 (11, 2) PC=0x0000002d7a: 0000cb29 c.beqz a4, pc + 82
The problem with LiteX is that there is no verification environment for configurations with a CPU attached, so I have to check the behavior myself. Since my own CPU is still being debugged at the same time, this is rather tough. It would be nice to extend this area a bit with things specific to my own CPU...
0000000000002d62 <uart_write>:
2d62: 20000637 lui a2,0x20000
2d66: 22062783 lw a5,544(a2) # 20000220 <tx_produce>
2d6a: 2785 addiw a5,a5,1
2d6c: 07f7f793 andi a5,a5,127
2d70: 30002773 csrr a4,mstatus
2d74: 8b21 andi a4,a4,8
2d76: 200006b7 lui a3,0x20000
2d7a: cb29 beqz a4,2dcc <uart_write+0x6a>
2d7c: 21c6a703 lw a4,540(a3) # 2000021c <tx_consume>
2d80: fef70ee3 beq a4,a5,2d7c <uart_write+0x1a>
2d84: 0c0025b7 lui a1,0xc002
2d88: 4198 lw a4,0(a1)
2d8a: ffe77813 andi a6,a4,-2
For now, it looks like it is writing something to the UART.

This is an English translation of the original Japanese post: LiteXによるSoC環境構築を試行する (久々の環境更新)
