|
logicname sample
{ -------------------------------------- }
{ 手続き譜 }
{ -------------------------------------- }
procedure spd
input a;
output q;
bitr rq[2];
switch(rq)
case 0:
if (a) rq = 1; endif
case 1:
if (a)
rq = rq;
else
rq = 2;
endif
case 2: rq = 0;
endswitch
q = rq.1;
endp
{ -------------------------------------- }
{ 実効譜 }
{ -------------------------------------- }
entity receive
input res;
input rs;
output q[8];
output sop;
output eop;
bitr ts[4];
bitr rc[4];
bitn rp;
bitr sc[4];
bitr d[8];
{ - - - - - - - - - - - - - - - - - - - }
{ 受信検知 }
{ - - - - - - - - - - - - - - - - - - - }
if (res)
ts = 0;
else
if (rs)
if (ts.2)
ts=ts;
else
ts=ts+1;
endif
else
if (ts.2)
ts=ts;
endif
endif
endif
{ - - - - - - - - - - - - - - - - - - - }
{ 受信クロック }
{ - - - - - - - - - - - - - - - - - - - }
if (ts.2)
rc = rc + 1;
endif
{ - - - - - - - - - - - - - - - - - - - }
{ データ取得起点 }
{ - - - - - - - - - - - - - - - - - - - }
rp = spd(rc.2);
{ - - - - - - - - - - - - - - - - - - - }
{ 取得計数 }
{ - - - - - - - - - - - - - - - - - - - }
if (ts.2)
if (rp)
if (sc==9)
sc = sc;
else
sc = sc + 1;
endif
else
sc = sc;
endif
endif
if (sc==9) eop = 1; endif
{ - - - - - - - - - - - - - - - - - - - }
{ データ取得 }
{ - - - - - - - - - - - - - - - - - - - }
if (ts.2)
if (sc>=8)
d = d;
else
if (rp)
d.7 = rs;
d.0:6 = d.1:7;
else
d = d;
endif
endif
else
d = 0;
endif
q = d;
sop = ts.2;
ende
{ -------------------------------------- }
{ 機能実行譜 }
{ -------------------------------------- }
entity sim
output res;
output rs;
output q[8];
output sop,eop;
bitr tc[8];
bitr b0c[4];
bitr b1c[4];
bitr td[8];
part receive(res,rs,q,sop,eop)
tc=tc+1;
if ((tc<5)|(tc>100)) res=1; endif
if (tc>5)
if (b0c==7)
b0c=0;
else
b0c=b0c+1;
endif
endif
if (tc>5)
if (b0c==7)
b1c=b1c+1;
else
b1c=b1c;
endif
endif
td=0x55; {←テストデータ}
switch(b1c)
case 1: rs=1;
case 2: rs=td.0;
case 3: rs=td.1;
case 4: rs=td.2;
case 5: rs=td.3;
case 6: rs=td.4;
case 7: rs=td.5;
case 8: rs=td.6;
case 9: rs=td.7;
case 10: rs=1;
endswitch
ende
endlogic
|
|