<> <> <> <<>> <> <<>> DIRECTORY FS, IO, Rope, Convert, BitOps; GenDynaBusInterfaceDBus2Impl: CEDAR PROGRAM IMPORTS FS, IO, Rope, Convert, BitOps ~ BEGIN outf: IO.STREAM; lineCount : CARD; nr:INT = 1; --number of colums in the right side of the line nl:INT = 6; --number of colums in the left side of the line NbRight : TYPE = [0..nr); NbLeft : TYPE = [0..nl); RightLine: TYPE = ARRAY NbRight OF Rope.ROPE; LeftLine: TYPE = ARRAY NbLeft OF Rope.ROPE; rl: RightLine; ll: LeftLine; comment: Rope.ROPE; <> Signal : TYPE = {T,F,X}; DSerialOut,DSerialIn,DExecute,DAddress : Signal; DShiftCK,nFreeze,nDReset: Signal; Init: PROC [] RETURNS [] ~ { DSerialIn _ F; DExecute _ F; DAddress _ F; DShiftCK _ F; nFreeze _ T; nDReset _ F; DSerialOut _ X; }; RopeFromSignal: PROC [s: Signal] RETURNS [r: Rope.ROPE] ~ { <> <<>> SELECT s FROM F => r _ "0"; T => r _ "1"; ENDCASE => r _ "X"; }; Inv: PROC [s: Signal] RETURNS [t: Signal] ~ { <> SELECT s FROM F => t _ T; T => t _ F; ENDCASE => t _ X; }; MergeOut: PROC [] RETURNS [] ~ { <> <> <<>> column : INT; r : Rope.ROPE; r _ " "; FOR column IN [0..nl) DO r _ Rope.Cat[r,ll[column]," "]; ENDLOOP; r _ Rope.Cat[r," | "]; FOR column IN [0..nr) DO r _ Rope.Cat[r,rl[column]," "]; ENDLOOP; outf.PutF["%g -- %g %g \n",IO.rope[r],IO.rope[Convert.RopeFromInt[lineCount]],IO.rope[comment]]; comment _ "" }; Send: PROC [] RETURNS [] ~ { <> <> <<>> ll[0] _ RopeFromSignal[DSerialIn]; ll[1] _ RopeFromSignal[nDReset]; ll[2] _ RopeFromSignal[nFreeze]; ll[3] _ RopeFromSignal[DExecute]; ll[4] _ RopeFromSignal[DAddress]; ll[5] _ RopeFromSignal[DShiftCK]; rl[0] _ RopeFromSignal[DSerialOut]; MergeOut; lineCount _ lineCount+ 1; }; SendAddress: PROC [address: CARDINAL] RETURNS [] ~ { <> <<>> adrs: CARDINAL _ address; s: INT; DAddress _ T; DSerialOut _ X; FOR s IN [0..16) DO DShiftCK _ F; IF (BitOps.WShift[adrs,s-15] MOD 2) = 0 THEN DSerialIn _ F ELSE DSerialIn _ T; Send; DShiftCK _ T; Send; ENDLOOP; DAddress _ F; DShiftCK _ F; Send; }; SendData: PROC [data: LONG CARDINAL, c: INT _ 16] RETURNS [] ~ { <> <<>> FOR s: INT DECREASING IN [0..c) DO DShiftCK _ F; IF (BitOps.DShift[data,-s] MOD 2) = 0 THEN DSerialIn _ F ELSE DSerialIn _ T; Send; DShiftCK _ T; Send; ENDLOOP; }; ReadandCheck: PROC [v: CARD, c: INT _ 16] RETURNS [] ~ { <> DAddress _ F; DShiftCK _ F; IF (BitOps.DShift[v,1-c] MOD 2) = 0 THEN DSerialOut _ F ELSE DSerialOut _ T; Send; FOR s: INT IN [1..c) DO DShiftCK _ T; IF (BitOps.DShift[v,s-c+1] MOD 2) = 0 THEN DSerialOut _ F ELSE DSerialOut _ T; Send; DShiftCK _ F; Send; ENDLOOP; DShiftCK _ T; DSerialOut _ X; Send; DShiftCK _ F; Send; }; SendReset: PROC [] RETURNS [] ~ { <> <> nDReset _ F; FOR i: NAT IN [0..10) DO Send; ENDLOOP; nDReset _ T; }; SendShiftClock: PROC [] RETURNS [] ~ { <> FOR i: NAT IN [0..4) DO DShiftCK _ T; Send; DShiftCK _ F; Send; ENDLOOP; }; AdDBus: PROC [bd,hyb,Int,ci,pth: CARDINAL _0] RETURNS [ad: CARDINAL _0] ~ { <
> <<>> << =0 is for BIC>> <<>> ad _ BitOps.WShift[bd,12]+BitOps.WShift[hyb,8]; ad _ ad+BitOps.WShift[Int,5]+BitOps.WShift[ci,3]+pth; }; IdCte: PROC [t,v:CARDINAL] RETURNS [id:CARDINAL] ~ { <> <> <<>> id _ 5000H + BitOps.WShift[t,6] + v; }; <> <> <> <<>> outf _ FS.StreamOpen["DynaBusInterfaceDBus2.oracle", $create]; outf.PutF["-- Test D-Bus for DynaBusInterface\n"]; outf.PutF[" \n"]; outf.PutF["-- Output :\n"]; outf.PutF["--DSerialIn: A, nDReset: B, nFreeze: C, DExecute: D, \n"]; outf.PutF["-- DAddress: E,nDShiftCK: F \n"]; outf.PutF["-- Input :\n"]; outf.PutF["-- DSerialOut:M \n"]; outf.PutF[" \n"]; outf.PutF["-- A B C D E F ~ M \n"]; outf.PutF["\n"]; <> <<>> lineCount_ 0; Init; Send; <> SendReset; <<>> <<>> comment _ "Address of the DynaBusInterface 0 ID path"; SendAddress[AdDBus[bd:0,hyb:0,Int:0,ci:0,pth:0]]; comment _ "ID of the DynaBusInterface type:0B, Version 1"; ReadandCheck[IdCte[t:11,v:1]]; <> <> <<>> <> <> <> <<>> <> <> <> <<>> <> <> <> <<>> <> <> <> <<>> <> <> <> <<>> comment _ "Address of the DynaBusInterface path nb 1"; SendAddress[AdDBus[bd:0,hyb:0,Int:0,ci:0,pth:1]]; SendData[0,4]; SendData[01234567H,32]; SendData[89ABCDEFH,32]; SendData[1,4]; SendData[12345678H,32]; SendData[9ABCDEF0H,32]; SendData[2,4]; SendData[23456789H,32]; SendData[0BCDEF01H,32]; SendData[3,4]; SendData[3456789AH,32]; SendData[0CDEF012H,32]; SendData[4,4]; SendData[456789ABH,32]; SendData[0DEF0123H,32]; comment _ "Address of the DynaBusInterface path nb 1"; SendAddress[AdDBus[bd:0,hyb:0,Int:0,ci:0,pth:1]]; ReadandCheck[0,4]; ReadandCheck[01234567H,32]; ReadandCheck[89ABCDEFH,32]; ReadandCheck[1,4]; ReadandCheck[12345678H,32]; ReadandCheck[9ABCDEF0H,32]; ReadandCheck[2,4]; ReadandCheck[23456789H,32]; ReadandCheck[0BCDEF01H,32]; ReadandCheck[3,4]; ReadandCheck[3456789AH,32]; ReadandCheck[0CDEF012H,32]; ReadandCheck[4,4]; ReadandCheck[456789ABH,32]; ReadandCheck[0DEF0123H,32]; FOR sometime: INT IN [0..200) DO Send; ENDLOOP; outf.PutF[". \n"]; -- end outf.Close[]; END.