Created
April 28, 2012 17:39
-
-
Save tadglines/2520713 to your computer and use it in GitHub Desktop.
A specification for a Universal Spaceship Bus for the 0x10c DCPU
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The Universal Spaceship Bus is a time division multiplexed ship wide communications | |
medium. On startup each device is assigned an address by the bus master. The bus master | |
cycles through each device in turn asking it if it has a message to send. If the device | |
has a message to send, the buss master will obtain the destination address from the source | |
and then ask the destination device if it is ready to receive a message, if yes, then the | |
bus master will transfer the message from source to destination. If the destination device | |
isn't ready, the bus master will move on to the next device on the bus. | |
The exchange looks like this: | |
Each line represents one clock cycle | |
T |SRC | |Master| | Dst | Comment | |
---+----+-----+------+-----+-----+----- | |
01 | | <-- | RTS? | | | | |
02 |ACK | --> | | | | Or send NACK if not ready to send | |
03 | | | RTR? | --> | | | |
04 | | | | <-- | ACK | Or send NACK if not ready to receive | |
05 | | <-- | SND | | | | |
06 |HDR | --> | | | | | |
07 |PLD1| --> | HDR | --> | | | |
08 |PLD2| --> | PLD1 | --> | | | |
09 |PLD3| --> | PLD2 | --> | | | |
10 |PLD4| --> | PLD3 | --> | | | |
11 |PLD5| --> | PLD4 | --> | | | |
12 |PLD6| --> | PLD5 | --> | | | |
13 | | | PLD6 | --> | | | |
14 | | | | <-- | ACK | Or send NACK if message was corrupted | |
15 | | <-- | ACK | | | Or forward NACK | |
The message above are: | |
RTS = Are you ready to send | |
RTR = Are you ready to receive | |
ACK = Yes or Received | |
NACK = No or not received/send | |
HDR = Payload Header (The first 8 bits contain the payload type and command to | |
destination) The second 8 bits are an 8 bit CRC that includes the first | |
8 bits of the header plus the 4 payload words. | |
PLD1 = First payload word | |
PLD2 = Second payload word | |
PLD3 = Third payload word | |
PLD4 = Fourth payload word | |
PLD5 = Fourth payload word | |
PLD6 = Fourth payload word | |
If the destination answers NACK, or fails to reply, the master will send a NACK to the | |
source and move on to the next device. | |
The maximum message rate for the USSB is one message every 15 clock ticks. If the bus is | |
operating at 100KHz then the maximum message rate is 6666 messages per second or | |
106,666 bytes per second. | |
Most devices don't implement the bus protocol directly but instead use a bus interface card. | |
The bus interface card or BIC provides a simplified interface to the bus. The BIC allows | |
the device to place a single complete message in the BIC's transmit buffer that the BIC can | |
transmit at it's leisure. The BIC also buffers a single received message. | |
The BIC can notify the device of message transmission or reception via a pin assert (in the | |
case of an integrated circuit) or trigger an interrupt (in the case of a device card in a | |
computer system). | |
The message format that the BIC provides is: | |
+----------------+----------------+ | |
|TTTTSSSSSSSSSSSS|CCCCDDDDDDDDDDDD| | |
+----------------+----------------+ | |
|PPPPPPPPPPPPPPPP|PPPPPPPPPPPPPPPP| | |
+----------------+----------------+ | |
|PPPPPPPPPPPPPPPP|PPPPPPPPPPPPPPPP| | |
+----------------+----------------+ | |
|PPPPPPPPPPPPPPPP|PPPPPPPPPPPPPPPP| | |
+----------------+----------------+ | |
| | |
| T = Payload Type | |
| S = Source Address | |
| C = Device specific Command | |
| D = Destination Address | |
| P = Payload | |
| | |
+--------------------------------- | |
The first word contains the 12 bit source address and a 4 bit payload type code. The | |
payload type code is device specific but two codes are standardized. A value of 0 | |
indicated that the payload is empty and a value of 1 indicates that the payload contains | |
the device information. | |
The second word contains the 12 bit destination address and a 4 bit command code. The | |
command code is device specific but two values are standardized. A value of 0 indicates | |
a device probe and a value of 1 indicates a device probe reply. A device is expected to | |
reply to every device probe with a device information payload. | |
The device information payload is formatted as: | |
+----------------+----------------+ | |
|HHHHHHHHHHHHHHHH|HHHHHHHHHHHHHHHH| | |
+----------------+----------------+ | |
|MMMMMMMMMMMMMMMM|MMMMMMMMMMMMMMMM| | |
+----------------+----------------+ | |
|VVVVVVVVVVVVVVVV|DDDDDDDDDDDDDDDD| | |
+----------------+----------------+ | |
| | |
| H = Hardware Id (low word first) | |
| M = Hardware Manufacturer (low word first) | |
| V = Hardware Version | |
| D = Additional device specific information | |
| | |
+--------------------------------- | |
The BIC interface spec for the DCPU might look like this: | |
Name: USSB Interface Card | |
ID: TBD | |
Version: 1 | |
When the device receives an interrupt it will: | |
A | BEHAVIOR | |
---+---------------------------------------------------------------------------- | |
0 | Reset the BIC. All buffers are cleared, status word is set to 0 | |
1 | Place the BIC's status word into B | |
| Bit 0 is the RTS bit (0 = nothing to send, 1 = ready to send) | |
| Bit 1 is the RTR bit (0 = not ready to receive, 1 = ready to receive) | |
| Bits 8-11 are the send error code | |
| Bits 12-15 are the receive error code | |
2 | Take the 8 words from RAM starting at the address indicated by register B | |
| and place them in the transmit buffer. This will overwrite any values | |
| currently in the transmit buffer. RTS set from register C | |
3 | Take the 8 words from the receive buffer and write them to the RAM address | |
| indicated by register B. RTR set from register C | |
---+---------------------------------------------------------------------------- | |
When interrupts are enabled and the device sends an interrupt: | |
A | BEHAVIOR | |
---+---------------------------------------------------------------------------- | |
0 | An error has occurred. BIC Status word is placed in B | |
1 | Message was transmitted, RTS bit is cleared. | |
2 | Message has been received, RTR bit is cleared. | |
---+---------------------------------------------------------------------------- | |
The BIC Send error codes are: | |
0x00 = Last transmit succeeded | |
0x01 = Last transmit failed because device never replied | |
0x02 = Last transmit failed because device NACK'ed the RTR | |
0x03 = Last transmit failed because device NACK'ed the message | |
0x04 = Last transmit failed because the master detected an error in the CRC | |
The BIC recieve error codes are: | |
0x00 = The last received was a success | |
0x01 = Received an RTR, but didn't receive HDR | |
0x02 = Received full message but had to send NACK due to CRC error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment