This document provides guidelines for adding a new analog module to the UWASIC analog library.
Each module should follow this structure:
ModuleName/
├── README.md # Module documentation (REQUIRED)
├── GenerateVariant.py # Python variant generator (OPTIONAL)
├── VariantName1/ # Specific variant/implementation
│ ├── schematics/ # XSchem schematics
│ │ ├── component.sch
│ │ └── ...
│ ├── symbols/ # XSchem symbols
│ │ ├── component.sym
│ │ └── ...
│ └── testbenches/ # Testbench schematics (optional)
│ ├── component_tb.sch
│ └── ...
├── VariantName2/ # Another variant (if applicable)
│ └── ...
└── schematics/ # Alternative: Direct schematics if no variants
└── ...
AnalogMux/ (Direct schematics):
AnalogMux/
├── README.md
├── schematics/ # Direct schematic files
│ ├── analog_mux.sch
│ ├── Aswitch.sch
│ └── ...
└── symbols/
├── analog_mux.sym
└── ...
DAC/ (Variant-based):
DAC/
├── README.md
└── Custom/ # Variant subdirectory
├── schematics/
├── symbols/
└── testbenches/
Each module must include a README.md file in its root directory. This README will be automatically aggregated into the top-level library README.
Your module README should include:
- Module name and brief description
- Key specifications (voltage, current, performance metrics)
- Variants (if applicable - list available variants and their differences)
- Usage instructions (how to use the schematic or generate variants)
- Parameters (if using GenerateVariant.py - document all required parameters)
- Dependencies (required tools, PDK versions, etc.)
## ModuleName
Brief description of what this module does and its key features.
### Specifications
- Supply Voltage: X V
- Input Range: Y V
- Output Range: Z V
- Power Consumption: W μW
- Technology: Sky130 PDK
### Available Variants
- **VariantName1**: Description of this variant (use case, trade-offs)
- **VariantName2**: Description of this variant
### Usage
#### Direct Use
Open the schematic in XSchem:
\`\`\`bash
xschem schematics/component.sch
\`\`\`
#### Generating Variants (if applicable)
\`\`\`bash
python GenerateVariant.py --param1 value1 --param2 value2
\`\`\`
### Parameters (if using GenerateVariant.py)
| Parameter | Type | Description | Default |
|-----------|------|-------------|---------|
| param1 | int | Description | value |
| param2 | float| Description | value |
### Dependencies
- XSchem
- Sky130 PDK
- (Other dependencies as needed)If your module supports programmatic variant generation, include a GenerateVariant.py script in the module root.
The script automates the creation of different variants of the same component with different parameters or configurations.
- Clear parameter specification: Document all required and optional parameters
- Help message: Implement
--helpto show usage - Parameter validation: Validate user inputs before generating
- Output organization: Generate variants in organized subdirectories
#!/usr/bin/env python3
"""
GenerateVariant.py - Generate variants of ModuleName component
Usage:
python GenerateVariant.py --width 10 --length 0.5 --variant low_power
"""
import argparse
from pathlib import Path
def generate_variant(width: float, length: float, variant_name: str):
"""Generate a variant with specified parameters"""
# Create variant directory
variant_dir = Path(variant_name)
variant_dir.mkdir(exist_ok=True)
# Generate schematics, symbols, etc.
# ... implementation ...
print(f"✓ Generated variant '{variant_name}' with W={width}μm, L={length}μm")
def main():
parser = argparse.ArgumentParser(
description="Generate ModuleName variants"
)
# Required parameters
parser.add_argument("--width", type=float, required=True,
help="Transistor width in μm")
parser.add_argument("--length", type=float, required=True,
help="Transistor length in μm")
# Optional parameters
parser.add_argument("--variant", type=str, default="default",
help="Variant name (default: default)")
args = parser.parse_args()
# Validate parameters
if args.width <= 0 or args.length <= 0:
parser.error("Width and length must be positive")
generate_variant(args.width, args.length, args.variant)
if __name__ == "__main__":
main()When using GenerateVariant.py, your README must document:
- All parameters: Name, type, description, default value, valid range
- Example commands: Show how to generate common variants
- Output structure: Explain what files/directories are created
- Prerequisites: Any dependencies or setup required
Example:
### Generating Variants
\`\`\`bash
# Generate low-power variant
python GenerateVariant.py --width 5 --length 1.0 --variant low_power
# Generate high-speed variant
python GenerateVariant.py --width 20 --length 0.5 --variant high_speed
\`\`\`
This creates subdirectories:
- \`low_power/schematics/\`
- \`high_speed/schematics/\`
Each containing the generated schematics and symbols.Store XSchem files in organized subdirectories:
- schematics/: Main schematic files (
.sch) - symbols/: Symbol files (
.sym) for hierarchical use - testbenches/: Testbench schematics (optional but recommended)
- Module directory: PascalCase (e.g.,
OpAmp,AnalogMux,TransImpedanceAmplifier) - Variant subdirectories: PascalCase or descriptive (e.g.,
Custom,SAR,HighSpeed) - Python files: PascalCase for generators (e.g.,
GenerateVariant.py) - Schematic files: snake_case or descriptive (e.g.,
analog_mux.sch,Aswitch.sch)
Important: The top-level
README.mdis auto-generated. Do not edit it manually.
When you push changes to your module's README:
- GitHub Actions automatically runs
UpdateReadME.py - Your module README is aggregated into the top-level README
- The updated top-level README is committed back to the repository
Before submitting your module:
- Created module directory with proper naming
- Added comprehensive
README.mdwith all required sections - Organized schematics in
schematics/directory (or variant subdirectories) - Organized symbols in
symbols/directory - (Recommended) Added testbenches in
testbenches/directory - (If applicable) Created
GenerateVariant.pywith clear parameter documentation - (If using GenerateVariant.py) Documented all parameters in README
- Verified schematic files open correctly in XSchem
- Committed and pushed changes
- Verified top-level README was auto-updated via GitHub Actions
ModuleName/
├── README.md
├── schematics/
│ └── component.sch
└── symbols/
└── component.sym
ModuleName/
├── README.md
├── VariantA/
│ ├── schematics/
│ └── symbols/
└── VariantB/
├── schematics/
└── symbols/
ModuleName/
├── README.md
├── GenerateVariant.py
├── LowPower/ # Generated
│ ├── schematics/
│ └── symbols/
└── HighSpeed/ # Generated
├── schematics/
└── symbols/
If you have questions about module structure or conventions, refer to existing modules:
- AnalogMux/: Example of direct schematic organization
- DAC/: Example of variant-based organization
- ADC/SAR/: Example of nested variant structure