A powerful Java Swing-based GUI application for designing, simulating, and analyzing digital logic circuits.
- Visual Circuit Design: Drag-and-drop interface to add components and connections
- Logic Gates: Support for AND, OR, NOT, XOR, NAND, NOR, XNOR gates
- Interactive Components:
- Switches (toggle between open/closed states)
- LEDs (change color to indicate on/off status)
- Logic gates with multiple inputs
- Circuit Validation: Automatic detection of design errors and short circuits
- Truth Table Generation: Generate complete truth tables for all input combinations
- Signal Simulation: Real-time signal propagation through the circuit
- Save & Load: Persist circuits to files for later use
- Import/Export: Export circuit details as text files
- Java Development Kit (JDK) 8 or higher
- Operating System: Windows, Linux, or macOS
- Screen Resolution: Minimum 1400x900 pixels recommended
oops_prj_trial/
├── src/
│ └── com/circuitsimulator/
│ ├── gui/
│ │ ├── MainWindow.java # Main application window
│ │ └── CircuitPanel.java # Drawing canvas for circuits
│ ├── components/
│ │ ├── Component.java # Abstract base class
│ │ ├── Switch.java # Interactive switch
│ │ ├── LED.java # Visual LED display
│ │ ├── LogicGate.java # Abstract logic gate
│ │ ├── ANDGate.java
│ │ ├── ORGate.java
│ │ ├── NOTGate.java
│ │ ├── XORGate.java
│ │ ├── NANDGate.java
│ │ ├── NORGate.java
│ │ └── XNORGate.java
│ ├── circuit/
│ │ ├── Circuit.java # Main circuit manager
│ │ ├── Node.java # Circuit node (pin)
│ │ └── Connection.java # Connection between nodes
│ ├── validator/
│ │ ├── CircuitValidator.java # Circuit validation
│ │ └── TruthTableGenerator.java # Truth table generation
│ └── file/
│ └── CircuitFileManager.java # Save/Load functionality
├── bin/ # Compiled .class files
├── circuits/ # Saved circuit files directory
├── build_and_run.bat # Windows build and run script
├── build_and_run.sh # Linux/Mac build and run script
├── compile.bat # Windows compile only script
├── compile.sh # Linux/Mac compile only script
└── README.md # This file
Option 1: Build and Run (One Step)
build_and_run.batOption 2: Compile Only
compile.batThen run manually:
java -cp bin com.circuitsimulator.gui.MainWindowOption 1: Build and Run (One Step)
bash build_and_run.shOption 2: Compile Only
bash compile.shThen run manually:
java -cp bin com.circuitsimulator.gui.MainWindow-
Launch the Application
- Run the build script or execute the Java main class
-
Creating a New Circuit
- Go to
File → Newand enter circuit name - Or use the default "New Circuit"
- Go to
-
Adding Components
Using Toolbar:
- Select component type from dropdown (Switch, LED, AND, OR, NOT, XOR, NAND, NOR, XNOR)
- Click "Add" button
- Enter component name
- Component will appear at mouse position
Using Menu:
- Add components through right-click context menu or toolbar
-
Connecting Components
- Click "Connect" button
- Enter first node number (source)
- Enter second node number (destination)
- Connection is created and displayed
Node Numbering Scheme:
- Use numeric IDs for all nodes (1, 2, 3, etc.)
- Open LED connections default to GND (LOW)
- Open switch connections default to VCC (HIGH)
-
Interactive Simulation
- Double-click on switches to toggle between open/closed states
- LEDs automatically update to show current state
- Red color = HIGH (1)
- Gray color = LOW (0)
-
Component Interaction
-
Switches:
- Green circle = CLOSED (conducting)
- Red circle = OPEN (non-conducting)
- Double-click to toggle
-
LEDs:
- Bright red = ON (receiving HIGH signal)
- Dark gray = OFF (receiving LOW signal)
-
Logic Gates:
- Blue rectangles with gate type label
- Can be dragged to new positions
- Multiple input support
-
Validation
- Click "Validate" button or
Circuit → Validate - Checks for:
- Incomplete connections
- Short circuits (0 resistance from HIGH to LOW)
- Undriven inputs
- Missing outputs
Simulation
- Click "Simulate" button or
Circuit → Simulate - Propagates signals through all components
- Updates all outputs based on current inputs
- All LEDs will display the result
Truth Table Generation
- Click "Truth Table" button or
Circuit → Generate Truth Table - Automatically tests all possible input combinations
- Shows output states for each combination
- Useful for verification and testing
Save Circuit
File → Save- Saves circuit in binary format (.cir)
- Preserves all components, connections, and settings
- Default location:
circuits/directory
Load Circuit
File → Open- Loads previously saved circuit
- All components and connections restored
Export as Text
File → Export as Text- Exports circuit information as readable text
- Lists all components, nodes, and connections
- Useful for documentation
New Circuit
File → New- Clears all components and connections
- Starts fresh with given name
| Key | Action |
|---|---|
| Delete | Remove selected component |
| Double-click | Toggle switch state |
| Drag | Move component |
File Menu
- New - Create new circuit
- Open - Load saved circuit
- Save - Save current circuit
- Export as Text - Export to text file
- Exit - Close application
Edit Menu
- Clear All - Remove all components
- Delete Selected - Remove selected component
Circuit Menu
- Validate - Check circuit for errors
- Simulate - Run simulation
- Generate Truth Table - Create truth table
Help Menu
- About - Application information
The circuit uses a number-based connection scheme where each connection point (node) has a unique integer ID.
- Each node represents a connection point in the circuit
- Nodes are identified by unique integer numbers
- Multiple components can share the same node
- Nodes can carry either HIGH (1) or LOW (0) signals
- Unconnected LED inputs → Automatically set to GND (LOW / 0)
- Unconnected switch outputs → Automatically set to VCC (HIGH / 1)
- Type: Input source
- Function: Provides variable input signal
- States: OPEN (HIGH/1) or CLOSED (LOW/0)
- Interaction: Double-click to toggle
- Type: Output indicator
- Function: Displays output signal status
- Visual: Color change indicates state
- Colors: Red (ON/1), Gray (OFF/0)
- Input: 2+ inputs
- Output: 1
- Function: Output HIGH only when ALL inputs are HIGH
- Truth Table: See truth table generation feature
- Input: 2+ inputs
- Output: 1
- Function: Output HIGH if ANY input is HIGH
- Input: 1
- Output: 1
- Function: Output is inverse of input
- Input: 2+ inputs
- Output: 1
- Function: Output HIGH when ODD number of inputs are HIGH
- Input: 2+ inputs
- Output: 1
- Function: NOT(AND) - Output is LOW when ALL inputs are HIGH
- Input: 2+ inputs
- Output: 1
- Function: NOT(OR) - Output is LOW when ANY input is HIGH
- Input: 2+ inputs
- Output: 1
- Function: NOT(XOR) - Output is HIGH when EVEN number of inputs are HIGH
The validator checks for:
-
Structural Errors
- Missing input/output connections
- Unconnected components
-
Short Circuit Detection
- Detects 0-resistance connections from HIGH to LOW
- Prevents invalid electrical states
-
Data Flow Issues
- Identifies undriven inputs
- Finds potential floating nodes
- Checks for circular dependencies
- Generates all 2^n combinations (n = number of switches)
- Tests each combination automatically
- Shows outputs for all combinations
- Formatted table display with borders
- Useful for verification and debugging
Binary Format (.cir)
- Preserves all circuit information
- Efficient storage
- Fast load/save operations
- Version compatible
Text Export (.txt)
- Human-readable format
- Component details
- Connection information
- Node states
- Add 2 Switches (S1, S2)
- Add AND Gate (G1)
- Add LED (L1)
- Connect:
- S1 output → AND input 1
- S2 output → AND input 2
- AND output → LED input
- Double-click switches to test
- Generate truth table to verify
- Add 2 Switches (A, B)
- Add XOR Gate (Sum)
- Add AND Gate (Carry)
- Add 2 LEDs (SUM, CARRY)
- Connect inputs and outputs
- Test all 4 combinations
- Implement circuit for: (A AND B) OR (NOT C)
- Add 3 Switches, AND Gate, NOT Gate, OR Gate, 1 LED
- Build the logic structure
- Verify with truth table
Application won't start
- Check Java installation:
java -version - Ensure JDK is installed (not just JRE)
- Check PATH environment variable
Compilation errors
- Ensure all source files are present
- Use compile scripts in project root
- Check Java version compatibility
Circuit won't simulate
- Click "Validate" to check for errors
- Ensure all inputs are connected
- Verify node numbers are unique where needed
Short circuit warning
- Check for conflicting connections
- Verify node states are appropriate
- Review circuit logic
- HIGH (1): Logic state representing voltage
- LOW (0): Logic state representing ground
- All components inherit from base
Componentclass - Each has input and output nodes
evaluate()method calculates output from inputs
- Circuits saved as serialized Java objects
- Supports future extensions
- Backward compatible
- Combinational logic only (no flip-flops, latches)
- No analog components or voltage simulation
- Ideal gates (no propagation delays)
- No bus or multi-bit signals
- Maximum practical components: ~50 (GUI performance dependent)
- Sequential logic components (Flip-flops, Latches)
- Timing analysis and delay simulation
- More detailed gate properties (propagation delay, power)
- Custom component definitions
- Circuit library and templates
- Integrated circuit (IC) support
- Oscilloscope/waveform display
- Schematic view (in addition to block diagram)
This is an educational project demonstrating:
- Object-oriented design principles
- Swing GUI programming
- Digital logic simulation
- Data persistence
For issues, questions, or suggestions:
- Check the Troubleshooting section
- Review the User Guide
- Validate your circuit design
- Check error messages in console
Version: 1.0
Last Updated: April 2026
Platform: Java (Cross-platform compatible)