Skip to content
David Banks edited this page Jun 2, 2022 · 23 revisions

Contents

Overview

The BeebFpga project includes four cores for the Papilio Duo:

  • a BBC Micro (Model B) core with the original Video ULA
  • a BBC Master core with the original Video ULA
  • a BBC Micro (Model B) core with VideoNuLA
  • a BBC Master core with VideoNuLA

All four cores are combined with a boot loader and Master/Model B ROM images into a single FPGA bitstream that can be programmed into the Papilio Duo configuration FLASH.

These cores are designed to work with:

These boards can still (as of 2022) be bought from Seeed Studio:

The BBC Micro cores use the T65 6502 implementation. The BBC Master cores use Alan Daly's 65C02 implementation. Both of these are 100% cycle accurate, and have been extensively tested.

These BeebFpga Papilio Duo cores cover the following features:

  • Model B with a 6502 CPU
  • Master 128 with a 65C02 CPU
  • Original Video ULA (8 colours)
  • VideoNuLA (an extended colour palette with 4096 colours, and additional screen modes)
  • sRGB output @ 50Hz (identical in format to the BBC Micro sRGB output)
  • High quality VGA output @ 50Hz
  • High quality HDMI/DVI output via an external 12-bit RGBtoHDMI
  • Internal 4MHz 65C02 Co Processor (for Tube Elite!)
  • PS/2 Keyboard
  • Single Joystick
  • Music 5000 support
  • MMFS SD Card File System (using a seperate SPI port &FEAx for maximum compatibility)
  • Integrated ICE 6502/65C02 debugger (uses USB Serial Port at 115,200 baud)

There are a number of additional features present in the code base that are disabled due to space and/or I/O limitiations:

  • AMX Mouse
  • Beeb SID
  • Extenal PiTubeDirect Co Processor
  • Second Joystick

Jumper Options

The block of jumpers on the Classic Computing Shield are used as follows:

  • Jumper 1: Video Mode (Off = RGBS, On = VGA)
  • Jumper 2: 6502 Co Processor (Off = Disabled, On = Enabled)
  • Jumper 3: Model (Off = Model B, On = Master 128)
  • Jumper 4: Video ULA Type (Off = Original ULA, On = VideoNuLA)
  • Jumper 5: Power-Up Reset of the Current Core

Jumper 1 can be changed at any time and the effect will be immediate.

Jumper 2 can be changed at any time, but BREAK (F12) must then be pressed for the Beeb to restart in the new configuration.

Jumpers 3 and 4 are read on power-up by a special boot loader core, so after changing these you need to completely power cycle the Papilio Duo.

Jumper 5 will trigger a power-up reset on the current core. It does not re-run the boot loader.

Note, the jumpers are also connected to the push button switches:

  • Jumper 1 => Right Switch
  • Jumper 2 => Down Switch
  • Jumper 3 => Up Switch
  • Jumper 4 => Left Switch
  • Jumper 5 => Reset Switch

Video Connections

There are three ways to get video out of BeebFpga:

sRGB Video

(Jumper 1 should be off)

In this mode BeebFPGA outputs an Analog sRGB video signal with identical characteristics to the original BBC Micro.

The video is output on the VGA connector on the Classic Computing shield, using the following pins:

  • Pin 1: Red (0.7v)
  • Pin 2: Green (0.7v)
  • Pin 3: Blue (0.7v)
  • Pin 13: Composite Sync (3.3V TTL)
  • Pin 14: 3.3V
  • Pins 6, 7, 8, 10, 11: Ground

To connect to a old-school Analog RGB Monitor (with a 6-pin DIN connector), a custom cable will need to be made.

To connect to a more modern SCART-compatible TV, then a Spectrum Next Analog RGB cable can be used. These are widely available.

This mode provides maximum compatibility with pretty much all existing software.

Note: Many TVs with SCART support both RGB and Composite, with selection being automatic based on the voltage on SCART pin 16. If the voltage is 3V or above, then the TV should select the RGB input mode. This voltage can be sourced from pin 14 on the VGA connector, which outputs a fixed 3.3V (via a 82.5R resistor). This is how the Spectrum Next cables are wired.

VGA Video

(Jumper 1 should be on)

In this mode BeebFPGA outputs an 50Hz (Vertical) / 31.250HKz (Horizontal) VGA video signal, using a scan doubler.

An ordinary VGA cable can be used.

Note: Not that many VGA Monitors support 50Hz Vertical timing, so check the specifications.

A HP LP2065 works very well (and is 4:3 aspect ratio)

This mode provides very good compatibility with existing software, but there are one or two known test cases that don't work.

HDMI Video

(Jumper 1 should be off)

This mode provides maximum compatibility with pretty much all existing software.

The Classic Computing Shield needs to be split and the wing on the left hand side detached. This allows a cable for the 12-bit digital RGB video to be connected to RGBtoHDMI, via the RGBto HDMI 12-bit extender.

A custom cable is will need to be made up. Here is a photo of my cable (designed for the v1 12-bit extender; v2 is slightly different):

Keyboard

Connect a PS/2 Keyboard to PS2/A connector on the Classic Computing shield.

It's also possible to use a USB keyboard (via a purple PS/2 to USB adapter), but only if the keyboard supports PS/2 mode natively (which is never clearly documented, so you just needs to try it).

The keyboard mapping is based on physical key location on an original BBC Keyboard (at least where possible).

Some exceptions are:

  • F0 is mapped to F10
  • BREAK is mapped to F12
  • Copy is mapped to End
  • @ is mapped to the ~' key
  • \ and | are not currently mapped (TODO: fix this!)

Joystick

A standard 9-pin (Atari 2600, Commodore 64, classic Arcade) joystick that uses digital inputs can be connected to the JOYSTICK 1 connector on the Classic Computing shield.

This is mapped to the Beeb Analog Joystick 1.

Audio

Audio is available on the Audio 1 connector on the Classic Computing shield.

The audio from the SN76489 (mono) and the Music 5000 (stereo) are mixed together inside BeebFpga, so there is no need to manually select the source.

SD Card

BeebFPGA support the widely used MMFSv1 SD Card file, which uses the MMB container for 200K disk images.

It supports MMFS via a byte-wide SPI port style interface at &FEAx (where Econet would be).

This approach has three advantages over a User port connected device:

  • it's faster than using a 6522 connected device
  • it improves compatibility with existing software that uses the User Port
  • it's smaller than adding a second dedicated 6522

Copy a BEEB.MMB file onto a FAT32 formatted Micro SD Card and place this in the SD Card slot.

The SD Card must be 16GB or less in capacity (i.e. SDXC is not supported).

An example BEEB.MMB file can be found here:

In addition, BeebFpga contains a script to build an MMB file containing many test images:

Power

BeebFPGA should be powered using the larger of the two USB conectors on the Papilio Duo.

It draws ~250mA so can be powered from any USB port.

Using the Debugger

BeebFpga includes the powerful ICE-6502/65C02 debugger, allowing software running on BeebFpga to debugged, using breakpoints, watchpoints, single-stepping, etc.

The debugger can be accessed using from PC over the Papilio's USB cable

On Linux, you can use gtkterm:

gtkterm -s 115200 -p /dev/ttyUSB1

Once connected, if you hit the Reset button (on the Classic Computing shield) you should see this output on the serial terminal:

Pressing return will stop the 6502 and give you the debugger command propmpt:

For further documentation on TCE 6502/65C02 see:

Programming the FPGA Bitfile

The latest Papilio Duo bitfile (containing the 4 cores plus a boot loader) can be found here:

TODO: It will be there when I make the release....

There is lots of documentation on the Gadget Factory website covering programming the Papilip Duo:

Here's the command I use for programming the bitstream into FLASH:

# Program the Papilo Duo
PAPILIO_LOADER=/opt/GadgetFactory/papilio-loader/programmer
PROG=${PAPILIO_LOADER}/linux64/papilio-prog
BSCAN=${PAPILIO_LOADER}/bscan_spi_xc6slx9.bit
sudo ${PROG} -v -f beeb_fpga_papilio_duo.bit -b ${BSCAN}  -sa -r
# Reset the Papilio Duo
sudo ${PROG} -c

Programming the AVR Microcontroller

The Papilio Duo includes an AVR microcontroller (similar to an Arduino Leonardo). This shares many of the same signals that the Classic Computing sheild uses. If BeebFPGA starts behaving very erratically, it's likely the cause is AVR microcontroller, which needs to be disabled.

There are two ways to disable the AVR microcontroller:

  1. Switch SW1 on the Duo board towards the board edge.

This will hold the AVR in reset. Unfortunately, even in reset, the AVR's JTAG pins are still active, and these share connections with the VGA port on the classic computing shield.

If you are using a BeebFpga core containing the original Video ULA, then you shouldn't have any problems.

If you are using a BeebFpga core containing the VideoNuLA, using additional colours can trigger the JTAG boundary scan test mode on the AVR, which causes very eratic behaviour (which will be very obvious because the audio buzzes loudly). If you hit this issue, then you need to use method (2) below.

  1. Switch SW2 on the Duo board away from the board edge and program the following sketch into the AVR Microcontroller:
void setup() {
  // disable all the I/Os
  for (int i = 0; i < 24; i++) {
    pinMode(LED_PIN, INPUT_PULLUP);    
  }
  // disable JTAG
  MCUCR = (1<<JTD); 
  _NOP();
  MCUCR = (1<<JTD);
}
void loop() {
  delay(500);
}

The AVR Microcontroller can be programmed using the standard Arduino IDE, by setting the board type as an Arduino Leanoardo. This is probably the easiest way. You need to connect a second USB cable to the smaller USB connector to do the programming.

Alternatively, you can install GadgetFactory's DesignLab, which includes a customized version of the Arduino IDE that has specific support for the Papilio Duo as the board type. It's also possible to reprogram the AVR bootloader using this toolchain, not that you should ever have to do that....

Customizing BeebFpga

Customizing the ROMs

The Sideways ROMs are included in the .bit file, and can be easily customized by rebuilding this file.

Please contact hoglet if you want to know more about this.

Customizing the Cores

The following hardware customizations are possible:

  • including a second joystick
  • including support for AMX Mouse (using a mouse connected to the second PS/2 port)
  • including support for Beeb SID
  • connecting an external PiTubeDirect Co Processor

Doing this involves making changes to the top of bbc_micro_duo.vhd and recompiling:

-- Generic top-level entity for Papilio Duo board
entity bbc_micro_duo is
    generic (
        IncludeAMXMouse    : boolean := false;  -- Also must enable pullup on accel_io(8,9) in .ucf file
        IncludeSPISD       : boolean := true;
        IncludeSID         : boolean := false;
        IncludeMusic5000   : boolean := true;
        IncludeICEDebugger : boolean := true;
        IncludeCoPro6502   : boolean := true;
        IncludeCoProExt    : boolean := false;   -- Also helps to enable pulldown on D0/accel_io(8) in .ucf file
        IncludeRGBtoHDMI   : boolean := true;
        IncludeVideoNuLA   : boolean := false;
        IncludeBootstrap   : boolean := true;
        IncludeMaster      : boolean := false;
        IncludeMinimal     : boolean := false   -- Creates a build to test
                                                -- 4x16K ROM Images
    );

Please contact hoglet if you want to know more about this.

Known Issues

Interference from the AVR microcontroller

If the AVR Microcontroller is not properly disabled, using VideoNuLA can inadvertantly trigger JTAG boundary scan test mode, which causes very eratic behaviour. This is covered above in: Programming the AVR Microcontroller.

Software compatibility in VGA mode

In VGA Mode, MODE 7 is 624 lines progressive rather than 625 line interlaced, which might affect any software that expects exact VSYNC timing. There are very few such examples, and most are specific test cases.

In VGA Mode, software that dynamically switches between MODE 7 and another MODE will probably not work well. An example of this is the MODE4/7 test case.

Links