GARTHWILSON wrote:
I originally wrote this as a private E-mail to Samuel Falvo, then decided it ought to be on the forum for everyone, and modified it accordingly.
NOO!!!! Now everyone knows my superhero alter-ego!!
GARTHWILSON wrote:
This is regarding an interface to expand a
6502-based system, similar to how IEEE-488 is used to connect lab
instrumentation in a rack or on the workbench to a computer through
cables that may be up to several meters long. It is at best a
medium-speed interface, maxing out at perhaps a few hundred
kbps.
I think you under-estimate the capabilities of IDE cables. These are
80-conductor ribbon cable terminated with 40-pin IDC connectors (IIRC,
every other conductor is automatically a ground). These allowed IDE
drives to transfer hundreds of megabytes per second with up to two
devices on a single cable. I strongly doubt that these cables would
be the limiting factor in speed for a 6502/65816 system.
Quote:
--> The 6502's own buses are not run off the SBC-- not even in a card cage.
Believe it or not, even traditional bus interfaces like PCI satisfy
this criterion. PCI is 100% CPU independent, as its bus tenures look
much more like network packets than actual CPU-generated bus interface
tenures. PCI-X goes further, being an actual
serial expansion
infrastructure. The PC's northbridge chip is responsible for handling
bus-to-PCI translation.
But I am digressing.
Quote:
I'm sure your thinking has evolved some since then, and I'd
like to hear it.
For the Kestrel-2, I'm probably going to provide one or two CPU-local
bus slots for high-throughput devices (e.g., external video cards,
harddrive interfaces, etc), and the rest via some kind of high-speed
serial interface managed via the FPGA's logic (e.g., the FPGA would
implement a DMA channel and the requisite hardware for a real-life SPI
port).
However, I have not adequately arrived at a means of addressing just yet.
One of the things that Commodore's systems could do was to instruct
one peripheral to talk, another to listen, and then you can yank the
serial cable out of the Commodore itself. The I/O peripherals were
still able to communicate to each other. Ideally, I'd really like to
retain that capability, even though it is not likely going to be used
often (but it can be useful in many situations; copying a file from
one storage device to another storage device, for example, without
involving the controlling host).
Quote:
--> SPI would be less complex softwarewise for both the
controller and the devices than an interface loop would be.
In some manners, yes. However, how would you handle the issue of
safely auto-detecting whether a device is physically present?
Assuming you can successfully identify the presence of a device, can
you next detect what
kind of device is present (e.g., is it a
floppy drive, or a full-page scanner, or a robotics controller
interface, or . . . )?
Remember, one of your goals was the ability to not have to assign
addresses explicitly. Therefore, your software
must consider
the possibility of addresses changing, at least between boots, if not
even at run-time if you support hot-swapping.
Quote:
--> SPI could be faster than an interface loop when message
packs are small and/or there are a lot of devices connected.
Oh, absolutely! SPI's highest average speed seems to be 25Mbps (I've
seen some MMC specifications claim that 52Mbps (!!) is the fastest for
MMC interfaces), and not through any Motorola-enforced spec either.
It's just what MMC cards typically support now-a-days. Higher speeds
are possible through customized connectors that make use of twisted
pairs, for example.
I should point out that 25Mbps is 2.5x faster than 10-base-T Ethernet.
25Mbps is actually the speed of ATM-to-the-desktop network connectors
as well, and SPI lends itself quite well to ATM networking.
Quote:
--> With SPI, one slow device would not slow all the other
devices down.
But, since different devices can operate at different maximum speeds,
you must assume the lowest common denominator until you've somehow
negotiated higher speeds with each device. What is the protocol to
achieve this?
Quote:
--> Real SPI would require bit-banging if done with the 6522.
(The 6522's serial port is close to one of the most commonly used SPI
modes, but no cigar.)
Or, you could jerry-rig a "SPI controller" by using a 6522's parallel
I/O interface coupled to a dedicated ATmega or PIC microcontroller,
programmed to serve as a 6522-to-SPI bridge. This would put almost
all the bit-banging onto the microcontroller, leaving the 65xx free to
work on other things.
Quote:
--> To allow some cable length, slowish comparators like the
LM339, along with hysteresis, should be used at the receivers to keep
parasitically coupled transients from causing unwanted trigering. The
interface loop OTOH could just use something like cat-5 cable with
receiver ports terminated, so the cable would not limit the
speed.
I do not see the logic of this, since the physical layer of both the
loop and the bus are essentially the same. Can you explain more about
this?
Quote:
The CLK, DI, DO, and IRQ lines would be bussed
I prefer to stick to the names MISO and MOSI personally, since the
concept of input and output is relative to the perspective of master
versus slave. MISO and MOSI names place the signal intentions in an
absolute frame of reference.
Quote:
There would be seven select lines. This accomplishes two
things: the devices don't need to decode an address bus (which would
otherwise be 3 bits in this case), and auto-addressing can be done by
rotating the select lines from one connector to the other
This is how the Amiga handled floppy addressing. It had four select
lines, which were
shifted (not rotated) from one device to the
next. The shifting allowed 5 or more floppies to be connected to the
bus, but only the first four would respond. This prevented bus
contention issues.
With 7 select lines (I'm curious to learn why not 8?), you're looking
at a lot of pins.
You also lose the ability for peripherals to communicate with other
peripherals as well, since peripherals can no longer know which
addresses correspond to which devices.
Quote:
I don't foresee any hot-plugging with the commonly available
connectors. I don't know if that would really be a problem or
not.
The critical factor for hot-plugging is making sure the grounds
connect first upon device insertion, and are broken last upon device
removal. For example, if you look at MMC cards, which are designed
for hotplugging, you'll see that some pins are longer than others.
Quote:
It wouldn't be hard to shut the interface down at the
controller end so at least the controller itself doesn't have to be
turned off in order to connect or disconnect a device.
Nope; and, you can even specify a standard device interface feature
such as an "eject" button that requests the safe removal of the device
from the chain (e.g., it generates an interrupt, the host OS sees this
and properly shuts down the power to the specific device, then signals
the user that it's OK to remove the device).
Quote:
Ribbon cable with twisted pairs might be appropriate
7 select lines + MOSI + MISO + CLK + GND + power = 12 lines minimum.
If you interweave a ground pin on every line, you end up needing 24
conductor cables and IDC headers (worst-case, but heck, it's cheap
enough!). 32 conductor cables will allow you to push more power on
the supply rails.
My question is, though, what if you want more than 7 devices on a
single bus? There are two methods:
* A completely independent bus controller in parallel with the first,
thus adding 7 additional devices.
* Replacing the original with a controller that addresses (e.g.) 7 or
more devices. The bus topology is altered so that devices 7 through N
come
first in the daisy-chain. What used to appear as devices
0-6 must now come at the end of the chain, since their selects have
now been rotated down into the compatible select lines of the older,
narrower connectors.
However, the only thing I dislike about this system is that most of
the leads will be wasted on select lines. But, with relatively cheap
IDE cables, you can support 30 devices on a bus (10 pins used for
MOSI, MISO, CLK, GND, and VCC and their corresponding returns, leaving
30 more pins to be used for selects). This at least comes close to
IEEE-488, and with a substantially faster master/slave data throughput
at that (25Mbps average top-speed, versus 8Mbps for GPIB).