i've been trying to play with cpu design on sipeed fpga's and i'm really struggling with none of the gw5a parts having working ssram but running out of space on gw2a. managed to dual core rv32 on gw2a, then struggle on tang console 60k with the balance between luts and hitting routing limits vs bram. i'm curious if you tried pushing any of this far on sipeed parts or basically gave up with the lack of sram.
i have tang primer 25k, tang mega 138k, tang console 60k, and tang console 138k.
none have working ssram. apparently some of them may have had post-release ones but it seems that the tang console 138k shipped with the old revision still.
so my attention has moved towards the idea of jit/dbt and doing pipeline decode and so forth hoping that can process stuff quicker with the inability to have large caches due to routing pressure from larger caches impeding both clock rates and ability to fit. i realise it's kind of nice being predictable with times though for compatability and so forth, but the idea of doing full x86 on a cpu core is scary with all the edge cases. i've got basic x86 and rv32imac translation working with preprocessing, and managed to do well on coremark hitting sram, but scaling that to wider workloads with slower memory etc is pretty non-linear i suspect.
i'm curious what is good for benchmarking in between super complex workloads and super simple; atm i've only gone as far as simple checks/tests, coremark, zstd, and starting to look at parts of my compiler, but i have my own dos emulator with built in x86 cpu emulation, it's like my 3rd or 4th dos project, before that i tried v86 mode etc, but cpu emulation really is easier to debug, with interpreter or x86_64 jit (much easier to do x86 on x86_64 than other systems) so i can cluster out simple functions or such to test (my dos emulator actually is inspecting executables and running them and and can for instance replace turbo pascal overlay system, and it's easy to do turbo pascal programs to do a specific functional benchmark and test that component.
i both hate x86 and really want to do better on x86 at the same time, and was fascinated by the idea of the likes of z486/486tang, but it seemed kind of sluggish, and i kind of made my own x11 based remote keyboard/mouse app for it, but the mouse wasn't quite working well and i had no working netowrk and quickly moved on. i can't even remember if it had network, but i was in straight dos, i've got working network over usb2 on tang console i suppose potentially do some coexist thing, but i didn't manage to get linux to work on the ae350 cpu core even though it works on my network boot sbi system. but like every time i go down the path of all of this stuff i'm like i want network storage, network upload/download of files, restart, remote control etc.
the idea of using lockstep to do cpu development is how i managed my 68k cpu core originially but i did rv32 without, and i only did rv32 as a distraction after 68k being complex was getting frustrating. and 68k is easier than x86 :) even after using test386.asm on my x86 interpreter i kept hitting bugs and things not quite working right, and windows 98 was kind of fiddly, and then os/2 had it's own issues. i've been doing virtio-blk and virtio-net with os/2 and windows 98 to expose disk/network and replaced the tcp/ip stack on both of them to get better offload for running in virtual machine or my dos emulator, and did linux on the sipeed fgpa's with virtio-blk/virto-net from my custom smbi supervisor so that i didn't need linux to see microsd/my weird ethernet. but potentially doing similar for x86 type os could work well, i suspect they'd struggle with normal speeds too, i'm at 100 megabit on tang primer 20k, and up to like 120 to 170 megabit/sec on console 60k depending on cpu for the netboot part.
I've had similar experiences with the Gowin parts. The original z386 actually ran on the Tang 138K before I moved development to the DE10-Nano. Missing SSRAM, routing congestion and achievable clock speeds were all challenges. Also for larger designs, Xilinx toolchains and parts are still somewhat superior.
For benchmarking, I find DOS games quite useful as intermediate workloads. 3DBench, Doom, and Quake exercise different aspects of the CPU and memory subsystem, and simulating these with Verilator is still feasible. After that I go to Windows and Linux as system/protected mode workloads. Dhrystone is also useful for measuring integer IPC, although it's a much simpler workload.
I can definitely relate to the love-hate relationship with x86. The sheer complexity makes it frustrating, but getting decades-old software to run correctly on a CPU you designed yourself is satisfying.
The P6 does something quirky with its instruction cache, at least according to the patents. There's a 2-way L1 cache + a victim cache, and all prefetched instructions + all µops in the system have to come from bytes that are still in that L1 + victim cache. That allows the P6 to correctly refetch the exact same bytes and decode them to the exact same µops if it ever needs to -- which it sometimes does, for some reason I don't quite understand yet. The early NexGen/AMD patents also talk about refetching and redecoding but without documenting a system that would ensure the refetching would be exact.
That system is also used to detect self-modifying code -- all writes are checked against the L1 + victim cache and if there is a match, then the whole reordering machine gets flushed. It's really just a way to get to use fewer, narrower comparators.
The victim cache and the µop system cooperate in order to free up place in the victim cache once the µops that correspond to a line are gone from the system. That is done by sending a special µop through the system (that's what the relevant patent implies). Once that µop retires (or that group of µops? the mechanism isn't spelled out in detail), the corresponding victim cache line is freed.
How much of that is simulated by your system?
---
The µop width is implied to be somewhere around 116 bits (from memory) in one or two of the patents, but what the reverse engineers found was something a lot narrower. Do you have a theory that explains it?
---
Do you know why they bothered to have TRANSPORTUIP when they could have used a move-immediate µop instead?
The specific projects on your site (including this one), what made you decide to pursue those? I guess I'm asking to shed some light on the journey that got you into this stuff?
It started with NESTang (NES for Sipeed Tang FPGAs), which was mostly driven by curiosity about how the Nintendo NES worked. I gradually moved on to more sophisticated game consoles. The GBA project was particularly fun, as I had to adapt a new CPU core to make it work on the Tang FPGA. Since then, CPU design itself became the main focus, and that's what led to the x86 projects.
No questions just came here to say nand2mario you're a legend! I don't care about retro gaming whatsoever, but I did enjoy your writing, it's very instructive, and learned lots about SV design from your blog. I've been slowly trying to wrap my head around NIC designs on VCU1525 board, or rather banging my head against Vivado. It would help LOTS if you went into how you're dealing with Vivado yourself. So very little resources on it, and LLM's are not too much help unfortunately.
i've been trying to play with cpu design on sipeed fpga's and i'm really struggling with none of the gw5a parts having working ssram but running out of space on gw2a. managed to dual core rv32 on gw2a, then struggle on tang console 60k with the balance between luts and hitting routing limits vs bram. i'm curious if you tried pushing any of this far on sipeed parts or basically gave up with the lack of sram.
i have tang primer 25k, tang mega 138k, tang console 60k, and tang console 138k. none have working ssram. apparently some of them may have had post-release ones but it seems that the tang console 138k shipped with the old revision still.
so my attention has moved towards the idea of jit/dbt and doing pipeline decode and so forth hoping that can process stuff quicker with the inability to have large caches due to routing pressure from larger caches impeding both clock rates and ability to fit. i realise it's kind of nice being predictable with times though for compatability and so forth, but the idea of doing full x86 on a cpu core is scary with all the edge cases. i've got basic x86 and rv32imac translation working with preprocessing, and managed to do well on coremark hitting sram, but scaling that to wider workloads with slower memory etc is pretty non-linear i suspect.
i'm curious what is good for benchmarking in between super complex workloads and super simple; atm i've only gone as far as simple checks/tests, coremark, zstd, and starting to look at parts of my compiler, but i have my own dos emulator with built in x86 cpu emulation, it's like my 3rd or 4th dos project, before that i tried v86 mode etc, but cpu emulation really is easier to debug, with interpreter or x86_64 jit (much easier to do x86 on x86_64 than other systems) so i can cluster out simple functions or such to test (my dos emulator actually is inspecting executables and running them and and can for instance replace turbo pascal overlay system, and it's easy to do turbo pascal programs to do a specific functional benchmark and test that component.
i both hate x86 and really want to do better on x86 at the same time, and was fascinated by the idea of the likes of z486/486tang, but it seemed kind of sluggish, and i kind of made my own x11 based remote keyboard/mouse app for it, but the mouse wasn't quite working well and i had no working netowrk and quickly moved on. i can't even remember if it had network, but i was in straight dos, i've got working network over usb2 on tang console i suppose potentially do some coexist thing, but i didn't manage to get linux to work on the ae350 cpu core even though it works on my network boot sbi system. but like every time i go down the path of all of this stuff i'm like i want network storage, network upload/download of files, restart, remote control etc.
the idea of using lockstep to do cpu development is how i managed my 68k cpu core originially but i did rv32 without, and i only did rv32 as a distraction after 68k being complex was getting frustrating. and 68k is easier than x86 :) even after using test386.asm on my x86 interpreter i kept hitting bugs and things not quite working right, and windows 98 was kind of fiddly, and then os/2 had it's own issues. i've been doing virtio-blk and virtio-net with os/2 and windows 98 to expose disk/network and replaced the tcp/ip stack on both of them to get better offload for running in virtual machine or my dos emulator, and did linux on the sipeed fgpa's with virtio-blk/virto-net from my custom smbi supervisor so that i didn't need linux to see microsd/my weird ethernet. but potentially doing similar for x86 type os could work well, i suspect they'd struggle with normal speeds too, i'm at 100 megabit on tang primer 20k, and up to like 120 to 170 megabit/sec on console 60k depending on cpu for the netboot part.
I've had similar experiences with the Gowin parts. The original z386 actually ran on the Tang 138K before I moved development to the DE10-Nano. Missing SSRAM, routing congestion and achievable clock speeds were all challenges. Also for larger designs, Xilinx toolchains and parts are still somewhat superior.
For benchmarking, I find DOS games quite useful as intermediate workloads. 3DBench, Doom, and Quake exercise different aspects of the CPU and memory subsystem, and simulating these with Verilator is still feasible. After that I go to Windows and Linux as system/protected mode workloads. Dhrystone is also useful for measuring integer IPC, although it's a much simpler workload.
I can definitely relate to the love-hate relationship with x86. The sheer complexity makes it frustrating, but getting decades-old software to run correctly on a CPU you designed yourself is satisfying.
Author here. Happy to discuss FPGA development and retro CPU design.
The P6 does something quirky with its instruction cache, at least according to the patents. There's a 2-way L1 cache + a victim cache, and all prefetched instructions + all µops in the system have to come from bytes that are still in that L1 + victim cache. That allows the P6 to correctly refetch the exact same bytes and decode them to the exact same µops if it ever needs to -- which it sometimes does, for some reason I don't quite understand yet. The early NexGen/AMD patents also talk about refetching and redecoding but without documenting a system that would ensure the refetching would be exact.
That system is also used to detect self-modifying code -- all writes are checked against the L1 + victim cache and if there is a match, then the whole reordering machine gets flushed. It's really just a way to get to use fewer, narrower comparators.
The victim cache and the µop system cooperate in order to free up place in the victim cache once the µops that correspond to a line are gone from the system. That is done by sending a special µop through the system (that's what the relevant patent implies). Once that µop retires (or that group of µops? the mechanism isn't spelled out in detail), the corresponding victim cache line is freed.
How much of that is simulated by your system?
---
The µop width is implied to be somewhere around 116 bits (from memory) in one or two of the patents, but what the reverse engineers found was something a lot narrower. Do you have a theory that explains it?
---
Do you know why they bothered to have TRANSPORTUIP when they could have used a move-immediate µop instead?
Great stuff, very impressive!
The specific projects on your site (including this one), what made you decide to pursue those? I guess I'm asking to shed some light on the journey that got you into this stuff?
It started with NESTang (NES for Sipeed Tang FPGAs), which was mostly driven by curiosity about how the Nintendo NES worked. I gradually moved on to more sophisticated game consoles. The GBA project was particularly fun, as I had to adapt a new CPU core to make it work on the Tang FPGA. Since then, CPU design itself became the main focus, and that's what led to the x86 projects.
No questions just came here to say nand2mario you're a legend! I don't care about retro gaming whatsoever, but I did enjoy your writing, it's very instructive, and learned lots about SV design from your blog. I've been slowly trying to wrap my head around NIC designs on VCU1525 board, or rather banging my head against Vivado. It would help LOTS if you went into how you're dealing with Vivado yourself. So very little resources on it, and LLM's are not too much help unfortunately.