Close
0%
0%

MRC6502 - Modular Retro Computer

MRC6502 is a fantastic opportunity to learn more about digital electronics and 6502 assembly programming... step by step.

Similar projects worth following
The purpose of this project is to create a modular 6502 system with 64Kb of RAM, 32Kb of ROM, I/O (video, audio, SPI, serial).
An Arduino Mega can be used as code debugger, memory inspector and programmer to help you to develop the firmware and learn 6502 assembly.
Modularity means that any module (CPU, I/0, Video, Audio) is realized on a own single board and hosted on the motherboard: we can try and make experiments with different Video and Audio chips.

Target system features:

  • 64Kb RAM (full addressable on write, visible on read banking out ROM)
  • 32Kb ROM (not necessary for first firmware developing phase: full RAM operations)
  • programmable glue logic (PLD)
  • modularity for CPU, I/O, video and audio controllers
  • arduino as debugger, memory inspector and injector, code loader, execution stepper
  • 2 clock speeds switchable at runtime: slow (arduino driven) and fast (4 MHZ fosc)
  • configurable breakpoints at slow speed (arduino controlled) to stepping execution code
  • SPI and serial I/O
  • PS/2 keyboard
  • SD card as storage device

Constraints:

  • through-hole only components
  • 4Mhz CPU clock
  • WDC W65C02S CPU

Software developing:

  • cross IDE and assembler
  • direct RAM programming (no need to remove and program the ROM for each code modification)
  • stepping execution and breakpoints

  • The Arduino Mega shield

    padnest02/14/2022 at 10:17 0 comments

    I designed this shield to easily connect the Arduino Mega to the MRC6502 system.

     It has pass through headers for bus signals, control buttons and a socket for an additional usb serial module.

    • 40 pin male header to connect the MRC6502 mother board (1)
    • Arduino power supply selector (2)
    • power rails header (3)
    • CP-2102 usb serial module socket (4)
    • reset button (5)
    • CPU execution control buttons (6)
    • extra function buttons (7)

    Connections

    Arduino can access to the system bus in order to control the CPU execution, read and write memory and devices registers, generate slow system clock or enable fast board clock generator.

    Arduino used ports are:

    • PORT L (bidirectional) ==> bus data lines
    • PORT A (bidirectional) ==> low bus address lines
    • PORT C (bidirectional) ==> high bus address lines
    • PORT B:
      • bit 0 (output) ==> bus IRQ line
      • bit 1 (input) ==> bus PHI2 line
      • bit 2 (output) ==> bus RST line
      • bit 3 (output) ==> bus R/W control line
    • PORT E:
      • bit 3 (output) ==> mother board A-FOSCEN control line
      • bit 4 (input) ==> bus SYNCH line
      • bit 5 (output) ==> bus NMI line
    • PORT H:
      • bit 3 (output) ==> bus BE line
      • bit 4 (output) ==> mother board A-CLK line
    • PORT G:
      • bit 5 (output) ==> bus RDY line

    Schematics: here

    See you next step.

    Ciao!

  • The I/O board

    padnest02/09/2022 at 08:14 0 comments

    A computer with no I/O capabilities doesn't do much... right?

    So here we have the I/O board that will implement these interfaces:

    • USB serial :: to communicate with a modern PC
    • SPI (TTL) :: to experiment with any external SPI device like LCD display, sensors, real time clock, etc
    • SD card :: the mass memory to read and write files
    • GPIO user port :: for whatever else we want to connect
    • P/S2 keyboard :: the primary input device

    The I/O board has:

    • User Port header for GPIO (1)
    • PS2 keyboard adapter (2)
    • two VIA W65C22N-14 for parallel and SPI comm (3)
    • one ACIA W65C51N-14 for serial comm (4)
    • SPI port header supporting two general TTL devices (5)
    • CP-2102 module socket for USB serial (6)
    • SD levels adapter module (7)
    • SD card module socket (8)

    Schematics: here

    User port (1)

    It is a GPIO port directly connected to the peripheral data ports of VIA#1.

    This port also provides the system power supply (+5v).

    PS/2 keyboard adapter (2)

    Is the logic needed to adapt a standard PS/2 keyboard protocol to the VIA#2.

    The PS/2 keyboard clock and data lines go into an external serial register (74LS164) that feeds VIA#2 with:

    • KD0-KD7 ==> the keyboard data byte received (8 bits)
    • KD-RDY ==> the keyboard data byte ready signal (when a complete data byte is received)

    VIA#2 CA1 is configured as input to fire an CPU IRQ when keyboard data byte has been received and can be processed.

    VIA#2 CA2 is configured  as output to clean the serial register in order to receive the next keyboard data event.

    Perhaps it will also be necessary to add a protection between the logic and the VIA#2 port.

    VIAs (3)

    Two WDC Versatile Interface Adapters W65C22N (datasheet) are connected to the system bus in this way:

    Each VIA has 15 internal registers that can be accessed by address llines A0-A3.

    The base address is $DA00 for VIA#1 and $DB00 for VIA#2 and the memory mapping will be:

    ACIA (4)

    The WDC Asynchronous Communications Interface Adapter W65C51N (datasheet) is connected to the bus in the same way but it has only 4 internal registers so just two address lines, A0-A1, are used:

    The ACIA base address is $DC00 and the memory mapping of internal registers will be:

    SPI port and SD card module (5 & 8)

    The SPI protocol is hardware implemented using the serial registers of the two VIAs: this allows us to have the maximum possible data transmission speed!

    CB1 is configured as serial clock output on VIA#1 and as serial clock input on VIA#2.

    CB2 is configured as serial data output (MOSI) on VIA#1 and as serial data input (MISO) on VIA#2.

    Perhaps it will also be necessary to add a protection between VIA#1 CB1 and VIA#2 CB1.

    SPI is shared between the SPI Port and the SD Card module; the SPI port has two dedicated CS lines connected to VIA#2 PB5 and PB6

    Here the popular Arduino SD Card module that I have choosen:

    Usb serial (6)

    The usb serial interface is provided by a CP-2102 usb serial module and is connected to the ACIA:

    Here the CP-2102 usb serial module I'm using:

    Stay tuned for the next step!

    Ciao!

  • The MRC6502 development tools

    padnest02/05/2022 at 16:08 0 comments

    To develop on MRC6502 I will use:

    • Visual Studio Code
    • Kick Assembler
    • Arduino IDE :: for Arduino sketch programming and serial IO to the MRC6502 system
    • Phyton + Transduino.py :: to program MRC6502 RAM via Arduino
    • WinCUPL :: to compile PLD configuration
    • TL866II plus + Xgpro/XGecu :: to program the PLD and the EEPROM

    Setup

    Visual Studio Code configuration

    • Switch to Extension view (CTRL+SHIFT+X)
    • write 'kick assembler' in the search text box and install 'Kick Assembler 8-Bit Retro Studio' by Paul Hocker
    • open the settings (CTRL+,) ; write 'kick' in the search text box and in User tab set:
      • Kickassembler › Assembler: Jar  ==> full path to the kick assembler jar file
      • Kickassembler › Assembler: Main  ==> kickass.KickAssembler
      • Kickassembler › Assembler › Option: Output Directory  ==> bin
      • Kickassembler › Assembler › Option: Source Symbols  ==> checked
      • Kickassembler › Java: Runtime  => full path to openjdk  java executable file (usually in bin subdirectory)
      • Kickassembler › Opcodes: 65c02  ==> checked
    • open the keyboard shorcuts (CTRL+K  CTRL+S); write 'kick' in the search text box and:
      • assign 'F6' for 'Kick Assembler: Build'
      • assign 'SHITF + F6' for 'Kick Assembler: Build and Debug'
      • assign 'SHITF + F5' for 'Kick Assembler: Build and Debug Startup'
      • assign 'F5' for 'Kick Assembler: Build and Run'
      • assign 'CTRL + F5' for 'Kick Assembler: Build and Run Startup'
      • assign 'CTRL + F6' for 'Kick Assembler: Build Startup'

    Ciao!

  • Timings #1 - CPU vs RAM&ROM

    padnest01/29/2022 at 07:51 0 comments

    Timings are crucial! Let's check if we can go with a 4MHz clock using 70nS SRAM and the EEPROM.

    CPU timings

    First of all I want to try to recap CPU informations about timings from the WDC W65c02s datasheet.  

    In the picture:

    • PHI2: at 4MHz clock speed each PHI2 phase lasts 125nS for a total time of 250nS.
    • CPU addr+rw: setup time for A0-A15 and RW signals is 20nS; this happens after 10nS from the PHI2 HIGH-to-LOW transition.
    • CPU read: data acquisition happens after 115nS from PHI2 LOW-to-HIGH transition and it lasts 20nS.
    • CPU write: data exposure begins after 25nS from PHI2 LOW-to-HIGH transition and it lasts 110nS.

    Let's zoom now into PHI2 HIGH phase:

    It's very important to observe what happens after the PHI2 HIGH-to-LOW transition:

    • CPU read: the CPU requires no data changes for 10ns.
    • CPU write: the CPU holds data stable for 10ns.

    PLD delay

    PLD, as you already know now, handles all the glue logic; there is a propagation delay introduced by the ATF22V10C-15 (max 15nS) but this should have no practical effects on timings.

    RAM timings

    In the next picture:

    • RAM CE: PLD select the RAM (CE goes LOW) when the address matches and PHI2 goes HIGH; this will result in a (almost ***) perfect match.
    • RAM read: RAM presents stable data after 70nS from selection (CE goes LOW) .
    • RAM write: RAM requires to have stable data after 30nS from selection (CE goes LOW) .

    (almost ***): can we have problems when RAM CE goes HIGH but CPU is still reading for additional 10nS?

    From RAM datasheet:

    When CS goes HIGH the RAM hold valid data for tCHZ time that should be from 0nS to 25nS so we need to test RAM access @4Mhz to verify if this is true and if it can be a real or a pratical problem.

    Perhaps the PLD propagation delay (15uS) could save us here, I don't know... (tests are required).

    EEPROM timings

    Let's check now the AT28C256-15 EEPROM:

    • ROM CE: PLD select the ROM (CE goes LOW) when the address matches (without considering PHI2).
    • ROM read: ROM presents stable data after 150nS from selection (CE goes LOW) .

    I have to update the PLD glue logic table applying the changes in red:

    Next step: RAM/ROM test on access

    Let me know what do you think in the comments...

    Ciao!

    PS:

    I would like to thank everyone who sent join requests for the project. I'm considering whether or not to accept some collaborations maybe a little further on. Commenting on posts is already a way to collaborate and to help me. Many many thanks!

  • The (not only) CPU board

    padnest01/28/2022 at 14:48 0 comments

    The CPU board hosts:

    • the CPU (1)
    • the RAM (2)
    • the (EEP)ROM (3)
    • the PLD (4)
    • jumpers to configure memory mapping (5)

    In this board prototype I forgot to add a jumper in order to manually select the ROM banking (RAM14).

    I will add another jumper for this scope in the next revision.

    Schematics: here

    Read more »

  • The memory map

    padnest01/24/2022 at 11:25 0 comments

    I designed the system memory mapping with these purposes in mind:

    • to have 64Kb of RAM in the bottom layer
    • to have 16Kb of ROM in the top layer
    • to have the possibility of banking out the ROM having access to the background RAM
    • any write operation on ROM is always addressed to the background RAM
    • do not waste RAM mapping I/O devices

    Memory layers: 

    Memory configurations

    Bus lines EROM1 and EROM2 are used to enable or disable ROM layers: disabling the ROM you can read from the background RAM.

    These lines can be programmatically controlled by one of the VIAs port.

    Each I/O device has 256 memory locations (one page) of space to map internal registers.

    Read more »

  • The motherboard

    padnest01/21/2022 at 07:59 0 comments

    This is essentially the board that houses the other boards (modules) and provides some basic functionalities as system clock, arduino control, power-up reset, etc.

    The motherboard has:

    • four 2x22 pins bus connectors (1)
    • one 2x20 pins arduino connector (2)
    • the power supply plug (DC 5v - 3000mA), switch and led (3)
    • some leds to show SYNCH, IRQ and NMI lines status (4)
    • the power-up reset logic and the reset button (5)
    • the system clock switcher and the fast clock generator (4Mhz) (6)

    NOTE: this is still a prototype... I may have to change something if necessary.

    A bus socket is unpopulated (for now) to easily connect the probes.

    Schematics: here

    Read more »

  • Welcome to the project

    padnest01/19/2022 at 17:05 0 comments

    Hi and thank you for following my project! I will try to post at least one update per week... stay tuned and please support this project!

    Comments and suggestions are very welcome!!!

    Next Step? 

    The motherboard details.

    Ciao!

View all 8 project logs

Enjoy this project?

Share

Discussions

diurdac wrote 09/27/2022 at 17:03 point

Hi. I like this project a lot. Please, could you to show some part of the arduino's code to access to the VIAS's, or something else?

  Are you sure? yes | no

padnest wrote 02/04/2022 at 07:08 point

WDYT #1 - How to get CPU regs values from Arduino during debugging?

What strategy we can use to inspect, from Arduino, the values of CPU internal registers (A, X, Y, status, stack pointer) when stepping the code execution?

We can play with: SYNCH, RDY, BE, PHI2, NMI (see mother board H5 on schematic).

So... What Do You Think?

  Are you sure? yes | no

zpekic wrote 01/23/2022 at 18:48 point

Love the project and the modularity aspect especially. But maybe a few suggestions:

- how about moving the LEDs and reset button on the opposite side of the power connector? That way in future enclosure one can have a little "console" on front and power on back (there are LEDs and switches that project face forward while on PCB

- clock switcher (or maybe a single step button etc.) could be projecting to front too

- 12V step up circuit for power would allow it to be used as EPROM programmer or with some interesting chips (Am9511 FPU)

- are the chip select lines (EROM, VIA, ACIA) needed on bus connectors? I would imagine each slot board could simply contain hard - coded (or maybe microswitch / jumper) decode. The freed-up pins could be then used for communication between boards, +12V rail etc. 

Happy development!

  Are you sure? yes | no

padnest wrote 01/24/2022 at 08:12 point

Thank you for suggestions.

- enclusure: I started with no 'enclosure' in mind but I will consider your suggestion in the next motherboard review. probably I can add a connector to export all the LEDs and buttons lines for a front panel printed circuit.

- clock switcher: they will be placed on the external Arduino shield cause is used only for debugging but you make me think about the possibility to have Arduino hosted directly on board.

- 12V power: yes, I have chosen to use only single 5v power supply components but nothing prevents raising the voltage on the daughter board if necessary.

- chip select lines on bus: they are on the bus because the select logic is centralized to simplify and reduce components in the daughter boards; a single PLA will be programmed in order to select custom chips at the right time. To have more available RAM as possible each IO chip is selected by a dedicated line (VIA1, VIA2 and ACIA) hiding a single page only, of RAM, for each one.

Later I will show you the memory mapping and the CPU board...

Thanks a lot for your interest.

Ciao!

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates