RP6502-FPGA

RP6502 - Field Programmable Gate Array

Note

The FPGA is new and will have better documentation later.

Introduction

The RP6502-FPGA is the machine in fabric, a Picocomputer 6502 in programmable logic. The 65C02, the 65C22, the registers of the RIA, the VGA video renderer and the sound generators are RTL. The rest of the RIA is software, which runs on a Hazard3 RISC-V soft CPU. It keeps the split between a 6502 and a host that handles modern I/O, which is what defines a Picocomputer.

The Analogue Pocket Core

The Pocket core is the entire machine on a handheld. It has every video mode, the PSG and the OPL2, the dock, the keyboard layouts, the mouse, sleep, the memories, and the microSD card, which is the filesystem and is named FS:.

Install

Copy Cores, Platforms, Saves, and Assets onto the microSD card in the same folder structure. They merge with what’s already there, and nothing replaces another core’s files. Then open the core from the Pocket menu under openFPGA.

ROMs

Put .rp6502 files in Assets/rp6502/common/, and pick one from the list shown when the core opens. Find them on Discord, which has a forum for ROMs, or on itch.io under the RP6502 tag:

Assets/rp6502/common/ is also the working directory, so a program opens a file beside its ROM by its plain name. The working directory cannot be changed on the Pocket.

Saves

A program saves through SAVE:, as shown in Saves, and the core keeps those files in Saves/rp6502/common/. A successful syncfs does not mean the data is on the card, because the Pocket sends no reply once the data is written. The calls the Pocket lacks, such as folder listing, are listed under Compatibility.

Core Settings

  • Keyboard selects the layout.

  • UTC offset is three entries: a side, an hour, and a quarter hour. The Pocket has no time zones, so the offset and DST changes have to be set by hand. A list limit of sixteen options forces the split.

The Dock

The Pocket supports four controller slots, and the core passes all four to the RIA software as HID reports of buttons and axes. Keyboard and mouse is fully supported as well.

Internals

┌─ the Pocket ─ APF shell, core_bridge_cmd ─── clk_74a 74.25 MHz ─────┐
│ data slots · savestate · RTC · four controller slots · the scaler · │
│ the I2S codec · the pad ring. Analogue's, unmodified.               │
└──┬───────────────────────────────────────────────────────────┬──────┘
   │ bridge writes, target commands, controller state          │
   │                                     picture, sound, log   │
┌──┴───────────────────────────────────────────────────────────┴──────┐
│ src/host/pocket — the wrapper                     clk_sys 50.4 MHz  │
│ pocket_bridge  pocket_file  pocket_sst   pocket_video  pocket_i2s   │
│ pocket_sdram   pocket_sram  pocket_dbg   pocket_dbglog  pocket_fifo │
│ pocket_bars    pocket_pll: clk_sys ──> altclkctrl ──> clk_mach      │
│                pocket_pll: clk_a2 100.8 MHz, XRAM's render port     │
│                                                                     │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ src/core — the machine, platform independent                    │ │
│ │                                                                 │ │
│ │  ┌────────┐       ┌────────┐   w65c22 VIA at $FFD0-$FFDF        │ │
│ │  │ w65c02 ├───────┤ w65c22 │          RIA at $FFE0-$FFFF        │ │
│ │  └───┬────┘       └────────┘                                    │ │
│ │      │                                                          │ │
│ │  ┌───┴────┐                                                     │ │
│ │  │ria_regs│   phi2_div makes PHI2 — 0.1 to 8.0 MHz, exact       │ │
│ │  └───┬────┘                                                     │ │
│ │      │                                                          │ │
│ │  ┌───┴─────────────────────────────────┐  clk_rv 25.2 MHz —     │ │
│ │  │ rv_soc — Hazard3 RISC-V, 96 KB TCM  │  half clk_sys, off the │ │
│ │  │ a trimmed build of the RIA software │  PLL, rising with it   │ │
│ │  └───┬─────────────────────────────────┘                        │ │
│ │      │ one system bus, one master                               │ │
│ │  xram      vid_timing  vid_prog  vid_sched  vid_fill  vid_mode  │ │
│ │  vid_mode0 vid_mode1 vid_mode2 vid_mode3 vid_mode4 vid_mode5    │ │
│ │  vid_pixtail  vid_sprite  vid_sbuf  vid_palcache  vid_palram    │ │
│ │  vid_font  vid_compose   aud_psg  aud_opl  aud_rsmp             │ │
│ │  sst_engine, the serializer, on clk_sys, never gated            │ │
│ └────┬────────────────────────────────┬───────────────────────────┘ │
│      │ stage port,                    │ ram_a is the 6502's port,   │
│      │ through pocket_sdram           │ ram_b the soft CPU's window,│
│      │                                │ both through pocket_sram    │
└──────┼────────────────────────────────┼─────────────────────────────┘
       │                                │
┌──────┴───────┐                 ┌──────┴──────────┐
│ 64 MB SDRAM  │                 │ 256 KB SRAM     │  asynchronous,
│ staging store│                 │ the 6502's 64 KB│  55 ns access
│ ROM, fonts,  │                 └─────────────────┘
│ code pages,  │                 the board's third chip, 16 MB of
│ layouts      │                 PSRAM, is tied off and unused
└──────────────┘

The RISC-V runs at half speed because its frontend is the one block that can’t make 50.4 MHz. The performance of this processor is not critical, because it only has to keep up with I/O to the Pocket.

MiSTer

Planned. The project needs a significant amount of review and reorganization before additional platforms get added.