Ternary computer TRINITY-2004

Balanced Ternary Numeral System - forum was moved from http://ternary.info

Moderator: haqreu

User avatar
Shaos
Admin
Posts: 23989
Joined: 08 Jan 2003 23:22
Location: Silicon Valley

Re: Ternary computer TRINITY

Post by Shaos »

Some ideas about characters mapping for 3-trit architecture (copyright by me 2005-2008):

Image

It covers these languages:
1) English
2) Russian
3) Greek
4) Ukranian
5) Belorusian
6) Rusyn
7) Serbian
8) Bulgarian (one character looks little bit different from standard)
9) Macedonian that I later switch to Finnish (see below)

P.S. Later modification (September 2008):

Image
Here specific Macedonian characters Image were removed and specific Finnish characters Image were added.

P.P.S. So every character is coded by 3 trits only (triad), but because it's only covering 27 characters we need to understand context that may be switched by special codes. Pretty much it's 3 separate character sets with 3 layouts each (243 possible characters). 1st character set covers Latin characters, digits and some standard symbold from ASCII. 2nd character set covers Russian characters (with exception of those characters that look like Latin). 3rd character set covers pseudographics 2x2, Greek characters (with exception of those characters that look like Latin or Russian), some extra characters to support some Eastern European languages (Ukranian, Belorusian, Rusyn, Serbian, Bulgarian and Finnish) and some math symbols. Special codes: SL - switch layout (available in all character sets and all layouts), SF - switch font (to switch character set that only available in layout N of every font), NL - new line (only available in layout N of every font), TC - terminal character and space (also only available in layout N of every font). By default character set N with layout N is set. NL switches current character set to N. SF switch character set to the next one also switching layout to N. SL switches current layout to the next one for the same character set (after P layout will go again to N). TC is a marker of the end of the text.
Last edited by Shaos on 20 Sep 2012 20:52, edited 7 times in total.
User avatar
Shaos
Admin
Posts: 23989
Joined: 08 Jan 2003 23:22
Location: Silicon Valley

Re: Ternary computer TRINITY

Post by Shaos »

-4 N: triad from memory addressed by DPn (see below);
-3 O: triad from memory addressed by DPo (see below);
-2 P: triad from memory addressed by DPp (see below);
-1 F: flag register (see below);
0 A: accumulator register;
+1 B: auxiliary register;
+2 L: lower triad of current DP register (see below);
+3 M: middle triad of current DP register (see below);
+4 H: higher triad of current DP register (see below);

Register F is set of 3 flags:
Higher trit: RSF (Result Sign Flag)
Middle trit: DPF (Data Pointer Flag)
Lower trit: BCF (Borrow Carry Flag)

There are 3 9-trit DP (data pointer) registers - DPn, DPo, DPp, available through L/M/H when flag DPF has corresponding value (N, O, P).

So full set of opcodes is:
#NNN (-13) SAN - save register A to register N;
#NNO (-12) SAO - save register A to register O;
#NNP (-11) SAP - save register A to register P;
#NON (-10) SAF - save register A to register F;
#NOO (-9) SPCD - save PC (program counter) to current data pointer;
#NOP (-8) SAB - save register A to register B;
#NPN (-7) SAL - save register A to register L (lower triade of current data pointer);
#NPO (-6) SAM - save register A to register M (middle triade of current data pointer);
#NPP (-5) SAH - save register A to register H (higher triade of current data pointer);
#ONN (-4) RLA - rotate register A to the left through flag BCF;
#ONO (-3) ADD - add register A with B and flag BCF, save result to A and BCF, modify sign flag RSF;
#ONP (-2) RRA - rotate register A to the right through flag BCF;
#OON (-1) LAI # - load register A from immediate triad;
#OOO (0) ADI # - add register A with immediate triad and flag BCF, save result to A and BCF, modify sign flag RSF;
#OOP (1) OPA # - perform unary "tritwise" operation over register A (function set by immediate triad), modify sign flag RSF;
#OPN (2) LDI # # # - load current data pointer by immediate 3 triads (higher, middle, lower);
#OPO (3) JMP # # # - jump to address set by immediate 3 triads (put it to register PC: higher, middle, lower);
#OPP (4) OPB # # # - perform binary "tritwise" operation over registers A and B, save result to A (function set by immediate 3 triad), modify sign flag RSF;
#PNN (5) LAN - load register A from register N;
#PNO (6) LAO - load register A from register O;
#PNP (7) LAP - load register A from register P;
#PON (8) LAF - load register A from register F;
#POO (9) LPCD - load PC (program counter) from current data pointer;
#POP (10) LAB - load register A from register B;
#PPN (11) LAL - load register A from register L (lower triad of current data pointer);
#PPO (12) LAM - load register A from register M (middle triad of current data pointer);
#PPP (13) LAH - load register A from register H (higher triad of current data pointer);
Today I finished full emulator of this command set! A few days ago I designed "user interface" of first prototype my ternary computer. It consists of line of ternary LEDs and line of ternary switches. 9 LEDs always display state of PC, 3 LEDs display ternary data (see below) and 3 more LEDs always display state of accumulator register A. 9 switches set some address, 3 switches set some data and 3 more switches are control ones. So we have totally 15 LEDs and 15 switches. Control switches:

1) input/output ternary switch:
P (top position) - using specified address write data to the memory (data LEDs display this 3-trit data);
O (neutral position) - ignore address and data switches (data LEDs display data from memory address PC);
N (bottom position) - ignore data switches and display data from specified address;

2) subprogram ternary switch:
P (top position) - interrupt main program, save current PC and jump to specified address;
O (neutral position) - do not disturb working program;
N (bottom position) - stop subprogram and restore PC to return to main program;

3) step/run ternary switch:
P (top position) - execute one step of the program;
O (neutral position) - pause mode;
N (bottom position) - run program from current position.

Emulation program is a little bit smaller than 1000 lines of Java-code: http://www.nedopc.org/ternary/java.php?applet=3
Last edited by Shaos on 20 Sep 2012 20:44, edited 1 time in total.
eudoxie
Maniac
Posts: 277
Joined: 17 Sep 2012 13:36
Location: 81.170.128.52

Re: Ternary computer TRINITY

Post by eudoxie »

That's pretty neat. Just to see it in action, I fed it the values "+0+ -+- 0++ 0-+ ---" and it started performing some sort of operation (it looked like some sort of incrementation).
User avatar
Shaos
Admin
Posts: 23989
Joined: 08 Jan 2003 23:22
Location: Silicon Valley

Re: Ternary computer TRINITY

Post by Shaos »

eudoxie wrote: That's pretty neat. Just to see it in action, I fed it the values "+0+ -+- 0++ 0-+ ---" and it started performing some sort of operation (it looked like some sort of incrementation).
Image

Easiest way to see it in action is shifting most right switch down and it will run program from memory - OOO in each cell that is ADI 0 command (A=A+1) repeated multiple times:

Image
User avatar
Shaos
Admin
Posts: 23989
Joined: 08 Jan 2003 23:22
Location: Silicon Valley

Post by Shaos »

moving up
Я тут за главного - если что шлите мыло на me собака shaos точка net