Serdes master


This code from block 978 is loaded into node 001. Serdes is short for serializer/deserializer. This code interfaces the hardware serdes port to the ether software protocol.

An 18-bit word is sent over a serial link to another GreenArrays' chip. The link is fast (600 Mb/s) but unique to these chips. Conversely, an 18-bit word is received from the link. The node is fully occcupied with this task and can only pass the data to and from a comm port.

It is paired with code in the other chip called Serdes slave. The master initiates an ether message which may require a reply. Slave code is subtlely different.

This is pretty complicated code and should be modified very carefully.

init

Four numbers are put on the stack: 3fffe 0 77 focus.

slave

The first message is the code to be loaded into the slave node followed by ether code to be loaded into node 601. These messages require special handling.

Focus is put into the b register, the first word is sent, then the remaining words.

first

After loading this code into 001, the serdes port is still set to receive. The first word sent must change the port to send:

Register a is saved and restored. It is set to data, which is a variant of up. Storing to data is immediate, whereas up waits till the port is clear. The first word is fetched from the comm port and put into the serdes port. Then the send bit (17) is set in the io register to start transmission.

pay

When processing the payload of a message there are 2 numbers on the stack: the count word, specifying the length of the reply; the length of the payload to be transmitted.

Input may stack up behind the comm port; this is harmless, the result of port read/writes not being satisfied. In fact, if input is coming from the PC via the asynchronous port (260 us/w) this will not happen. But if it's coming from elsewhere it may.

Serdes takes ~30 ns to send a word, 3x slower than a comm port. But still, you must be careful not to exceed the speed at which the slave can handle its input. The present serdes lacks an acknowledge, so a delay is added. This (31 unexts) has been tuned for a video image; a different application may want to change this delay.

The reply count, in the high bits of the count word, is examined. If zero, transmission continues; otherwise the serdes port is turned to receive and the reply forwarded. The port is turned to recieve again, to synchronize with the slave (turning takes a while). Then the first word of the next message is sent to return to transmission. And the head of that message processed.

cont

To continue transmission is similar to first, except that send mode need not be established. The first word is simply sent.

head

A message has a 4-word header: So a modified header is relayed to the slave. Then the remaining payload is sent.

turn

To turn the bi-directional serial link from send to receive takes time (81 unexts). This is because pulling down the clock line is done by weak transistors.

The initial (2 unext) delay is again to synchronize with slave.

lis

listen, like first, has to work to establish receive mode. It saves and restores register a; resets bit 17 of the io register and stores 3fffe into data. 3fffe was on the stack, and must remain on the stack during receive, whence it will be restored into up to time each incoming word. lis must be called twice (I forget why).