I'm the lead developer of SBTCVM, a FOSS balanced ternary VM project, Ask Me Anything!

Did you find this post useful? Show some love!

Can you explain the project like I'm five? :)

I suppose i could try. :)

SBTCVM has several major parts:

The VM of SBTCVM uses instruction level simulation to simulate a type of digital computer originally developed in Russia. It uses a 'balanced' base number. A balanced base number has an equal number of positive and negative digits. for example:

Here's a 2 trit(similar to a bit) number table as an example.

-- -4
-0 -3
-+ -2
0- -1
00 0
0+ 1
+- 2
+0 3
++ 4

not only does it have 9 states, 4 of them are negative. This inherit signing causes balanced ternary computing to be quite different from binary in places.

The (latest version's) CPU itself uses 18-trit words divided into a 9-trit instruction word, and a 9-trit data word, along with a 9-trit memory bus. This means it has 19,683 words of memory. It uses an additional 9-trit IO bus, providing 19,683 IO addresses.

The second part of SBTCVM is the programming tools. Currently SBTCVM has a fairly advanced low-level assembler, and a currently numeric, higher level language that provides a basic integer object abstraction system, along with the ability to use some assembly in-line if your feeling brave :)

A trom (memory image) dump utility is also provided, as a standard hex viewer obviously isn't going to help much. :)

The third part is software that runs in the VM. Now, the latest codebase isn't ready for huge interactive programs yet, but we do have some exciting plans... :)

I'm sorry, but that explanation was for 20-year-old folks. 😝

So, if I'm not mistaken, it's a virtual machine like the JVM? What is it going to be useful at? For instance, will it be deployed on specific hardware? Will it allow creation of compiled/interpreted programming languages? Etc., etc.

Edit: I did check out en.wikipedia.org/wiki/Ternary_comp... eventually, and I think this is kind of exciting. Ternary logic instead of binary? Talk about flipping the entire script!

Basically SBTCVM simulates a ternary computer. It has 19683 words of memory, (all ram) and at the moment programs are primarily loaded as memory images called troms (or ternary roms), but disk-based programs are in future plans. (we just haven't written the disk system yet. :p)

As far as what SBTCVM is actually useful for, learning and experimenting with balanced ternary is what lead to the first prototype in the first place, and remains an important part of the project.

what balanced ternary is

while regular ternary has 0, 1, & 2, balanced ternary has +1, 0, & -1

counting

That negative digit can be quite confusing to beginners. For example:
lets count to 4 in Balanced ternary (p/+=+1 n/-=-1)

center: standard SBTCVM notation, right: alphanumeric notation which is less confusing in written math.

1 0+ 0p
2 +- pnHuh? where's zero?
3 +0 p0
4 ++ pp
Obvious in hindsight: the negative trit (trit: same idea as a bit) comes before zero.

converting to decimal

the second trit (left) is worth 31 (3)
the first is 30 (1)

so taking 2 as an example:

pn = +3-1 = 2

As as result of the negative digit, balanced ternary is never unsigned. So things like addresses start at the Max Negative Integer (or MNI for short.), and zero tends to fall in the middle of things.

github of latest version:
github.com/SBTCVM/SBTCVM-Gen2-9
the blog has some guides and such as well:
sbtcvm.blogspot.com/

What challenges are you facing in terms of development?

Here are some of the main ones:

Research:

SBTCVM has its own architecture for a reason. one of the key challenges has been translating elements from more modern computers to balanced ternary. You see, the last actual hardware example was built in the late 50s in Russia. So we don't have a massive amount of examples to build on.

Building the whole programming workflow

SBTCVM, having its own architecture, and not even being binary in the first place, can't use any common tools or compilers. So not only is the VM running on a custom math library, everything from SBTCVM assembly to SSTNPL to the romdump utility has been built from scratch.

having to design encodings and devices from scratch.

SBTCVM has involved inventing things from the start. the simplest of these creations is the 2 text encodings it has used: SBTCVM-BTT-6 and SBTCVM-BTT2 (current).

While SBTGA, sbtcvm's graphics system, is yet to be implemented in the new codebase, it can't use standard resolutions or color modes for obvious reasons.

Codebase & implementation

Along with the design challenges, actually implementing the architecture is quite a task. the latest codebase runs the CPU at 6.5Khz. that doesn't sound like much, but for python, it is.

The new codebase uses plenty of python classes in a modular architecture design that keeps the primary components separated (and has allowed us to plan multiple frontends i.e. curses, pygame, tk).

the assembler and SSTNPL's compiler are also class-based, but divide the instruction-specific parsing into class instances in a large list. This has allowed a variety of powerful features, and has somewhat simplified their upkeep.

programming the VM

Another challenge has been writing programs to make the VM more useful, and acting as examples for proper programs. The latest codebase doesn't have much outside the usual barrage of test programs, but the previous codebase did manage to run an RPN calculator.

Classic DEV Post from Aug 3

Keeping up in the JavaScript world πŸƒβ€

JavaScript fatigue has been on the rise for a while now. You often hear develop...

READ POST
Follow @superkarolis to see more of their posts in your feed.
dev.to is now open source!
View Announcement Post View GitHub Repo
Thomas Leathers
Hi, i'm Thomas, cheif developer of the SBTCVM project, and all around artist and programmer. I do have more of an understanding of balanced ternary than most i would say.
Trending on dev.to
What are your thoughts on multiples package managers?
#discuss
I'm a dev who has a vision for a new internet. I've even started building software, Ask Me Anything!
#ama
What's the deal with downing PHP development?
#discuss
I teach web development in college and have done so for 10+ years to 500+ students. AMA!
#ama
I am a Java developer, Ask Me Anything!
#ama
I am a JavaScript's biggest fan, Ask Me Anything!
#ama
Open Source Has Not Failed. Don't Cover Up Corporate Abuse of Open Source
#opensource #technology #career #rant
Looking For a Simpler Way To Develop WordPress Themes Locally.
#wordpress #discuss #help