0% found this document useful (0 votes)
1 views

Lab Sheet 1

Uploaded by

peetadevaraj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Lab Sheet 1

Uploaded by

peetadevaraj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Elements of Computing Lab Sheet 1

Study of HDL program

Refer the web site https://nand2tetris.github.io/web-ide/chip/

NAND2TETRIS:

Nand2Tetris is a course and textbook that teach students how to build a computer system from
the ground up, including both the hardware and software. The course is designed to help
students understand how computers work and are built, and to practice computer science
abstractions.
HDL Program
• The designer specifies the chip structure by writing an HDL program, which is then subjected
to a rigorous battery of tests.
• These tests are carried out virtually, using computer simulation: A special software tool,
called a hardware simulator, takes the HDL program as input and builds an image of the
modeled chip in memory.
• Next, the designer can instruct the simulator to test the virtual chip on various sets of inputs,
generating simulated chip outputs.
• The outputs can then be compared to the desired results, as mandated by the client who
ordered the chip built.
• HDL program can become the blueprint from which many copies of the physical chip can be
stamped in silicon.
Example: Xor Gate

Building a Xor Gate As we have seen in figure 1, one way to define exclusive or is
Xor(a, b) = Or(And(a, Not(b)), And(Not(a), b)).
This logic can be expressed graphically, as a gate diagram, or textually, as an HDL program.
Test Script
• The first two lines of the test script instruct the simulator to load the Xor.hdl program
and get ready to print the values of selected variables.
• Next, the script lists a series of testing scenarios, designed to simulate the various
contingencies under which the Xor chip will have to operate in “real-life” situations.
• In each scenario, the script instructs the simulator to bind the chip inputs to certain data
values, compute the resulting output, and record the test results in a designated output
file.
• In the case of simple gates like Xor, one can write an exhaustive test script that
enumerates all the possible input values of the gate.
Basic Logic Gates

• Some of the logic gates presented here are typically referred to as “elementary” or “basic.” At
the same time, every one of them can be composed from Nand gates alone..
• The single-input Not gate, also known as “converter,” converts its input from 0 to 1 and vice
versa.

The And function returns 1 when both its inputs are 1, and 0 otherwise.

The Or function returns 1 when at least one of its inputs is 1, and 0 otherwise.

The Xor function, also known as “exclusive or,” returns 1 when its two inputs have opposing values, and
0 otherwise.
Exercises:
1. Write a HDL code to implement the basic gates using Nand2tetris
AND, OR, NOT, NOR
2. Write a HDL code to implement the XOR gate.
3. Write a HDL code to implement the XNOR gate
4. Write a HDL code to implement the NAND gate

You might also like