Digital Circuit Simulation on the Web

Digital WorkShop v1.10.b1

Fall '96 Senior Project for
Deborah E. Lynch

Under the Supervision of
Professor Paul Fishwick


This project fulfills the requirements for completion of my BS degree in Computer & Information Sciences from the Liberal Arts and Sciences College at the University of Florida. The focus of my senior project is the further development of an existing Java based application that allows users to create digital schematics in a CAD (Computer Aided Drawing) environment, which can then be simulated to show how the circuit would perform if actually constructed.

While this particular software package lacks the sophistication of other currently available commercial packages, it could find a significant niche as an educational tool that is freely accessible over the internet if maintained at websites within the university system.

The original application has several drawbacks that restrict its applicability in this context. I have improved upon the original by making it more user friendly and visually appealing, by expanding the basic functionality of the simulator, by expanding the library of example schematics and by increasing the instructional depth of the help files.

Table of Contents:

Starting Digital WorkShop:

This Java applet is best viewed with a Netscape 2.0x or better browser and the Java language is supported on Windows 95, Windows NT, Sun Solaris, Macintosh and UNIX systems. Also, the application will load and run faster in Netscape if the cache is cleared first. This can be easily done by completing the following steps now.

  1. Select <Network Preferences> from the <Options> menu.
  2. On the Cache window click on the <Clear Disk Cache Now> button.
  3. On the Cache window click on the <OK> button.
  4. On the Preferences window click on the <OK> button.
  5. Click here...Digital Workshop
  6. Please allow 3-5 minutes for the applet to load.
  7. Please e-mail your comments and suggestions.


Digital WorkShop has been designed to capitalize on the resources provided by the internet and Java programming language to provide a useful educational simulation application that is freely accessible to the academic community. The application was derived from an existing application to provide an educational introduction to digital circuits in an interactive and informative manner. The Software Improvement Plan outlines the original modifications planned using four categories: cosmetic improvements, documentation improvements, implementation improvements and functional improvements, and the Solution Statement details how the improvements were realized. Screen shot and graphical comparisons between the two applications are made in the results section. Relevant observations, a description of any unresolved issues and other modifications that could be implemented in Digital WorkShop are examined in the conclusion section.

Keyword Index: Simulation, Digital Circuits, Java, program optimization.



The problem defined for this senior project is to capitalize on the resources provided by the internet and Java programming language to provide a simulation application that can be used as an instructional tool. Specifically, Digital WorkShop provides and introduction to digital circuits in an interactive and informative manner, and the application is freely accessible to anyone in the academic community with access to the internet.


The internet provides an ideal information sharing environment, with a vast future potential for educational systems at all instructional levels. The usefulness of the internet as a virtually unlimited database has already been proven, but initially the internet's ability to provide useful applications remained relatively limited.

Now however, Sun Microsystems has promoted the Java programming language and the appearance of applications including games, spreadsheets, graphing programs and animation controllers are appearing on more and more homepages. The most interesting of these applications in terms of educational potential, are the computer simulation models. Simulators allow people to test out ideas for various real world technical and engineering problems with minimal expenditures of time and resources.

Although the Java programming language has only been an active force in the internet programming community since 1993, the interest that it has generated is considerable. Even though many Java programs are simply animations that individuals have added to their websites to make them more visually appealing, more and more application oriented programs are being developed to solve problems and offer services to the internet community. The following site list provides a general cross section of the kinds of simulator applications that are currently being presented on the internet.

Digital circuit design has provided the modern world with a multitude of useful products. Computers, calculators, audio and video equipment, robotics, medical tools and an unending source of toys and gadgets are continuously being generated with no apparent end in sight. But the technology behind modern electronic equipment is rather inscrutable to most individuals, and students are fortunate if they complete their schooling with a decent grasp of standard math and science, much less a basic grasp of modern technology. Funding for the kind of equipment required to allow students to build and test actual electronic circuits is simply beyond many school systems. This provides exactly the kind of problem best solved by simulation.

Solution Statement:

While most of the above simulation examples are interesting, in general they represent a general tendency in the programming community to offer simulators that offer few interactive opportunities for the user. In most instances the simulation is for a fixed set of parameters in the specific problem domain, and the user simply views the results. DigSim, however, offers an application with the potential to provide an educational introduction to digital circuits in an interactive and informative manner. At the same time, the application in its original form has several underlying deficiencies that limited its usefulness in this context.

Digital Workshop has been derived from this existing application to provide a more user friendly and visually appealing interface, with expanded simulator functionality. In order to tailor the application as an instructional device, the library of example schematics has been expanded with circuits relevant to key educational concepts and to provide users with a detailed view of the potential application of all  the logical components available. Additionally, the instructional depth of the help files has been increased.

Problem Domain:

In solving the problem stated for this senior project it was necessary to blend multiple disciplines. The main motivation behind the project is to create a mechanism for providing an introduction to digital circuits. A clear understanding binary logic and number theory was therefore necessary in order to include relevant information in the application's help files, for determining the kinds of schematics to include in the example library and in deciding the programming techniques used to modify the individual digital components.

The original application is programmed using the Java language so that the application can be run on the internet. This means that the Java language as well as object oriented programming techniques had to be learned through individual study before actual modifications to the application could be initiated. Furthermore, simulation methods and graphics techniques are integral the structure of the application, and this combined with the fact that the application is intended to operate on the internet using graphic intensive images made the use of efficient programming methods an imperative concern.

Software Improvement Plan:

The proposed improvements to the original application are broken into four general categories as described below.

Cosmetic Improvements:

Documentation Improvements:

Implementation Improvements:

Functional Improvements:

Solution Section:

Cosmetic Improvements:

Introducing "Digital WorkStation," the next generation of "DigSim." This new title was chosen to more accurately reflect that the application is a tool for building and testing digital circuits rather than just another toy in the tradition of SimEarth. All references to the application title have been modified throughout the displays and help files.

The color system of Digital WorkStation has been reformatted to provide a more muted appearance, using gray for the background, white for text and black for uninitialized wires and the grid display. Modifying the background also made it necessary to slightly alter the color formatting of the oscillator, ground and inactive wire components so that they display properly.

The grid display has also been modified to only display grid steps at every fifth step. The new display is not as visually striking as the display in the original application, however, it focuses attention on the schematic components in a much more effective manner.

The functioning of the Dual Color LED component has been clarified by the addition of a '+' marker on each side of the component displayed in the color to indicate the proper polarity with which the LED should be connected in order to achieve that color illumination.

Documentation Improvements:

Digital WorkShop represents version 1.10.b1 of the original code, therefore, the class headers have been modified to reflect their inclusion in the new version. Furthermore, additional commenting has been provided in the modified classes to make the coding easier to understand and modify for future versions. In the library of example schematics, any labeling errors were corrected and schematic titles were added where necessary. Spelling and grammar errors were corrected throughtout the interface.

To make the application more directed towards an educational introduction to digital logic, the help files that deal with logical device objects were expanded to provide a more complete description of their logical operation and general use in circuits.

Implementation Improvements:

When running on the internet every aspect of the original application responds slowly. This is a serious detriment to the usability of the simulator. Part of the problem is the manner in which menu selections are executed. Most of the menu selections select specific components to be placed into a schematic, which means that the execution steps for these menu items are very similar. The other menu selections perform various editing and simulation triggering functions, which have more variable execution requirements and often require more extensive processing.

In the original application, menu selections are verified by searching a linear array for string equality to an excepted list of available menu selections. The same menu label string is then subjected to another linear search for string equality to determine which instructions to execute. This makes the system response to menu selections widely variable and slow on average. The same problem also exists in the functions which handle the creation of a schematic which has to be loaded by parsing a text file containing component descriptors.

These functions have been optimized by applying binary search techniques. Menu selection routines now depend on three arrays, one for components available from the menu, one for the auxiliary menu selections and one for components available from schematic files. The arrays were constructed in alpha-numeric order so that labels can be located in a binary search. A numeric identity rather than a boolean value is returned from the search, and a return value of zero indicates that the label was not found in the given array. The numeric identity returned is then subjected to a binary comparison that reduces the number of cases that must be examined to determine the proper instruction set for a given label to a maximum of five. Because the array of available auxiliary menu selections is much smaller than the array of available component selections, this array is searched first when a menu selection is made. The functions driven by these selections generally respond more slowly than component selections, so they deserve the extra prioritization that this affords

Simulation cycles are imposed by the main thread's sleep/wake cycles. While it is necessary to impose these sleep/wake cycles on the simulator, the slow response of the application when it runs on the internet requires that the sleep time of the main thread be minimized. In the original application, the main thread imposes a 10 millisecond sleep cycle on each iteration. The original application attempts to improve simulation speed by simulating four cycles before returning control to the main thread. However, this approach has the side effect of unreasonably slowing the application's response to mouse events outside of the schematic panel when the simulator is running.

Digital WorkShop substantially improves upon the original application both in simulator speed and responsiveness during simulation. This is accomplished by reducing the main thread's sleep cycle to 5 milliseconds and only simulating one cycle per iteration of the main thread. While it may not appear to be the obvious solution, Digital WorkShop executes faster by sleeping longer. The application now releases CPU control for approximately twice the10 milliseconds provided by the original application but each sleep cycle has a shorter duration. This allows the CPU running the application more opportunities to keep display, modem and other auxiliary functions up to date.

The new distribution of sleep cycles also maximizes the usefulness of buffering techniques. All the graphics needed during one iteration of the main thread have been built during the preceding iteration of the main thread, while the graphics for that iteration were being displayed. Additionally, returning control to the main thread after each simulation cycle roughly quadruples the speed with which the application responds to mouse events that occur outside of the schematic panel. This corrects an annoying tendency in the original application for a running simulator to continue operating for several cycles before responding to a user's attempt to stop the simulation.

Functional Improvements:

The oscillator component was modified to allow the user to select divisions of the fastest cycle rate allowed by a given schematic. The user can now arbitrarily assign the base cycle to represent the highest frequency that will be used in a circuit, and thereafter oscillators can be set to any lower frequency, where the new oscillator frequency equals the highest assigned frequency divided by the number entered by the user. If an entry is less than one, the oscillator frequency is automatically synchronized to the base cycle rate.

The logic analyzer has been modified to display signals that continuously advance, along with a ruled indicator of all currently displayed simulation cycles. Also, a user control has been provided that allows a given probe to be deleted. Finally, the analyzer automatically resets when the simulator is stopped and restarted, so that previously deleted probes reappear and the current cycle resets to zero on successive simulations.

The clocked flip flops and four bit binary counter have been modified with the addition of a reset pin to more accurately model real world flip flops. The reset is activated by a 5 volt signal so this pin does not have to be connected for the component to operate normally. A reset signal automatically produces a 0 volt signal at the 'Q' outputs of the flipflops and at all of the outputs of the four bit binary counter regardless of whether the clock input is currently triggering the component.

The library of example schematics was expanded and corrected as follows:


Screen Shots Displaying Cosmetic Improvements:

DigSim Interface

Digital WorkShop Interface

Test Results of Implementation Improvements:

All of the comparisons discussed here are based on tests conducted on an IBM capatible 486 DX-2 80 machine with 8 MB of RAM running under Windows 95. Java's applet viewer was used in testing comparable trails between the two applications rather than actual internet access in order to minimize external influences on the results. All trial times were measured to an accuracy of 10 ms using in line code.

With this in mind, the results of  the implementation improvements are graphically presented in the following bar chart.

Percent Reduction in Trial Times:

Digital WorkShop Vs. DigSim

Screen Shots Displaying Functional Improvements:

DigSim Analyzer Frame

Digital WorkShop Analyzer Frame

Modified Components in Digital WorkShop

Library of Example Schematics Expansions


In the end, the effort expended to make an application available on the internet is wasted if the application operates so slowly that the user loses interest. The response time improvements realized by Digital WorkShop are significant and will hopefully keep frustration levels to a minimum.

The overall look of Digital WorkShop is now more professional and pleasing to the eye. Still, everyone has individual preferences, so it would be beneficial to include color formatting in the preferences menu for a future version. The best approach would be to offer a fixed set of color formats so that the proper display of all components could be assured for any selected color format.

The mouse dragging routines in Digital WorkShop also require future modifications, as they suffer significant delays between the current mouse position and where dragged components are being displayed. Ghosting techniques should improve this problem, however, it may not be possible to implement them within the constraints of the Java Language. The main difficulty is the manner in which repainting occurs in Java. It is possible that the creation of a new sub-class of the schematic panel could be implemented to separate the repainting of dragged components from the repainting of the entire schematic panel. However, it is not clear how to make the background of the new class transparent to the underlying schematic display or how the timing between the repainting of each class should be managed.

Components in Digital WorkShop are only displayed in one axial reference: left to right and top to bottom. Creating schematics could be substantially simplified by allowing a selection between the four main axial rotations. One button could be provided to allow the user to step through these rotations in a fixed order, or four buttons could be provided to allow the user to arbitrarily select one of the four rotations for a selected component. Implementing this feature will require extensive modification of the drawing methods for the forty plus classes that handle the component drawing in  Digital WorkShop.

Because Digital WorkShop was developed and tested exclusively on a Windows 95 platform, additional testing needs to be performed on the various platforms that the Java language supports.


I would like to thank my advisor, Professor Paul Fishwick for his assistance and direction during the development of Digital WorkShop, and Beverly A. Sanders for providing additional insight concerning the Java language.

I would also like to express my appreciation to Iwan van Rienen for placing DigSim in the public domain. If you like Digital WorkShop, check out the original to see where it started.


The original application from which this project was derived was DigSim, developed by Iwan van Rienen ,and all source code was obtained off of the web from:

http: //

Basic programming instruction, the java compiler and the applet viewer required to modify the source code for this application, along with supplementary java application examples were provided by:

Walnum, Clayton. Java by Example. Indiana: Que Corporation, 1996.

Pertinent examples of usable functions, and a user friendly environment were provided by examining the structure and interface contained in:

Capilano Computing Systems, Ltd. LogicWorks 3: Interactive Circuit Design Software for Windows and Macintosh. California: Addison-Wesley Publishing Company, Inc., 1996.

Additional conceptual understanding of the modular components inherent to the execution of Java applications was accessed from Sun Microsystems at their web site:

http: //


Abbreviated User's Manual

Starting the Digital Simulator Test Site :

Digital WorkShop is a Java applet, best viewed with a Netscape 2.0x or better browser. Also, the application will load and run faster in Netscape if the cache is cleared first. This can be easily done by completing the following steps in Netscape.

File Operations:

Standard file operations are disabled when Digital WorkShop is operating on the internet due to Java security measures. Example schematics have been included however, and they can be loaded into the simulator by selecting "Open example" from the file menu.

This will pop up a window that displays a list of the available examples. Examples are categorized as beginner, simple or advanced and selecting a category from the example type menu will display the examples in that category.

The currently displayed schematic can be cleared by selecting "new" from the file menu or by pressing the blank page icon from the tool bar.

Placing Components:

All of the components available to be placed into a schematic in Digital WorkShop can be selected from the menu bar under the following main menu selections.

After a component has been selected, it appears in the upper left corner of the schematic display. To move a component, click the mouse within the body of the component and while holding the mouse button down, drag the component to the desired position.


Cut, copy and paste functions are available from both the main menu's edit menu as well as from the toolbar. To cut or copy a component previously placed in a schematic, select the component by clicking inside the body of the component and then select the desired function.

Multiple components can be selected by holding down the shift key during the selection process.

All of the components in a schematic can be selected simultaneously by pressing "Select All" from the edit menu.

Selecting the paste function will cause the last cut or copied component to appear in the upper left of the schematic display.

The Oscillator:

The oscillator is synchronized with the master clock, and all oscillators are initialized to the master clock frequency which changes its level every simulation cycle.

To change the frequency of an oscillator, double-click within the body of the oscillator and change the value of n that is displayed in the Dialog box. The new frequency of the oscillator is then MAX FREQUENCY/n, where MAX FREQUENCY is the arbitrary value that you assign to the master clock. This IS NOT the actual frequency that the simulator operates at. Actual operation speed, fluctuates depending on the system running the simulator.

Operating the Simulator:

Simulation is controlled by the start and stop selections from the main menu's simulate menu. Furthermore, a stopped simulation can be started or a started simulation can be stopped by pressing the button with the lightening bolt icon in the tool bar.

Once a simulation has started, switches and pushbuttons can be toggled by placing a mouse click within the body of the component. This is the only action that is allowed while a simulation is running.

The Logic Analyzer:

A probe placed in a schematic will display the signal trace of the circuit at that position in the logic analyzer. The signal trace is reset each time the simulator is stopped.

To name the signal that the probe will display in the analyzer, double click inside the body of the probe. Then enter the new name at the prompt provided.

If a probe is present in a schematic ,the analyzer window will pop up automatically. The automatic pop up function can be disabled in the options window that can be selected from the main menu's simulate menu. If the analyzer window has been previously dismissed or the automatic pop up function has been disabled the analyzer can be displayed by selecting the "Show Analyzer" menu item from the main menu's simulate menu.

The signal trace of a given probe will be removed from the analyzer window if the cut button for that probe is pressed. The signal trace of a cut probe will reappear if the the simulator is stopped and then restarted unless the probe itself is deleted in the schematic.

On-Line Help:

Help file displays can be popped up by selecting help from the help menu or by pressing the question mark icon from the tool bar, and then selecting the item for which help is desired.