def test_simple_no_buffer(self): root = Gate(Coordinate([0, 0]), ElectroProperty([10, 0])) root[1] = Gate(Coordinate([10, 0]), ElectroProperty([0, 5])) unit_rc = ElectroProperty([1 / Coordinate.scale] * 2) self.assertEqual(DFS(root, unit_rc, RCAdjustment()).delay()[0], 250)
def test_binary_tree(self): driver_0 = Gate(Coordinate([0, 0]), ElectroProperty([1, 0])) buffer_1 = Gate(Coordinate([6, 0]), ElectroProperty([2, 2])) node_2 = Node(Coordinate([6, 0])) buffer_3 = Gate(Coordinate([6, 0]), ElectroProperty([5, 5])) sink_4 = Gate(Coordinate([26, 0]), ElectroProperty([0, 10])) sink_5 = Gate(Coordinate([16, 0]), ElectroProperty([0, 10])) node_6 = Node(Coordinate([0, 10])) sink_7 = Gate(Coordinate([0, 20]), ElectroProperty([0, 5])) buffer_8 = Gate(Coordinate([0, 10]), ElectroProperty([4, 4])) sink_9 = Gate(Coordinate([0, 16]), ElectroProperty([0, 10])) driver_0[1] = buffer_1 buffer_1[2] = node_2 node_2[3] = buffer_3 buffer_3[4] = sink_4 node_2[5] = sink_5 driver_0[6] = node_6 node_6[7] = sink_7 node_6[8] = buffer_8 buffer_8[9] = sink_9 unit_rc = ElectroProperty([1 / Coordinate.scale] * 2) self.assertEqual(DFS(driver_0, unit_rc, RCAdjustment()).delay()[0], 667)
def test_two_branch_one_buffer(self): root = Gate(Coordinate([0, 0]), ElectroProperty([10, 0])) root[1] = Node(Coordinate([5, 0])) root[1][1] = Gate(Coordinate([5, 0]), ElectroProperty([10, 10])) root[1][1][1] = Gate(Coordinate([10, 0]), ElectroProperty([0, 5])) root[1][2] = Gate(Coordinate([10, 5]), ElectroProperty([0, 10])) unit_rc = ElectroProperty([1 / Coordinate.scale] * 2) self.assertEqual(DFS(root, unit_rc, RCAdjustment()).delay()[0], 662.5)
def test_complex_case(self): root = Gate(Coordinate([0, 0]), ElectroProperty([5, 0])) root[1] = Node(Coordinate([0, 10])) root[1][1] = Gate(Coordinate([0, 10]), ElectroProperty([10, 10])) root[1][2] = Gate(Coordinate([0, 50]), ElectroProperty([0, 10])) root[1][1][1] = Node(Coordinate([0, 40])) root[1][1][1][1] = Gate(Coordinate([0, 40]), ElectroProperty([5, 5])) root[1][1][1][2] = Gate(Coordinate([0, 60]), ElectroProperty([0, 5])) root[1][1][1][1][1] = Gate(Coordinate([0, 50]), ElectroProperty([0, 5])) unit_rc = ElectroProperty([1 / Coordinate.scale] * 2) self.assertEqual(DFS(root, unit_rc, RCAdjustment()).delay()[0], 3250)
def setUp(self): self._adjustment = RCAdjustment()
class RCAdjustmentTest(unittest.TestCase): def setUp(self): self._adjustment = RCAdjustment() def test_single_coord(self): self._adjustment.set_adjustment(0, CoordSelector.LEFT, 1.234) self.assertEqual(self._adjustment.get_adjustment(0, CoordSelector.LEFT), 1.234) self.assertEqual(self._adjustment.get_adjustment(0, CoordSelector.LEFT), 1.234) self._adjustment.set_adjustment(1, CoordSelector.LEFT, 2.333) self.assertEqual(self._adjustment.get_adjustment(1, CoordSelector.LEFT), 2.333) self.assertEqual(self._adjustment.get_adjustment(1, CoordSelector.LEFT), 2.333) self._adjustment.set_adjustment(1, CoordSelector.RIGHT, 10.234) self.assertEqual(self._adjustment.get_adjustment(1, CoordSelector.RIGHT), 10.234) self.assertEqual(self._adjustment.get_adjustment(1, CoordSelector.RIGHT), 10.234) self._adjustment.set_adjustment(2, CoordSelector.RIGHT, 20.333) self.assertEqual(self._adjustment.get_adjustment(2, CoordSelector.RIGHT), 20.333) self.assertEqual(self._adjustment.get_adjustment(2, CoordSelector.RIGHT), 20.333) def test_str(self): self._adjustment.set_adjustment(0, CoordSelector.LEFT, 1.234) self._adjustment.set_adjustment(1, CoordSelector.LEFT, 1.234) self._adjustment.set_adjustment(2, CoordSelector.LEFT, 1.234) self._adjustment.set_adjustment(1, CoordSelector.RIGHT, 1.234) self._adjustment.set_adjustment(2, CoordSelector.RIGHT, 1.234) self.assertTrue(bool(re.compile(r'X random numbers:\n(\d \d\.\d+\n)+Y random numbers:\n(\d \d\.\d+\n)+').match( str(self._adjustment))))
def __init__(self, variation_file): super(VariationParser, self).__init__(variation_file) self._rc_adjustment = RCAdjustment()
def test_no_buffer(self): self.assertEqual(DFS(self._root_gate, self._unit_rc, RCAdjustment()).delay()[0], 324.5)
class RCAdjustmentTest(unittest.TestCase): def setUp(self): self._adjustment = RCAdjustment() def test_single_coord(self): self._adjustment.set_adjustment(0, CoordSelector.LEFT, 1.234) self.assertEqual( self._adjustment.get_adjustment(0, CoordSelector.LEFT), 1.234) self.assertEqual( self._adjustment.get_adjustment(0, CoordSelector.LEFT), 1.234) self._adjustment.set_adjustment(1, CoordSelector.LEFT, 2.333) self.assertEqual( self._adjustment.get_adjustment(1, CoordSelector.LEFT), 2.333) self.assertEqual( self._adjustment.get_adjustment(1, CoordSelector.LEFT), 2.333) self._adjustment.set_adjustment(1, CoordSelector.RIGHT, 10.234) self.assertEqual( self._adjustment.get_adjustment(1, CoordSelector.RIGHT), 10.234) self.assertEqual( self._adjustment.get_adjustment(1, CoordSelector.RIGHT), 10.234) self._adjustment.set_adjustment(2, CoordSelector.RIGHT, 20.333) self.assertEqual( self._adjustment.get_adjustment(2, CoordSelector.RIGHT), 20.333) self.assertEqual( self._adjustment.get_adjustment(2, CoordSelector.RIGHT), 20.333) def test_str(self): self._adjustment.set_adjustment(0, CoordSelector.LEFT, 1.234) self._adjustment.set_adjustment(1, CoordSelector.LEFT, 1.234) self._adjustment.set_adjustment(2, CoordSelector.LEFT, 1.234) self._adjustment.set_adjustment(1, CoordSelector.RIGHT, 1.234) self._adjustment.set_adjustment(2, CoordSelector.RIGHT, 1.234) self.assertTrue( bool( re.compile( r'X random numbers:\n(\d \d\.\d+\n)+Y random numbers:\n(\d \d\.\d+\n)+' ).match(str(self._adjustment))))