Help:

Circuit Simulator 0.7.1.07 by Nicholas Duchon

This simulator will model circuits based on elementary logic gates, test the circuit by changing the input values, save a circuit reload a save circuit, and print a circuit.

Component colors:

To use the save, load and clipboard features, you will have to run this simulator as an application, not an applet - see notes below..

The control menus (left, bottom and top) are tear-off and movable menus.

Right-Click on a component to change its Label or other properties.
The basic elements of a circuit are the gates:


Button
Comments
In
An input gate, allows output links, may be changed using the "Next" and "Toggle" buttons.
All of the input gates with no input links form an ordered set used to move through all possible bit patterns using the "Next" button.
Allows a single input link, which is active, removes this component from the Next sequence and disallows Toggle.
Out
An output gate. Allows a single input link. Also allows output links.
And
A gate that allows many inputs and a single output, and performs the AND logical operation on all of the inputs.
Or
A gate that allows many inputs and a single output, and performs the OR logical operation on all of the inputs.
XOr A gate that allows many inputs and a single output, and performs the XOr logical operation on all of the inputs.
Not A gate that allows a single input and a single output, and performs the NOT logical operation on its input.
D ff
A D flip-flop, a single input and a single output. The value changes on the "Tick" button press.
JK ff
A JK flip-flop, two inputs and a single output. The value changes on the "Tick" button press.
Join
This is a connector which allows a single input and multiple outputs. Used to help the diagram look prettier.
Text
This is used to put comments into a diagram. This component has no input or output links.
Box
A box - some inputs, some selectors and some outputs. Default box has no internal logic
PLA
A programmable Logic array - a kind of Box
Supports some inputs, some outputs and does not support selectors.
The internal logic includes value and NOT value for each input line.
The vertical lines are AND's of the input lines with dots.
The output lines are OR's of the vertical lines with dots.
To toggle an intersection, use <ctrl>-left_mouse_button.
Right-mouse-click will bring up the properties window.
In the connections list, the connections are paired, with the first number in each pair representing the horizontal line, the second the vertical.
The first line in each direction is indexed 0.
ROM
A read-only memory component - a kind of Box
Some inputs (address lines), some outputs, no selectors.
Right-mouse-click to change configuration and memory values
Input lines over 5 look pretty bad when working with the memory - this may be fixed eventually
Setting values only works after the input and output line counts are fixed
Spaces must separate bit values, as shown in the memory display
The order of bits is high bit is left-most bit
This component acts as a gate array - input changes are immediately reflected in the output
CNT
An up/down counter with enable and parallel load, acts like a bunch of Flip-Flops (ie, updates on Tick)
This component has 4 control lines, with the indicated default values:
Label
Default
CLEAR False
LOAD False
ENABLE
False
Up/Down
True = Up
The control lines take precedence from top to bottom, ie,
LOAD only happens if CLEAR is false,
ENABLE (count) only happens if both CLEAR and LOAD are false.
The number of input lines is equal to the number of output lines.
Task
A comment box that can be linked. Best when used with the LinkS links.

To add a gate to your drawing, just click on the appropriate button on the component (left) menu. The component will be added to the drawing at the location indicated by the tick marks at the top and left hand sides of the drawing area. Adding a component will move the tick marks vertically down, reset will move them to the top of a new column, and left-clicking the mouse anywhere in the display area will set the tick marks to that location.

Then to link these gates together, click the Link button and use and use the mouse to connect gates. Some gates only allow one input connection, while the AND, OR and XOR gates allow many inputs. The simulator automatically connects the source and target gates with a line, and will distribute multiple input lines to a single gate.

The vertical line in a link can be moved by moving the cursor near the center of the vertical line, highlighting the line, then click-dragging the vertical line. There are left and right motion limits. Horizontal lines can also be moved by moving the cursor near the center of the horizontal segment, left-click on the segment and move to preferred position.

Right-clicking on most components will bring up a properties menu which will allow you to change some of the properties of the component.

The other buttons on the Gate Menu are:

Button
Comments
Reset
The location of the next  gate (including when reading a file) is shown by the top and left tick marks.
This button causes the next object to be inserted to the right of the current gate and near the top of the display.
Sort
Recomputes the order of the Input Gates, which is used in the Next calculation.
Dots
Puts dots on the diagram where links from the same source diverge.
Helps make the drawings more readable, but slight misalignments in the link paths can have unexpected effects on the dot locations.
Arrow
Puts arrows on links. Use right-click on links to control whether arrows show at start and/or end.

A summary of the control tool-bar items:

Button
Comments
Help
Creates a frame displaying this help.
Lessons
Lists a series of predefined circuits available from particular web directories.
Next
This will cycle through the various bit patterns of the input gates as a single set.
Tick
This will act as a clock tick for the clocked gates. Affects D ff, JK ff, and CNT.
Normal
MODE: In this mode, the mouse is used to move components around the drawing area.
Toggle
MODE: In this mode, the mouse is used to change the current value of Input gates and flip-flops by left-clicking on them. The values of other components are changed accordingly.
Link
MODE: In this mode, the mouse is used to connect components.
Move mouse over a component (highlighting it), left-click, then drag to target component and release.
Releasing outside a component or in a component that will not accept the input and will abandon the operation.
LinkS
MODE: In this mode, the mouse is used to connect components with a center to center straight line.
Most useful with the Task gate.
Delete
MODE: Will delete one component from the drawing.
After a single component is deleted, the mode returns to NORMAL.
Clean
The program tries to order the inputs of a component top to bottom. Typically requires 2 clicks to get the screen to refresh correctly. Only useful for gates which allow multiple inputs, such as AND, OR, XOR. The location of the inputs may need to be exaggerated to achieve the desired result.
+Area
This button will double the width and height of the drawing area.
Clear
This button will remove all of the components in the drawing area and resets various drawing parameters.
Reindex
Each component has a unique index - this button gives the components new numbers starting at 1.
Useful when creating larger circuits from smaller saved circuits.
Dump
This will produce a text representation of the current drawing sent to standard output. If the program is running as an applet in a browser, the output goes to the Java Console.
Print
This will print the drawing.
After a printer is selected, the user will be prompted for a scale factor.
A factor of 1.0 will produce a rather large drawing, values between 0.5 and 0.75 seem to work best.
Save *
Only when program runs as an application.
This will send a text representation of the drawing to a file.
It would be a good idea to use a ".txt" extension, since this output is a plain text file.
Load *
Only when program runs as an application.
This will load a drawing representation saved using the Save command at the location indicated by the tick marks.
This operation will not clear the display before loading the data file.
Text files may be edited, but the input processing is quite brittle, bad formats and errors are not handled well.
Better to load a drawing, making changes in the program, and then saving the drawing to another (or the same) file.
UnLoad
Removes the previous load or lesson - only if no other operation has been performed in the meantime. Button turns bright when available.
Text IO
This presents the user with a text interface for showing and loading a text representation of a drawing. This can be used to handle a representation in an applet. The text can be copied from or pasted into this display. The "Clear" button in the text-io window only clears that display, not the drawing area.
To Clip *
Sends a bitmap of the current drawing to the clipboard, which can then be copied into a document. There is an option for saving the image as black and white or color.
Quit *
This button will close the program frame. If it is running as an application, this will end the program. Applets running in a browser will continue until the browser leaves the supporting web page.
*
These commands are only available in the Application mode - see below.

Keyboard Commands

The following commands are available from the keyboard:
Key
Effects
d, D
duplicate element currently highlighted by mouse, only works in Normal Mode
u, U
move most recently highlighted element up one pixel, will move the horizontal part of a link
i, I
move most recently highlighted element down one pixel, will move the horizontal part of a link
j, J
move most recently highlighted element right one pixel, will move a vertical part of a link
k, K
move most recently highlighted element left one pixel, will move a vertical part of a link
Cntrl-z
undo the most recent operation. This function is still experimental, so use with caution.

Display

This display bar at the bottom of the window shows a variety of information about the cursor and the component that is currently selected. None of this information can be directly entered, but the display can help during alignment operations, particularly when used with the keyboard commands listed above.

The arrow buttons on the left can be used to move the entire circuit one pixel at a time in the indicated direction.

The "+" and "-" zoom the display by a factor of 4/3 and 3/4, respectively.

Cautions:

  1. Sometimes right-mouse-click on a component when running in a browser, to bring up the Properties window, does not completely populate the fields in that window - typically missing the labels. I don't know what causes this and the program seems to go into a "semi-freeze" mode - this window will not go away. The only way I have found to get out of this state is to exit the browser.
  2. The text IO window still seems to work, so the work in this applet can be save in a text file (or even just the copy/paste buffer). Stop the browser and restart.

Application:

Instructions for running this code as an application
  1. Download the jar file - Circuits.jar (see link on home page under Documentation, about 105KB).
    1. If your browser insists on using a zip extension for the file, change the extension to jar after the download is complete.
  2. Save the file in a convenient location, C:\ or your desktop are reasonable
  3. In newer operating systems, double-clicking the icon should start the program
  4. In older operating systems, you will need to use a command line
    1. Run the file, use the following command:
      > java -jar Circuits.jar
    2. If you have saved the jar file as C:\Circuits.jar, you can run the program quickly by using
      Start --> Run... --> java -jar C:\Circuits.jar
    3. Note that the case of the commands and file names is important.
  5. Once you have done this, the Save, Load and ToClip commands will also be available.

Copyright Notice

//    This file is part of Circuits.
//    Copyright 2000-2008 by Nicholas Duchon
//
//    Circuits is free software; you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation; either version 2 of the License, or
//    (at your option) any later version.
//
//    Circuits is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with Circuits ; if not, write to the Free Software
//    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA