Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions checks.zen
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ def voltage_within(
# drop nominal in within:
within = VoltageRange(min=within.min, max=within.max)
# ensure voltage is within within
min_valid = voltage.min >= within.min
max_valid = voltage.max <= within.max
err_msg = "Voltage range " + str(voltage) + " of " + net_name + " is not within " + str(within)
check(min_valid and max_valid, err_msg)
check(voltage in within, err_msg)

def check_gen(power: Power, severity: Severity = severity, name: str = name):
check_name = power.NET.name + "_" + name
if not power.voltage:
if not hasattr(power, "voltage"):
return
builtin.add_electrical_check(
name=check_name,
Expand Down
24 changes: 24 additions & 0 deletions test/test_checks.zen
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
load("../checks.zen", "voltage_within")
load("../interfaces.zen", "Power", "VoltageRange")

# Test 3.3V rail with tolerance
v3v3 = Power("3V3", voltage=VoltageRange("3.3V 1%"))
# Check if 3.3V +/- 1% is within 3.3V +/- 5%
check_3v3 = voltage_within("3.3V 5%")
check_3v3(v3v3)

# Test 5V rail with explicit range
v5 = Power("5V", voltage=VoltageRange("5V"))
# Check if 5V is within 4.5V to 5.5V (using +/- 10% notation)
check_5v = voltage_within("5V 10%")
check_5v(v5)

# Test with tighter tolerance on the rail than the check
v1v8 = Power("1V8", voltage=VoltageRange("1.8V 1%"))
check_1v8 = voltage_within("1.8V 5%")
check_1v8(v1v8)

# Test rail with no voltage set (should be ignored)
v_unknown = Power("UNKNOWN")
check_unknown = voltage_within("5V 10%")
check_unknown(v_unknown)