|
| 1 | +import unittest |
| 2 | +from typing_extensions import override |
| 3 | + |
| 4 | +from . import Er_Oled_096_1_1 |
| 5 | +from ....vendor_parts.generic import * |
| 6 | +from ...connector import Fpc050Bottom, HiroseFh12sh |
| 7 | +from ....circuits import * |
| 8 | +from ....abstract_parts.IdealIoController import IdealIoController |
| 9 | + |
| 10 | + |
| 11 | +class OledI2cTest(DesignTop): |
| 12 | + def __init__(self) -> None: |
| 13 | + super().__init__() |
| 14 | + self.pwr = self.Block(DummyVoltageSource(voltage_out=3.3 * Volt(tol=0))) |
| 15 | + self.gnd = self.Block(DummyGround()) |
| 16 | + with self.implicit_connect( |
| 17 | + ImplicitConnect(self.pwr.pwr, [Power]), |
| 18 | + ImplicitConnect(self.gnd.gnd, [Common]), |
| 19 | + ) as imp: |
| 20 | + self.dut = imp.Block(Er_Oled_096_1_1()) |
| 21 | + |
| 22 | + self.rst = self.Block(DummyDigitalSource()) |
| 23 | + self.connect(self.rst.io, self.dut.reset) |
| 24 | + |
| 25 | + self.mcu = imp.Block(IdealIoController()) |
| 26 | + self.i2c_pull = imp.Block(I2cPullup()) |
| 27 | + self.connect(self.mcu.i2c.request(), self.dut.i2c, self.i2c_pull.i2c) |
| 28 | + |
| 29 | + @override |
| 30 | + def refinements(self) -> Refinements: |
| 31 | + return Refinements( |
| 32 | + class_refinements=[ |
| 33 | + (Resistor, GenericChipResistor), |
| 34 | + (Capacitor, GenericMlcc), |
| 35 | + (Fpc050Bottom, HiroseFh12sh), |
| 36 | + ], |
| 37 | + class_values=[(IdealModel, ["allow_ideal"], True)], |
| 38 | + ) |
| 39 | + |
| 40 | + |
| 41 | +class OledSpiTest(DesignTop): |
| 42 | + def __init__(self) -> None: |
| 43 | + super().__init__() |
| 44 | + self.pwr = self.Block(DummyVoltageSource(voltage_out=3.3 * Volt(tol=0))) |
| 45 | + self.gnd = self.Block(DummyGround()) |
| 46 | + with self.implicit_connect( |
| 47 | + ImplicitConnect(self.pwr.pwr, [Power]), |
| 48 | + ImplicitConnect(self.gnd.gnd, [Common]), |
| 49 | + ) as imp: |
| 50 | + self.dut = imp.Block(Er_Oled_096_1_1()) |
| 51 | + |
| 52 | + self.rst = self.Block(DummyDigitalSource()) |
| 53 | + self.connect(self.rst.io, self.dut.reset) |
| 54 | + |
| 55 | + self.mcu = imp.Block(IdealIoController()) |
| 56 | + self.connect(self.mcu.spi.request(), self.dut.spi) |
| 57 | + self.cs = self.Block(DummyDigitalSource()) |
| 58 | + self.connect(self.cs.io, self.dut.cs) |
| 59 | + self.dc = self.Block(DummyDigitalSource()) |
| 60 | + self.connect(self.dc.io, self.dut.dc) |
| 61 | + |
| 62 | + @override |
| 63 | + def refinements(self) -> Refinements: |
| 64 | + return Refinements( |
| 65 | + class_refinements=[ |
| 66 | + (Resistor, GenericChipResistor), |
| 67 | + (Capacitor, GenericMlcc), |
| 68 | + (Fpc050Bottom, HiroseFh12sh), |
| 69 | + ], |
| 70 | + class_values=[(IdealModel, ["allow_ideal"], True)], |
| 71 | + ) |
| 72 | + |
| 73 | + |
| 74 | +class OledInterfacesTestCase(unittest.TestCase): |
| 75 | + def test_oled_i2c(self) -> None: |
| 76 | + compiled = ScalaCompiler.compile(OledI2cTest) |
| 77 | + |
| 78 | + def test_oled_spi(self) -> None: |
| 79 | + compiled = ScalaCompiler.compile(OledSpiTest) |
0 commit comments