GenIOBDBus0Impl.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Jean Gastinel September 11, 1987 6:55:57 pm PDT
Oracle Generation for the DBus
DIRECTORY
FS, IO, Rope, Convert, OracleGen;
GenIOBDBus0Impl: CEDAR PROGRAM
IMPORTS FS, IO, Rope, Convert, OracleGen
~ BEGIN
outf: IO.STREAM;
lineCount : CARD;
Variables for the Oracle File
nr:INT = 7; --number of colums in the right side of the line
nl:INT = 5; --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;
Special variables of the PC-Bus
Signal : TYPE = {T,F,X};
MDSerialIn,MDExecute,MDAddress : Signal;
MDShiftCK,MnDFreeze,MnDReset : Signal;
MDSerialOut: Signal;
IOWPC,IORPC,nIOWPC,nIORPC: Signal;
Address,DataIn,DataOut: INT; --negative Data & Address means X
Init: PROC [] RETURNS [] ~ {
MDSerialIn ← X;
MDExecute ← X;
MDAddress ← X;
MDShiftCK ← X;
MnDFreeze ← X;
MnDReset ← X;
Address ← 0;
DataIn ← -1; --negative INT means X
DataOut ← -1;
IOWPC ← F;
IORPC ← F;
MDSerialOut ← F;
};
RopeFromSignal: PROC [s: Signal] RETURNS [r: Rope.ROPE] ~ {
Convert a signal {F,T,X} into the corresponding Rope {0,1,X}
SELECT s FROM
F  => r ← "0";
T  => r ← "1";
ENDCASE  => r ← "X";
};
Inv: PROC [s: Signal] RETURNS [t: Signal] ~ {
t gets the invert of s
SELECT s FROM
F  => t ← T;
T  => t ← F;
ENDCASE  => t ← X;
};
Send: PROC [] RETURNS [] ~ {
This Proc convert the variables into ropes rl[i] & ll[i] for generating the line
then call MergeOut for writing the line
Verification :
Send :
nIOWPC ← Inv[IOWPC];
nIORPC ← Inv[IORPC];
IF Address >= 0 THEN ll[0] ← OracleGen.LExtend[OracleGen.Hex[Address],5]
ELSE ll[0] ← "XXXXX";
IF DataOut >= 0 THEN ll[1] ← OracleGen.LExtend[OracleGen.Hex[DataOut],2]
ELSE ll[1] ← "XX";
ll[1] ← Rope.Concat["XX",ll[1]];
ll[2] ← RopeFromSignal[nIOWPC];
ll[3] ← RopeFromSignal[nIORPC];
ll[4] ← RopeFromSignal[MDSerialOut];
IF DataIn >= 0 THEN rl[0] ← OracleGen.LExtend[OracleGen.Hex[DataIn],2]
ELSE rl[0] ← "XX";
rl[0] ← Rope.Concat["XX",rl[0]];
rl[1] ← RopeFromSignal[MDSerialIn];
rl[2] ← RopeFromSignal[MDExecute];
rl[3] ← RopeFromSignal[MDAddress];
rl[4] ← RopeFromSignal[MDShiftCK];
rl[5] ← RopeFromSignal[MnDFreeze];
rl[6] ← RopeFromSignal[MnDReset];
MergeOut;
lineCount ← lineCount+ 1;
};
MergeOut: PROC [] RETURNS [] ~ {
This proc merge into two Rope Right and Left different elements of the line
and write the result in the output stream
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 ← ""
};
Write: PROC [Adrs : INT,Da : INT] RETURNS [] ~ {
Address ← Adrs;
DataOut ← Da;
Send;
IOWPC ← T;
Send;
IOWPC ← F;
Send;
DataOut ← -1;
Send;
};
ReadAndCheck: PROC [Adrs : INT,Da : INT] RETURNS [] ~ {
Address ← Adrs;
Send;
IORPC ← T;
Send;
DataIn ← Da;
Send;
IORPC ← F;
DataIn ← -1;
Send;
};
Start of the Program
Here the program start :
Create or Append the file
outf ← FS.StreamOpen["///Chip/IOBDBus0.oracle", $create];
outf.PutF["-- Test D-Bus by PC interface\n"];
outf.PutF[" \n"];
outf.PutF["-- Output :\n"];
outf.PutF["-- Address: A, Data: B, nIOWPC: C, nIORPC: D, MDSerialOut:E \n"];
outf.PutF["-- Input :\n"];
outf.PutF["-- DataIn :M, MDSerialIn:N, MDExecute:O, MDAddress:P, \n"];
outf.PutF["-- MDShiftCK:Q, MnFreeze:R,MnReset:S,\n"];
outf.PutF[" \n"];
outf.PutF["-- A B C D E ~ M N O P Q R S \n"];
outf.PutF["\n"];
Start Generation :
lineCount← 0;
Init;
Send;
comment ← "Test the six bits Out";
Write[600FH,0];
ReadAndCheck[600FH,0];
Write[600FH,1];
ReadAndCheck[600FH,1];
Write[600FH,2];
ReadAndCheck[600FH,2];
Write[600FH,4];
ReadAndCheck[600FH,4];
Write[600FH,8];
ReadAndCheck[600FH,8];
Write[600FH,16];
ReadAndCheck[600FH,16];
Write[600FH,32];
ReadAndCheck[600FH,32];
Write[600FH,0];
comment ← "Test MDSerialOut";
MDSerialOut ← F;
ReadAndCheck[600FH,0];
MDSerialOut ← T;
ReadAndCheck[600FH,128];
outf.PutF[". \n"];  -- end
outf.Close[];
END.