<?xml version="1.0"?>
<!DOCTYPE nta PUBLIC "-//Uppaal Team//DTD Flat System 1.0//EN" "http://www.docs.uu.se/docs/rtmv/uppaal/xml/flat-1_0.dtd">
<nta>
  <declaration>//Insert declarations of global clocks, variables, constants and channels.

const N 9;

const wireCount0 9;
int[0, wireCount0] bus0Wire;

const wireCount1 18;
int[0, wireCount1] bus1Wire;


chan begSig, endSig, begBuff, endBuff, begMem,endMem;
chan switch;

int space[N*2];
int reg[N];

int[0,1] ready[N];

int[0,N] openBus;

chan tick, tack;
int[0,3] turn;

int starting:=0;
urgent chan start;

//clock systemtime;</declaration>
  
  <template><name x="32" y="72">BusOLD</name><parameter x="32" y="88">const wireCount, delay, period;
int bus;
chan beg, end</parameter><declaration>clock timer;
</declaration><location id="id0" x="-544" y="-928"><name x="-608" y="-960">Begin</name><committed/></location><location id="id1" x="-768" y="-928"><name x="-768" y="-976">End</name><committed/><committed/></location><location id="id2" x="-672" y="-832"><name x="-688" y="-872">Wait</name><label kind="invariant" x="-712" y="-808">timer&lt;=period</label></location><location id="id4" x="-560" y="-1032"><name x="-570" y="-1062">Start</name><label kind="invariant" x="-640" y="-1064">timer&lt;=delay</label></location><init ref="id4"/><transition><source ref="id0"/><target ref="id0"/><label kind="assignment" x="-440" y="-968">bus:=bus+1</label><label kind="guard" x="-440" y="-1016">bus&lt;wireCount-1</label><label kind="synchronisation" x="-440" y="-992">beg!</label><nail x="-448" y="-1056"/><nail x="-448" y="-928"/></transition><transition><source ref="id0"/><target ref="id2"/><label kind="guard" x="-616" y="-888">bus==wireCount-1</label><label kind="assignment" x="-616" y="-856">timer:=0</label><label kind="synchronisation" x="-616" y="-872">beg!</label></transition><transition><source ref="id1"/><target ref="id1"/><label kind="synchronisation" x="-944" y="-976">end!</label><label kind="assignment" x="-944" y="-952">bus:=bus-1</label><label kind="guard" x="-944" y="-1000">bus&gt;0</label><nail x="-864" y="-928"/><nail x="-864" y="-1056"/></transition><transition><source ref="id2"/><target ref="id1"/><label kind="guard" x="-808" y="-896">timer==period</label></transition><transition><source ref="id1"/><target ref="id0"/><label kind="guard" x="-696" y="-952">bus==0</label><label kind="synchronisation" x="-688" y="-928">end!</label></transition><transition><source ref="id4"/><target ref="id0"/><label kind="guard" x="-656" y="-1024">timer==delay</label><label kind="assignment" x="-616" y="-1008">bus:=0</label></transition></template><template><name x="5" y="5">Buffer</name><parameter x="8" y="24">const startId, id, size, inWire, outWire; int inBus, outBus;
chan begPut; chan endPut; const putAmount; 
chan begGet; chan endGet; const getAmount</parameter><declaration/><location id="id6" x="240" y="352"><name x="208" y="320">Idle</name><label kind="invariant" x="230" y="367"/></location><location id="id7" x="480" y="128"><name x="456" y="96">Writing</name><label kind="invariant" x="470" y="143"/></location><location id="id8" x="480" y="576"><name x="456" y="592">Reading</name><label kind="invariant" x="470" y="591"/></location><location id="id9" x="720" y="352"><name x="736" y="344">ReadingWriting</name><label kind="invariant" x="710" y="367"/></location><location id="id10" x="480" y="352"><name x="496" y="344">Overflow</name><label kind="invariant" x="470" y="367"/><committed/></location><location id="id11" x="64" y="352"><name x="54" y="322">Start</name></location><init ref="id11"/><transition><source ref="id6"/><target ref="id7"/><label kind="guard" x="248" y="88">inWire==inBus,
space[id+N]&gt;=putAmount</label><label kind="synchronisation" x="248" y="136">begPut?</label><label kind="assignment" x="248" y="152">space[id+N]:=space[id+N]-putAmount</label><nail x="240" y="128"/></transition><transition><source ref="id7"/><target ref="id6"/><label kind="synchronisation" x="272" y="216">endPut?</label><label kind="assignment" x="272" y="232">space[id]:=space[id]+putAmount</label><label kind="guard" x="272" y="200">inWire==inBus</label></transition><transition><source ref="id6"/><target ref="id8"/><label kind="guard" x="248" y="536">outWire==outBus,
space[id]&gt;=getAmount</label><label kind="synchronisation" x="248" y="576">begGet?</label><label kind="assignment" x="248" y="600">space[id]:=space[id]-getAmount</label><nail x="240" y="576"/></transition><transition><source ref="id8"/><target ref="id6"/><label kind="synchronisation" x="256" y="440">endGet?</label><label kind="assignment" x="256" y="456">space[id+N]:=space[id+N]+getAmount</label><label kind="guard" x="256" y="424">outWire==outBus</label></transition><transition><source ref="id8"/><target ref="id9"/><label kind="guard" x="552" y="536">inWire==inBus,
space[id+N]&gt;=putAmount</label><label kind="synchronisation" x="552" y="576">begPut?</label><label kind="assignment" x="552" y="592">space[id+N]:=space[id+N]-putAmount</label><nail x="720" y="576"/></transition><transition><source ref="id9"/><target ref="id7"/><label kind="synchronisation" x="608" y="216">endGet?</label><label kind="assignment" x="608" y="232">space[id+N]:=space[id+N]+getAmount</label><label kind="guard" x="608" y="200">outWire==outBus</label></transition><transition><source ref="id9"/><target ref="id8"/><label kind="synchronisation" x="592" y="488">endPut?</label><label kind="assignment" x="592" y="504">space[id]:=space[id]+putAmount</label><label kind="guard" x="592" y="472">inWire==inBus</label></transition><transition><source ref="id7"/><target ref="id9"/><label kind="guard" x="536" y="88">outWire==outBus,
space[id]&gt;=getAmount</label><label kind="synchronisation" x="536" y="128">begGet?</label><label kind="assignment" x="536" y="144">space[id]:=space[id]-getAmount</label><nail x="720" y="128"/></transition><transition><source ref="id6"/><target ref="id10"/><label kind="guard" x="320" y="280">inWire==inBus,
space[id+N]&lt;putAmount</label><label kind="synchronisation" x="336" y="320">begPut?</label><nail x="320" y="320"/><nail x="400" y="320"/></transition><transition><source ref="id6"/><target ref="id10"/><label kind="guard" x="320" y="368">outWire==outBus,
space[id]&lt;getAmount</label><label kind="synchronisation" x="336" y="400">begGet?</label><nail x="320" y="384"/><nail x="400" y="384"/></transition><transition><source ref="id8"/><target ref="id10"/><label kind="guard" x="488" y="392">inWire==inBus,
space[id+N]&lt;putAmount</label><label kind="synchronisation" x="488" y="432">begPut?</label></transition><transition><source ref="id7"/><target ref="id10"/><label kind="guard" x="488" y="248">outWire==outBus,
space[id]&lt;getAmount</label><label kind="synchronisation" x="488" y="288">begGet?</label><nail x="480" y="240"/></transition><transition><source ref="id11"/><target ref="id6"/><label kind="assignment" x="88" y="352">space[id]:=0,
space[id+N]:=size</label><label kind="guard" x="88" y="320">starting==startId</label><label kind="synchronisation" x="88" y="336">start?</label></transition></template><template><name x="88" y="128">Adder</name><parameter x="83" y="155">chan begA, endA;
chan begAp, endAp;
chan begS, endS;
chan begSp, endSp</parameter><declaration/><location id="id5" x="-208" y="-224"><name x="-264" y="-264">SwitchCycle</name></location><location id="id12" x="-144" y="-288"><committed/><committed/><committed/><committed/><committed/><committed/><committed/><committed/><committed/></location><location id="id13" x="-64" y="-288"><committed/><committed/><committed/><committed/><committed/><committed/><committed/><committed/></location><location id="id14" x="16" y="-288"><committed/><committed/><committed/><committed/><committed/><committed/><committed/></location><location id="id15" x="80" y="-224"><name x="72" y="-256">Cycle</name></location><location id="id16" x="16" y="-160"><committed/></location><location id="id17" x="-64" y="-160"><committed/></location><location id="id18" x="-144" y="-160"><committed/></location><init ref="id5"/><transition><source ref="id5"/><target ref="id12"/><label kind="synchronisation" x="-176" y="-256">begA?</label></transition><transition><source ref="id12"/><target ref="id13"/><label kind="synchronisation" x="-128" y="-288">begAp?</label></transition><transition><source ref="id13"/><target ref="id14"/><label kind="synchronisation" x="-48" y="-288">begS?</label></transition><transition><source ref="id14"/><target ref="id15"/><label kind="synchronisation" x="0" y="-264">begSp?</label></transition><transition><source ref="id15"/><target ref="id16"/><label kind="synchronisation" x="16" y="-216">endA?</label></transition><transition><source ref="id16"/><target ref="id17"/><label kind="synchronisation" x="-40" y="-184">endAp?</label></transition><transition><source ref="id17"/><target ref="id18"/><label kind="synchronisation" x="-120" y="-184">endS?</label></transition><transition><source ref="id18"/><target ref="id5"/><label kind="synchronisation" x="-176" y="-208">endSp?</label></transition></template><template><name x="-320" y="88">Register</name><parameter x="-144" y="88">const startId, idMem, idBuff, spaceId, status; int bus;
chan begBuff, endBuff;
chan begMem, endMem</parameter><declaration/><location id="id3" x="-192" y="480"><name x="-240" y="496">Wait</name></location><location id="id28" x="64" y="288"><name x="72" y="232">Ready</name></location><location id="id30" x="-384" y="192"><name x="-400" y="160">Start</name></location><location id="id32" x="64" y="480"><name x="-8" y="448">TransferM</name></location><location id="id19" x="-192" y="288"><name x="-224" y="256">TransferB</name></location><location id="id21" x="258" y="478"><name x="256" y="448">Prepare</name></location><location id="id22" x="256" y="288"><name x="248" y="256">bufferBusy1</name></location><location id="id23" x="64" y="672"><name x="-16" y="680">bufferBusy2</name></location><location id="id24" x="256" y="672"><name x="264" y="680">Prepare2</name></location><location id="id25" x="-192" y="672"><name x="-280" y="680">bufferBusy3</name></location><init ref="id30"/><transition><source ref="id3"/><target ref="id19"/><label kind="guard" x="-208" y="336">reg[idMem]&lt;512,
space[spaceId]&gt;=32,
bus==idBuff</label><label kind="synchronisation" x="-208" y="384">begBuff?</label><label kind="assignment" x="-232" y="408">reg[idMem]:=reg[idMem]+32</label><nail x="-216" y="440"/><nail x="-216" y="328"/></transition><transition><source ref="id30"/><target ref="id3"/><label kind="assignment" x="-376" y="264">reg[idMem]:=status,
ready[idMem]:=0</label><label kind="guard" x="-376" y="216">status&lt;512,
starting==startId</label><label kind="synchronisation" x="-376" y="248">start?</label><nail x="-384" y="480"/></transition><transition><source ref="id28"/><target ref="id32"/><label kind="guard" x="72" y="344">openBus==idMem</label><label kind="synchronisation" x="72" y="368">begMem?</label><label kind="assignment" x="72" y="392">reg[idMem]:=reg[idMem]-128</label></transition><transition><source ref="id32"/><target ref="id3"/><label kind="guard" x="-128" y="456">reg[idMem]==0</label><label kind="synchronisation" x="-128" y="480">endMem?</label><label kind="assignment" x="-128" y="496">ready[idMem]:=0</label></transition><transition><source ref="id32"/><target ref="id21"/><label kind="guard" x="128" y="424">reg[idMem]&gt;0</label><label kind="synchronisation" x="128" y="448">endMem?</label><nail x="112" y="448"/><nail x="208" y="448"/></transition><transition><source ref="id19"/><target ref="id3"/><label kind="synchronisation" x="-40" y="392">endBuff?</label><label kind="guard" x="-40" y="352">reg[idMem]&lt;512,
bus==idBuff</label><nail x="-48" y="336"/><nail x="-48" y="432"/></transition><transition><source ref="id21"/><target ref="id32"/><label kind="synchronisation" x="128" y="480">begMem?</label><label kind="assignment" x="72" y="496">reg[idMem]:=reg[idMem]-128</label><nail x="208" y="496"/><nail x="112" y="496"/></transition><transition><source ref="id21"/><target ref="id24"/><label kind="synchronisation" x="200" y="584">begBuff?</label><label kind="guard" x="168" y="568">bus==idBuff</label><nail x="256" y="488"/></transition><transition><source ref="id24"/><target ref="id21"/><label kind="synchronisation" x="296" y="560">endBuff?</label><label kind="guard" x="296" y="544">bus==idBuff</label><nail x="288" y="624"/><nail x="288" y="528"/></transition><transition><source ref="id22"/><target ref="id28"/><label kind="synchronisation" x="128" y="320">endBuff?</label><label kind="guard" x="112" y="296">bus==idBuff</label><nail x="208" y="320"/><nail x="112" y="320"/></transition><transition><source ref="id28"/><target ref="id22"/><label kind="synchronisation" x="144" y="256">begBuff?</label><label kind="guard" x="128" y="232">bus==idBuff</label><nail x="112" y="256"/><nail x="208" y="256"/></transition><transition><source ref="id19"/><target ref="id28"/><label kind="guard" x="-144" y="232">reg[idMem]==512, bus==idBuff</label><label kind="assignment" x="-144" y="264">ready[idMem]:=1</label><label kind="synchronisation" x="-144" y="248">endBuff?</label></transition><transition><source ref="id30"/><target ref="id28"/><label kind="guard" x="-272" y="176">status==512, starting==startId</label><label kind="assignment" x="-272" y="192">reg[idMem]:=status, ready[idMem]:=1</label><label kind="synchronisation" x="-72" y="176">start?</label><nail x="64" y="192"/></transition><transition><source ref="id32"/><target ref="id23"/><label kind="synchronisation" x="-32" y="560">begBuff?</label><label kind="guard" x="-56" y="536">bus==idBuff</label><nail x="32" y="528"/><nail x="32" y="632"/></transition><transition><source ref="id23"/><target ref="id32"/><label kind="synchronisation" x="72" y="560">endBuff?</label><label kind="guard" x="72" y="544">bus==idBuff</label></transition><transition><source ref="id23"/><target ref="id24"/><label kind="guard" x="120" y="632">reg[idMem]&gt;0</label><label kind="synchronisation" x="128" y="656">endMem?</label><nail x="112" y="656"/><nail x="208" y="656"/></transition><transition><source ref="id24"/><target ref="id23"/><label kind="synchronisation" x="128" y="680">begMem?</label><label kind="assignment" x="96" y="704">reg[idMem]:=reg[idMem]-128</label><nail x="208" y="704"/><nail x="112" y="704"/></transition><transition><source ref="id23"/><target ref="id25"/><label kind="guard" x="-128" y="648">reg[idMem]==0</label><label kind="synchronisation" x="-128" y="672">endMem?</label></transition><transition><source ref="id25"/><target ref="id3"/><label kind="guard" x="-184" y="552">bus==idBuff</label><label kind="synchronisation" x="-184" y="576">endBuff?</label><label kind="assignment" x="-184" y="600">ready[idMem]:=0</label></transition><transition><source ref="id22"/><target ref="id23"/><label kind="guard" x="272" y="320">openBus==idMem</label><label kind="synchronisation" x="320" y="344">begMem?</label><label kind="assignment" x="200" y="368">reg[idMem]:=reg[idMem]-128</label><nail x="384" y="288"/><nail x="384" y="768"/><nail x="64" y="768"/></transition><transition><source ref="id3"/><target ref="id19"/><label kind="guard" x="-344" y="336">reg[idMem]&lt;512,
space[spaceId]&lt;32,
bus==idBuff</label><label kind="synchronisation" x="-344" y="384">begBuff?</label><nail x="-352" y="432"/><nail x="-352" y="336"/></transition></template><template><name x="328" y="224">Arbiter</name><parameter x="328" y="248">const period;
chan beg, end</parameter><declaration>const unsafe 15625;
const refreshTime 100;
const maxSafe unsafe-25;
clock memtimer, timer;</declaration><location id="id34" x="704" y="336"><name x="720" y="328">Start</name><committed/></location><location id="id35" x="704" y="512"><name x="736" y="520">Ready</name><label kind="invariant" x="736" y="536">timer&lt;=period</label></location><location id="id36" x="352" y="512"><name x="280" y="504">Transfer</name><label kind="invariant" x="280" y="528">timer&lt;=period</label></location><location id="id20" x="704" y="704"><name x="728" y="680">Refresh</name><label kind="invariant" x="728" y="696">memtimer&lt;=unsafe+refreshTime</label><urgent/></location><location id="id26" x="352" y="336"><name x="328" y="304">Finish</name><committed/></location><location id="id27" x="480" y="512"><name x="464" y="528">Setup</name><label kind="invariant" x="432" y="544">timer&lt;=period</label></location><init ref="id34"/><transition><source ref="id34"/><target ref="id35"/><label kind="assignment" x="712" y="384">timer:=0,
openBus:=0,
memtimer:=0</label></transition><transition><source ref="id26"/><target ref="id35"/><label kind="assignment" x="384" y="336">openBus:=(openBus==N-1?0:openBus+1)</label><label kind="guard" x="384" y="312">reg[openBus]==0</label><nail x="656" y="336"/></transition><transition><source ref="id35"/><target ref="id35"/><label kind="guard" x="872" y="432">memtimer&lt;=maxSafe,
timer==period,
ready[openBus]==0</label><label kind="assignment" x="872" y="480">openBus:=(openBus==N-1?0:openBus+1),
timer:=0</label><nail x="864" y="432"/><nail x="864" y="512"/></transition><transition><source ref="id20"/><target ref="id35"/><label kind="guard" x="744" y="600">memtimer==unsafe+refreshTime</label><label kind="assignment" x="744" y="624">memtimer:=0,
timer:=0</label><nail x="736" y="656"/><nail x="736" y="568"/></transition><transition><source ref="id35"/><target ref="id20"/><label kind="guard" x="560" y="592">memtimer&gt;maxSafe</label><nail x="672" y="568"/><nail x="672" y="656"/></transition><transition><source ref="id35"/><target ref="id27"/><label kind="guard" x="520" y="408">memtimer&lt;=maxSafe,
timer==0,
ready[openBus]==1,
reg[openBus]==512</label><nail x="672" y="480"/><nail x="512" y="480"/></transition><transition><source ref="id36"/><target ref="id26"/><label kind="guard" x="392" y="376">timer==period</label><label kind="synchronisation" x="392" y="392">end!</label><label kind="assignment" x="392" y="408">timer:=0</label><nail x="384" y="464"/><nail x="384" y="376"/></transition><transition><source ref="id26"/><target ref="id36"/><label kind="guard" x="208" y="384">reg[openBus]&gt;0</label><label kind="synchronisation" x="288" y="400">beg!</label><nail x="320" y="376"/><nail x="320" y="464"/></transition><transition><source ref="id27"/><target ref="id36"/><label kind="guard" x="384" y="488">timer==period</label><label kind="assignment" x="384" y="528">timer:=0</label><label kind="synchronisation" x="384" y="512">beg!</label></transition><transition><source ref="id35"/><target ref="id27"/><label kind="guard" x="544" y="496">memtimer&lt;=maxSafe,
timer==period,
ready[openBus]==1,
reg[openBus]==512</label><label kind="assignment" x="544" y="560">timer:=0</label><nail x="669" y="542"/><nail x="513" y="544"/></transition></template><template><name x="5" y="5">inBuffer</name><parameter x="8" y="24">const startId, id, size, initial, regId, inWire, outWire; int inBus, outBus;
chan begPut; chan endPut; const putAmount; 
chan begGet; chan endGet; const getAmount</parameter><declaration/><location id="id29" x="224" y="352"><name x="208" y="360">Idle</name><label kind="invariant" x="230" y="367"/></location><location id="id31" x="480" y="96"><name x="488" y="56">Writing</name><label kind="invariant" x="470" y="143"/></location><location id="id33" x="480" y="608"><name x="496" y="624">Reading</name><label kind="invariant" x="470" y="591"/></location><location id="id37" x="736" y="352"><name x="736" y="360">ReadingWriting</name><label kind="invariant" x="710" y="367"/></location><location id="id39" x="0" y="320"><name x="-24" y="288">Start</name></location><location id="id45" x="224" y="-160"><name x="176" y="-192">WritingIgnoreRead</name></location><location id="id46" x="-32" y="96"><name x="-80" y="48">IgnoreRead</name></location><init ref="id39"/><transition><source ref="id29"/><target ref="id31"/><label kind="guard" x="264" y="96">inWire==inBus,
space[id+N]&gt;=putAmount</label><label kind="synchronisation" x="264" y="128">begPut?</label><label kind="assignment" x="248" y="144">space[id+N]:=space[id+N]-putAmount</label><nail x="240" y="112"/></transition><transition><source ref="id31"/><target ref="id29"/><label kind="synchronisation" x="312" y="216">endPut?</label><label kind="assignment" x="264" y="232">space[id]:=space[id]+putAmount</label><label kind="guard" x="296" y="200">inWire==inBus</label></transition><transition><source ref="id29"/><target ref="id33"/><label kind="guard" x="248" y="528">outWire==outBus,
space[id]&gt;=getAmount,
ready[regId]==0</label><label kind="synchronisation" x="248" y="576">begGet?</label><label kind="assignment" x="248" y="592">space[id]:=space[id]-getAmount</label><nail x="224" y="608"/></transition><transition><source ref="id33"/><target ref="id29"/><label kind="synchronisation" x="344" y="448">endGet?</label><label kind="assignment" x="232" y="472">space[id+N]:=space[id+N]+getAmount</label><label kind="guard" x="320" y="416">outWire==outBus,
ready[regId]==0</label></transition><transition><source ref="id33"/><target ref="id37"/><label kind="guard" x="544" y="544">inWire==inBus,
space[id+N]&gt;=putAmount</label><label kind="synchronisation" x="544" y="576">begPut?</label><label kind="assignment" x="536" y="592">space[id+N]:=space[id+N]-putAmount</label><nail x="736" y="608"/></transition><transition><source ref="id37"/><target ref="id31"/><label kind="synchronisation" x="592" y="216">endGet?</label><label kind="assignment" x="488" y="232">space[id+N]:=space[id+N]+getAmount</label><label kind="guard" x="568" y="184">outWire==outBus,
ready[regId]==0</label></transition><transition><source ref="id37"/><target ref="id33"/><label kind="synchronisation" x="536" y="456">endPut?</label><label kind="assignment" x="504" y="472">space[id]:=space[id]+putAmount</label><label kind="guard" x="512" y="440">inWire==inBus</label></transition><transition><source ref="id31"/><target ref="id37"/><label kind="guard" x="520" y="80">outWire==outBus,
space[id]&gt;=getAmount,
ready[regId]==0</label><label kind="synchronisation" x="520" y="128">begGet?</label><label kind="assignment" x="520" y="144">space[id]:=space[id]-getAmount</label><nail x="736" y="96"/></transition><transition><source ref="id39"/><target ref="id29"/><label kind="assignment" x="0" y="368">space[id]:=initial,
space[id+N]:=size-initial</label><label kind="guard" x="0" y="336">starting==startId</label><label kind="synchronisation" x="0" y="352">start?</label></transition><transition><source ref="id29"/><target ref="id33"/><label kind="guard" x="176" y="632">outWire==outBus,
ready[regId]==1</label><label kind="synchronisation" x="176" y="672">begGet?</label><nail x="160" y="352"/><nail x="160" y="672"/><nail x="480" y="672"/></transition><transition><source ref="id31"/><target ref="id37"/><label kind="guard" x="680" y="32">outWire==outBus,
ready[regId]==1</label><label kind="synchronisation" x="736" y="72">begGet?</label><nail x="480" y="32"/><nail x="800" y="32"/><nail x="800" y="352"/></transition><transition><source ref="id33"/><target ref="id29"/><label kind="guard" x="360" y="352">outWire==outBus,
ready[regId]==1</label><label kind="synchronisation" x="408" y="384">endGet?</label><nail x="480" y="368"/><nail x="464" y="352"/></transition><transition><source ref="id37"/><target ref="id31"/><label kind="guard" x="488" y="296">outWire==outBus,
ready[regId]==1</label><label kind="synchronisation" x="496" y="328">endGet?</label><nail x="496" y="352"/><nail x="480" y="336"/></transition><transition><source ref="id31"/><target ref="id45"/><label kind="guard" x="328" y="-64">outWire==outBus,
space[id]&lt;getAmount,
ready[regId]==0</label><label kind="synchronisation" x="328" y="-16">begGet?</label></transition><transition><source ref="id45"/><target ref="id46"/><label kind="guard" x="104" y="32">inWire==inBus</label><label kind="synchronisation" x="120" y="48">endPut?</label><label kind="assignment" x="16" y="64">space[id]:=space[id]+putAmount</label><nail x="208" y="80"/></transition><transition><source ref="id46"/><target ref="id29"/><label kind="guard" x="36" y="194">outWire==outBus</label><label kind="synchronisation" x="36" y="209">endGet?</label></transition><transition><source ref="id29"/><target ref="id46"/><label kind="guard" x="72" y="112">outWire==outBus,
space[id]&lt;getAmount,
ready[regId]==0</label><label kind="synchronisation" x="144" y="160">begGet?</label><nail x="208" y="112"/></transition><transition><source ref="id46"/><target ref="id45"/><label kind="guard" x="-16" y="-80">inWire==inBus,
space[id+N]&gt;=putAmount</label><label kind="synchronisation" x="-16" y="-40">begPut?</label><label kind="assignment" x="-24" y="-24">space[id+N]:=space[id+N]-putAmount</label></transition><transition><source ref="id45"/><target ref="id31"/><label kind="guard" x="248" y="40">outWire==outBus</label><label kind="synchronisation" x="248" y="56">endGet?</label><nail x="240" y="80"/></transition></template><template><name x="5" y="5">outBuffer</name><parameter x="8" y="24">const startId, id, size, initial, regId, inWire, outWire; int inBus, outBus;
chan begPut; chan endPut; const putAmount; 
chan begGet; chan endGet; const getAmount</parameter><declaration/><location id="id38" x="224" y="352"><name x="208" y="320">Idle</name><label kind="invariant" x="230" y="367"/></location><location id="id40" x="480" y="96"><name x="496" y="72">Writing</name><label kind="invariant" x="470" y="143"/></location><location id="id41" x="480" y="608"><name x="416" y="584">Reading</name><label kind="invariant" x="470" y="591"/></location><location id="id42" x="736" y="352"><name x="736" y="328">ReadingWriting</name><label kind="invariant" x="710" y="367"/></location><location id="id44" x="-8" y="424"><name x="-40" y="384">Start</name></location><location id="id47" x="224" y="864"><name x="248" y="832">ReadingIgnoreWrite</name></location><location id="id48" x="-32" y="608"><name x="-104" y="576">IgnoreWrite</name></location><init ref="id44"/><transition><source ref="id38"/><target ref="id40"/><label kind="guard" x="248" y="80">inWire==inBus,
ready[regId]==0,
space[id+N]&gt;=putAmount</label><label kind="synchronisation" x="248" y="128">begPut?</label><label kind="assignment" x="248" y="144">space[id+N]:=space[id+N]-putAmount</label><nail x="224" y="96"/></transition><transition><source ref="id40"/><target ref="id38"/><label kind="synchronisation" x="296" y="232">endPut?</label><label kind="assignment" x="264" y="248">space[id]:=space[id]+putAmount</label><label kind="guard" x="272" y="200">inWire==inBus,
ready[regId]==0</label></transition><transition><source ref="id38"/><target ref="id41"/><label kind="guard" x="240" y="512">outWire==outBus,
space[id]&gt;=getAmount</label><label kind="synchronisation" x="248" y="544">begGet?</label><label kind="assignment" x="248" y="560">space[id]:=space[id]-getAmount</label><nail x="240" y="592"/></transition><transition><source ref="id41"/><target ref="id38"/><label kind="synchronisation" x="256" y="448">endGet?</label><label kind="assignment" x="248" y="464">space[id+N]:=space[id+N]+getAmount</label><label kind="guard" x="256" y="432">outWire==outBus</label></transition><transition><source ref="id41"/><target ref="id42"/><label kind="guard" x="536" y="528">inWire==inBus,
ready[regId]==0,
space[id+N]&gt;=putAmount</label><label kind="synchronisation" x="536" y="576">begPut?</label><label kind="assignment" x="536" y="592">space[id+N]:=space[id+N]-putAmount</label><nail x="736" y="608"/></transition><transition><source ref="id42"/><target ref="id40"/><label kind="synchronisation" x="608" y="232">endGet?</label><label kind="assignment" x="496" y="248">space[id+N]:=space[id+N]+getAmount</label><label kind="guard" x="592" y="216">outWire==outBus</label></transition><transition><source ref="id42"/><target ref="id41"/><label kind="synchronisation" x="552" y="448">endPut?</label><label kind="assignment" x="504" y="464">space[id]:=space[id]+putAmount</label><label kind="guard" x="520" y="416">inWire==inBus,
ready[regId]==0</label></transition><transition><source ref="id40"/><target ref="id42"/><label kind="guard" x="552" y="64">outWire==outBus,
space[id]&gt;=getAmount</label><label kind="synchronisation" x="552" y="96">begGet?</label><label kind="assignment" x="528" y="112">space[id]:=space[id]-getAmount</label><nail x="736" y="96"/></transition><transition><source ref="id44"/><target ref="id38"/><label kind="assignment" x="8" y="360">space[id]:=initial,
space[id+N]:=size-initial</label><label kind="guard" x="8" y="328">starting==startId</label><label kind="synchronisation" x="8" y="344">start?</label></transition><transition><source ref="id38"/><target ref="id40"/><label kind="guard" x="168" y="32">inWire==inBus,
ready[regId]==1</label><label kind="synchronisation" x="168" y="64">begPut?</label><nail x="160" y="353"/><nail x="159" y="32"/><nail x="480" y="31"/></transition><transition><source ref="id40"/><target ref="id38"/><label kind="guard" x="376" y="296">inWire==inBus,
ready[regId]==1</label><label kind="synchronisation" x="376" y="328">endPut?</label><nail x="480" y="336"/><nail x="461" y="352"/></transition><transition><source ref="id42"/><target ref="id41"/><label kind="guard" x="496" y="352">inWire==inBus,
ready[regId]==1</label><label kind="synchronisation" x="496" y="384">endPut?</label><nail x="498" y="352"/><nail x="481" y="371"/></transition><transition><source ref="id41"/><target ref="id42"/><label kind="guard" x="696" y="616">inWire==inBus,
ready[regId]==1</label><label kind="synchronisation" x="712" y="648">begPut?</label><nail x="478" y="673"/><nail x="802" y="671"/><nail x="799" y="350"/></transition><transition><source ref="id48"/><target ref="id38"/><label kind="guard" x="24" y="480">inWire==inBus</label><label kind="synchronisation" x="16" y="504">endPut?</label></transition><transition><source ref="id38"/><target ref="id48"/><label kind="guard" x="72" y="520">inWire==inBus,
ready[regId]==0,
space[id+N]&lt;putAmount</label><label kind="synchronisation" x="72" y="576">begPut?</label><nail x="208" y="595"/></transition><transition><source ref="id48"/><target ref="id47"/><label kind="guard" x="8" y="680">outWire==outBus,
space[id]&gt;=getAmount</label><label kind="synchronisation" x="8" y="712">begGet?</label><label kind="assignment" x="8" y="728">space[id]:=space[id]-getAmount</label></transition><transition><source ref="id47"/><target ref="id48"/><label kind="guard" x="64" y="616">outWire==outBus</label><label kind="synchronisation" x="104" y="632">endGet?</label><label kind="assignment" x="24" y="648">space[id+N]:=space[id+N]+getAmount</label><nail x="208" y="624"/></transition><transition><source ref="id47"/><target ref="id41"/><label kind="guard" x="256" y="624">inWire==inBus</label><label kind="synchronisation" x="256" y="640">endPut?</label><nail x="241" y="624"/></transition><transition><source ref="id41"/><target ref="id47"/><label kind="guard" x="280" y="680">inWire==inBus,
ready[regId]==0,
space[id+N]&lt;putAmount</label><label kind="synchronisation" x="288" y="736">begPut?</label></transition></template><template><name x="328" y="224">ArbiterS</name><parameter x="328" y="248">const period;
chan beg, end</parameter><declaration>const unsafe 625;
const refreshTime 100;
const maxSafe unsafe-25;
clock memtimer, timer;</declaration><location id="id43" x="704" y="336"><name x="720" y="328">Start</name><committed/></location><location id="id49" x="704" y="512"><name x="736" y="520">Ready</name><label kind="invariant" x="736" y="536">timer&lt;=period</label></location><location id="id50" x="352" y="512"><name x="280" y="504">Transfer</name><label kind="invariant" x="280" y="528">timer&lt;=period</label></location><location id="id51" x="704" y="704"><name x="728" y="680">Refresh</name><label kind="invariant" x="728" y="696">memtimer&lt;=unsafe+refreshTime</label><urgent/></location><location id="id52" x="352" y="336"><name x="328" y="304">Finish</name><committed/></location><location id="id53" x="480" y="512"><name x="464" y="528">Setup</name><label kind="invariant" x="432" y="544">timer&lt;=period</label></location><init ref="id43"/><transition><source ref="id43"/><target ref="id49"/><label kind="assignment" x="712" y="360">timer:=0,
openBus:=0,
memtimer:=0</label></transition><transition><source ref="id52"/><target ref="id49"/><label kind="assignment" x="384" y="336">openBus:=(openBus==N-1?0:openBus+1)</label><label kind="guard" x="384" y="312">reg[openBus]==0</label><nail x="656" y="336"/></transition><transition><source ref="id49"/><target ref="id49"/><label kind="guard" x="872" y="432">memtimer&lt;=maxSafe,
timer==period,
ready[openBus]==0</label><label kind="assignment" x="872" y="480">openBus:=(openBus==N-1?0:openBus+1),
timer:=0</label><nail x="864" y="432"/><nail x="864" y="512"/></transition><transition><source ref="id51"/><target ref="id49"/><label kind="guard" x="744" y="600">memtimer==unsafe+refreshTime</label><label kind="assignment" x="744" y="624">memtimer:=0,
timer:=0</label><nail x="736" y="656"/><nail x="736" y="568"/></transition><transition><source ref="id49"/><target ref="id51"/><label kind="guard" x="560" y="592">memtimer&gt;maxSafe</label><nail x="672" y="568"/><nail x="672" y="656"/></transition><transition><source ref="id49"/><target ref="id53"/><label kind="guard" x="520" y="408">memtimer&lt;=maxSafe,
timer==0,
ready[openBus]==1,
reg[openBus]==512</label><nail x="672" y="480"/><nail x="512" y="480"/></transition><transition><source ref="id50"/><target ref="id52"/><label kind="guard" x="392" y="376">timer==period</label><label kind="synchronisation" x="392" y="392">end!</label><label kind="assignment" x="392" y="408">timer:=0</label><nail x="384" y="464"/><nail x="384" y="376"/></transition><transition><source ref="id52"/><target ref="id50"/><label kind="guard" x="208" y="384">reg[openBus]&gt;0</label><label kind="synchronisation" x="288" y="400">beg!</label><nail x="320" y="376"/><nail x="320" y="464"/></transition><transition><source ref="id53"/><target ref="id50"/><label kind="guard" x="384" y="488">timer==period</label><label kind="assignment" x="384" y="528">timer:=0</label><label kind="synchronisation" x="384" y="512">beg!</label></transition><transition><source ref="id49"/><target ref="id53"/><label kind="guard" x="544" y="496">memtimer&lt;=maxSafe,
timer==period,
ready[openBus]==1,
reg[openBus]==512</label><label kind="assignment" x="544" y="560">timer:=0</label><nail x="669" y="542"/><nail x="513" y="544"/></transition></template><template><name x="328" y="224">ArbiterN</name><parameter x="328" y="248">const period;
chan beg, end</parameter><declaration>clock timer;</declaration><location id="id54" x="704" y="336"><name x="720" y="328">Start</name><committed/></location><location id="id55" x="704" y="512"><name x="736" y="520">Ready</name><label kind="invariant" x="736" y="536">timer&lt;=period</label></location><location id="id56" x="352" y="512"><name x="280" y="504">Transfer</name><label kind="invariant" x="280" y="528">timer&lt;=period</label></location><location id="id58" x="352" y="336"><name x="328" y="304">Finish</name><committed/></location><location id="id59" x="480" y="512"><name x="464" y="528">Setup</name><label kind="invariant" x="432" y="544">timer&lt;=period</label></location><init ref="id54"/><transition><source ref="id54"/><target ref="id55"/><label kind="assignment" x="712" y="360">timer:=0,
openBus:=0</label></transition><transition><source ref="id58"/><target ref="id55"/><label kind="assignment" x="384" y="336">openBus:=(openBus==N-1?0:openBus+1)</label><label kind="guard" x="384" y="312">reg[openBus]==0</label><nail x="656" y="336"/></transition><transition><source ref="id55"/><target ref="id55"/><label kind="guard" x="872" y="432">timer==period,
ready[openBus]==0</label><label kind="assignment" x="872" y="480">openBus:=(openBus==N-1?0:openBus+1),
timer:=0</label><nail x="864" y="432"/><nail x="864" y="512"/></transition><transition><source ref="id55"/><target ref="id59"/><label kind="guard" x="520" y="424">timer==0,
ready[openBus]==1,
reg[openBus]==512</label><nail x="672" y="480"/><nail x="512" y="480"/></transition><transition><source ref="id56"/><target ref="id58"/><label kind="guard" x="392" y="376">timer==period</label><label kind="synchronisation" x="392" y="392">end!</label><label kind="assignment" x="392" y="408">timer:=0</label><nail x="384" y="464"/><nail x="384" y="376"/></transition><transition><source ref="id58"/><target ref="id56"/><label kind="guard" x="208" y="384">reg[openBus]&gt;0</label><label kind="synchronisation" x="288" y="400">beg!</label><nail x="320" y="376"/><nail x="320" y="464"/></transition><transition><source ref="id59"/><target ref="id56"/><label kind="guard" x="384" y="488">timer==period</label><label kind="assignment" x="384" y="528">timer:=0</label><label kind="synchronisation" x="384" y="512">beg!</label></transition><transition><source ref="id55"/><target ref="id59"/><label kind="guard" x="544" y="496">timer==period,
ready[openBus]==1,
reg[openBus]==512</label><label kind="assignment" x="544" y="552">timer:=0</label><nail x="669" y="542"/><nail x="513" y="544"/></transition></template><template><name x="5" y="5">Timer</name><parameter x="5" y="20">const startId, period, count</parameter><declaration>clock time;</declaration><location id="id57" x="-176" y="-32"><name x="-216" y="-16">Prepare</name><committed/><committed/></location><location id="id60" x="-24" y="-32"><name x="-24" y="-64">Ticking</name></location><location id="id61" x="-368" y="-160"><name x="-392" y="-192">Pause</name><label kind="invariant" x="-416" y="-208">time&lt;=period</label></location><location id="id62" x="-176" y="-160"><name x="-184" y="-200">Start</name></location><location id="id63" x="-368" y="-32"><name x="-384" y="-16">Tacking</name></location><init ref="id62"/><transition><source ref="id57"/><target ref="id60"/><label kind="synchronisation" x="-128" y="-80">tick!</label><label kind="guard" x="-136" y="-64">turn&lt;count</label><nail x="-136" y="-64"/><nail x="-56" y="-64"/></transition><transition><source ref="id60"/><target ref="id57"/><label kind="synchronisation" x="-128" y="-16">tick?</label><label kind="assignment" x="-136" y="0">turn:=turn+1</label><nail x="-56" y="0"/><nail x="-136" y="0"/></transition><transition><source ref="id62"/><target ref="id57"/><label kind="assignment" x="-168" y="-120">turn:=0</label><label kind="guard" x="-168" y="-152">starting==startId</label><label kind="synchronisation" x="-168" y="-136">start?</label></transition><transition><source ref="id57"/><target ref="id61"/><label kind="guard" x="-296" y="-176">turn==count</label><label kind="assignment" x="-296" y="-160">time:=0,
turn:=turn-1</label><nail x="-208" y="-160"/></transition><transition><source ref="id61"/><target ref="id63"/><label kind="synchronisation" x="-328" y="-96">tack!</label><label kind="guard" x="-328" y="-112">time==period</label><nail x="-336" y="-128"/><nail x="-336" y="-64"/></transition><transition><source ref="id63"/><target ref="id61"/><label kind="synchronisation" x="-408" y="-112">tack?</label><label kind="assignment" x="-408" y="-96">turn:=turn-1</label><label kind="guard" x="-408" y="-128">turn&gt;0</label><nail x="-416" y="-64"/><nail x="-416" y="-128"/></transition><transition><source ref="id63"/><target ref="id57"/><label kind="guard" x="-264" y="-56">turn==0</label><label kind="synchronisation" x="-256" y="-32">tack?</label></transition></template><template><name x="328" y="224">ArbiterNT</name><parameter x="328" y="248">const startId, me;
chan beg, end</parameter><declaration/><location id="id64" x="800" y="448"><name x="792" y="408">Start</name></location><location id="id65" x="800" y="640"><name x="808" y="584">Ready</name></location><location id="id66" x="448" y="384"><name x="424" y="344">Transfer</name></location><location id="id67" x="448" y="576"><name x="400" y="576">Wait</name></location><location id="id68" x="544" y="640"><name x="520" y="608">Setting</name></location><location id="id69" x="640" y="640"><name x="632" y="664">Setup</name><committed/><committed/></location><location id="id70" x="448" y="640"><name x="360" y="632">FinishSetup</name><committed/><committed/></location><location id="id71" x="480" y="448"><committed/></location><location id="id72" x="480" y="512"><committed/></location><location id="id73" x="416" y="448"><committed/></location><location id="id74" x="416" y="512"><committed/></location><location id="id75" x="960" y="640"><name x="968" y="592">Switch</name><committed/><committed/></location><location id="id76" x="1120" y="640"><name x="1136" y="632">SkipTack2</name><committed/><committed/></location><location id="id77" x="1024" y="640"><name x="1024" y="584">Switching</name></location><location id="id78" x="544" y="704"><name x="560" y="696">SkipTack</name><committed/><committed/></location><location id="id79" x="544" y="768"><name x="560" y="768">WaitForTick</name></location><location id="id80" x="448" y="768"><name x="376" y="760">SkipTick</name><committed/><committed/></location><location id="id81" x="448" y="704"><name x="384" y="696">Setting2</name></location><location id="id82" x="1120" y="704"><name x="1136" y="696">WaitForTick2</name></location><location id="id83" x="1120" y="768"><name x="1136" y="760">SkipTick2</name><committed/><committed/></location><location id="id84" x="800" y="704"><name x="824" y="696">FinishSwitch</name><committed/><committed/></location><location id="id85" x="800" y="768"><name x="712" y="752">Switching2</name></location><init ref="id64"/><transition><source ref="id64"/><target ref="id65"/><label kind="assignment" x="808" y="504">openBus:=0</label><label kind="guard" x="808" y="472">starting==startId</label><label kind="synchronisation" x="808" y="488">start?</label></transition><transition><source ref="id72"/><target ref="id65"/><label kind="assignment" x="504" y="512">openBus:=(openBus==N-1?0:openBus+1)</label><label kind="guard" x="568" y="472">reg[openBus]==0</label><label kind="synchronisation" x="568" y="488">tack!</label><nail x="768" y="512"/></transition><transition><source ref="id77"/><target ref="id76"/><label kind="guard" x="1040" y="624">turn==me</label><label kind="synchronisation" x="1048" y="640">tack?</label></transition><transition><source ref="id65"/><target ref="id69"/><label kind="guard" x="656" y="592">turn==me,
ready[openBus]==1,
reg[openBus]==512</label><label kind="synchronisation" x="664" y="648">tick?</label></transition><transition><source ref="id71"/><target ref="id72"/><label kind="synchronisation" x="488" y="464">end!</label></transition><transition><source ref="id74"/><target ref="id73"/><label kind="synchronisation" x="384" y="472">beg!</label></transition><transition><source ref="id69"/><target ref="id68"/><label kind="synchronisation" x="584" y="616">tick!</label></transition><transition><source ref="id81"/><target ref="id70"/><label kind="guard" x="456" y="656">turn==me</label><label kind="synchronisation" x="456" y="672">tack?</label></transition><transition><source ref="id70"/><target ref="id67"/><label kind="synchronisation" x="456" y="600">tack!</label></transition><transition><source ref="id66"/><target ref="id71"/><label kind="guard" x="472" y="384">turn==me</label><label kind="synchronisation" x="488" y="400">tack?</label><nail x="480" y="416"/></transition><transition><source ref="id72"/><target ref="id67"/><label kind="synchronisation" x="480" y="552">tack!</label><label kind="guard" x="488" y="536">reg[openBus]&gt;0</label><nail x="480" y="544"/></transition><transition><source ref="id67"/><target ref="id74"/><label kind="guard" x="352" y="536">turn==me</label><label kind="synchronisation" x="392" y="552">tick?</label><nail x="416" y="544"/></transition><transition><source ref="id73"/><target ref="id66"/><label kind="synchronisation" x="384" y="400">tick!</label><nail x="416" y="416"/></transition><transition><source ref="id65"/><target ref="id75"/><label kind="guard" x="824" y="608">turn==me,
ready[openBus]==0</label><label kind="synchronisation" x="848" y="640">tick?</label></transition><transition><source ref="id75"/><target ref="id77"/><label kind="synchronisation" x="976" y="640">tick!</label></transition><transition><source ref="id84"/><target ref="id65"/><label kind="synchronisation" x="808" y="664">tack!</label></transition><transition><source ref="id68"/><target ref="id78"/><label kind="guard" x="560" y="656">turn==me</label><label kind="synchronisation" x="560" y="672">tack?</label></transition><transition><source ref="id78"/><target ref="id79"/><label kind="synchronisation" x="552" y="728">tack!</label></transition><transition><source ref="id79"/><target ref="id80"/><label kind="guard" x="472" y="744">turn==me</label><label kind="synchronisation" x="480" y="768">tick?</label></transition><transition><source ref="id80"/><target ref="id81"/><label kind="synchronisation" x="456" y="720">tick!</label></transition><transition><source ref="id76"/><target ref="id82"/><label kind="synchronisation" x="1128" y="664">tack!</label></transition><transition><source ref="id82"/><target ref="id83"/><label kind="guard" x="1128" y="720">turn==me</label><label kind="synchronisation" x="1128" y="736">tick?</label></transition><transition><source ref="id83"/><target ref="id85"/><label kind="assignment" x="824" y="768">openBus:=(openBus==N-1?0:openBus+1)</label><label kind="synchronisation" x="888" y="744">tick!</label></transition><transition><source ref="id85"/><target ref="id84"/><label kind="guard" x="808" y="720">turn==me</label><label kind="synchronisation" x="808" y="736">tack?</label></transition></template><template><name x="32" y="72">Bus</name><parameter x="32" y="88">const startId, me, wireCount, skipCount;
int bus;
chan beg, end</parameter><declaration>int counter;</declaration><location id="id86" x="-352" y="-832"><name x="-328" y="-840">Begin</name><committed/></location><location id="id87" x="-640" y="-928"><name x="-656" y="-968">End</name><committed/><committed/></location><location id="id88" x="-640" y="-832"><name x="-672" y="-864">Wait</name></location><location id="id89" x="-352" y="-1024"><name x="-392" y="-1064">Start</name></location><location id="id90" x="-352" y="-928"><name x="-336" y="-936">Stop</name></location><location id="id91" x="-512" y="-832"><name x="-544" y="-872">FinishBegin</name><committed/><committed/></location><location id="id92" x="-512" y="-928"><name x="-536" y="-968">FinishEnd</name><committed/><committed/></location><location id="id93" x="-640" y="-704"><name x="-672" y="-688">SkipTack</name><committed/></location><location id="id94" x="-768" y="-704"><name x="-808" y="-688">WaitForTick</name></location><location id="id95" x="-768" y="-832"><name x="-848" y="-840">SkipTick</name><committed/></location><init ref="id89"/><transition><source ref="id86"/><target ref="id86"/><label kind="assignment" x="-432" y="-720">bus:=bus+1</label><label kind="guard" x="-432" y="-752">bus&lt;wireCount-1</label><label kind="synchronisation" x="-432" y="-736">beg!</label><nail x="-320" y="-736"/><nail x="-448" y="-736"/></transition><transition><source ref="id86"/><target ref="id91"/><label kind="guard" x="-480" y="-848">bus==wireCount-1</label><label kind="synchronisation" x="-480" y="-832">beg!</label></transition><transition><source ref="id87"/><target ref="id87"/><label kind="synchronisation" x="-760" y="-936">end!</label><label kind="assignment" x="-760" y="-920">bus:=bus-1</label><label kind="guard" x="-760" y="-952">bus&gt;0</label><nail x="-768" y="-864"/><nail x="-768" y="-968"/></transition><transition><source ref="id88"/><target ref="id87"/><label kind="guard" x="-632" y="-912">turn==me,
counter==skipCount</label><label kind="synchronisation" x="-632" y="-880">tack?</label></transition><transition><source ref="id87"/><target ref="id92"/><label kind="guard" x="-600" y="-952">bus==0</label><label kind="synchronisation" x="-592" y="-928">end!</label></transition><transition><source ref="id89"/><target ref="id90"/><label kind="assignment" x="-344" y="-976">bus:=0</label><label kind="guard" x="-344" y="-1008">starting==startId</label><label kind="synchronisation" x="-344" y="-992">start?</label></transition><transition><source ref="id90"/><target ref="id86"/><label kind="guard" x="-344" y="-896">turn==me</label><label kind="synchronisation" x="-344" y="-872">tick?</label></transition><transition><source ref="id91"/><target ref="id88"/><label kind="synchronisation" x="-584" y="-848">tick!</label><label kind="assignment" x="-608" y="-832">counter:=0</label></transition><transition><source ref="id92"/><target ref="id90"/><label kind="synchronisation" x="-472" y="-944">tack!</label></transition><transition><source ref="id88"/><target ref="id93"/><label kind="guard" x="-632" y="-784">turn==me,
counter&lt;skipCount</label><label kind="synchronisation" x="-632" y="-752">tack?</label><label kind="assignment" x="-632" y="-736">counter:=counter+1</label></transition><transition><source ref="id95"/><target ref="id88"/><label kind="synchronisation" x="-728" y="-856">tick!</label></transition><transition><source ref="id93"/><target ref="id94"/><label kind="synchronisation" x="-720" y="-720">tack!</label></transition><transition><source ref="id94"/><target ref="id95"/><label kind="synchronisation" x="-800" y="-768">tick?</label><label kind="guard" x="-832" y="-792">turn==me</label></transition></template><template><name x="5" y="5">Starter</name><parameter x="5" y="20"/><declaration/><location id="id99" x="-80" y="0"><name x="-96" y="-40">Start</name><committed/></location><location id="id100" x="88" y="0"><name x="80" y="-32">Stay</name></location><init ref="id99"/><transition><source ref="id99"/><target ref="id99"/><label kind="synchronisation" x="-96" y="40">start!</label><label kind="assignment" x="-128" y="64">starting:=starting+1</label><label kind="guard" x="-112" y="24">starting&lt;21</label><nail x="-160" y="64"/><nail x="8" y="64"/></transition><transition><source ref="id99"/><target ref="id100"/><label kind="guard" x="-32" y="-24">starting==21</label><label kind="synchronisation" x="-16" y="0">start!</label></transition></template><template><name x="328" y="224">ArbiterT</name><parameter x="328" y="248">const startId, me;
chan beg, end</parameter><declaration>const unsafe 2304; // 3125;
const refreshCycle 20;
int counter;
//3119 prepare for refresh
const maxSafe unsafe-6;
//3125+20=3139 end of full refresh
const maxUnsafe unsafe+refreshCycle;
</declaration><location id="id96" x="800" y="400"><name x="784" y="352">Start</name></location><location id="id97" x="800" y="512"><name x="744" y="480">Ready</name></location><location id="id98" x="448" y="384"><name x="424" y="344">Transfer</name></location><location id="id101" x="448" y="576"><name x="400" y="576">Wait</name></location><location id="id102" x="520" y="608"><name x="496" y="576">Setting</name></location><location id="id103" x="640" y="608"><name x="608" y="616">Setup</name><committed/><committed/></location><location id="id104" x="448" y="640"><name x="360" y="632">FinishSetup</name><committed/><committed/></location><location id="id105" x="480" y="448"><committed/></location><location id="id106" x="480" y="512"><committed/></location><location id="id107" x="416" y="448"><committed/></location><location id="id108" x="416" y="512"><committed/></location><location id="id109" x="960" y="416"><name x="936" y="432">Switch</name><committed/><committed/></location><location id="id110" x="1120" y="416"><name x="1088" y="384">SkipTack2</name><committed/><committed/></location><location id="id111" x="1024" y="416"><name x="992" y="376">Switching</name></location><location id="id112" x="520" y="704"><name x="536" y="696">SkipTack</name><committed/><committed/></location><location id="id113" x="520" y="768"><name x="536" y="768">WaitForTick</name></location><location id="id114" x="448" y="768"><name x="376" y="760">SkipTick</name><committed/><committed/></location><location id="id115" x="448" y="704"><name x="384" y="696">Setting2</name></location><location id="id116" x="1120" y="464"><name x="1136" y="448">WaitForTick2</name></location><location id="id117" x="1120" y="512"><name x="1136" y="512">SkipTick2</name><committed/><committed/></location><location id="id118" x="864" y="512"><name x="832" y="528">FinishSwitch</name><committed/><committed/></location><location id="id119" x="952" y="512"><name x="928" y="544">Switching2</name></location><location id="id120" x="960" y="624"><name x="984" y="600">SwithRefresh</name><committed/></location><location id="id121" x="960" y="736"><name x="984" y="728">Refresh</name></location><location id="id122" x="800" y="736"><name x="696" y="720">LeaveRefresh</name><committed/></location><init ref="id96"/><transition><source ref="id96"/><target ref="id97"/><label kind="assignment" x="704" y="440">openBus:=0,
counter:=0</label><label kind="guard" x="696" y="408">starting==startId</label><label kind="synchronisation" x="696" y="424">start?</label></transition><transition><source ref="id106"/><target ref="id97"/><label kind="assignment" x="504" y="512">openBus:=(openBus==N-1?0:openBus+1)</label><label kind="guard" x="568" y="472">reg[openBus]==0</label><label kind="synchronisation" x="568" y="488">tack!</label><nail x="760" y="512"/></transition><transition><source ref="id111"/><target ref="id110"/><label kind="guard" x="1040" y="416">turn==me</label><label kind="synchronisation" x="1048" y="432">tack?</label></transition><transition><source ref="id97"/><target ref="id103"/><label kind="guard" x="656" y="544">turn==me,
ready[openBus]==1,
reg[openBus]==512,
counter&lt;=maxSafe</label><label kind="synchronisation" x="664" y="608">tick?</label><label kind="assignment" x="656" y="624">counter:=counter+1</label><nail x="784" y="608"/></transition><transition><source ref="id105"/><target ref="id106"/><label kind="synchronisation" x="488" y="464">end!</label></transition><transition><source ref="id108"/><target ref="id107"/><label kind="synchronisation" x="384" y="472">beg!</label></transition><transition><source ref="id103"/><target ref="id102"/><label kind="synchronisation" x="560" y="584">tick!</label></transition><transition><source ref="id115"/><target ref="id104"/><label kind="guard" x="456" y="656">turn==me</label><label kind="synchronisation" x="456" y="672">tack?</label></transition><transition><source ref="id104"/><target ref="id101"/><label kind="synchronisation" x="456" y="600">tack!</label></transition><transition><source ref="id98"/><target ref="id105"/><label kind="guard" x="472" y="384">turn==me</label><label kind="synchronisation" x="488" y="400">tack?</label><nail x="480" y="416"/></transition><transition><source ref="id106"/><target ref="id101"/><label kind="synchronisation" x="472" y="560">tack!</label><label kind="guard" x="480" y="544">reg[openBus]&gt;0</label><nail x="480" y="544"/></transition><transition><source ref="id101"/><target ref="id108"/><label kind="guard" x="344" y="520">turn==me</label><label kind="synchronisation" x="344" y="536">tick?</label><label kind="assignment" x="344" y="552">counter:=counter+1</label><nail x="416" y="544"/></transition><transition><source ref="id107"/><target ref="id98"/><label kind="synchronisation" x="384" y="400">tick!</label><nail x="416" y="416"/></transition><transition><source ref="id97"/><target ref="id109"/><label kind="guard" x="832" y="360">turn==me,
ready[openBus]==0,
counter&lt;=maxSafe</label><label kind="synchronisation" x="856" y="416">tick?</label><label kind="assignment" x="808" y="432">counter:=counter+1</label><nail x="832" y="416"/></transition><transition><source ref="id109"/><target ref="id111"/><label kind="synchronisation" x="976" y="416">tick!</label></transition><transition><source ref="id118"/><target ref="id97"/><label kind="synchronisation" x="824" y="488">tack!</label></transition><transition><source ref="id102"/><target ref="id112"/><label kind="guard" x="536" y="616">turn==me</label><label kind="synchronisation" x="536" y="672">tack?</label></transition><transition><source ref="id112"/><target ref="id113"/><label kind="synchronisation" x="528" y="728">tack!</label></transition><transition><source ref="id113"/><target ref="id114"/><label kind="guard" x="448" y="744">turn==me</label><label kind="synchronisation" x="480" y="768">tick?</label><label kind="assignment" x="432" y="784">counter:=counter+1</label></transition><transition><source ref="id114"/><target ref="id115"/><label kind="synchronisation" x="456" y="720">tick!</label></transition><transition><source ref="id110"/><target ref="id116"/><label kind="synchronisation" x="1128" y="432">tack!</label></transition><transition><source ref="id116"/><target ref="id117"/><label kind="guard" x="1136" y="464">turn==me</label><label kind="synchronisation" x="1136" y="480">tick?</label><label kind="assignment" x="1136" y="496">counter:=counter+1</label></transition><transition><source ref="id117"/><target ref="id119"/><label kind="assignment" x="944" y="528">openBus:=(openBus==N-1?0:openBus+1)</label><label kind="synchronisation" x="1032" y="488">tick!</label></transition><transition><source ref="id119"/><target ref="id118"/><label kind="guard" x="880" y="472">turn==me</label><label kind="synchronisation" x="896" y="488">tack?</label></transition><transition><source ref="id97"/><target ref="id120"/><label kind="guard" x="832" y="552">turn==me,
counter&gt;maxSafe</label><label kind="synchronisation" x="832" y="584">tick?</label><label kind="assignment" x="832" y="600">counter:=counter+1</label><nail x="832" y="624"/></transition><transition><source ref="id120"/><target ref="id121"/><label kind="synchronisation" x="936" y="640">tick!</label></transition><transition><source ref="id121"/><target ref="id122"/><label kind="guard" x="824" y="672">turn==me, 
counter&lt;maxUnsafe</label><label kind="synchronisation" x="832" y="704">tack?</label><nail x="928" y="768"/><nail x="832" y="768"/></transition><transition><source ref="id121"/><target ref="id122"/><label kind="guard" x="816" y="768">turn==me,
counter==maxUnsafe</label><label kind="synchronisation" x="816" y="800">tack?</label><label kind="assignment" x="816" y="816">counter:=0</label><nail x="928" y="704"/><nail x="832" y="704"/></transition><transition><source ref="id122"/><target ref="id97"/><label kind="synchronisation" x="808" y="640">tack!</label></transition></template><template><name x="328" y="224">ArbiterTO</name><parameter x="328" y="248">const startId, me;
chan beg, end</parameter><declaration>const unsafe 3124; //2304;
const refreshCycle 20;
int counter;
//3119 prepare for refresh
const maxSafe unsafe-6;
//3125+20=3139 end of full refresh
const maxUnsafe unsafe+refreshCycle;
</declaration><location id="id123" x="608" y="384"><name x="584" y="344">Start</name></location><location id="id124" x="800" y="512"><name x="744" y="480">Ready</name></location><location id="id125" x="448" y="384"><name x="424" y="344">Transfer</name></location><location id="id126" x="448" y="576"><name x="400" y="576">Wait</name></location><location id="id127" x="520" y="608"><name x="496" y="576">Setting</name></location><location id="id128" x="640" y="608"><name x="608" y="616">Setup</name><committed/><committed/></location><location id="id129" x="448" y="640"><name x="360" y="632">FinishSetup</name><committed/><committed/></location><location id="id130" x="480" y="448"><committed/></location><location id="id131" x="480" y="512"><committed/></location><location id="id132" x="416" y="448"><committed/></location><location id="id133" x="416" y="512"><committed/></location><location id="id134" x="984" y="352"><name x="968" y="368">Switch</name><committed/><committed/></location><location id="id135" x="1152" y="352"><name x="1120" y="320">SkipTack2</name><committed/><committed/></location><location id="id136" x="1056" y="352"><name x="1024" y="312">Switching</name></location><location id="id137" x="520" y="704"><name x="536" y="696">SkipTack</name><committed/><committed/></location><location id="id138" x="520" y="768"><name x="536" y="768">WaitForTick</name></location><location id="id139" x="448" y="768"><name x="376" y="760">SkipTick</name><committed/><committed/></location><location id="id140" x="448" y="704"><name x="384" y="696">Setting2</name></location><location id="id141" x="1152" y="416"><name x="1176" y="400">WaitForTick2</name></location><location id="id142" x="1152" y="512"><name x="1176" y="512">SwitchRefresh</name><committed/></location><location id="id143" x="1056" y="512"><name x="1032" y="472">Refresh</name></location><location id="id144" x="928" y="512"><name x="896" y="472">SkipTack1</name><committed/><committed/></location><init ref="id123"/><transition><source ref="id123"/><target ref="id124"/><label kind="assignment" x="664" y="384">openBus:=0,
counter:=0</label><label kind="guard" x="640" y="352">starting==startId</label><label kind="synchronisation" x="648" y="368">start?</label></transition><transition><source ref="id131"/><target ref="id124"/><label kind="assignment" x="504" y="512">openBus:=(openBus==N-1?0:openBus+1)</label><label kind="guard" x="568" y="472">reg[openBus]==0</label><label kind="synchronisation" x="568" y="488">tack!</label></transition><transition><source ref="id136"/><target ref="id135"/><label kind="guard" x="1072" y="352">turn==me</label><label kind="synchronisation" x="1080" y="368">tack?</label></transition><transition><source ref="id124"/><target ref="id128"/><label kind="guard" x="664" y="544">turn==me,
ready[openBus]==1,
reg[openBus]==512,
counter&lt;=maxSafe</label><label kind="synchronisation" x="664" y="624">tick?</label><label kind="assignment" x="664" y="640">counter:=counter+1</label><nail x="800" y="608"/></transition><transition><source ref="id130"/><target ref="id131"/><label kind="synchronisation" x="488" y="464">end!</label></transition><transition><source ref="id133"/><target ref="id132"/><label kind="synchronisation" x="384" y="472">beg!</label></transition><transition><source ref="id128"/><target ref="id127"/><label kind="synchronisation" x="560" y="584">tick!</label></transition><transition><source ref="id140"/><target ref="id129"/><label kind="guard" x="456" y="656">turn==me</label><label kind="synchronisation" x="456" y="672">tack?</label></transition><transition><source ref="id129"/><target ref="id126"/><label kind="synchronisation" x="456" y="600">tack!</label></transition><transition><source ref="id125"/><target ref="id130"/><label kind="guard" x="472" y="384">turn==me</label><label kind="synchronisation" x="488" y="400">tack?</label><nail x="480" y="416"/></transition><transition><source ref="id131"/><target ref="id126"/><label kind="synchronisation" x="472" y="560">tack!</label><label kind="guard" x="480" y="544">reg[openBus]&gt;0</label><nail x="480" y="544"/></transition><transition><source ref="id126"/><target ref="id133"/><label kind="guard" x="344" y="520">turn==me</label><label kind="synchronisation" x="344" y="536">tick?</label><label kind="assignment" x="344" y="552">counter:=counter+1</label><nail x="416" y="544"/></transition><transition><source ref="id132"/><target ref="id125"/><label kind="synchronisation" x="384" y="400">tick!</label><nail x="416" y="416"/></transition><transition><source ref="id124"/><target ref="id134"/><label kind="guard" x="808" y="312">turn==me,
ready[openBus]==0</label><label kind="synchronisation" x="816" y="360">tick?</label><label kind="assignment" x="808" y="384">counter:=(counter==maxUnsafe-1?
0:counter+1)</label><nail x="800" y="352"/></transition><transition><source ref="id134"/><target ref="id136"/><label kind="synchronisation" x="1008" y="352">tick!</label></transition><transition><source ref="id127"/><target ref="id137"/><label kind="guard" x="536" y="616">turn==me</label><label kind="synchronisation" x="536" y="672">tack?</label></transition><transition><source ref="id137"/><target ref="id138"/><label kind="synchronisation" x="528" y="728">tack!</label></transition><transition><source ref="id138"/><target ref="id139"/><label kind="guard" x="448" y="744">turn==me</label><label kind="synchronisation" x="480" y="768">tick?</label><label kind="assignment" x="432" y="784">counter:=counter+1</label></transition><transition><source ref="id139"/><target ref="id140"/><label kind="synchronisation" x="456" y="720">tick!</label></transition><transition><source ref="id135"/><target ref="id141"/><label kind="synchronisation" x="1168" y="360">tack!</label></transition><transition><source ref="id141"/><target ref="id142"/><label kind="guard" x="1160" y="424">turn==me</label><label kind="synchronisation" x="1160" y="440">tick?</label><label kind="assignment" x="1160" y="456">counter:=(counter==maxUnsafe-1?0:counter+1),
openBus:=(openBus==N-1?0:openBus+1)</label></transition><transition><source ref="id142"/><target ref="id143"/><label kind="synchronisation" x="1096" y="488">tick!</label></transition><transition><source ref="id143"/><target ref="id144"/><label kind="guard" x="968" y="488">turn==me</label><label kind="synchronisation" x="976" y="512">tack?</label></transition><transition><source ref="id144"/><target ref="id124"/><label kind="synchronisation" x="856" y="488">tack!</label></transition><transition><source ref="id124"/><target ref="id142"/><label kind="guard" x="920" y="544">turn==me,
ready[openBus]==1,
counter&gt;maxSafe</label><label kind="synchronisation" x="920" y="592">tick?</label><label kind="assignment" x="840" y="616">counter:=(counter==maxUnsafe-1?0:counter+1)</label><nail x="864" y="608"/><nail x="1088" y="608"/></transition></template><instantiation>//Insert process assignments.

starter:=Starter();

//Timer: const period, count
timer:=Timer(21, 5, 3);

//BusOLD: const wireCount, delay, period; int bus; chan beg, end
// bus0:=BusOLD(wireCount0, 20, 10, bus0Wire, begSig, endSig);


//Bus: const me, wireCount, skipCount; int bus; chan beg, end
bus0:=Bus(1, 0, wireCount0, 1, bus0Wire, begSig, endSig);

// const id, size, initial, regId, inWire, outWire; int inBus, outBus;
// chan begPut; chan endPut; const putAmount; 
// chan begGet; chan endGet; const getAmount
buf0:=inBuffer(2, 0, 1024, 0, 0, 0, 1, bus0Wire, bus1Wire, 
	begSig, endSig, 8, begBuff, endBuff, 32);

buf1:=inBuffer(3, 1, 1024, 0, 1, 1, 3, bus0Wire, bus1Wire, 
	begSig, endSig, 8, begBuff, endBuff, 32);

buf2:=outBuffer(4, 2, 512, 512, 2, 5, 2, bus1Wire, bus0Wire, 
	begBuff, endBuff, 32, begSig, endSig, 8);

buf3:=outBuffer(5, 3, 2048, 1024, 3, 7, 3, bus1Wire, bus0Wire, 
	begBuff, endBuff, 32, begSig, endSig, 16);

buf4:=outBuffer(6, 4, 512, 512, 4, 9, 4, bus1Wire, bus0Wire, 
	begBuff, endBuff, 32, begSig, endSig, 8);

buf5:=outBuffer(7, 5, 512, 512, 5, 11, 5, bus1Wire, bus0Wire, 
	begBuff, endBuff, 32, begSig, endSig, 8);

buf6:=outBuffer(8, 6, 2048, 1024, 6, 13, 6, bus1Wire, bus0Wire, 
	begBuff, endBuff, 32, begSig, endSig, 16);

buf7:=inBuffer(9, 7, 2048, 0, 7, 7, 15, bus0Wire, bus1Wire, 
	begSig, endSig, 16, begBuff, endBuff, 32);

buf8:=inBuffer(10, 8, 2048, 0, 8, 8, 17, bus0Wire, bus1Wire, 
	begSig, endSig, 16, begBuff, endBuff, 32);

bus1:=Bus(11, 1, wireCount1, 1, bus1Wire, begBuff, endBuff);


// const idMem, idBuff, spaceId, status; chan begBuff, endBuff; chan begMem, endMem
reg0:=Register(12, 0, 0, 0, 0, bus1Wire, begBuff, endBuff, begMem, endMem);

reg1:=Register(13, 1, 2, 1, 0, bus1Wire, begBuff, endBuff, begMem, endMem);

reg2:=Register(14, 2, 4, 2+N, 512, bus1Wire, begBuff, endBuff, begMem, endMem);

reg3:=Register(15, 3, 6, 3+N, 512, bus1Wire, begBuff, endBuff, begMem, endMem);

reg4:=Register(16, 4, 8, 4+N, 512, bus1Wire, begBuff, endBuff, begMem, endMem);

reg5:=Register(17, 5, 10, 5+N, 512, bus1Wire, begBuff, endBuff, begMem, endMem);

reg6:=Register(18, 6, 12, 6+N, 512, bus1Wire, begBuff, endBuff, begMem, endMem);

reg7:=Register(19, 7, 14, 7, 0, bus1Wire, begBuff, endBuff, begMem, endMem);

reg8:=Register(20, 8, 16, 8, 0, bus1Wire, begBuff, endBuff, begMem, endMem);

//ArbiterN: const period; chan beg, end
//arbiter:=ArbiterN(5, begMem, endMem);

//ArbiterNT: const const me; chan beg, end
arbiter:=ArbiterTO(0, 2, begMem, endMem);</instantiation>
  <system>//Edit system definition.
system starter, timer, bus0, bus1, 
buf0, buf1, buf2, buf3, buf4, buf5, buf6, buf7, buf8, 
reg0, reg1, reg2, reg3, reg4, reg5, reg6, reg7, reg8,
arbiter;</system>
</nta>
