drogon wrote:
It sounds interesting, but I can't think of anything that would use that sort of network, although without going into it in more detail, who knows.
It's just a simple, point to point network.
I looked at it some more, it's kind of clever I think.
By "token passing", that's a mechanism for network arbitration. It's not a ball bouncing from node to node like a hot potato.
So, what happens is that at start up, one of the nodes is set as the Master. Or, rather, WAS the Master. This node has no real control over the bus at this point.
When any of the nodes wants to send a payload, it requests Master. Now what happens, is when the network sees someone raise the "I want master" flag, the node that USED to be Master asserts a signal on its CHOUT pin. All of the nodes have their CHOUT pin connected to their neighbors CHIN pin. When a node see the CHIN pin asserted, if that node does NOT want Master, they simply passes it along by asserting their CHOUT pin.
When it eventually arrives to the node that wants Master, then it's handed off. This is the "token" passing component of the network. If more than one node wants Master at the same time, the one closest to the previous Master is the one that gets control.
Once it has control, it'll tell the CPU that it's ready to go. The interrupt routine puts data in to the data registers (4 bytes, top 3 are node address). Once the LSB is written, the controller starts clocking the data on to the data lines. All of the nodes on the network simultaneously clock the data in to their local registers.
Now, the node to who the data was addressed to will do three things. 1) It'll raise a signal to the net saying "I got it", then it will flag its data as ready to read to the host, finally it will interrupt its local processor to go and get the data. When the host CPU reads the 4th byte of the data, that will automatically reset the "ready to read" bit.
Meanwhile, on the Master node, it will see the "AOK" signal, and interrupt it processor to let it know that the data was received.
If a node has the "read pending" bit set, then it will NOT clock in the data from network. It will just sit there. If that node is the one that the data was addressed to, then it will not flag the AOK signal, and the Master node will see that the AOK wasn't fired, interrupt its host and tell it "message sent, but not delivered" so it can try again.
At this point, the bus effectively goes idle waiting for the next "Hi, I want to send data".
So, the bus arbitration only takes a few clock cycles, the CPU itself is not involved. That means that during a bulk transfer, you almost have the full bandwidth of the bus to move the data. Meaning you can almost achieve 128KB/s on a 4MHz clock. That's a theoretical limit, not a practical one because there's downtime staging the next 4 bytes and raising the Master flag again. If you have one node wanting to bulk transfer to another, it stages the data up, and waits for the interrupt to fire to load it again (which will happens in ~32 cycles).
The destination will get the interrupt to read the data, and at this point it's a race to read the data out before the Master tries to send again. You do NOT want the Master to win that race, because the retry is costly. I think would take some careful study to make sure that Master is not writing faster than the destination wants to take it. Mind, again, it's not a data corruption issue, it's just a performance issue. Wasting a packet send to a deaf node is expensive. When the AOK flag goes up, both nodes are in a race with each other.
But, that said, it would not surprise me if you could not get 4 nodes, streaming to a respective partner, and saturating the bus at 128KB/s between them. With the interrupt handling and everything, I think you'd be hard pressed to get 4 bytes of processing done in 32 cycles. It takes 44 cycles just to move 4 bytes in to/from a buffer not counting interrupt overhead (LDA ABS, STA ZP,Y, INY) x 4. I think I'd stick a NOP or two in to the Master routine, just to make sure that reader was done.
But still, 128KB/s is not nothing with 4MHz.
Now, how does this compare to SPI? Compared to SPI, any node can be Master. It's a 4 wire bus with up to 8 nodes. SPI uses hardware to select (more nodes, more wires) and, as I understand it, is Master to Slave only. A Slave can't push back (directly) to the master. Being a 4 byte transaction, there's probably a wee bit more bandwidth too.
Use cases? Eh, who knows. But I would say if the '265 had this, I'd consider seeing if it could be used to talk to the RPi (but I don't know if the RPi could keep up consistently with a 4MHz serial clock, much less an 8MHz one). My protocol is likely faster being parallel, and more deterministic and probably better suited for the Pi. But takes a lot more wires than 4.