Making a 16-bit Computer in Gimkit! (Chapter 1: CPU, Part 2: Logic Gates)

Previous part: Making a 16-bit Computer in Gimkit! (Chapter 1: CPU; Part 1: Instruction Set and CPU)

Making a 16-Bit Computer in GKC

Chapter 1: CPU; Part 2: Logic Gates


Intro

Logic gates are the backbone of computer science. They take 1-bit binary inputs (1 or 2) and outputs another 1-bit binary number.


AND, OR, NOT

AND, OR, and NOT are what I consider as the Big 3 of logic gates.

AND

An AND gate is a 2 input gate, meaning it requires 2 inputs. The AND gate checks if both inputs are 1, if so, outputs 1, otherwise outputs 0. The following is the truth table and block code for the AND gate.


(A and B are inputs and Q is the output)

A B Q
0 0 0
0 1 0
1 0 0
1 1 1

OR

The OR gate outputs 1 if atleast one of the inputs is 1. The following is the truth table and block code for the OR gate.

A B Q
0 0 0
0 1 1
1 0 1
1 1 1

NOT

The NOT gate is special: it's one of 2 gates that only have one input! (the other being BUFFER). The NOT gate acts like an inverter. It outputs the opposite of the input. The following is the truth table and block code for the NOT gate.

A Q
0 1
1 0

Inverted AND and OR (NAND and NOR)

The NAND and NOR gates are simply inverting the AND and OR gates.


NAND truth table and block code:

A B Q
0 0 1
0 1 1
1 0 1
1 1 0

NOR truth table and block code:

A B Q
0 0 1
0 1 0
1 0 0
1 1 0

Exclusive AND and OR (XAND and XOR)

XAND and XOR, in simple terms, XAND outputs 1 if the two inputs are equal, otherwise 0. XOR outputs 1 if exactly 1 input is 1, otherwise 0.


XAND truth table and block code

A B Q
0 0 1
0 1 0
1 0 0
1 1 1

XOR truth table and block code

A B Q
0 0 0
0 1 1
1 0 1
1 1 0

Summary

Aaand, that’s about it for Chapter 1, Part 2 of building a 16-bit computer in GKC! Today we built the main 7 logic gates in block code, and I also gave a truth table and an explanation for each (mostly…).

6 Likes

NICE… I put 10/10 because the formatting is good for me, and because I want to make a computer for my game :smiley:

5 Likes

So is the Q property constantly outputting zeros and ones? I’m assuming that it’s keeping track of the code overall.

Q value is the output of logic gates (that’s what I use). A and B are inputs

1 Like

Ahhh, so A and B feed the code and Q translates it into binary.

Not exactly, logic gates take 2 binary inputs and outputs 1 binary output. They’re named logic gates for a reason, they are based on logic. For example, the AND gate outputs positive if A is positive AND B is positive. (0 is negative 1 is positive btw)

idk

anyways I gtg

3 Likes

Got it! Thank you for clarifying.

2 Likes

just to note, the secondary goal of this project was to push GKC to its limits, and it will take up a lot of memory

2 Likes

Wow, you are working fast! Good job.
A few things:

  1. XAND is not the standard name for the gate you described(which happens to be an inversion of the XOR gate). Instead, it’s called an XNOR(exclusive nor) gate.
  2. Maybe explain how some gates can be designed to take in multiple inputs(besides just 2), and some others can produce more than 1 output.
  3. Maybe you could expand on the NOR and NAND gates to say how they’re universal gates(capable of recreating any other gate using multiples of such gate).
  4. I noticed confusion on the Q variable, so maybe explain how that is the output you’re using? (also explain inputs and outputs and their differences and relationships in regards to logic gates, and also connect this to the computer to explain it more in-depth)
  5. I think adding more in-depth explanations for each logic gate could be helpful, but I think it’s pretty good overall.
4 Likes

It might be a bit expensive in terms of memory but you could just create several properties such as the following:

property "0or0" = "0"
property "0or1" = "1"
property "1or0" = "1"
property "1or1" = "1"
property "0and0" = "0"
property "0and1" = "0"
property "1and0" = "0"
property "1and1" = "1"
property "not0" = "1"
property "not1" = "0"

This might not be more efficient than your idea, but it might make the block code less complicated if you’re used to combining text.

1 Like

ik XAND and XNOR are equal, i thought that the idea of an exclusive inverted gate would throw some people off. I wasn’t going to talk about NAND being universal because this is mostly just an introduction to logic gates.

2 Likes

Guys I have a question, would this fit under community made guides or devices?

Devices is my suggestion

1 Like

The title says: make a 16-bit computer… and that means you’re helping others learn how to make one, so I guess it’s a guide, unless you change something.

3 Likes

I’d keep this in Community Made Guides

4 Likes

Just so everyone knows, I will be making a slight change (not really), the computer will now be 4 bit sized. This will make it much easier to make and hopefully will be able to fit better in terms of memory

3 Likes

Bumped into the guide using a high-tech 16-bit computer

1 Like