LogicCity: On-Line Digital Logic Simulator

A primary challenge for science educators is to develop ways to help students understand new ideas that cannot be directly observed. The application of computer simulations is one method instructors may use to address the problem of teaching for conceptual understanding. The use of computer simulations for science teaching is increasing steadily because simulations provide students with the opportunity to witness or "perform" experiments that might otherwise be too expensive, too time consuming, or too dangerous for them to do in the lab. Simulation, in general, is a very effective way for both a student and a professional to visualize concepts and ideas and to check the accuracy of results generated theoretically. Typically, computer simulations represent real world events on the computer and allow students to observe new phenomena by performing various manipulations that affect the on-screen events. Here, at the University of Rhode Island, introductory computer science courses include computer organization and architecture with concepts that can often be difficult to grasp. This dilemma lays the foundation for the need for educational software "simulation" which better enables students to understand the concepts and ideas presented in class. In this project, we set to design and develop LogicCity, a prototype model of an on-line interactive digital logic design simulator that will be used as a


Abstract
A primary challenge for science educators is to develop ways to help students understand new ideas that cannot be directly observed. The application of computer simulations is one method instructors may use to address the problem of teaching for conceptual understanding. The use of computer simulations for science teaching is increasing steadily because simulations provide students with the opportunity to witness or "perform" experiments that might otherwise be too expensive, too time consuming, or too dangerous for them to do in the lab. Simulation, in general, is a very effective way for both a student and a professional to visualize concepts and ideas and to check the accuracy of results generated theoretically. Typically, computer simulations represent real world events on the computer and allow students to observe new phenomena by performing various manipulations that affect the on-screen events.
Here, at the University of Rhode Island, introductory computer science courses include computer organization and architecture with concepts that can often be difficult to grasp. This dilemma lays the foundation for the need for educational software "simulation" which better enables students to understand the concepts and ideas presented in class. In this project, we set to design and develop LogicCity, a prototype model of an on-line interactive digital logic design simulator that will be used as a ii teaching aid by complementing class discussions. LogicCity can be used as a stand-alone application or it can be incorporated into the Web as an applet. Students may use this simulator as a tool to build combinational digital circuits and generate accurate results. It is also designed to work in conjunction with the coaching material of an introductory computer organization course.
iii                    2. Exploratory education, such as an encyclopedia CD, permits the student to browse and view the information displayed. This kind of application presents complex tasks and engages students in active problem solving.

List of Tables
3. Applications, such as word processors and spreadsheets, provide students with the tools to facilitate writing tasks or analysis of data. These applications also promote higher-order thinking by engaging the students within a collaborative learning context [21]. 4. Communication education, allows students to exchange information among themselves through networks such as the Internet. This cooperative network allows long distance learning and gives students access to a broader range of resources.
Computers have taken a major position in the world because they can execute many tasks more effectively and efficiently than humans. Computers play an important role in helping students to learn by communicating information more efficiently as well as by captivating the mind of the student. For computers to reach a higher level in educating, one new element is essential: they must be· allowed to teach students without a human intermediary between the student and the computer. The idea is that students learn better when they are forced to take an active constructive role. As tutors, computers can revolutionize education as thoroughly as they have transformed almost every commercial activity in the twentieth century [3]. The technological progress of modern society creates an ever-increasing need for improved training materials. However, producing highquality material for computer-based education is, and continues to be, very expensive.
Widespread use and reuse of high-quality basic learning materials is the most practical One of the biggest advantages that a computer offers students of all ages is independence. This independence boosts a student's self-esteem and generates a drive that is imperative to learning. After initially grasping a basic understanding as to how a computer operates, students are free to explore a world of new and exciting things.
Besides increasing a student's learning opportunities, motivation, and achievement, 3 computerized education helps them acquire skills that are rapidly becoming essential in the work place. In addition, it gives students more control and responsibility of their own learning. In our opinion, it is of the utmost importance to prepare students to be technically literate by the time they are ready to go out to the working world.
Technological literacy is defined as the computer skills and the ability to use computers and other technology to improve learning, productivity and performance [19]. Students are entering a world in which 60% of the jobs will require technological competency, and students must continue to update their occupational and technological skills in order to be successful [20]. Technology can enhance traditional classroom presentations and engage students in more active learning.
Since students respond well to visual stimuli, working on a computer is much more fun and effective than having a teacher lecture. Computers allow a student to work and progress at his or her own pace -a teacher's dream. If a teacher feels the majority of the class grasps a concept, s/he must move on and then offer extra help to those who are struggling. A computer on the other hand lets students learn at the pace that is right for them.
The key to educational technology is how teachers and students use the software available to them. Easy to use multimedia-authoring applications, digital media collections, the Internet, and new educationally valid curriculem based software are all making the learning-centered classroom a reality [3]. Presentability is the software's overall appeal to the user (See Figure 1.2). Black and white, two-dimensional flip screen workbooks cannot possibly compete with the exciting, full-color media that students and teachers are exposed to daily. Rich, three-dimensional graphics, enhanced stereo sound, captivating animation and video, and interactive devices that students can control and manipulate are all necessary elements of successful educational software.  The mam contribution of this thesis work 1s to introduce a new learning environment and a new tool to aid the beginning students in understanding the materials presented in class. "LogicCity" is designed and developed using the Java programming language, thereby it is accessible though the Internet. LogicCity enables students to build on-screen digital logic circuits and to simulate their behavior. This software has an interactive graphical interface format that help stimulate the students in achieving a higher level of conceptual cognition. In chapters 4 and 5, LogicCity is introduced in greater detail and a full discussion of its features and data structures are presented. 6

Chapter 2 Background & Related Work
The popularity of the Internet among students and teachers has stemmed from its ability to fulfill the needs of users to travel the world seeking knowledge. Through the advances of communications and fiber optics technology, anybody can surf the World Wide Web at a minimal cost. Email, for example, is used extensively between teachers and students. Class notes are no longer limited to paper productions, as the Web has become home to all sorts of publications --among which are educational material.
Leaming is no longer restricted to the classroom. An increasing numbers of teachers resort to the Internet for publishing their course mater!als. Time, energy and resources are greatly reduced with the use of electronic communication. Leaming in the digital age is about computer supported education and computer-based simulations in the form of interactive, graphical, and dynamic content.
The Internet is the beginning of a new age m which electronic learning environments will have to try and obtain a firm footing at schools and on the home market. The Internet, therefore gives the electronic learning environment industry and Computer Based Leaming a new opportunity. The interactive multimedia has now entered its second stage due to the incorporation of audio and video content. Computer- 7 based simulations have many applications in higher education. There are many different computer-based simulations: patient-simulations, model-driven simulations, animations and simulations in which modeling comes first. Simulation, in general, can be used as a learning tool to gain insight into some phenomena that is hard or may be impossible to demonstrate in a classroom.

Educational Environments
Learning environments, and simulations in particular, can only be justified as a learning environment when provided with proper instructions adapted to a lesson and with relevant assignments (See Figure 2.

). Assignments and instructional materials
should be up-to-date and easy to modify for an individual teacher or school. An important aspect of learning environments is that teachers like to be able to add useful material or they may want to adapt something to the materials in question. It should be possible to make suitable assignments or easily accommodate existing instructional materials. All materials should be embedded into this electronic learning environment. For learning environments with simulations, the interactive simulator should be designed in such a way that modifications are simple and effortless. The instructional materials, and assignments, on the other hand, should be supplied with more flexibility, in order for the teacher to be able to distinguish him/herself, and gear his/her teaching materials and the accompanying materials to the needs of the target group. greatest disadvantages is that the Web has a very rigid interface concept that results in certain limitations with respect to stand-alone software (applications). 9

Simulation and Education
Attention will now be focused on computer simulation with special attention to computer simulation in education. Some questions that are addressed here include: • What is computer simulation?
• How is computer simulation used in education?
• What are the characteristics of a computer simulation?
• What are the advantages of computer simulation?
• What is meant by fidelity in relationship to computer simulation design?
The word simulate means to imitate something. Generally, simulation involves some kind of model or representation. The model imitates important concepts of what is being simulated. A simulation model can be a mathematical model, a computer model, a physical model or even a combination of all [1]. Applications (models) range from biological systems to business and industrial systems. But what exactly is a model?
A model is a carefully structured description of the simulated system. A model describes the state of the system and the possible transitions of the state of the system in the form of rules or equations. There are two types of models in general [ 14]: (1) qualitative models based on logical and/or conditional relations between variables and, (2) quantitative models based on mathematical equations of the relations between variables. Most computer simulations are based on quantitative models, which may contain parameters with fixed values that represent the properties of the system.
The main purpose of an educational computer simulation program is to provide students with a representation of reality. Students are able to manipulate this representation by changing either the properties or the conditions under which the representation operates. The behavior of this representation as a result of the modifications is similar to the represented part [18]. Computer simulation programs are discovery environments in the sense of experimenting with a model of a system in order to retrieve information about the model and the system. In addition, as mentioned earlier in the introduction, computer simulations are classified as exploratory environments that stimulate learning process (See Figure 2.2). The idea is that the meaningful incorporation of information into the student's cognitive structure becomes easier because the student is forced to take an active constructive attitude [ 5].

Hysteresis Applet
A 64x64 2-dimensional simulation. 2 -This applet simulates a simple model, which describes the sort of hysteresis seen in a magnetic tape. When you apply an external magnetic field to an initially unmagnetized tape, it becomes magnetized. However, when you remove the external magnetic field, the tape remains partially magnetized. (If not, there would be nothing recorded on our tapes!) 11 whole, but they have indistinct relations in the whole and can therefore not be represented in a model.

A computer simulation program cannot develop the students' emotional and intuitive
awareness whereas the use of simulations is specifically directed at establishing relations between variables in a model. This intuition has to be developed in a different way.
3. Computer simulation cannot react to unexpected "sub-goals" which the student may develop during a learning-process. These sub-goals would be brought up during a teacher-student interaction but they remain unsaid during the individual student use of a simulation.
4. Computer simulation programs may function well from a technical point of view, but they are sometimes viewed as difficult to fit into a curriculum.
5. Often a computer simulation program cannot be adapted to take different student levels into account within a group or class. A computer simulation program can certainly be made to adapt to different circumstances if it is designed that way; however, for many computer simulation programs this has not happened.
6. During the experience of interaction with a computer simulation program, the student is frequently asked to solve problems in which creativity is often the decisive factor to success. The fact that this creativity is more present in some pupils than in others is not taken into account by the simulation. Mutual collaboration and discussion among students while using the software could be a solution for this. 15

Instructional Design for Computer Simulation
Fidelity is defined as how close a simulation imitates reality [8]. A linear relationship is assumed to exist between fidelity and the transfer of learning --increase/ decrease the fidelity and you increase/decrease the transfer of learning. There is no concrete evidence regarding this assumption because [8]: • High fidelity means higher complexity which taxes memory and other cognitive abilities, and • Proven instructional techniques, which improve initial learning, tend to lower fidelity.
These reasons lead to the hypothesis that the relationship between learning and fidelity is non-linear and depends on the instructional (knowledge) level of the student. The amateur student learns best from a relatively low-fiddity simulation, the experienced student learns best from an intermediate-fidelity simulation, and the advanced student learns best from a high-fidelity simulation. Some conflict is created here because increasing fidelity, which theoretically should increase transfer, may inhibit initial learning that in turn will backfire and inhibit transfer. This conflict should be taken into consideration for the inexperienced student.
When working with simulations the student is exploring and discovering new knowledge. This knowledge is best gained wheri the computer-based simulation that is being used has been properly designed (See Figure 2.4). According to Reigeluth & Schwartz [17], one must consider three major design aspects: (1) a scenario that recreates the real life situation, the scenario determines what happens and how it takes place._ It also determines the role of the student and how s/he will interface with the simulation. (2) A mathematical model that reflects the relationships that govern the system and (3) an 16 instructional overlay. The instructional overlay is that part of the program that optimizes learning and motivation. The authors have found that the nature of the content being taught is the major influence on the instructional features a simulation should have. The applet illustrates a simplified simulation of virtual memory implementation in a processor running multiple processes (four, in this example) and scheduling the processes based only on page faults by the processes.
These authors further have identified three phases in the learning process. The learner must first acquire a basic knowledge of the content or behavior. Then s/he must 17 learn to apply this knowledge to the full range of relevant cases or situations. The final stage is an assessment of what has been learned. Therefore, the first set of instructional features in a general model for simulations should be concerned with acquisition of the content, the second set with application of the content, and the third with assessment of learning. The simulation is preceded by an introduction which should present to the student the scenario, goals and objectives, and directions and rules regarding the use of the program. During the acquisition stage the student should develop an understanding of the content.
Simulation-based learning can be improved if the user is supported while working with the simulation (See Figure 2.5). Part of this instructional support can be achieved through off-screen material such as a workbook, and sometimes an individual tutor can be available to monitor and assist the student at work. A large part of the necessary support functionality can, however, be accommodated within the computer program itself. The challenge is to strike the right balance between exploratory freedom and instructional constraint. The instructional constraint is divided into non-directive support and directive support. The non-directive support is defined by the interface of the computer program. The interface is the component of an instructional system that mediates between a student and the system. This interface serves only as a communication aid and has nothing to do with instructional process itself (simulation).
As for directive support, it depends on the characteristics of the simulation, the characteristics of the student and the characteristics of the learning goals. The authors have elaborated on the concept of instructional support for simulations. He has tried to derive from cognitive theory, from instructional design theory and from existing 18 exploratory learning environments instructional features (strategies, actions, approaches) that could be relevant to the design of simulations. student or trainee computer simulation system outp t computer si mul at ion pro~r m inpu worksheets Figure 2.5 -The learning environment for a computer simulation session with a complete computer simulation program, included worksheets, manuals, hardware, software and courseware. The mathematical model is the heart of such computer simulation programs.
Properly designed systems for educational computer simulation programs have several distinct characteristics [ 18]: • The operating system of the ·computer is never shown to the user.
• The underlying model is never shown to the user.
• The only input device for the user is the mouse.
• Some input can be accepted from the user.
• The output of the program can be presented in a highly graphical display.
• There are options with which the user can influence the running of the model. • Changing model elements is possible.
• Some typical cases can be pre-programmed (sample situations).

19
• Additional coaching material can be provided on or off-screen.
Research with such simulation programs show that the additional materials were of utmost importance in the instructional aspect for the student [14]. In light of this, the notion of the Parallel Instruction Theory was proposed. The Parallel Instruction Theory states that students are best served when the simulation as well as additional materials in a simulation-based learning environment are within reach. If the additional material is paper-based, it has been noticed that they are not used. Therefore, computer-based materials are preferred, because they are more available. This led to an additional guideline for designing simulation-based learning materials, when designing materials the designer should take notice that all material should be within reach when the material is presented to the student. 20

Chapter 3 Digital Logic Simulation
Logic simulation is the process of building and exercising a model of a digital circuit on a digital computer. When the user exercises the simulation, the evaluation of signal values in the modeled circuit occurs for applied input variables. There are two main applications for a logic simulator. The first type of application is concerned with the evaluation of a new design. The logic designer is interested in testing for logic correctness, as well as signal propagation characteristics. For VLSI circuits, where design errors are very costly and breadboarding is impractical, logic simulation is an invaluable aid. A second application for logic simulation exists in the area of fault analysis. Here, the test engineer or logic designer may desire info_ rmation related to faults that are detected by a proposed test sequence, or related to the operational characteristic of the circuit under specific fault conditions. The scope of this thesis will be focused on the former application.

Why Computer Simulation
Digital logic design is typically taught m a "computer organization" course.
Textbooks usually use a series of figures to illustrate the life cycle of a combinational digital circuit. Students see raw numeric output on the screen after a program executes.

21
Simulation will offer students an alternative method to better grasp ideas presented in a classroom by providing a visual and graphical interface. A more effective way of teaching would be to use graphics to illustrate concepts because: • Visualization is an extremely powerful form of education.
• Drawing pictures provides an easier way for a better understanding.
• Pictures present concepts better than numbers.
• Graphical interfaces best match the human perception.
• Graphics provide a more productive learning environment and promote the development of more intuitive understanding. An interactive graphic system allows the user to input commands and see realtime pictorial output on the screen. The use of computer graphics in circuit design eliminates the need to draw and erase wires and gates on paper thereby saving considerable time. The manipulation of a circuit is easily updated graphically and eliminates errors generated by wiring inputs to the wrong gates. A typical student assignment will consist of designing a logic circuit and producing its correct output.
Computer simulation enables the students to do their homework quicker and easier by building circuits on screen and verifying the correct output. In addition, it create a stimulating learning environment, better able to interest and educate computer science and computer engineering students. Students can experiment with the simulator at their own pace and investigate various logic circuits to reinforce conceptual understanding independent from the classroom and other students. 22

How Simulation Work
The central idea of component-based logic simulation is to build a simulation environment using software components. On modern personal computers or workstations, windows, menus, and file folders are usually represented by software components, which are the breakthrough concept of Object Oriented Programming.
Traditionally, logic simulation is first accomplished by mapping a circuit description into a data structure. Then a piece of code called "simulator," which is most commonly event driven, is needed to interpret the data structure and execute the input vector. When implemented using the event driven technique, the simulator is able to exploit the infrequency of logic switching in a digital circuit. Only the logic gates with changing inputs are processed. In the case of event-driven simulation, each component simulates itself and then drives another component into the next cycle thereby executing the whole computation of the circuit. The simulation method that describes the behavior of the component does its interaction with the external world through the input and the output objects.
The event-driven technique is more adaptive, scalable, and efficient to perform simulation for digital systems with various complexities. The structural description might be at gate level, which consists of the topology ·of the circuit and the circuit element types, along with a list of primary inputs and primary outputs. A high level language is often used for describing input sequence, desired output format, etc. The simulator, therefore, is a program that interprets all the inputs, applies the input data to the digital system and computes the outputs. 23

Commercial Algorithms
Most of the commercially available tools that perform digital simulation basically work in the same way. First, a simulator is synthesized by mapping the entire digital system at the gate level into a piece of runable code. Then the simulator is executed to check for the behavior of the design. The fundamental element of a simulation environment is the formation of an object by the encapsulation of the behavior of a functional block within a digital system. The complete simulation process can be characterized as the interaction of many different objects. Each individual object selfdescribing its behavior is subject to external inputs, initial conditions, and the interchanging of inputs and outputs with each other.
Although we do not intend to compete with the commercially available simulation products, we will give a brief introduction to some of what is available to the public. (In the next chapter, we will introduce more information specific to logic simulation and its terminology).

• Time-Driven (Analog)
In my undergraduate study in Electrical Engineering, I had the opportunity to use Spice, a VLSI simulation algorithm. Spice basically constructs a sparse matrix and solves design equations at transistor level by manipulating voltage and current.
Disadvantages to the Time-Driven system are (1) huge calculations, (2) it is extremely time consuming, and (3) this system requires the user to read an extensive manual before any attempt can be made to use it.
• Event-Driven 24 Verilog, Vhdl, RSIM (all of which are simulation algorithms) construct an event list using a data structure. This data structure holds all the events generated and executes them in the order in which they are received. These algorithms operate at the gate level, and logic states are used as variables 1 (high) and 0 (low). Although propagation delay time is considered to be a problem, statistics show that for big digital circuits, only 14 percent of the gates will frequently have events, thereby making it an efficient technique.

• Compiled Mode
Other software algorithms compile all the circuit description into one piece of executable code, and then define the initial and final states. The code is run during the cycle and pointers to the initial states and final states are swapped. This technique allows the next simulation to be run using the previous final state. Only state variables are of concern, and the intermediate values are not of the interest. This cycle based algorithm could be very efficient using native C code.
There are two types of event-driven simulation: discrete-event and continuous-event algorithms [2]. In discrete-event simulation, an event 1s defined as an incident that causes the system to change its state in some way. For example, a new event is created whenever a simulation component generates an output. A succession of these events provides an effective dynamic model of the system being simulated. The variables of a discrete system jump from one point to another and do not necessarily occupy intermediate values. Therefore, events in a discrete-event simulator can occur only during a distinct unit of time during the simulation. Discrete system simulations are often event oriented in that time is not advanced in uniform increments, and events are not permitted to occur in 25 between time units. In contrast, the variables of a continuous-event system undergo transition from one value to another m a smooth continuous manner, occupymg all intermediate values.
In the case of digital simulation of continuous systems, time is usually subdivided into uniform intervals and the simulation is "clocked" in terms of the basic time interval.
What separates discrete-event simulation from continuous simulation is the fact that discrete systems are often characterized by difference equations, while continuous systems are described by differential equations. Discrete event simulation is generally more popular than continuous simulation because it is usually faster while also providing a reasonably accurate approximation of a system's behavior.

Limitations of Available Models
One of the digital logic simulators currently used by the Computer Science Department at the University of Rhode Island is Dizzy (See Figure 3 .1) [22]. When the user first opens the software, a menu with several gate options as well as some editing options, is displayed to the side. The editing options include shifting the grid display around using a "hand" icon, deleting an object from the screen using a "zapper" icon, saving a circuit to a file, and opening a previously built circuit. Dizzy also custom saves a random circuit in the form of a black box, which allows for the use of modules. Although Dizzy works fine and allows the user to build many large circuits, it does have some rather serious limitations.  Figure 3 .1 -Dizzy program shows the application window and its tool menu. Several objects are displayed that all have the same "square" box shape.
The first major limitation is that when Dizzy initially starts up it opens a fixed window. In particular, the user can not build a circuit larger than the size of the  True. When a simple circuit was constructed on Logg-0, the correct output resulted.
However, Logg-0 does have limitations as well. When the program starts up, a fixed window is displayed, which, as discussed earlier, limits the size of the circuits built. In addition, the size of a single logic gate is so large that only a handful of gates may be placed on the screen at a time. This is the reason the test circuit used to demo the system is simple. The behavior of the program may be undetermined if a large circuit is constructed. The only way to "test drive" the stability of this system is to construct a large circuit, and this is not feasible. Furthermore, if an input signal is introduced into the system using a considerable circuit, evaluation time. may be unacceptably long.
Although both Dizzy and Logg-0 produce accurate results and are fully functional, both seem to be unintuitive to an amateur student. An interface design with an intuitive approach enables the user to operate the software in a very timely manner and without much struggle. Students encounter enough challenges with class assignments, 29 never mind spending more time trying to figure out how a program works. It is always imperative for a graphical interface to be as clear as possible and follow industry standards.

Chapter 4 System Specification and Features
One of the objectives of this thesis is to prototype a simulation system, using the Java programming language, that will allow students to access the internet from anywhere to run the simulation program. The development of this digital logic simulation provides a good demonstration of object-oriented technology. In the next few paragraphs, Java is briefly discussed in order to show why we chose to use it, and why it is revolutionizing the Internet. Features and drawbacks of Java are also presented. Then we will introduce LogicCity, our prototype model simulator and instructional software.
LogicCity contains many features and functions, which will all be presented in detail. A thorough discussion of the internals of the system will be discussed in the following chapter.

The Java Programming Language
According to Cornell [3], the promise of Java is to become the universal glue that connects users with information, from Web servers, databases, and any other imaginable source. It is a very well designed language with a solid foundation that incorporates syntax very familiar to programmers. Object-oriented programming is considered the 31 break through in practice, and Java is thoroughly object-oriented even more so than C++.
Everything in Java is an object (except for basic types like numbers). Yet like all other programming languages, Java does have its advantages and disadvantages.
A main key advantage is Java's run time library that provides platform independence; that is, you can use a Java program on any other operating system including Windows, Solaris, and Macintosh. The compiler generates a neutral byte code, which is easy to interpret and execute on many processors. Debugging a Java program is much easier than debugging a C++ program. Manual memory allocation and deallocation is eliminated in Java because memory is automatically garbage collected. True arrays that eliminate pointer arithmetic are introduced, and multiple inheritance is replaced with a much easier interface that has the same functionality. Java has an extensive library of methods for dealing with TCP /IP protocols like HTTP and FTP. Java applications can open and access objects across a network via URLs as easily as accessing a local file system. Also since Java is intended to be used in networks and distributed environments, much consideration has been placed on security. Basically, Java's security system prevents a program from corrupting memory outside its own process space and prohibits reading and writing local files.
Java is simple; a user can download Java byte code from the internet and run it on a local machine. Java programs that work on Web pages are called applets. To use an applet, one needs a Java-enabled Web browser that will interpret the byte code downloaded. A Java program can also be run on a stand-alone basis, in this case, it is referred to as an application. Both applets and applications have advantages and 32 disadvantages, which are summarized in Table 1. Following are a few common misconceptions of Java, which are based on a review done by Cornell [3]: • Java is not an extension of HTML. They have nothing in common except that there are HTML extensions for placing Java applets on a Web page.
• No programming language as powerful as Java is as easy as Java to learn.
• The native Java development environment is not an easy environment to use.
• Java is interpreted, but it is not too slow for serious applications. All programs, regardless of the language used, will detect mouse events in adequate time. There are no serious performance issues once an interpreter is used to translate the byte code.
• Not all Java programs run inside a Web page. All Java applets do run inside a Web page. However, stand-alone programs that run independent of a Web browser cannot always be run in a Web page.

The System's Web Site
LogicCity's design and implementation usmg this programmmg language, is based on the many advantages of Java and its ability to use the Internet. LogicCity consists of two integrated parts, suitable text-based material and interactive software. As students access LogicCity's Web page, they are presented with the relevant material for that course (See Figure 4.1 ). The course material is divided into several parts and each part is linked to the next. A student can browse through the various parts as desired as well as link to the software. At any time, the student is able to intermix reading with using the software provided, which we feel, provides students with the exploratory environment we mentioned earlier. When accessmg the simulator page, students have the option of usmg the simulator directly while on-line in an "applet" format or downloading the full-featured "application" version (See Figure 4.2).

Figure 4.2 -Simulator Web Page
A recommendation is given to read the simulator manual and documentation in the link provided if a question arises regarding how to use the simulator. The zipped file received is quickly and easily decompressed using standard system utilities found on many platforms. In this case, the simulator is considered a stand-alone application and only needs a Java interpreter to run the program.

LogicCity
Assuming that the application version is downloaded and after the simulator program begins, a new frame (window) with the title "Welcome to LogicCity" appears at the top (See Figure 4.3). This circuit window is to be used for drawing a logic circuit schematic. This frame has standard window functionalities meaning that it can be moved around the screen, minimized, iconized or even closed. The default is set to maximize the window to the screen size in order to provide the greatest workspace. This workspace Menus are available at the top and on the left side of the window. The default setting for the simulator is the edit or build mode. In build mode, students can click on any gate from the gate menu and place it on the screen. There are several basic logic gates provided on that menu, namely, AND, OR, NOT, XOR, NAND, NOR. There is also a menu for inputs, outputs and connectors (See Figure 4.4). These are used to input signals into a constructed circuit, and to receive output signals from that circuit.
Connectors can be used to tie components together and route wires around in a clean and neat manner. The prototype's graphical interface lets the student select and modify different input scenarios. The user is also given options for the canvas background color.
At the top of the simulator window, there is yet another menu for editing which provides facilities for opening a circuit saved to a file, or saving a circuit currently being built. The edit menu also has means for the deletion of a single component from the circuit being built or the option of deleting the whole circuit, thus, clearing the entire screen. The intuitive and appealing format of the simulator's graphical interface allows a student to merely look at the window in order to figure out the functionality of the interface. This intuitive design reduces the difficulty the learner will have with the system and allows the student to concentrate on the circuit being designed rather than on how the system works. The simulator interface, which operates via the mouse, is fully interactive.
The user need not use a keyboard or any other input device. The consistency of functions makes the system easy to learn and use. This form of interactive interface provides a more dynamic and stimulating environment for the student that encourages learning and exploration. To start building a combinational digital logic circuit, the user just needs to click on the desired gate from the gate menu. The gate menu is composed of buttons so that once a gate button is clicked, the user moves the mouse over to the canvas area and places the selected gate at the desired location with another mouse click. The user can continue to place gates on canvas in the same manner.

Software Features
To draw a connection line (wire) between two gates, the user can click on the input or output pins of one gate and move the mouse over to the second gate (See Figure   4.5). As the mouse is being moved, a line, which ·basically mirrors the mouse' s motion and shows the connection made between two gates, is drawn on the canvas. A second mouse click at the receiving gate will make the line connection permanent, thereby creating what is called a solder point. Other gates can be created and connected in the same fashion. In order to provide straight routing wires around gates a connector object is created and placed on the canvas in the same manner as gates are. Any gate can send 38 input into the connector object; however, there is no limit as to the number of outputs the connector can send out. The simplicity created here is that one gate can be used to send many outputs to several other gates. As a matter of fact, all gates can equally send multiple output lines to any other object available. Logically, a gate can accept only one input signal at a time, but it does not matter how many output signals are sent out.
Once a logic circuit is designed and constructed, input and output objects are needed to facilitate the introductions of signals into and out of the circuit (See Figure   4.5). For that reason, two more buttons are displayed next to the connector button that allow for the creation of input signals as well as output signals. Input signals are displayed as a square box with an outgoing line and their default value is set to either low or logic zero. A blue color was chosen for this box to visually give the illusion of an initial low (cold) input signal. The output object is displayed in the form of a light gray square box and is initially set to low. The gray color gives the illusion of a low (dimmed) signal to indicate a "dead" output line but when in simulation mode this box glows in red if the output signal evaluates to high.

~ 4 -bit Comparator
Pir;J D  A scroll bar is provided to give the user the ability to build circuits larger than the size of the screen. Students can "tum" pages easily while viewing or working on a large circuit design. With several pages of available space in both screen dimensions, logic circuits may grow to be quite complex. This complexity necessitates a save button on the edit menu to allow students to save their work to a file at the end of a session. After a circuit is put together, a student may easily save his/her work by clicking on the save button. A dialog box, which permits the user to enter the name of the file to be saved, pops up (See Figure 4.7). This modal window has the same functions and appearance as in a Windows environment and is provided by Java. Briefly, modal dialog boxes cease the running application until some command or option is entered. This prevents the accidental mistakes that could prove devastating. As soon as a valid name is entered, the simulator saves the current circuit to file and confirms this operation by displaying the new name of this file at the top of the window. If the canvas is empty, that is, there is no circuit displayed on screen, the save button is deactivated.  Students also have the option to cancel the open file call altogether. The circuit recovered at that point is ready either for editing, addition, or just simulation. Before any circuit is 42 opened or placed on the canvas, the entire screen 1s first cleared to eliminate any confusion or mistakes.  Initially, all input signals are set to low; however circuit design always necessitate the introduction of several high input signals (See figure 4.10). This is accomplished by clicking on the input object desired. A click toggles the state of the input object from low to high; another click on the same object resets it back to low. Only input objects are allowed to change their states when reacting to mouse clicks because any other way would defeat the purpose of the object. Once an input signal is toggled to high, its state value is displayed in red along with the sending wire. The output object (if any) that is getting this high signal will glow in red to visually confirm the "hot" line just received. The next chapter will discuss the data structures used to implement the simulator software. Algorithm design and implementation will be detailed along with challenges that were presented in the implementation phase.

Chapter 5 Data Structures
LogicCity is an easy to use tool for entering a logic circuit schematic and performing simulations of its behavior. The creation of LogicCity was done in three major stages. The first stage, the design stage, entailed careful planning of the necessary data structure used for the design of the prototype. In the second stage we implemented the methods specified in the design stage. The final stage tests the overall performance of the software for accurate results and for proper functionality and appearance on the Web.
In the following paragraphs, a detailed analysis and discussion of all three stages, as well as a discussion of the challenges we had to overcome, will be presented.

System Design
Since there is usually more than one way to go about solving a problem, it is always worthwhile to imagine several solutions and then compare their advantages and disadvantages in order to insure a complete and thorough search. Solutions to more complex problems might typically involve multiple layers of data representations and many iterations of the stepwise refinement process. In addition, an important skill for computer scientists to master is reasoning because it is key when creating and debugging 46 algorithms, when figuring out how to improve an algorithm's performance, and when verifying that methods inside a larger program work correctly.
Deciding on a "good" data structure is crucial because data handling and manipulation can be extremely simplified. We took a divided approach, both "top-down" and "bottom-up" design techniques, to develop the data structure for the simulator application. We eventually arrived at an executable Java program. In the "top-down" approach, we began at the highest conceptual level by imagip.ing a general abstract solution and by sketching a program strategy in outline form before choosing any particular low-level data representations or algorithms. Then, step-by-step in progressive refinements, we filled in the details to implement the parts of the previously sketched solution in higher-level description. In order to implement the parts in parallel, we found it easier to use the "bottom-up" approach, where we first considered what information was needed, and then how to obtain this information. Next, we made a draft of definitions for the methods before using them inside other higher-level methods. This brought us to the details of the bottom layers of the overall program before filling in the higher levels that use the methods we had already written at the fower levels. This approach is not always the best approach for programming because one may reach a point where the methods already defined become inadequate and need to be redefined as the application evolves.
The design process began by developing the model's data structure. This data structure must be able to hold all the information needed to run the simulator application while simultaneously providing the user the ease of running the application. The data structure must have a clear interface while concealing all the details of implementation 47 from the user because in reality a user does not care how a system is built as long as s/he can use it satisfactorily. The second step in the design stage was researching, selecting, and then developing the programming language. One of the big advantages to this simulator is that it is accessible to the public through the Internet, so we chose Java, the Internet language, as the programming language for LogicCity. Since LogicCity is platform-independent, any person with a computer and a Java savvy browser can run the simulator applet. Java is currently the only language that brings dynamic web pages to life and allows for animated graphics and multimedia.
The topmost level of the object-oriented design for the simulator application consists of three interacting Java objects, each of which encapsulates its own hidden, private data fields. These objects interact only by making method calls on each other's "services" (where the services are the publicly available methods in each object's interface). There are no global variables that hold shared values or data structures on which different objects operate. Consequently, the design is an example of pure modular programming in which the modules (the Java objects) interact only in clean simple ways through their interfaces with their internal mechanisms .hidden from view.
In the design stage, we had to declare the major objects of the data structure essential to holding the data to be processed. Several drafts were made before a final one was realized. The higher level abstraction of the data structure is divided into three main parts. One part declares the attributes of the basic logic component (gate), the second part declares the operations (methods) invoked on such a component, and the third part builds the actual graphical interface. There are no dependencies on any particular operating 48 system since Java is platform independent. However sufficient memory, which 1s available in almost all computers today, is required to run the simulation program.
LogicCity is totally object-oriented in design, meaning that an object bundles together data and some behavior. An object's data can be a collection of variables whose values give the object's internal state, whereas an object's behaviors can be a set of operators that change its state. These data and variables are hidden from the user and are encapsulated in a "module" package that a user can have access to only through invoking its available methods. There are a couple of benefits to the encapsulated object format used for this project. One benefit is that the application's GUI (Graphical User Interface) is an event-driven interface in which mouse events (generated by the user clicking the mouse on the screen) must be handled by event-handler code. The application and GUI must be set up to handle mouse events so as to trigger method calls on the problemsolving objects, to receive the computed solutions they return, and to display the results graphically on screen. Another benefit is that the canvas code that translates from mouse events to computed solutions is not completely trivial. The event handling and data manipulation mechanisms are complex enough that using the module as an encapsulated entity saves us from the effort of having to reinvent them and debug them in another program. This benefit creates important enhancements for software productivity for the future.

System Implementation
The overall organization of the data structure is composed of an abstract object (super class) of a logic gate, and a simulator object that sets up the graphical interface 49 which in turn calls methods for acting on a logic circuit. The simulator object is one of the main components in the data structure that creates the top-level window (See Figure   5.1). This top-level window is derived from the Frame class supplied by Java. The simulator object uses one of the most sophisticated Java supplied layout managers. The layout manager, called Grid Bag Layout, arranges all components in a panel into rows and columns. Each component is told to occupy one or more of the little boxes on the screen. The idea is that this layout manager allows you to align components without requiring that they all be the same size since you are only concerned with which cells they will occupy. Incidentally, the purpose of layout managers is to keep the arrangement of the components reasonable under different font sizes and operating systems. The simulator object controls the master switch that enables the system to either build a logic circuit or simulate its behavior. It also owns the main() method that starts up the entire system. In main(), a simulator object is created, initialized, and displayed to the viewer.
The simulator object is parent to three panel components --the editMenu, the gateMenu, and thePanel. The editMenu contains circuit edit buttons such as "save", "open", "erase" and "clear all". These buttons invoke actions to be taken on an individual basis when the user triggers specific events. That is, each button calls on its actionPerformed method to process the particular event. The gateMenu contains all circuit parts in a palette format that a user can choose from and consists of several basic logic gates, a connector object, and input and output objects.  Since the simulator application is a totally interactive graphical interface, mouse event handlers do most of the necessary work. For example, dragging the mouse around moves a gate around the screen. Therefore the mouseDragged method must be defined in 53 a way that accomplishes this task. In order for theCanvas to handle all mouse events, it must define the interfaces that supply these mouse events. There are three interfaces in theCanvas --ActionListener, MouseMotionListener, and MouseListener. Combined they provide several mouse methods, all of which must be defined to handle certain conditions of the system. ActionListener has only one method, actionPerformed, to be defined. The objective of actionPerformed is to tell the canvas which button in the system has been clicked. For this method we had to invent analysis techniques to determine which button is clicked since the most current version of Java does not provide facilities for doing this yet. Once a button is identified, this method sets a pointer to the object.
MouseMotionListener is responsible for providing two mouse action methods, mouseMoved and mouseDragged. The objective of the mouseMoved method is to keep track of mouse motion by setting the xCoordinate and the yCoordinate variables accordingly because this method is invoked every time the mouse is moved on screen.
The mouseDragged method is called for every time the mouse is dragged on an object on screen and is responsible for locating the dragged component, updating its canvas coordinates, and refreshing the screen display.
MouseListener provides several mouse-related methods, which are mouseEntered, mouseExited, mouse Pressed, mouseReleased, and mouseClicked. The mouseEntered method is utilized to initialize a logic circuit once the mouse has entered the dimensions of the "Function" button that switches to simulate mode. The mouseExited and mouseReleased methods are left undefined at this time. They are included in the implementation however to satisfy the compiler's requirement. The mousePressed method is defined to select one of the several color options provided by the Choice 54 object. The latter is a pull down menu that allows for different canvas background colors. The runSimulation method is responsible for performing the actual simulation of the behavior of the logic circuit and displaying the results of this simulation on screen by displaying the logic states of every individual gate object in the circuit. This method displays "O" to denote a logic low or "1" to denote a logic high. The runSimulation method also allows the user to change the states of any arbitrary gate object on the screen depending on the circuit design. By clicking on the input objects to a particular component, the user can easily change the state value of the component.
The canvas also allows for two dialog boxes to be instantiated. These dialog boxes serve as a safety feature against the accidental destruction of an unsaved logic circuit. Input is received form the user through these dialogs and processed accordingly.
We accomplished this by creating two new objects, each handling a dialog box separately, which allows for providing a different warning message on each dialog box plus different option buttons. 55 In Java the various GUI building blocks, such as buttons, input areas for text, and scrollbars, are usually called components. The user interface is constructed using these various building blocks, and one can program the interface to respond to various events.
These building blocks are called "controls" in Windows programming and "widgets" in X-Windows programming. To build the user interface, we needed to first decide how the interface should look, particularly what components are needed and how they should appear. Unfortunately since Java lacks a form designer (like Visual Basic has that generates code templates), we had to write code for most everything. We had to write code to make the components in the user interface look the way we want them to look, and we had to layout (position) the user interface components where we want them to be inside the window. We also had to handle user input by programming the components to recognize the events to which we want them to respond.
In order for the system to display the animation resulting from the circuit, the paint method in theCanvas must be overridden. The paint method handles the drawing of the whole simulation in one central location, which eliminates the need to pass the circuit around among the different objects. This also simplifies the implementation of the A logic circuit consists of a combination of logic gates, and in turn, a logic gate is an object that is instantiated by the user during the design of a circuit. The way we implemented logic objects is by creating a super (parent) class, which is a stand-alone entity; that is, it is not derived from any existing Java object. The super class, called LogicGate, declares several methods that p. roduce necessary information at different stages of the life cycle of a logic gate. Some of these methods are defined within the super class itself whereas several others are declared as abstract, which is the equivalent of virtual functions in C++. From the super class, many objects are derived as children and inherit the attributes of the parent object. These objects represent the basic logic gates, the connector object, and the input and output objects. Each child derived from the parent class declares additional, exclusive methods.
Careful consideration was given as to what attributes a logic gate must have (See is capable of returning sufficient information to the requester. Information such as the state of the input pins and the output pin. A gate object can also identify itself by returning its type as a reference, its position in the circuit, and its canvas location. A gate can tell what part of it is clicked by trapping mouse events and processing them, and a gate can draw itself, calculate its operation, and change its input states. The constructor for the super class, LogicGate, is the one responsible for instantiating all logic objects in the circuit. As theCanvas requests that a specific gate object be created, it passes the necessary information to the super class of that gate. This information is the gate number in the circuit (its position) and its canvas location. Then LogicGate places the selected gate object in the center of the grid specified by these coordinates. LogicGate defines the method whichGate that returns the gate being clicked once a mouse click position is given. After a gate is identified, LogicGate can return the part of the gate selected, which can be either inputs or the output pin. Fine-tuning is further done in the event input is selected in order for the canvas to determine which input pin is clicked. LogicGate can also return a Boolean value of True or False if an output of a gate is clicked. Further more, LogicGate c· an return to theCanvas the position of the gate selected.
Logic objects derived from the super class, LogicGate, inherit all the attributes and methods of the parent. In addition, each "child" subclass further defines the functionality specific to it such as the logic operation of each gate. All abstract methods that are declared in the parent class must be defined in any inheriting child. However a subclass can of course declare methods that do not exist in the super class. Each subclass object can display itself on screen through a request from theCanvas. Obviously each 60 paint method is different among the logic gates. The paint method draws the object it belongs to and then draws all wire connections to this object. Wire connections for each gate are stored separately in each gate's connection Vector. A logic gate can change its input state with the togglelnput method. This method allows the user to change the input states between 'high' and 'low.' A gate generates its correct output by simply following two rules at all times.
One rule is to always keep the output value consistent with the inputs received on the input side. Performing the appropriate logic operation of the gate on the inputs received validates the consistency. This condition must be true at any time. As one or more input pins changes states, the output consequently must be rechecked and recalculated. Correction is done by changing the value of the output pin in accordance with the result of the logic operation. This leads to the second rule --if the output changes states then all gates that are connected to it must be reevaluated. The output value of a gate must at all times be consistent with the value of all input pins connected to it.

System Testing
The final stage of building this prototype's model was to test its performance to assure its correct output in accordance with the speCifications theoretically generated. We tested the simulator program to insure its accurateness by using it for designing and simulating many circuits. Initially, each gate object was tested separately for accurate output. Next, simple circuits were constructed and tested, and their results were verified.
Finally larger circuits, such as a 4-bit full adder, 1-bit ALU (arithmetic logic unit), and 1bit left/right shift register, were built. All circuits generated accurate results and 61 performed satisfactorily regardless of their size or complexity. This is important to predict the stability of the system under various circuit designs and sizes. The next step was to transform the application to an applet format in order to incorporate it into the Web. Several changes had to be made for this transformation. First, an HTML page with an applet tag was constructed. Second, the main() method had to be eliminated since the Web browser does the initiation for the applet automatically. Next, the application title was also removed as it interferes with the browser's naming mechanism. Applets do not have title bars, but one can title the Web page itself using the <title> HTML tag. Then the simulator class had to be modified so that it is derived from the Applet class instead of from the Frame class. Next, the simulator class constructor had to be replaced with a method called init. When the browser creates an object of the applet class, it calls it's init() method. If the application's frame implicitly uses a border layout (for placing components), the layout manager for the applet must be set in the init method. Additionally, all menus must be replaced with buttons since applets cannot have menu bars.
Finally, the instructional materials of the course were transformed into HTML so that they can be viewed on the Web. This way, a student can read the course text and use the simulator in parallel, which stresses conceptual understanding. A manual for the simulator is added on the site through a hyper link. Afterwards, an extensive test is performed on the whole Web site for the following: • To ensure the readability of the course materials, • To validate the correct links among the site's many pages, • To verify the ability of the Web browser to initiate the simulator applet, 62 • To inspect for accurate functionality of the simulator, and • To confirm the ability of the Web browser to download the application version of the simulator.

Design Challenges
We came across many challenges while building the prototype's model. In the beginning, it was difficult to determine what object should have what functionality.
Dividing responsibilities among the different classes took some time to establish.
Initially, the gate objects super class was given numerous responsibilities that later proved to be inadequate, so LogicGate had to be redefined and carefully redesigned.
Thereafter the objective became apparent --a gate must handle only gate operations. The isolation or abstraction technique proved very effective in designing the simulator as totally object-oriented.
Another challenge we faced in the implementation of the program to learn Java and new Java oriented techniques. Luckily Java does not use explicit pointers, so programming was somewhat simplified as compared to C++ for example. Yet we still had to gain sufficient knowledge of the internals of the Java language and the different libraries it offers in order to use them effectively. · One of the principal challenges that we encountered was how to implement the methods declared for each object. On several occasions we had to re-implement methods that we would later discover did not cover all the necessary bases. We had difficulty deciding how to pass information around from one method to another or between different objects. On occasion we had to decide whether a variable should be declared 63 "global' or should be created as a temporary variable inside a method that uses it. We were able to carefully distinguish when to use each case and why by isolating a variable to a method if it is used in that method alone. If several methods may need such a temporary variable, each method should create its own temporary variable. The variable's scope stays within the method definition and disappears as the method exits. On the other hand if many methods need to have access to the same variable then it is best to declare it globally. Actually the term global does not exist in Java, as the language is completely object-oriented. Instead a global variable is declared at the object level and it can be private, protected, or public.
The single most significant programming challenge that we faced was debugging the application. We spent a great deal of time debugging using the time-honored method of inserting print statements into the code. However, we can tell you that debugging with print statements is not one of life's more joyful experiences. We constantly had to add and remove the print statements, then recompiling the program. Using a debugger is better because a debugger runs a program in full motion until it reaches a breakpoint, and then one can look at everything that is of interest. One can purchase excellent debuggers on most platforms, but if you are on a budget or working on an unusual platform, you may still need to resort to the print statements. The Java development kit includes an extremely primitive command-line debugger, and its user interface is so minimal that you will not find it useful. In my opinion, this debugger is really more a proof of concept than a useful tool.

Chapter 6 Conclusion
Computer simulation is the discipline of designing a model for an actual or theoretical physical system, executing the model on a digital computer, and analyzing the executed output. Simulation embodies the principle of "learning by doing." The use of simulation is an activity that is as natural as a child who role-plays. Children understand the world around them by simulating (with the use of toys and figures) most of their interactions with other people, animals, and objects. To understand reality and all of its complexity, we must build artificial objects and dynamically act out roles with them.
Computer simulation is the electronic equivalent of this type of role-playing and it serves to drive synthetic environments and virtual worlds.
Computer simulations are currently used in a wide range of applications in the physical sciences, as well as in the social sciences and economics. For example, much of what is known about the likely behavior of nuclear reactors during accidents is derived from computer simulation models. Needless to say, testing actual reactors or even scaled down models under emergency conditions would involve excessive risks. Thus, computer simulation is of critical importance. Computer simulations are also used in meteorology to forecast the weather. Chemists use computer simulations to explain and view chemical reactions occurring at the molecular level.
Technologies such as simulation will dominate the entertainment and science forefronts well into the next century. While what we may do today may be primitive by standards set in science fiction movies such as "Star Trek" (The Holodeck) and "Lawnmower Man," the present computer simulation discipline will lead the way to these eventual goals. The key word is "digital," as pointed out by many such as Nicholas Negroponte at the MIT Media Lab in his recent text "Being Digital". Scientists want to create digital replicas of everything we see around us. Digital objects may soon be located anywhere on the Internet, and users will be able to use some help tools to locate the building block objects for a digital world. Some of this type of work is being done in Distributed Interactive Simulation, a major project pioneered by the Department of Defense. The implications of these distributed interactive simulations are profound since this idea has enormous potential with the Department of Defense as well as in the industrial and entertainment fields.
The primary purpose of writing simulations in the Java programming language is to allow "live diagrams" to be incorporated into documents. With Java, people can experiment with a working simulation model by clicking on a Web link. This is different from simulations written in a traditional simulation language, C++ for example, where exporting simulation code requires recompilation and installation on each different platform. Java incorporates the language features necessary for simulation, notably objects and threads. Current Java implementations compile down to an intermediate byte code which is then interpreted. Thus, the main disadvantage of using Java, as compared to C++, is longer simulation run times. 66 The focus of this thesis is on the application of computer simulation for learning purposes. Educational computer simulation programs are available for many subjects such as biology, chemistry, medicine, physics, and economics. Many experiments with high educational value cannot be executed in the classroom. Some systems are too large (planetary systems) or too small (molecular systems) to be studied. Others may involve processes, which are too slow (the growth of biological systems) or too fast (chemical reactions and electronic circuits). In addition, there are experiments that are never executed because they are too dangerous (medical experiments), or unethical, or too costly. Furthermore, some experiments deal with systems that are much too complicated to be fully understood by students. Problems with these complex experiments can be overcome by using educational computer simulation programs.
The objective of this project is to construct a component based logic simulation environment using the Java programming language. This simulation environment will provide electronic designers and students a more scalable, more reliable, and more efficient way of performing verification for digital logic circuits. LogicCity is designed and developed as a computer simulation program that aids students in learning the subject material by enabling them to enter a circuit schematic and run a simulation of its behavior.
As for the computer science field, some computer organization and architecture courses teach digital logic design as an introduction. Some material can be difficult to grasp or visualize, thus necessitating some other form of educational aid to help drive home those tough parts of the subject. Digital logic simulation is an essential tool in helping students emphasize conceptual understanding, while complementing class 67 discussions. LogicCity has a very user: friendly, interactive graphical interface that allows students to validate the accuracy of their designs and helps them to do their homework.

Future Work
LogicCity has many features and benefits as an educational tool but like all programs further improvements are necessary. The architectural structure of the system operates at the gate level. Many arbitrary circuits can be designed and built using the simulator however efficiency might be compromised for very large circuits if they are to be built at the gate level. One can go one abstraction level up by wrapping all the smaller components (gates) to represent the basic building block for a more complex system, thus utilizing the "chip" formats in building more complex circuit modules. Modularity allows for the construction of virtually any electronic circuit with speed and ease.
The graphical interface for the simulator, though intuitive and clear, can still be additionally improved by employing the standard Windows format. Additionally, more sophisticated options can be added in the form of pull down menus that add various useful functionalities.

II
II The constructor positions a new gate in one of the free grids selected.
public LogicNand(int x, int y, int gatePosition) { super(x,y,gatePosition); calculateGateOperation(); }II end constructor public boolean getlnputState(int whichPin) II** Returns the state of the gate's input. Given which pin was clicked, this II** method returns the value of that input pin whether high or low. II** Returns true of the pin is high , false otherwise.
public LogicNor(int x, int y, int gatePosition) { super(x,y,gatePosition); calculateGateOperation(); }II end constructor public boolean getlnputState(int whichPin) II** Returns the state of the gate's input. Given which pin was clicked, this II** method returns the value of that input pin whether high or low. II** Returns true of the pin is high, false otherwise.
{ if(whichPin = topPin) { return toplnputPin; } else { return bottomlnputPin; } }II end getlnputState public boolean getOutputState() II** Returns the state of the gate's output. this method returns the value II** of the output pin whether high or low.
{ return OutputPin; }II end getOutputState public void displayGate(Graphics g) II** Displays the NOR gate, along with any wire connections.
II** High value is indicated with a red color, black for low value.
{ toplnputPin = ! toplnputPin; // no change, since this object is just a buffer. calculateGateOperation(); · }//end togglelnput public void calculateGateOperation() II** This method passes the signal through from the connector's II** input pin. }II end getlnputState public int whichlnput(Point point) II** Returns which one of two inputs to a gate has been clicked. It is modified II** here since a connector object has only one input. } }II end isOutput 97 public void displayStates(Graphics g) 11* * Shows the gate input and output states at simulation time. If an input II** to a gate is changed, this change is passed throughout the whole circuit. II** High value is indicated with a red color, black for low value.

II
public MyPanel(Simulator simulator)// need to pass simulator object. { super(); //call the parent constructor, must be first line here. setLayout(new GridLayout(l ,O)); 11 Creates a grid layout with the specified number of rows and columns. II All components in the layout are given equal size. II One, but not both, of rows and cols can be zero, which means that any II number of objects can be placed in a row or in a column. this.simulator= simulator; II pass the simulator object. simulator.theCanvas =new MyCanvas(simulator); //create drawing canvas. simulator.theCanvas.setBackground (new Color(204,204,255)); add(simulator.theCanvas); //add the drawing canvas to the layout. ScrollPane pane= new ScrollPane(); //create scrollable pane. setLayout(new BorderLayout()); //select type of layout. pane.add(simulator.theCanvas); //add drawing canvas to the scrollable pane. add("Center" , pane); //position the pane into the center of the screen. Adjustable horizontal= pane.getHAdjustable(); //get the horizontal scroll object.
horizontal.setUnitlncrement( 40); II change the horizontal scroll increment. Adjustable vertical= pane.getV Adjustable(); II get the vertical scroll object. vertical.setUnitlncrement(20); II change the vertical scroll increment. }II end constructor public void paint(Graphics g) II paint specifies how object g is to be displayed. All drawing in Java II must go through a graphics object. note: any time you need to put text or II graphics into a window, you need to override the paint method from the II Component class, so you need to write a new class for this that overrides II the paint method.