Skip to content

acadamic course in campus il about building a modern computer from basic logic gates such as "nand" to a general computer architecture that is designed execute any program such as "Tetris". and also building assambler

Notifications You must be signed in to change notification settings

lironmiz/nand2tetrisCourse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 

Repository files navigation

🧠 nand2tetrisCourse 🧠

the course is on building a modern computer from basic logic gates to a general computer architecture capable of executing programs such as "Tetris".

during the course i was learn how to design and build all the hardware components (chips) using a hardware description language taught in the course. I was responsible for building these components from scratch and testing them using a hardware simulator provided along with the course materials. This hands-on experience was provided me with an in-depth understanding of the computer's inner workings. Additionally, I will also learn how to build an assembler program to translate programs written in symbolic language into binary code. This skill will enable me to program my computer and execute my own code.

By the end of this course, I will have the knowledge and practical experience necessary to build a fully functional computer and write my own programs. This is a challenging but rewarding course that will provide me with a unique understanding of how computers work.

Course instructors:

Prof. Shimon Shoken, Interdisciplinary Center

Noam Nissan, Hebrew University

contributors last update forks stars open issues language count

Size top language

📔 Table of Contents

🌟 The Graduation Certificate

(back to top)

📚 Course Material

+ Introduction to building systems
+ Language Description Hardware
+ Boolean algebra
+ building basic logic gates
+ Binary representation of numbers
+ Boolean arithmetic
+ Building adders and an algebraic-logic unit (ALU)
+ Time representation
+ Clock cycles
+ Flip-flop gates
+ Construction of registers and memory units (ROM, RAM) 
+ Machine language: symbolic representation, binary 
+ Writing and running programs in a low level programming language.
+ Computer architectures
+ Central processing unit
+ Management of input/output units
+ Building a processor 
+ Translation of programs: syntax, semantics, parsing, code generation, symbol tables
+ Assembler development

(back to top)

👽 Course Summary

1. TABLE OF CONTENTS

2. BOOLEAN VALUES

TrueOrFalseAndyCohenGIF (2)

A Boolean value is a data type that has two possible values, either "true" or "false". Boolean values are often used in programming to make decisions, comparisons, and to control program flow.

image

3. BOOLEAN VARIABLES

ThereAreSoManyVariablesInPlayDavidRoseGIF

A Boolean variable is a variable that can store a Boolean value. It is a variable that can only hold the value "true" or "false". Boolean variables are often used to represent conditions, such as whether a condition is true or false.

4. BOOLEAN FUNCTIONS

JojiFilthyFrankGIF

A Boolean function is a function that takes one or more Boolean values as input and produces a single Boolean value as output. Boolean functions are used to perform logical operations on Boolean values. Some common Boolean functions include AND, OR, NOT, XOR, and NAND. These functions are used to combine, negate, or compare Boolean values to determine whether a given condition is true or false.

image

5. BOOLEAN ALGEBRA

AWholeNewWorldAladdinGIF

oolean algebra is a branch of mathematics that deals with logical operations on true or false values, which are represented as 1 and 0, respectively. It is an algebraic system that is used to represent logical propositions and analyze their properties.

Here's a summary of some of the key concepts in Boolean algebra:

Boolean operators: The three primary Boolean operators are AND, OR, and NOT. These operators are used to perform logical operations on Boolean values.

Boolean expressions: A Boolean expression is a combination of Boolean variables and operators that evaluates to a Boolean value. For example, the expression "A AND B" is a Boolean expression that is true only if both A and B are true.

Truth tables: A truth table is a table that lists all possible combinations of inputs for a Boolean expression and the resulting output. Truth tables are used to analyze and evaluate Boolean expressions.

Laws of Boolean algebra: There are several laws of Boolean algebra, including the commutative, associative, distributive, and identity laws. These laws provide a set of rules that can be used to simplify and manipulate Boolean expressions.

Boolean functions: A Boolean function is a function that takes one or more Boolean values as input and produces a single Boolean value as output. Boolean functions are used to perform logical operations on Boolean values.

Boolean algebra is an important concept in computer science and digital electronics, and is used extensively in the design and analysis of digital circuits and systems.

Law Equation
Commutative Law A AND B = B AND A
A OR B = B OR A
Associative Law (A AND B) AND C = A AND (B AND C)
(A OR B) OR C = A OR (B OR C)
Distributive Law A AND (B OR C) = (A AND B) OR (A AND C)
A OR (B AND C) = (A OR B) AND (A OR C)
Identity Law A AND 1 = A
A OR 0 = A
Negation Law A AND NOT A = 0
A OR NOT A = 1
Double Negation Law NOT (NOT A) = A
De Morgan's Law NOT (A AND B) = (NOT A) OR (NOT B)
NOT (A OR B) = (NOT A) AND (NOT B)
Absorption Law A OR (A AND B) = A
A AND (A OR B) = A

6. DISJUNCTIVE NORMAL FORM

ICanDoItJonTafferGIF

DNF stands for Disjunctive Normal Form, which is a way to represent a Boolean function as the logical OR of multiple AND terms. In other words, it is a way to express a Boolean function as a sum of products.

To convert a Boolean expression to DNF, one needs to:

Expand the expression into a sum of minterms, which are the product terms that evaluate to 1 for the given combination of input variables. Combine the minterms with logical OR operator to obtain the DNF. DNF is useful in digital circuit design because it provides a way to represent a Boolean function in a form that is amenable to logic gate implementation. Additionally, DNF can be used to find the minimal sum-of-products representation of a Boolean function, which is the expression that uses the smallest number of terms and literals to represent the function.

7. NAND

IveGotThePowerJimCarreyGIF

NAND (not-and) is a logical operation in Boolean algebra that returns a FALSE output only when both of its inputs are TRUE, and returns a TRUE output for all other input combinations. In other words, it is the negation of the logical AND operation.

NAND is a universal gate, which means that any Boolean function can be expressed using NAND gates only. This is because NAND can be used to implement all the other basic Boolean operations such as NOT, AND, OR, and XOR. In fact, it is possible to construct an entire digital circuit using only NAND gates.

NAND gates are widely used in digital circuit design because they are relatively simple to implement and provide a compact and efficient way to represent Boolean functions. Additionally, NAND gates have the property of logical equivalence, which means that any Boolean expression can be transformed into an equivalent expression using only NAND gates, without changing the logical function that it represents.

image

8. LOGIC GATES

FeelMeThinkAboutItGIF

Logic gates are electronic circuits that perform logical operations on one or more binary inputs to produce a single binary output. They are the building blocks of digital circuits and computers, and are used to implement Boolean algebraic functions in electronic devices.

There are several types of logic gates, including:

  • NOT gate: also known as an inverter, it produces an output that is the opposite of its input.

  • AND gate: it produces an output of 1 only when all of its inputs are 1.

  • OR gate: it produces an output of 1 when any of its inputs are 1.

  • XOR gate: it produces an output of 1 when exactly one of its inputs is 1.

  • NAND gate: it produces an output of 0 only when all of its inputs are 1, otherwise it produces an output of 1.

  • NOR gate: it produces an output of 0 when any of its inputs are 1, otherwise it produces an output of 1.

Logic gates are used to build more complex circuits such as adders, multipliers, memory units, and microprocessors. The design of digital circuits using logic gates is an important part of computer engineering and is used in various fields, including robotics, communications, and control systems.

9. HARDWARE DESCRIPTION LANGUAGE

GandalfICanHelpGIF

In computer science, HDL stands for Hardware Description Language. It is a specialized programming language used to design and describe digital circuits and systems at the register-transfer level (RTL). HDLs are used to specify the behavior of digital circuits and can be used to simulate, verify, and synthesize digital circuits. HDLs are used to create designs for logic gates and other digital components, and can be used to describe the structure and functionality of entire digital systems. Some popular HDLs include Verilog and VHDL.

image

image

image

image

image

10. BUSES

LittleBitOfThisLittleBitOfThatMarissaRachelGIF

In computer architecture and digital electronics, a bus of bits refers to a collection of wires or conductors that carry multiple bits of data in parallel. Buses of bits are used to transfer data and signals between different components or devices within a computer or electronic system. The size of a bus of bits, commonly referred to as its width, is measured in bits and determines the maximum amount of data that can be transferred in a single clock cycle.

Buses of bits can be classified based on their purpose, such as data buses, address buses, control buses, and expansion buses. They are commonly used in microprocessors, memory systems, and other digital circuits where high-speed data transfer is required. Buses of bits are an essential component of digital systems and play a critical role in determining the performance and capabilities of the system.

image

image

11. MULTIPLEXOR

DependsOnTheMoodDeanSchneiderGIF

In digital electronics and computer architecture, a multiplexer (also known as a MUX) is a device that selects one of several input signals and forwards it to a single output line. A multiplexer operates by using a set of control inputs to determine which of the input signals should be routed to the output.

Multiplexers are commonly used in digital circuits to reduce the number of wires required to transmit data, as well as to select between different sources of data or signals. They are often used in combination with demultiplexers to transmit and receive data over shared communication lines.

Multiplexers are available in a range of sizes, typically based on the number of input signals that they can handle. Common examples include 2-to-1, 4-to-1, 8-to-1, and 16-to-1 multiplexers. Multiplexers are widely used in digital design and play a critical role in many modern electronic systems.

image

image

12. DEMULTIPLEXOR

ThisIsSoSimilarYetDifferentRachelSmithGIF

In digital electronics and computer architecture, a demultiplexer (also known as a DEMUX) is a device that takes a single input signal and routes it to one of several output lines based on a set of control inputs. A demultiplexer is essentially the reverse of a multiplexer, which takes several input signals and selects one of them to be forwarded to a single output line.

A demultiplexer is commonly used to expand the capacity of a shared communication line, allowing multiple data streams to be transmitted and received over a single channel. Demultiplexers can also be used to route signals to different processing units or to control the flow of data within a larger system.

Like multiplexers, demultiplexers are available in a range of sizes based on the number of output lines they can handle, such as 1-to-2, 1-to-4, and 1-to-8 demultiplexers. Demultiplexers play a critical role in digital design and are widely used in many modern electronic systems.

image

image

13. PROJECT1

not logic gate solution:

// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Not.hdl

/**
 * Not gate:
 * out = not in
 */
CHIP Not {
    IN in;
    OUT out;

    PARTS:
    Nand(a=in, b=in, out=out);
}

output file not gate:

image

compare file not gate:

image

not gate simulation:

image

or logic gate solution:

// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Or.hdl

 /**
 * Or gate:
 * out = 1 if (a == 1 or b == 1)
 *       0 otherwise
 */

CHIP Or {
    IN a, b;
    OUT out;

    PARTS:
	Not(in=a, out=notA);
	Not(in=b, out=notB);
	Nand(a=notA, b=notB, out=out);
}

output file or gate:

image

compare file or gate:

image

or gate simulation:

image

and logic gate solution:

// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/And.hdl

/**
 * And gate: 
 * out = 1 if (a == 1 and b == 1)
 *       0 otherwise
 */

CHIP And {
    IN a, b;
    OUT out;

    PARTS:
	Nand(a=a, b=b, out=nandOutput);
	Not(in=nandOutput, out=out);
}

output file and gate:

image

compare file and gate:

image

and gate simulation:

image

xor logic gate solution:

// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Xor.hdl

/**
 * Exclusive-or gate:
 * out = not (a == b)
 */

CHIP Xor {
    IN a, b;
    OUT out;

    PARTS:
    Or(a=a, b=b, out=c1);
    Nand(a=a, b=b, out=c2);
    And(a=c1, b=c2, out=out);
}

output file xor gate:

image

compare file xor gate:

image

xor gate simulation:

image

mux logic gate solution:

// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Mux.hdl

CHIP Mux {
    IN a, b, sel;
    OUT out;

    PARTS:
    Not(in=sel, out=nsel);
    And(a=sel, b=b, out=c1);
    And(a=nsel, b=a, out=c2);
    Or(a=c1, b=c2, out=out);
}

output file mux gate:

image

compare file mux gate:

image

mux gate simulation:

image

dmux logic gate solution:

// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/DMux.hdl

/**
 * Dmultiplexor.  
 * {a,b} = {in,0} if sel == 0
 *         {0,in} if sel == 1
 */

CHIP DMux {
    IN in, sel;
    OUT a, b;

    PARTS:
    Not(in=sel, out=nsel);
    And(a=nsel, b=in, out=a);
    And(a=sel, b=in, out=b);
}

output file dmux gate:

image

compare file dmux gate:

image

dmux gate simulation:

image

not16 logic gate solution:

// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Not16.hdl

/**
 * 16-bit Not gate: for i = 0..15: out[i] = Not in[i]
 */

CHIP Not16 {
    IN in[16];
    OUT out[16];

    PARTS:
    Nand(a=in[0], b=in[0], out=out[0]);
    Nand(a=in[1], b=in[1], out=out[1]);
    Nand(a=in[2], b=in[2], out=out[2]);
    Nand(a=in[3], b=in[3], out=out[3]);
    Nand(a=in[4], b=in[4], out=out[4]);
    Nand(a=in[5], b=in[5], out=out[5]);
    Nand(a=in[6], b=in[6], out=out[6]);
    Nand(a=in[7], b=in[7], out=out[7]);
    Nand(a=in[8], b=in[8], out=out[8]);
    Nand(a=in[9], b=in[9], out=out[9]);
    Nand(a=in[10], b=in[10], out=out[10]);
    Nand(a=in[11], b=in[11], out=out[11]);
    Nand(a=in[12], b=in[12], out=out[12]);
    Nand(a=in[13], b=in[13], out=out[13]);
    Nand(a=in[14], b=in[14], out=out[14]);
    Nand(a=in[15], b=in[15], out=out[15]);
}

output file not16 gate:

image

compare file not16 gate:

image

not16 gate simulation:

image

and16 logic gate solution:

// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/And16.hdl

/**
 * 16-bit-wise And gate: for i = 0..15: out[i] = a[i] And b[i]
 */

CHIP And16 {
    IN a[16], b[16];
    OUT out[16];

    PARTS:
    And(a=a[0], b=b[0], out=out[0]);
    And(a=a[1], b=b[1], out=out[1]);
    And(a=a[2], b=b[2], out=out[2]);
    And(a=a[3], b=b[3], out=out[3]);
    And(a=a[4], b=b[4], out=out[4]);
    And(a=a[5], b=b[5], out=out[5]);
    And(a=a[6], b=b[6], out=out[6]);
    And(a=a[7], b=b[7], out=out[7]);
    And(a=a[8], b=b[8], out=out[8]);
    And(a=a[9], b=b[9], out=out[9]);
    And(a=a[10], b=b[10], out=out[10]);
    And(a=a[11], b=b[11], out=out[11]);
    And(a=a[12], b=b[12], out=out[12]);
    And(a=a[13], b=b[13], out=out[13]);
    And(a=a[14], b=b[14], out=out[14]);
    And(a=a[15], b=b[15], out=out[15]);
}

output file and16 gate:

image

compare file and16 gate:

image

and16 gate simulation:

image

mux16 logic gate solution:

// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Mux16.hdl

/**
 * 16-bit multiplexor. If sel == 1 then out = b else out = a.
 */

CHIP Mux16 {
    IN a[16], b[16], sel;
    OUT out[16];

    PARTS:
    Mux(a=a[0], b=b[0], sel=sel, out=out[0]);
    Mux(a=a[1], b=b[1], sel=sel, out=out[1]);
    Mux(a=a[2], b=b[2], sel=sel, out=out[2]);
    Mux(a=a[3], b=b[3], sel=sel, out=out[3]);
    Mux(a=a[4], b=b[4], sel=sel, out=out[4]);
    Mux(a=a[5], b=b[5], sel=sel, out=out[5]);
    Mux(a=a[6], b=b[6], sel=sel, out=out[6]);
    Mux(a=a[7], b=b[7], sel=sel, out=out[7]);
    Mux(a=a[8], b=b[8], sel=sel, out=out[8]);
    Mux(a=a[9], b=b[9], sel=sel, out=out[9]);
    Mux(a=a[10], b=b[10], sel=sel, out=out[10]);
    Mux(a=a[11], b=b[11], sel=sel, out=out[11]);
    Mux(a=a[12], b=b[12], sel=sel, out=out[12]);
    Mux(a=a[13], b=b[13], sel=sel, out=out[13]);
    Mux(a=a[14], b=b[14], sel=sel, out=out[14]);
    Mux(a=a[15], b=b[15], sel=sel, out=out[15]);
}

output file mux16 gate:

image

compare file mux16 gate:

image

mux16 gate simulation:

image

or16 logic gate solution:

// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Or16.hdl

/**
 * 16-bit bitwise Or:
 * for i = 0..15 out[i] = (a[i] or b[i])
 */

CHIP Or16 {
    IN a[16], b[16];
    OUT out[16];

    PARTS:
    Or(a=a[0], b=b[0], out=out[0]);
	Or(a=a[1], b=b[1], out=out[1]);
	Or(a=a[2], b=b[2], out=out[2]);
	Or(a=a[3], b=b[3], out=out[3]);
	Or(a=a[4], b=b[4], out=out[4]);
	Or(a=a[5], b=b[5], out=out[5]);
	Or(a=a[6], b=b[6], out=out[6]);
	Or(a=a[7], b=b[7], out=out[7]);
	Or(a=a[8], b=b[8], out=out[8]);
	Or(a=a[9], b=b[9], out=out[9]);
	Or(a=a[10], b=b[10], out=out[10]);
	Or(a=a[11], b=b[11], out=out[11]);
	Or(a=a[12], b=b[12], out=out[12]);
	Or(a=a[13], b=b[13], out=out[13]);
	Or(a=a[14], b=b[14], out=out[14]);
	Or(a=a[15], b=b[15], out=out[15]);
}

output file or16 gate:

image

compare file or16 gate:

image

or16 gate simulation:

image

or8Way logic gate solution:

// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Or8Way.hdl

/**
 * 8-way Or: 
 * out = (in[0] or in[1] or ... or in[7])
 */

CHIP Or8Way {
    IN in[8];
    OUT out;

    PARTS:
    Or(a=in[0], b=in[1], out=out01);
	Or(a=in[2], b=in[3], out=out23);
	Or(a=in[4], b=in[5], out=out45);
	Or(a=in[6], b=in[7], out=out67);
	Or(a=out01, b=out23, out=out0123);
	Or(a=out45, b=out67, out=out4567);
	Or(a=out0123, b=out4567, out=out);
}

output file or8Way gate:

image

compare file or8Way gate:

image

or8Way gate simulation:

image

DMux4Way logic gate solution:

// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/DMux4Way.hdl

/**
 * 4-way demultiplexor:
 * {a, b, c, d} = {in, 0, 0, 0} if sel == 00
 *                {0, in, 0, 0} if sel == 01
 *                {0, 0, in, 0} if sel == 10
 *                {0, 0, 0, in} if sel == 11
 */

CHIP DMux4Way {
    IN in, sel[2];
    OUT a, b, c, d;

    PARTS:
    Not(in=sel[0], out=notsel0);
    Not(in=sel[1], out=notsel1);
    And(a=notsel0, b=notsel1, out=sela);
    And(a=sela, b=in, out=a);
    And(a=sel[0], b=notsel1, out=selb);
    And(a=selb, b=in, out=b);
    And(a=notsel0, b=sel[1], out=selc);
    And(a=selc, b=in, out=c);
    And(a=sel[0], b=sel[1], out=seld);
    And(a=seld, b=in, out=d);
}

output file DMux4Way gate:

image

compare file DMux4Way gate:

image

DMux4Way gate simulation:

image

DMux8Way logic gate solution:

// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/DMux8Way.hdl

/**
 * 8-way demultiplexor:
 * {a, b, c, d, e, f, g, h} = {in, 0, 0, 0, 0, 0, 0, 0} if sel == 000
 *                            {0, in, 0, 0, 0, 0, 0, 0} if sel == 001
 *                            etc.
 *                            {0, 0, 0, 0, 0, 0, 0, in} if sel == 111
 */

CHIP DMux8Way {
    IN in, sel[3];
    OUT a, b, c, d, e, f, g, h;

    PARTS:
    Not(in=sel[0], out=notsel0);
    Not(in=sel[1], out=notsel1);
    Not(in=sel[2], out=notsel2);
    And(a=notsel0, b=notsel1, out=sela1);
    And(a=sela1, b=notsel2, out=sela);
    And(a=sela, b=in, out=a);
    And(a=sel[0], b=notsel1, out=selb1);
    And(a=selb1, b=notsel2, out=selb);
    And(a=selb, b=in, out=b);
    And(a=notsel0, b=sel[1], out=selc1);
    And(a=selc1, b=notsel2, out=selc);
    And(a=selc, b=in, out=c);
    And(a=sel[0], b=sel[1], out=seld1);
    And(a=seld1, b=notsel2, out=seld);
    And(a=seld, b=in, out=d);
    And(a=notsel0, b=notsel1, out=sele1);
    And(a=sele1, b=sel[2], out=sele);
    And(a=sele, b=in, out=e);
    And(a=sel[0], b=notsel1, out=self1);
    And(a=self1, b=sel[2], out=self);
    And(a=self, b=in, out=f);
    And(a=notsel0, b=sel[1], out=selg1);
    And(a=selg1, b=sel[2], out=selg);
    And(a=selg, b=in, out=g);
    And(a=sel[0], b=sel[1], out=selh1);
    And(a=selh1, b=sel[2], out=selh);
    And(a=selh, b=in, out=h);
}

output file DMux8Way gate:

image

compare file DMux8Way gate:

image

DMux8Way gate simulation:

image

Mux4Way16 logic gate solution:

// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Mux4Way16.hdl

/**
 * 4-way 16-bit multiplexor:
 * out = a if sel == 00
 *       b if sel == 01
 *       c if sel == 10
 *       d if sel == 11
 */

CHIP Mux4Way16 {
    IN a[16], b[16], c[16], d[16], sel[2];
    OUT out[16];

    PARTS:
    Mux16(a=a, b=b, sel=sel[0], out=outab);
    Mux16(a=c, b=d, sel=sel[0], out=outcd);
    Mux16(a=outab, b=outcd, sel=sel[1], out=out);
}

output file Mux4Way16 gate:

image

compare file Mux4Way16 gate:

image

Mux4Way16 gate simulation:

image

Mux8Way16 logic gate solution:

// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Mux4Way16.hdl

/**
 * 4-way 16-bit multiplexor:
 * out = a if sel == 00
 *       b if sel == 01
 *       c if sel == 10
 *       d if sel == 11
 */

CHIP Mux4Way16 {
    IN a[16], b[16], c[16], d[16], sel[2];
    OUT out[16];

    PARTS:
    Mux16(a=a, b=b, sel=sel[0], out=outab);
    Mux16(a=c, b=d, sel=sel[0], out=outcd);
    Mux16(a=outab, b=outcd, sel=sel[1], out=out);
}

output file Mux8Way16 gate:

image

compare file Mux8Way16 gate:

image

Mux8Way16 gate simulation:

image

14. ALU

RonBurgundyBigDealGIF

ALU stands for Arithmetic Logic Unit. It is a digital circuit that performs arithmetic and logic operations on binary numbers. The arithmetic operations include addition, subtraction, multiplication, and division. The logic operations include AND, OR, NOT, and XOR.

The ALU is an essential component of a microprocessor or CPU (Central Processing Unit), where it performs mathematical and logical operations to process instructions and data. It receives input from the processor's registers, performs the necessary operation, and stores the result in a register for later use.

The ALU's design varies depending on the architecture of the processor, but it typically consists of combinational logic circuits and a set of control circuits to manage the operations. ALUs are typically built with a variety of bit-widths, such as 8-bit, 16-bit, 32-bit, or 64-bit, depending on the processor's design.

Overall, the ALU is a critical component of any digital circuit that performs arithmetic and logic operations on binary numbers, making it an essential part of modern computing.

image

15. NUMERAL SYSTEM

HaveFaithInTheSystemReginaldJuneGIF

A numeral system, also known as a number system, is a mathematical notation for representing numbers using digits or symbols. The most commonly used numeral systems are the decimal system (base-10), binary system (base-2), octal system (base-8), and hexadecimal system (base-16).

In a numeral system, each digit represents a specific value, and the position of the digit determines its place value. For example, in the decimal system, the digit "3" represents three ones, while the digit "3" in the tens place represents three tens (or 30).

The binary system is used extensively in computing, where all data is represented in binary form. It uses only two digits (0 and 1) and is the foundation for digital electronics.

The octal system is commonly used in computer programming, particularly when working with Unix or Linux operating systems, while the hexadecimal system is frequently used in computer programming and digital electronics because it provides a convenient way to represent large binary numbers in a compact form.

Overall, numeral systems are essential to mathematics and computing, as they allow us to represent and manipulate numbers in a systematic and consistent way.

image

16. BINARY NUMBERS

WeOnlyHaveTwoOnlyTwoGIF

Binary numbers are a base-2 number system that uses only two digits, 0 and 1, to represent all values. Each digit in a binary number represents a power of two, with the rightmost digit representing 2^0 (or 1), the second rightmost representing 2^1 (or 2), and so on. The number is formed by summing the values of the digits that are set to 1. Binary numbers are commonly used in computing and digital electronics because they can easily be represented as electronic signals, and digital logic can easily manipulate them. Converting between binary and decimal (base-10) numbers involves multiplying or adding the powers of 2 corresponding to the set 1 digits in the binary number.

image

17. BINARY ARITHMETIC

HoodycatHoodycatsGIF

Binary arithmetic is a form of arithmetic that operates on binary numbers, which are numbers represented in the base-2 numeral system. In binary arithmetic, there are only two digits: 0 and 1. Binary arithmetic includes basic mathematical operations such as addition, subtraction, multiplication, and division.

In binary addition, the rules are similar to decimal addition, except that when the sum of two digits is 2 or greater, a carry-over occurs. For example, in binary addition, 1 + 1 = 10, where the 1 is carried over to the next digit. In binary subtraction, the rules are also similar to decimal subtraction, but borrowing may occur when the digit in the minuend is smaller than the corresponding digit in the subtrahend.

In binary multiplication, the process is similar to decimal multiplication, but the multiplication table is much simpler since there are only two digits. In binary division, the process is similar to decimal division, but the steps are more complex since there may be multiple digits involved in the dividend and divisor.

Binary arithmetic is used extensively in computer science and digital electronics since digital devices operate using binary signals. The principles of binary arithmetic are also important for understanding concepts such as binary code, digital circuits, and computer programming.

image

image

image

image

18. HACK ALU

WowTheRockGIF

Hack ALU (Arithmetic Logic Unit) is a component of the Hack computer, which is a simple computer architecture designed for educational purposes. The ALU is responsible for performing arithmetic and logical operations on binary data.

The Hack ALU is a 16-bit unit that supports several arithmetic operations, including addition, subtraction, and bitwise logical operations such as AND, OR, and NOT. It also supports some comparison operations such as equal, less than, and greater than.

The Hack ALU is built using basic logic gates such as AND, OR, and XOR gates, and uses a combination of these gates to perform the various operations. The output of the ALU is a 16-bit value that can be stored in a register or used as input to other components of the computer.

The Hack computer architecture was designed as a teaching tool to help students learn about computer organization and architecture. The design is simple and easy to understand, making it a good starting point for beginners. The Hack ALU is an important component of the computer and provides a basic understanding of how arithmetic and logical operations are performed in a computer system.

image

image

image

19. PROJECT2

ItsJustTooEasyMonétXChangeGIF

half adder

A half adder is a digital circuit that adds two binary digits (bits) and produces a sum bit and a carry bit as output. It is called a "half" adder because it can only add two bits, whereas a full adder can add three bits. The half adder has two inputs, one for each bit being added, and two outputs, one for the sum and one for the carry. The sum output is the result of adding the two input bits together, while the carry output indicates whether there is a carry to the next place value in a multi-digit addition operation. The circuit for a half adder consists of an XOR gate and an AND gate.

image

halfAdder logic gate solution:

// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/02/HalfAdder.hdl

/**
 * Computes the sum of two bits.
 */

CHIP HalfAdder {
    IN a, b;    // 1-bit inputs
    OUT sum,    // Right bit of a + b 
        carry;  // Left bit of a + b

    PARTS:
    Xor(a=a, b=b, out=sum);
    And(a=a, b=b, out=carry);
}

output file halfAdder gate:

image

compare file halfAdder gate:

image

halfAdder gate simulation:

image

full adder

ImJustTellingTheTruthCalvinRodneyGIF

A full adder is a digital circuit that adds three binary digits (bits) and produces a sum bit and a carry bit as output. It is used to add multi-digit binary numbers by combining multiple full adders to create a ripple carry adder. The full adder has three inputs, one for each of the two bits being added and one for the carry-in from the previous place value, and two outputs, one for the sum and one for the carry-out to the next place value. The circuit for a full adder consists of two XOR gates, two AND gates, and an OR gate. The sum output is the result of adding the three input bits together, while the carry output indicates whether there is a carry to the next place value in a multi-digit addition operation.

fullAdder logic gate solution:

// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/02/FullAdder.hdl

/**
 * Computes the sum of three bits.
 */

CHIP FullAdder {
    IN a, b, c;  // 1-bit inputs
    OUT sum,     // Right bit of a + b + c
        carry;   // Left bit of a + b + c

    PARTS:
    HalfAdder(a=a, b=b, sum=sumab, carry=carryab);
    HalfAdder(a=sumab, b=c, sum=sum, carry=carryabc);
    Or(a=carryab, b=carryabc, out=carry);
}

output file fullAdder gate:

image

compare file fullAdder gate:

image

fullAdder gate simulation:

image

🤝 Contact

liron_mizrahi liron.mizrhai1234 liron LinkedIN

(back to top)

💎 Acknowledgements

Links to information that helped me during construction and learning:

(back to top)

☎️ About the authors

  • Liron Mizarhi - Navy soldier and programmer

(back to top)

:octocat: Project Status

Project is: In Progress!

(back to top)