DIRECTORY
BitOps, TamarinOps, TamarinOpsUtils, TamarinPorts, Core, CoreClasses, CoreCreate, CoreProperties, Ports, Rosemary, RosemaryUser;
TamarinPortsImpl:
CEDAR
PROGRAM
IMPORTS Ports, TamarinOpsUtils
EXPORTS TamarinPorts
= BEGIN
Word: TYPE = TamarinOps.Word;
SetPVal:
PUBLIC
PROC [p: Ports.Port, port:
NAT, value:
CARD] = {
SELECT p[port].levelType
FROM
l => p[port].l ← IF value=0 THEN L ELSE H;
ls => Ports.LCToLS[value, p[port].ls];
c => p[port].c ← value;
lc => p[port].lc ← value;
b =>
SELECT value
FROM
0 => p[port].b ← FALSE;
1 => p[port].b ← TRUE;
ENDCASE => ERROR;
ENDCASE => ERROR;
};
GetPVal:
PUBLIC
PROC [p: Ports.Port, port:
NAT]
RETURNS [value:
CARD] = {
value ←
SELECT p[port].levelType
FROM
l => IF p[port].l = H THEN 1 ELSE 0,
ls => Ports.LSToLC[p[port].ls],
c => p[port].c,
lc => p[port].lc,
b => IF p[port].b THEN 1 ELSE 0,
ENDCASE => ERROR;
};
HasXs:
PUBLIC
PROC [p: Ports.Port, port:
NAT]
RETURNS [hasXs:
BOOL ←
FALSE] = {
SELECT p[port].levelType
FROM
l => hasXs ← p[port].l = X;
ls =>
FOR bit:
NAT
IN [0..p[port].ls.size)
WHILE
NOT hasXs
DO
hasXs ← p[port].ls[bit] = X;
ENDLOOP;
c => hasXs ← FALSE;
lc => hasXs ← FALSE;
b => hasXs ← FALSE;
ENDCASE => ERROR;
};
SetP:
PUBLIC
PROC [p: Ports.Port, port:
NAT, value:
CARD] = {
SetPVal[p, port, value];
p[port].d ← force;
};
ClrP:
PUBLIC
PROC [p: Ports.Port, port:
NAT, xit:
BOOL ←
FALSE] = {
IF xit
THEN
SELECT p[port].levelType
FROM
l => p[port].l ← X;
ls => Ports.SetLS[p[port].ls, X];
c => p[port].c ← 0;
lc => p[port].lc ← 0;
b => p[port].b ← FALSE;
ENDCASE => ERROR;
p[port].d ← none;
};
CheckP:
PUBLIC
PROC [p: Ports.Port, port:
NAT, value:
CARD] = {
SetPVal[p, port, value];
p[port].d ← expect;
};
SetX:
PUBLIC
PROC [p: Ports.Port, port:
NAT] = {
ClrP[p, port];
p[port].d ← force;
};
PortToBool:
PUBLIC
PROC [p: Ports.Port, port:
NAT]
RETURNS [
BOOL] = {
RETURN[GetPVal[p, port] = 1];
};
PortToNat:
PUBLIC
PROC [p: Ports.Port, port:
NAT]
RETURNS [
NAT] = {
RETURN[GetPVal[p, port]];
};
PortToCard:
PUBLIC
PROC [p: Ports.Port, port:
NAT]
RETURNS [
CARD] = {
RETURN[GetPVal[p, port]];
};
PortToTamWord:
PUBLIC
PROC [p: Ports.Port, port:
NAT]
RETURNS [Word] = {
RETURN[TamarinOpsUtils.CardToWord[GetPVal[p, port]]];
};
END.