Skip to content
Julian Brown edited this page Mar 19, 2025 · 1 revision

SAMx64

The replacement for the original 6883 SAM is a synthetic FPGA solution (the SAMx64) that provides all of the original functionality required to operate the main board while adding new features to support the additional hardware. Following Ciaran Anscomb's naming convention, the full name of the implementation should be SAMx64K - 65536 times the original addressing capacity of the original Motorola SAM chip.

Memory

The expansion of the memory address space from 64KB to 4MB requires paging of the RAM, allowing software to associate blocks of the default addressable 64KB to any equivalent sized block within the full memory space.

CPU Speed

The original Dragon CPU ran at 0.89MHz with options to run at higher speed depending on the address being accessed (address dependent mode) or full double speed but this rendered the video output unusable. The SAMx64 enables faster speed operations, the default remains 0.89MHz, address dependent mode is as before but the double speed does not disrupt the video output. In addition to this the CPU can run at 3.6MHz provided the fitted CPU can support it, for this it is recommended to use an Hitachi HD63C09e.

The interleaved video reads needs to be managed to maintain the correct clock speed for video independently of the CPU speed. At normal operating speed the CPU:VDG ratio is 1:1. At double clock speed the ratio is 2:1, and at quad speed it is 4:1. The VDG is fed data through a buffer that only loads data on the VDG read cycle. If an expanded video mode is used that requires a double speed for VDG reads the CPU must also be operating at double speed.

The video expansion slot has the capability to drive the Z address bus independently (orchestrated by the SAMx4 still), this would bypass any memory paging set.

Video Operation

In the original SAM, responsibility for video data reads is shared between the VDG and SAM. The SAM generates the video clock, the VDG generates the lowest single bit of the video address while the SAM expands the video address and triggers the data read. The speed of data reads is limited to 0.89MHz which equates to 1 bit of data per pixel of the video generation. With the CPU clock running at higher speeds the possibility for higher definition video is possible. With a stock VDG only the original video and pixel clock speeds are viable but an upgraded VDG can leverage more colours or higher resolution.

The standard SAM can repeat rows of video data for lower resolution modes or text modes but is limited to 12 rows (for text), 3 or 2 rows for graphic data. The SAMx64 extends the options to 8 rows (intended for text).

Another limitation of the standard SAM is that (unless set to DMA) the lower bits of the video address register are reset at the end of each row. This results in the address covering 16 bytes or 32 bytes of data are erased, the upgraded video can render 40 byte wide or 64 byte wide data which requires the standard reset of address bits needs to be modified.

note: the faster video operation results in an increase in the amount of RAM required for the video bitmap up to a maximum of 25KB

Revised V Register

V0-3 /X /Y Behaviour on HS Notes
0000 1 12 clear B1-4 Alpha
0001 3 1 clear B1-3
0010 1 3 clear B1-4
0011 2 1 clear B1-3
0100 1 2 clear B1-4
0101 1 1 clear B1-3
0110 1 1 clear B1-4
0111 1 1 none (DMA)
1000 1 12 B - 40 Wide Alpha
1001 1 8 clear B1-4 Short Alpha
1010 1 1 B - 40
1011 1 8 B - 40 Wide Short Alpha
1100 1 1 clear B1-5
1101 1 1 B - 64 16-bit data
1110 1 1 B - 80 Wide 16-bit data
1111 1 1 none (DMA)

The additional modes enable three extra (possible) features:

  1. 40 byte screen width - (320 pixels)
  2. 8 row height text
  3. Double rate data (64 or 80 byte width)

The practicality of using these modes and how the row reset behaves on repeated rows (12, 8, 3 or 2). The default BASIC roms will not provide support for the new modes, custom code will be required.

SAMx64 Register Switches

For a comprehensive list of all SAM registers and their mapped addresses: SAMx4 Registers

Design Notes

CPU Speed and VDG Interaction

Normally the VDG is exposed to data from both parts of the timing phase but given we don't need to send CPU data to the VDG, the LS273 can be set to only expose graphic data. The RAS0 signal used to trigger a load on the LS273 is artificial in nature given the memory is SRAM so no RAS/CAS multiplexing is technically required. In this context the RAS0 signal needs to isolated from the "regular" RAS0 and then timed to only fire at the original 0.89MHz.

The alternative to this is to use a block of dual port memory that allows the VDG to operate on a completely different clock cycle to the CPU, severing the need for the CPU to operate at a multiple of the VDG speed. In this mode of operation the SAM no longer needs to provide the VCLK signal or prepare the RAS0 signal and data. There are clear advantages to this approach but it does add other complexities and a 32k DPSRAM is not the cheapest option (although two 16k DPSRAM is likely to be much cheaper) or the smallest given the need for twice as many IO pins.

Interrupt Masking

As a prelude to enabling a blitter operation on the SAM, all interrupt lines are wired through the SAM itself. Normally these would be fed directly to the CPU.

The current design simply outputs these directly to the CPU.

For the blitter operations, if the target is the flashrom it is essential that the CPU does not attempt to access the CPU vectors at the top of memory, or make any reads from the ROM. To this end the SAM has the ability to suspend all interrupts, and generate synthetic interrupts should the need arise.

The proposed blitter operation requires the CPU to inform the SAM of the source and target addresses (within the current paging scheme), then go into a wait state. The SAM then performs the entire copy, stealing cycles from the video side of the clock cycle. At full pace this allows one or more 256 byte blocks to be written to the flashrom within the vertical sync period making the entire operation transparent. The SAM must issue a synthetic interrupt once the operation is completed.

Other approaches are possible utilising the CPU - if a 6309 is fitted the TFM operations can perform the same block copy operations, provided the interrupts are similarly masked. In this situation the CPU needs only indicate to the SAM that masking is required and it is entirely up to the CPU to then notify when the masking is to be removed. This approach is significantly slower than the SAM blitter approach.

The third approach is to utilise the built-in bus control signals from the CPU itself, stealing cycles when the CPU itself is not requesting bus access. This typically provides a single cycle per instruction but can extend to more depending on the addressing mode. It is however a slow and convuluted approach.

The final approach is simply to enforce a halt on the CPU until the operation is completed. The CPU state is preserved, provided the clock is maintained but it is important for the SAM to observe the end of instruction signal to guarantee that the CPU is halted. In this approach there is no need to mask interrupts as the CPU will not respond while the HALT signal is asserted. The TSC signal could be used to ensure that the data and address bus on the CPU is in a high-impedence state.

Data Bus Arbitration

The original design requires that the CPU data bus be isolated from video data reads. Likewise the video subsystem should only be exposed to data reads. The original specification allowed CPU and video reads to be exposed to the VDG but for fast operation this is refined to only allow video reads to hit the VDG and for that data to be maintained for a full VDG read cycle, which may be 1, 2 or 4 times the length of a CPU clock cycle depending on CPU clock speed.

Other than the VDG all other data driven components on the board are permanently connected to the data and address buses.

It is the responsibility of the memory board to provide data on both data buses and control when the data is exposed on read operations.

Blitter Operation

The SAMx64 is capable of performing memory copies without the need for read and write operations from the CPU.

To enable blitter operation the CPU must surrender control of the data bus. This is done by triggering the start of a blit through the SAMx64 which will then HALT the CPU.

A blit can be up-to 256bytes of memory for RAM to ROM copies or 8Kb for other copies.

Preconditions and Performance

The blit operation occurs in the vertical blank period of the video display timing. If performance is a consideration it is best to wait until just before the vertical sync to trigger the blit otherwise the time required can be a full video frame.

The blit operations runs at the full 4x clock speed requiring just a single cpu clock tick to perform the read and write. This is done by "borrowing" the video side of the clock cycle. This limits the size of the copy to what can be performed in the 35 rows of the vertical sync. This is an upper limit of 14000 bytes but is reduced to 8192 bytes to minimise the size of the blitter byte counter and ensure adequate time for the process to resume normal clock operation. In practise this means that a full RAM page can be copied on every single video frame.

Because the blit operation is independent of the CPU the maximum size of the blit is the same regardless of the CPU performance capability.

Clone this wiki locally