Files
Basys3RiscV/include/basys3.h
T
brad ArantandClaude Opus 5.5 5930b958b4 Basys 3 RISC-V computer
The Basys 3 Z-80 computer with the Z-80 replaced by an RV32IM processor
written from scratch (rtl/rv32_cpu.v): multi-cycle, 90 MHz, CSRs and
traps, interrupts, two hardware triggers and a resumable NMI for the
monitor. Passes riscv-tests rv32ui/um/mi.

rv32_system.v keeps all the Z-80 machine's peripherals, with I/O port N
at FFFFFF00h + N, 80 KB of RAM with BASIC preloaded, and a 32 KB monitor
ROM. BASIC, the five games and the monitor (with an RV32 disassembler,
assembler, breakpoints and single step) are ported to RISC-V GCC. Python
emulator and tests in tools/; full-system simulation in sim/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 18:09:18 -08:00

30 lines
1.4 KiB
C

/* The Basys 3 RISC-V computer's I/O, for C programs (see rtl/rv32_system.v).
*
* Port N of the Z-80 machine is the byte at FFFF_FF00 + N, so IO8(0x01) = c
* compiles to one store relative to x0. The 32-bit registers are at
* FFFF_FE00 + N. */
#ifndef BASYS3_H
#define BASYS3_H
#define IO8(n) (*(volatile unsigned char *)(0xFFFFFF00u + (n)))
#define IO32(n) (*(volatile unsigned int *)(0xFFFFFE00u + (n)))
#define IO_MS IO32(0x00) /* milliseconds since reset */
#define IO_US IO32(0x04) /* microseconds since reset */
#define IO_TIMECMP IO32(0x08) /* timer interrupt when IO_US reaches it */
#define IO_BP0 IO32(0x10) /* monitor breakpoint addresses */
#define IO_BP1 IO32(0x14)
#define ROM_TOP 0x0000A000u /* BASIC's code below: the hardware ignores writes */
#define ARENA_BASE 0x0000A000u /* BASIC's program area */
#define GAME_BASE 0x0000A200u /* machine-code programs loaded into it */
#define MC_FREE 0x00012000u /* 12000h-12FFFh: free for machine code */
#define MON_BASE 0x00020000u /* the monitor: NMI entry */
#define MON_TRAP 0x00020004u /* the monitor's trap entry (mtvec) */
/* BASIC's clock, set by DATE, at a fixed place the monitor can read */
#define CLK_SEC (*(volatile unsigned int *)0x13FF8u) /* seconds since 2000 */
#define CLK_MS (*(volatile int *)0x13FFCu) /* IO_MS at CLK_SEC */
#endif