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>
This commit is contained in:
commit
5930b958b4
103 files changed
+55677
No files matched your search
@@ -0,0 +1,75 @@
|
||||
/* The few string functions the programs use, small rather than fast
|
||||
(newlib's versions pull in its stdio and malloc). */
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
void *memcpy(void *d, const void *s, size_t n)
|
||||
{
|
||||
unsigned char *p = d;
|
||||
const unsigned char *q = s;
|
||||
while (n--) *p++ = *q++;
|
||||
return d;
|
||||
}
|
||||
|
||||
void *memmove(void *d, const void *s, size_t n)
|
||||
{
|
||||
unsigned char *p = d;
|
||||
const unsigned char *q = s;
|
||||
if (p < q) while (n--) *p++ = *q++;
|
||||
else { p += n; q += n; while (n--) *--p = *--q; }
|
||||
return d;
|
||||
}
|
||||
|
||||
void *memset(void *d, int c, size_t n)
|
||||
{
|
||||
unsigned char *p = d;
|
||||
while (n--) *p++ = (unsigned char)c;
|
||||
return d;
|
||||
}
|
||||
|
||||
int memcmp(const void *a, const void *b, size_t n)
|
||||
{
|
||||
const unsigned char *p = a, *q = b;
|
||||
for (; n; n--, p++, q++) if (*p != *q) return *p - *q;
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t strlen(const char *s)
|
||||
{
|
||||
const char *p = s;
|
||||
while (*p) p++;
|
||||
return p - s;
|
||||
}
|
||||
|
||||
int strcmp(const char *a, const char *b)
|
||||
{
|
||||
while (*a && *a == *b) { a++; b++; }
|
||||
return (unsigned char)*a - (unsigned char)*b;
|
||||
}
|
||||
|
||||
char *strcpy(char *d, const char *s)
|
||||
{
|
||||
char *p = d;
|
||||
while ((*p++ = *s++));
|
||||
return d;
|
||||
}
|
||||
|
||||
char *strcat(char *d, const char *s)
|
||||
{
|
||||
strcpy(d + strlen(d), s);
|
||||
return d;
|
||||
}
|
||||
|
||||
int strncmp(const char *a, const char *b, size_t n)
|
||||
{
|
||||
for (; n; n--, a++, b++)
|
||||
if (*a != *b || !*a) return (unsigned char)*a - (unsigned char)*b;
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *strrchr(const char *s, int c)
|
||||
{
|
||||
const char *r = 0;
|
||||
do if (*s == (char)c) r = s; while (*s++);
|
||||
return (char *)r;
|
||||
}
|
||||
Reference in new issue
Block a user