Digital Circuits

Java Library for a CAD (Computer Assisted Design) tool for designing and testing digital circuits.

In this assignment I developed components for a CAD (Computer Assisted Design) tool for designing and testing digital circuits. Digital circuits consisted of a set of connected digital components. Each digital component took zero or more inputs and produced zero or more outputs. The input and output values were either true or false. A typical digital component is an AND gate which takes two inputs and produces one output which is true only if both input signals are also true:

The assignment was developed using the NetBeans IDE, creating a Java Class Library called “DigitalCircuits”.

Basic Components

Most of these implementations are the same, so code was refactored by creating sub-classes such as CircuitComponent, Gate, BinaryGate, UnaryGate in order to avoid duplicating fields and code. Each of the individual Gate class implementations only include code that is unique to them, i.e. the name of the image file and the method for recomputing outputs.

Binary Gates

Unary Gates

LED Output

A digital LED component was used to display output states. An LED component has one input and no output terminals. The user interface of the LED is similar to a gate, but there are two images, one to be shown when the input is true and one to be shown when the input is false:

Switch Input

Input is supported by digital Switch component. The Switch component outputs either true or false depending on its state.

Gate Testing

Bit Adder Circuit

A Bit Adder circuit performs addition of one bit numbers using the other gates.
This circuit is designed to add together two one bit numbers (plus a carry bit). It produces a one bit number as output, plus a carry bit (if the addition overflows).

Bit Adder Component

To create an n-bit adder we would need to chain together n of these circuits. Displaying the entire circuit replicated many times is not ideal, so the entire circuit is encapsulated as a single digital component.

4 Bit Adder Circuit

Next, we’ll chain together a sequence of bit adders to create a 4-bit adder. Two higher level input and output components that allow 4-bit numbers to be entered and displayed in decimal form were created. These two components are DigitalInput and DigitalOutput respectively.

The DigitalInput and DigitalOutput Components were used with the Bit Adder Component to create the following 4-bit adder test circuit

Connecting Wires

To order to visually depict which components are connected Connecting Wires were added to the Components. Each Component in the Circuit Board container draws its incoming connections. This was an optional task only recommended for high achieving students.