begin "epd"
require "prom.sai" source!file;
$256;

define

data0 =[a0], data1 =[a1], data2 =[a2], data3 =[a3],
state0 =[a4], state1 =[a5], state2 =[a6], state3 =[a7],

d(x3,x2,x1,x0) =[((data0 div d0 = x0)  (data1 div d1 = x1)
    (data2 div d2 = x2)  (data3 div d3 = x3))],
onetransition =[(d(0,0,0,1)  d(0,0,1,1)  d(1,0,0,1))],
zerotransition =[(d(0,1,1,0)  d(1,1,0,0)  d(1,1,1,0))],
notransition =[(d(0,0,0,0)  d(1,0,0,0)  d(0,1,1,1)  d(1,1,1,1))],
idletransition =[(d(0,0,0,0))],
goodtransition =[(onetransition  zerotransition)],
badtransition =[(goodtransition  notransition)], comment all others;
—85—transition =[(data0  data1  data0  data1)], comment in sync with 85;

state  =[((state0 + state1 + state2 + state3) div d4)],
active  =[(state  0)],
duration =[(if —85—transition then state else (state+1))],

idle  =[(active  idletransition)],
startbit =[(active  onetransition)],
lostsync =[(active  (idletransition  onetransition))],
toomany  =[(active  badtransition)],
setup  =[(active  goodtransition  (2duration5))],
datatrans =[(active  goodtransition  (6duration10))],
toofew  =[(active  (goodtransition  badtransition)  (11duration15))],
timeout  =[(active  notransition  (13state15))],
jam  =[(timeout  data0)],
eop  =[(timeout  data0)],

data—zero =[(zerotransition  datatrans)],
data—one =[((onetransition  datatrans)  startbit)],
collision =[(lostsync  jam  toomany  toofew)],
start  =[(startbit  lostsync  jam  datatrans  toofew)],
carrier  =[(nextstate  0)],
data  =[(collision  data—one)],
shift  =[(data—zero  data—one)],
nextstate =[(if (idle  eop) then 0
   else if jam then 15
   else if (start  —85—transition) then 1
   else if (start  —85—transition) then 2
   else (state+2))];
prombegin

prom(0,d0, carrier);
prom(0,d1, data);
prom(0,d2, shift);
prom(0,d3, collision);
prom(0,d4, nextstate land d0);
prom(0,d5, nextstate land d1);
prom(0,d6, nextstate land d2);
prom(0,d7, nextstate land d3);

promend;
writeprom("epd",0);
end;