Code: Select all
/*
Signals (alphabet T):
N - negative (-1)
O - ground (0)
P - positive (+1)
U - unplugged
Special marks:
! - last value (used in simulation of memory)
? - bad value (used as exception mark in simulation)
Unary blocks:
MEM - memory cell
BUF - buffer
INV - inverter
BLN - block negative (foreward diode)
BLP - block positive (backward diode)
PRP - pull-up resistor to +1
PRO - pull-down resistor to 0
PRN - pull-down resistor to -1
CAO - comparator above O (>0)
CAN - comparator above N (>-1)
CBO - comparator below O (<0)
CBP - comparator below P (<+1)
Binary blocks:
NOD - node (2->1)
SOP - switch O-off P-on
SPO - switch P-off O-on
SNP - switch N-off P-on
SPN - switch P-off N-on
Schemes:
BUF2 - buffer with 3 outputs
INV2 - inverter with 3 outputs
*/
alf T:N,O,P,U "Ternary alphabet for hardware implementation"
def MEM T:T "Memory"
N:N
O:O
P:P
U:!
end
def BUF T:T "Buffer"
N:N
O:O
P:P
U:?
end
def INV T:T "Inverter"
N:P
O:O
P:N
U:?
end
def BLP T:T "Block positive"
N:N
O:U
P:U
U:U
end
def BLN T:T "Block negative"
N:U
O:U
P:P
U:U
end
def PRP T:T "Pull-up resistor to +1"
N:N
O:O
P:P
U:P
end
def PRO T:T "Pull-down resistor to 0"
N:N
O:O
P:P
U:O
end
def PRN T:T "Pull-down resistor to -1"
N:N
O:O
P:P
U:N
end
def CAO T:T "Comparator above O"
N:N
O:N
P:P
U:?
end
def CAN T:T "Comparator above N"
N:N
O:P
P:P
U:?
end
def CBO T:T "Comparator below O"
N:P
O:N
P:N
U:?
end
def CBP T:T "Comparator below P"
N:P
O:P
P:N
U:?
end
def NOD TT:T "Node 2->1"
NN:?
NO:?
NP:?
NU:N
ON:?
OO:?
OP:?
OU:O
PN:?
PO:?
PP:?
PU:P
UN:N
UO:O
UP:P
UU:U
end
def SOP TT:T "Switch O-off P-on"
NN:?
NO:U
NP:N
NU:?
ON:?
OO:U
OP:O
OU:?
PN:?
PO:U
PP:P
PU:?
UN:?
UO:U
UP:U
UU:?
end
def SPO TT:T "Switch P-off O-on"
NN:?
NO:N
NP:U
NU:?
ON:?
OO:O
OP:U
OU:?
PN:?
PO:P
PP:U
PU:?
UN:?
UO:U
UP:U
UU:?
end
def SNP TT:T "Switch N-off P-on"
NN:U
NO:?
NP:N
NU:?
ON:U
OO:?
OP:O
OU:?
PN:U
PO:?
PP:P
PU:?
UN:U
UO:?
UP:U
UU:?
end
def SPN TT:T "Switch P-off N-on"
NN:N
NO:?
NP:U
NU:?
ON:O
OO:?
OP:U
OU:?
PN:P
PO:?
PP:U
PU:?
UN:U
UO:?
UP:U
UU:?
end