Datasheet timing specifications (min/max ranges). Attributes: T0H_min, T0H_max: T0H valid range (nanoseconds) T0L_min, T0L_max: T0L valid range (nanoseconds) T1H_min, T1H_max: T1H valid range (nanoseconds) T1L_min, T1L_max: T1L valid range (nanoseconds)
| 30 | |
| 31 | @dataclass |
| 32 | class TimingSpec: |
| 33 | """Datasheet timing specifications (min/max ranges). |
| 34 | |
| 35 | Attributes: |
| 36 | T0H_min, T0H_max: T0H valid range (nanoseconds) |
| 37 | T0L_min, T0L_max: T0L valid range (nanoseconds) |
| 38 | T1H_min, T1H_max: T1H valid range (nanoseconds) |
| 39 | T1L_min, T1L_max: T1L valid range (nanoseconds) |
| 40 | """ |
| 41 | |
| 42 | T0H_min: int |
| 43 | T0H_max: int |
| 44 | T0L_min: int |
| 45 | T0L_max: int |
| 46 | T1H_min: int |
| 47 | T1H_max: int |
| 48 | T1L_min: int |
| 49 | T1L_max: int |
| 50 | |
| 51 | def validate(self, ds: "TimingDatasheet") -> tuple[bool, list[str]]: |
| 52 | """Validate datasheet timing against specifications. |
| 53 | |
| 54 | Args: |
| 55 | ds: Datasheet timing to validate |
| 56 | |
| 57 | Returns: |
| 58 | Tuple of (is_valid, list of error messages) |
| 59 | """ |
| 60 | errors: list[str] = [] |
| 61 | |
| 62 | if not (self.T0H_min <= ds.T0H <= self.T0H_max): |
| 63 | errors.append( |
| 64 | f"T0H={ds.T0H}ns out of spec (valid: {self.T0H_min}-{self.T0H_max}ns)" |
| 65 | ) |
| 66 | if not (self.T0L_min <= ds.T0L <= self.T0L_max): |
| 67 | errors.append( |
| 68 | f"T0L={ds.T0L}ns out of spec (valid: {self.T0L_min}-{self.T0L_max}ns)" |
| 69 | ) |
| 70 | if not (self.T1H_min <= ds.T1H <= self.T1H_max): |
| 71 | errors.append( |
| 72 | f"T1H={ds.T1H}ns out of spec (valid: {self.T1H_min}-{self.T1H_max}ns)" |
| 73 | ) |
| 74 | if not (self.T1L_min <= ds.T1L <= self.T1L_max): |
| 75 | errors.append( |
| 76 | f"T1L={ds.T1L}ns out of spec (valid: {self.T1L_min}-{self.T1L_max}ns)" |
| 77 | ) |
| 78 | |
| 79 | return (len(errors) == 0, errors) |
| 80 | |
| 81 | |
| 82 | class TimingDatasheet: |
no outgoing calls
no test coverage detected