nedoPC.org

Community of electronics hobbyists established in 2002

...
Atom Feed | View unanswered posts | View active topics It is currently 23 Jun 2018 02:38



Reply to topic  [ 42 posts ]  Go to page 1, 2, 3  Next
[Ternary] Ternary base representation 
Author Message
Maniac

Joined: 17 Sep 2012 14:36
Posts: 277
Location: 81.170.128.52
Reply with quote
I'm playing around with a virtual ternary machine I've made, and modeled roughly after the (binary) 6502 processor, but with ternary features.

It is in a fairly working state, so now I'm writing an assembler for it. I am looking for an analogue to hexadecimal notation in binary, to represent addresses and that sort of thing.

My machine uses 6 trit wide balanced trytes. The natural choice is to use balanced base-27, but this is very difficult hard to represent in letters and numbers, since there are no negative digits.

I tried using a-m to represent positive 1-13, 0 to represent 0, and A-M to represent negative 1-13. But that was very counter-intuitive, and caused much headache. It would be very elegant to somehow work the 26 English letters into a representation (because then you could represent text very effectively, all possible bigrams could be represented in one tryte.)

Is there any ideas or conventions on how to represent trinary numbers in a non-decimal base?


27 Dec 2007 10:57
Profile
Admin
User avatar

Joined: 09 Jan 2003 00:22
Posts: 16604
Location: Colorado
Reply with quote
It's great!

What do you think about using "overlined" characters for negative digits representation?

Example:

Code:
_____________
DCBA9876543210123456789ABCD
_
1A = -1*27+10 = -17
  _
10D = 1*729+0*27-13 = 716


28 Dec 2007 09:54
Profile WWW
Maniac

Joined: 17 Sep 2012 14:36
Posts: 277
Location: 81.170.128.52
Reply with quote
It's an interesting thought, but then the problem becomes representing those overlined characters on binary architectures (with ASCII characters).

They're probably supported in UNICODE, so that could be a way, but then the problem is that there is no obvious way of entering them on a standard keyboard.

-- edit --

I've come up with a way that works pretty well now: Representing a tryte with triplets of balanced base 9. So I get DCBA01234.


28 Dec 2007 16:07
Profile
Admin
User avatar

Joined: 09 Jan 2003 00:22
Posts: 16604
Location: Colorado
Reply with quote
eudoxie wrote:
It's an interesting thought, but then the problem becomes representing those overlined characters on binary architectures (with ASCII characters).

They're probably supported in UNICODE, so that could be a way, but then the problem is that there is no obvious way of entering them on a standard keyboard.


Actually you can write it in ASCII the same way like I just did it here - using previous line to put "underline" character in needed places to simulate "overline" for the next line of characters. Disadvantage of this approach is to use 2 lines instead of 1 line to represent separate line of ternary numbers.

eudoxie wrote:
I've come up with a way that works pretty well now: Representing a tryte with triplets of balanced base 9. So I get DCBA01234.


So 1 tryte with 6 trits in your system should look like 3-character word (A01 or 0DD), right? Unusual :)


28 Dec 2007 18:08
Profile WWW
Maniac

Joined: 17 Sep 2012 14:36
Posts: 277
Location: 81.170.128.52
Reply with quote
Quote:
So 1 tryte with 6 trits in your system should look like 3-character word (A01 or 0DD), right? Unusual :)


Exactly. It's a bit exotic in the beginning, but you get used to it quickly, and then it's pretty intuitive and a lot easier to "think" in than base 27. Besides, there's some sort of elegant symmetry in a ternary system having three symbols to represent a tryte, where binary systems usually have two.

It goes very well with what I'm trying to do with my system. I'm trying to make a ternary virtual computer people without a degree in computer science can associate to. That's why I modeled it after the 6502 (because it's very simple and well-known, yet very easy to do meaningful and relatively powerful stuff in.)


28 Dec 2007 18:35
Profile
Admin
User avatar

Joined: 09 Jan 2003 00:22
Posts: 16604
Location: Colorado
Reply with quote
It's very interesting to see results of your work. Do you have specification or some kind of detailed description of proposed ternary command set?

P.S. In Russia most common and well-known microprocessor from XX century is Intel 8080 (there are a few Soviet/Russian clones and extensions of it) and almost nobody knows 6502 for some unknown reasons...

P.P.S. On our forum we have link to Java simulator of ternary processor based on PDP command set:
http://www.nedopc.org/forum/viewtopic.php?t=75


28 Dec 2007 19:28
Profile WWW
Maniac

Joined: 17 Sep 2012 14:36
Posts: 277
Location: 81.170.128.52
Reply with quote
I don't have any specs yet, but it's got almost all 6502 operations (here is a good overview of that architecture) -- or operations with similar ternary behavior, with a few extensions.

I can only speculate that the reason for the 6502's limited use in Russia has something to do with Soviet/Western relations.

The 8080 (and sequels) is probably the biggest one here as well (especially with the advent of the PC), but the 6502 (and sequels) was also widely used in the 1980's, machines such as the Commodore 64, early Apple computers, the BBC Micro, the NES and so forth used it.


28 Dec 2007 19:47
Profile
Admin
User avatar

Joined: 09 Jan 2003 00:22
Posts: 16604
Location: Colorado
Reply with quote
Thanks for the link to 6502 overview!

Do you plan to use one of the coolest features of ternary command set as "ternary" conditional branch in one "atomic" command?

if a<b goto A1
if a==b goto A2
if a>b goto A3


28 Dec 2007 20:30
Profile WWW
Maniac

Joined: 17 Sep 2012 14:36
Posts: 277
Location: 81.170.128.52
Reply with quote
Unfortunately, I don't think that's going to be possible (it would be possible, but it would be an eyesore in the specs).

All my operations take zero to two trytes as arguments. That operation would take six trytes as argument. It's a bit too abstract for machine code. It would be really easy and elegant to implement in a higher level language based on my machine though.


29 Dec 2007 08:53
Profile
Admin
User avatar

Joined: 09 Jan 2003 00:22
Posts: 16604
Location: Colorado
Reply with quote
eudoxie wrote:
Unfortunately, I don't think that's going to be possible (it would be possible, but it would be an eyesore in the specs).

All my operations take zero to two trytes as arguments. That operation would take six trytes as argument. It's a bit too abstract for machine code. It would be really easy and elegant to implement in a higher level language based on my machine though.


Probably it could be done by using 3 special address registers - not directly


29 Dec 2007 12:09
Profile WWW
Maniac

Joined: 17 Sep 2012 14:36
Posts: 277
Location: 81.170.128.52
Reply with quote
Hm, my machine doesn't have that many address registers. Though, it could be doable using the stack instead.


Anyways, I made a rough draft of my machine's specifications http://nedopc.org/ternary/tunguska/specsdraft.pdf

It's probably a bit esoteric at the moment, but it should give you an idea of how it works.


29 Dec 2007 12:59
Profile
Admin
User avatar

Joined: 09 Jan 2003 00:22
Posts: 16604
Location: Colorado
Reply with quote
Thanks! It's interesting to read


29 Dec 2007 14:33
Profile WWW
Maniac

Joined: 17 Sep 2012 14:36
Posts: 277
Location: 81.170.128.52
Reply with quote
Yeah. I'm in the process of cleaning it up and fixing the worst bugs, making a usable memory image to start with (at least an image that does -something-), and then I'm going to release it for a public alpha version.


29 Dec 2007 14:59
Profile
Retired

Joined: 03 Aug 2003 23:37
Posts: 1483
Location: Moscow
Reply with quote
Don't you have plans to add a parity flag to program status register ? It is very usefull thing in ternary :) I'll be glad to see working emulator or something and to help you in your work.


30 Dec 2007 15:03
Profile
Maniac

Joined: 17 Sep 2012 14:36
Posts: 277
Location: 81.170.128.52
Reply with quote
I'm not sure if a parity flag is going to be necessary. There is an operation that allows you to set the status flags as though a tritwise AND operation with the accumulator has been performed. With an and-mask that masks out all trits except one arbitrary trit, you will transfer that trit to the sign flag, and from there -- for all intents and purposes, it can be a parity flag.

I've got a few things to fix before I release a public alpha version of it. It shouldn't be -that- far away, things are in fairly working order, -- maybe a month? (optimistically) But when that's done, I'll be sure to post a notification here, and you're welcome to tinker in the code (it's going to be open source).


31 Dec 2007 06:56
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 42 posts ]  Go to page 1, 2, 3  Next

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.