Circuits

To create a circuit, we select parts from the Parts Menu, position them and wire them up. Also, any circuit will have inputs and outputs.

Inputs and Outputs

Inputs may be binary bits carried over wires (white) or bus (yellow) lines that carry integer values. Interactive input parts are: IO, Clock, and ToggleSwitch.

Outputs that give visual feedback are IO, Display, and BusDisplay.

IO parts that are only intended for use with the circuit tester to define named pins are Wire and Bus.

If you need a fixed high or low input, you may use the V+ or Gnd parts.

The above parts are categorized under Utility in the Parts Menu.

The IO part has a rich feature set which will be expanded upon later.

Logic Gates

The basic logic gates AND, NAND, OR, NOR, XOR, and NOT are provided. These are the building blocks for standard digital circuits. Their logic is defined as follows:

Where:

Truth tables are often shown of the output value for all combinations of input values.

Wiring up these logic gates in various ways enables useful circuits to be made such as decoders, multiplexers, flip flops, counters, and registers.

Chips

These are common functional blocks to encapsulate logic circuits. For example, the PC is a programmable counter.

Peripheral parts

These are other parts such as 7-segment displays, and Screen.

Helpers

Other parts are not circuit components but provide useful features such as:

These parts and their data are saved with the circuit when it is saved.

Special parts

BusTap

This part is used to access one bit of a data bus and output it to a wire. Enter a number on the part to specify which bit to tap. This saves having to split out a data bus with an IO part to get to a bit.

MemoryInjector

This part is used by the circuit tester to inject values into RAM. It is attached to any output bus of a RAM chip to associate itself with that chip. The address in memory is entered to the part by the user.

MemoryProbe

This part is used by the circuit tester to read the value at an address in a RAM part. Again, it is attached to any output bus of a RAM chip to associate itself with that chip. The address in memory is entered to the part by the user. The part also displays the value at the given address.

Keyboard

This has a text-input box where the user may type characters. When a key is pressed, the ASCII code for the character is emitted and zero is emitted when the key is released.

Testing

The reader may be a bit confused as to what is meant by Testing in the context of this simulator software. To test a simple logic circuit you may vary the input values by means of toggle switches or IO parts. Then you observe the output values to compare against wanted results.

The built-in tester feature in the Tools menu is to be used with Nand2Tetris files. These files are:

The name of the file must match that of the title given to the circuit.

When the test button is pressed, the relevant files are searched for based on the title of the circuit. If the files are found then the Tester window is popped up.

Tests may be stepped through or played in sequence at a variable rate. At the start of running the tests the circuit is checked for the presence of the required IO pins and then the tests are run.

The outputs are compared to the values in the .cmp file, and if they match then the pass is indicated by green text (otherwise red text).

At the end of the test run, OK is displayed.

The idea is to figure out how to build all the projects specified in the Nand2Tetris course and pass each of the tests.

Some parts were included specifically to be able to complete the Nand2Tetris challenges, namely:

Building Blocks

Circuits may be loaded as blocks to create sub-circuits which are like parts with IO pins matching the IO pins of the loaded circuit. These blocks are listed in the Part Menu for later retrieval.

The IO pin names are taken from IO, Wire, Bus, and TriState parts. But the IO part must have no wires to its input side to be considered an input for the block, similarly the output side of an IO part must have no output wires.

What can you create?

The Clock is useful for supplying a variable rate pulsing output. This can be used to clock a shift register or counter. Then the outputs could be used to address a ROM that contains memory-mapped codes that drive circuits or displays.

There are many data sheets and papers online that contain logic diagrams for chips, microprocessor architectures, and designs for simple educational computers. These can be a source for ideas for things to emulate.