Hi Mika
As a general comment looking through the source code I wonder if this example should be published as is in the Xmos software reference section, it's an exceptionally sloppy piece of work even by my poor standards! It really needs a clean up, Don't get me wrong I like to see examples of how things are done, but this kind of stuff belongs on a wiki until it's been polished and peer reviewed!
What I doesn't understand is how the getCmd just can be stand alone. I cannot find any calls to the getCmd.
To answer your question I think they re-factored the code without cleaning up and that function should be either commented out or better still removed. Instead I think they used :
Code: Select all
#define SLAVE_CASE(enabled, sram_chan, Cmd, Adrs, Count) case enabled => slave { sram_chan :> Cmd; sram_chan :> Adrs; sram_chan :> Count; }:
in the following
Code: Select all
select
{
#define SLAVE_CASE(enabled, sram_chan, Cmd, Adrs, Count)
case enabled => slave { sram_chan :> Cmd; sram_chan :> Adrs; sram_chan :> Count; }:
SLAVE_CASE(chanEnabled[0], port1, Cmd, Adrs, Count);
serverActive = SRAM_SvrCmdExec(port1, Cmd, Adrs, Count);
break;
SLAVE_CASE(chanEnabled[1], port2, Cmd, Adrs, Count);
serverActive = SRAM_SvrCmdExec(port2, Cmd, Adrs, Count);
break;
SLAVE_CASE(chanEnabled[2], port3, Cmd, Adrs, Count);
serverActive = SRAM_SvrCmdExec(port3, Cmd, Adrs, Count);
break;
}
But it's fairly sloppy and difficult to read especially with the commented out stuff in the middle (which I removed for clarity)!!
(With this example I'm able to do 3 out instructions without any outct instructions in between)
by combining the 3 channel outputs into a slave transaction the synchronisation happens after all 3 have executed, without that the processing would pause on each output as it synchronised. Thus the transactional (master/slave) arrangement provides more efficient and timely transfers.
Actually I would like to see XC support for
protocols alongside channels, these could include automatic transactional channel usage in exactly this kind of situation. What's more it promotes better type safety, simpler semantics and more sophisticated communication patterns for inter-process communication.