Testing
Zener provides testing infrastructure for validating module connectivity, topology, and electrical properties. Tests are defined in.zen files and executed with pcb test.
TestBench
TestBench creates a test bench for validating module connectivity and properties without requiring inputs.
name: String identifier for the test benchmodule: Module instance to test (created withModule())checks: List of check functions to execute
Check Functions
Check functions receive a singleModule argument containing circuit data:
module.nets: Maps net names to connected port tuples (e.g.,{"VCC": [("U1", "VDD"), ("C1", "P1")]})module.components: Maps component paths to component objectsmodule["name"]: Direct indexing access to child components and submodules
- Use
check(condition, message)orerror(message)to signal failures - Unhandled exceptions are treated as test failures
- Use
print()for informational output
- Evaluates the module with relaxed input requirements (missing required inputs are allowed)
- Stores check functions for deferred execution
- When executed by
pcb test: runs each check in order, reports failures with source locations
Module Indexing
Within check functions, you can access components and submodules using dictionary-style indexing:Circuit Graph Analysis
Circuit graph analysis validates module connectivity and topology by converting schematics into searchable graphs.Getting the Graph
Every module generates a circuit graph:Path Finding
graph.paths(start, end, max_depth=10) finds all simple paths between two points:
- Component ports:
("ComponentName", "PinName")- e.g.,("TPS82140", "VIN") - External nets:
"NetName"- public nets fromio()declarations
start: Component port tuple or external net nameend: Component port tuple or external net namemax_depth: Maximum components to traverse (default: 10)
Path Objects
Path Validation
Basic validation:path.matches():
Datasheet Validation Examples
Power supply decoupling:Built-in Matchers
Custom Matchers
Error Suppression
Usesuppress_errors=True to test patterns without failing: