U255TableImpl.mesa
Last modified:
Stewart, December 22, 1983 3:06 pm
DIRECTORY
Commander,
IO,
Real,
RealFns,
Rope,
U255;
U255TableImpl: PROGRAM IMPORTS Commander, IO, Real, RealFns, U255 = {
OPEN U255;
Main: Commander.CommandProc = TRUSTED {
ENABLE ABORTED => GOTO Quit;
out: IO.STREAM;
wt: REF WTab;
name: Rope.ROPE;
res: BOOL;
l: NAT;
out ← cmd.out;
out.PutF["\nu255Tables running at %t\n", IO.time[]];
name ← "SilenceTable1.table";
out.PutF["Writing %g ... ", IO.rope[name]];
wt ← MakeSilenceTable[];
res ← WriteBitsFile[name: name, data: wt];
out.PutF[IF res THEN "OK.\n" ELSE "Failed!\n"];
FOR i: NAT IN [0..10] DO
l ← i*5;
name ← IO.PutFR["LossTable%02d.table", IO.int[l]];
out.PutF["Writing %g ... ", IO.rope[name]];
wt ← MakeReturnLossTable[dBToLoss[l]];
res ← WriteBitsFile[name: name, data: wt];
out.PutF[IF res THEN "OK.\n" ELSE "Failed!\n"];
ENDLOOP;
FOR i: NAT IN [0..10] DO
l ← i*5;
name ← IO.PutFR["HybridTable%02d.table", IO.int[l]];
out.PutF["Writing %g ... ", IO.rope[name]];
wt ← MakeHybridTable[dBToLoss[l]];
res ← WriteBitsFile[name: name, data: wt];
out.PutF[IF res THEN "OK.\n" ELSE "Failed!\n"];
ENDLOOP;
name ← "HybridTable09.table";
out.PutF["Writing %g ... ", IO.rope[name]];
wt ← MakeHybridTable[0.0];
res ← WriteBitsFile[name: name, data: wt];
out.PutF[IF res THEN "OK.\n" ELSE "Failed!\n"];
name ← "LinearTable0.bcpl";
out.PutF["Writing %g ... ", IO.rope[name]];
wt ← MakeLinearTable[];
res ← WriteTableFile[name: name, data: wt];
out.PutF[IF res THEN "OK.\n" ELSE "Failed!\n"];
out.PutF["\nu255Tables finished at %t\n", IO.time[]];
out.Flush[];
EXITS
Quit => NULL;
};
Constructs a 256 x 16 bit table
Address = u-255 value
Value = left justified 16 bit two's complement
MakeLinearTable: PROC RETURNS [t: REF WTab] = {
t ← NEW[WTab[256]];
FOR i: CARDINAL IN [0..256) DO
t[i] ← U255.Decode[LOOPHOLE[i]];
ENDLOOP;
};
Constructs a 256 x 16 bit table
Address = u-255 value
Value = right justified 12 bit offset two's complement attenuated
according to loss. (value is multiplied by loss, loss < 1)
(Values are IN [0..4095])
MakeHybridTable: PROC [loss: REAL] RETURNS [t: REF WTab] = {
x: REAL;
j: INTEGER;
t ← NEW[WTab[256]];
FOR i: CARDINAL IN [0..256) DO
j ← U255.Decode[LOOPHOLE[i, INTEGER]];
x ← j;
x ← x*loss;
j ← Real.RoundI[x];
t[i] ← IntToRJInt[j];
ENDLOOP;
};
Constructs a 4096 x 16 table
Address = right justified 12 bit offset two's complement
Value = silence value to be added to silence register
MakeSilenceTable: PROC RETURNS [t: REF WTab] = {
iv: INTEGER; -- the un-offset version of the address
t ← NEW[WTab[4096]];
FOR i: CARDINAL IN [0..4096) DO
iv ← OffToInt[i];
t[i] ← And[U255.Encode[iv], 0177B];
ENDLOOP;
};
Constructs a 4096 x 16 table
Address = right justified 12 bit offset two's complement
Value = right justified u-255, attenuated by loss
MakeReturnLossTable: PROC [loss: REAL] RETURNS [t: REF WTab] = {
iv: INTEGER; -- the un-offset version of the address
t ← NEW[WTab[4096]];
FOR i: CARDINAL IN [0..4096) DO
iv ← OffToInt[i];
t[i] ← U255.Encode[Real.RoundI[iv*loss]];
ENDLOOP;
};
dBToLoss: PROC [dBloss: REAL] RETURNS [loss:REAL] = {
RETURN [RealFns.Power[base: 10.0, exponent: -dBloss/20.0]];
};
Init: PROC = {Commander.Register[key: "u255Tables.~", proc: Main, doc: "Program to write tables for Lark Slave CPU"]; };
Main program
Init[];
}.
June 12, 1983 3:25 pm, L. Stewart, Cedar 4.2
December 22, 1983 3:06 pm, L. Stewart, Cedar 5