View on GitHub

Overview

The src/opentestability/core module has been reorganized into a cleaner, more maintainable structure with separate packages for SCOAP, DAG, and reconvergence functionality.

New Structure

src/opentestability/core/
├── __init__.py                      # Main package initialization
├── scoap/                           # SCOAP testability analysis
│   ├── __init__.py
│   ├── main.py                      # Main run() function
│   ├── netlist_parser.py            # Netlist parsing (130 lines)
│   ├── gate_logic.py                # Gate-level logic (75 lines)
│   ├── controllability.py           # Controllability computation (160 lines)
│   ├── observability.py             # Observability computation (120 lines)
│   ├── parallel.py                  # Parallel computation (240 lines)
│   └── output.py                    # Output formatting (70 lines)
├── dag/                             # DAG construction
│   ├── __init__.py
│   └── builder.py                   # DAG builder (235 lines)
└── reconvergence/                   # Reconvergence detection
    ├── __init__.py
    ├── basic.py                     # Basic algorithm (220 lines)
    ├── simple.py                    # Simple algorithm (223 lines)
    └── advanced.py                  # Advanced algorithm (515 lines)

Changes from Old Structure

Before (Monolithic Files)

core/
├── scoap.py                         # 736 lines - TOO LARGE
├── dag_builder.py                   # 235 lines
├── reconvergence.py                 # 220 lines
├── simple_reconvergence.py          # 223 lines
└── advanced_reconvergence.py        # 515 lines

After (Organized Packages)

Benefits

  1. Maintainability: Smaller, focused files are easier to understand and modify
  2. Modularity: Related functionality grouped together in packages
  3. Testability: Each module can be tested independently
  4. Clarity: Clear naming and organization
  5. Scalability: Easy to add new modules without cluttering the core directory

Module Descriptions

SCOAP Package (scoap/)

Handles testability analysis (controllability and observability):

DAG Package (dag/)

Handles DAG construction and manipulation:

Reconvergence Package (reconvergence/)

Provides multiple reconvergent fanout detection algorithms:

Import Changes

Old Imports

from opentestability.core.scoap import run
from opentestability.core.dag_builder import create_dag_from_netlist
from opentestability.core.simple_reconvergence import SimpleReconvergenceDetector

New Imports (Still Work!)

# These still work - backward compatible through core/__init__.py
from opentestability.core import run_scoap
from opentestability.core import create_dag_from_netlist

# Or use the new explicit imports
from opentestability.core.scoap import run
from opentestability.core.dag import create_dag_from_netlist
from opentestability.core.reconvergence import SimpleReconvergenceDetector

Backward Compatibility

The reorganization maintains backward compatibility:

File Sizes

Before: Largest file was 736 lines (scoap.py)

After:

Updated Files

All imports have been updated in:

Verification

All files compile successfully:

# Compile all core modules
Get-ChildItem "src/opentestability/core" -Recurse -Filter "*.py" | 
    ForEach-Object { python -m py_compile $_.FullName }
# ✓ All 15 files compiled successfully

# Compile tests and examples
python -m py_compile tests/*.py
python -m py_compile examples/*.py
# ✓ All compiled successfully

Migration Guide

No migration needed! The reorganization is transparent to users. However, for new code, we recommend using the explicit package imports:

# Recommended for new code
from opentestability.core.scoap import run
from opentestability.core.dag import create_dag_from_netlist
from opentestability.core.reconvergence import SimpleReconvergenceDetector

# Run SCOAP with parallel support
run('circuit.txt', 'output.txt',
    reconvergent_roots=['n5', 'n12'],
    parallel=True,
    max_workers=4)

Future Enhancements

The new structure makes it easy to add:

Summary

The reorganization successfully:

The codebase is now better organized, more maintainable, and easier to extend!