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

define

carrier  =[a0],
jam  =[a1],
word  =[a2],
ready  =[a3], 
inhibit  =[a4],
timeout  =[a5],
state0  =[a6],
state1  =[a7],

state  =[((state1 + state0) div d6)],
idle  =[(state=0)],
idlebit  =[(nextstate=0)],
send  =[(state=1)],
sendcrc  =[(state=2)],
go  =[((send  sendcrc)  jam)],
reload  =[(send  ready  inhibit  jam  word)],
start  =[(idle  ready  inhibit  carrier)],
nextstate =[(if (state=3) then 0  comment unused state;
  else if ( ! idle;
  timeout 
  jam 
  (idle  start) 
  (send  word  ready)  comment abort if data underflow;
  (sendcrc  word)  comment return to idle;
  ) then 0 else
  if ( ! send;
  (start) 
  (reload) 
  (send  word)
  ) then 1 else
  if ( ! sendcrc;
  (send  word  inhibit)   comment all data has been sent;
  (sendcrc  word)
  ) then 2 else
  error(cvs($$adrs)&": didn't assign any state!")
  )];

prombegin

prom(0,d0, go);
prom(0,d1, go);
prom(0,d2, reload);
prom(0,d3, 0);
prom(0,d4, idlebit);
prom(0,d5, idlebit);
prom(0,d6, nextstate land d0);
prom(0,d7, nextstate land d1);

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