Beispiel #1
0
    def test_obstruction(self) -> None:
        d = {
            "type": "obstruction",
            "path": "path/to/placement",
            "x": Decimal(4),
            "y": Decimal(6),
            "width": Decimal(10),
            "height": Decimal(20),
            "orientation": "mx"
        }
        with self.assertRaises(ValueError):
            # This should assert because we are missing obs_types
            tc = PlacementConstraint.from_dict(d)

        d.update({"obs_types": ["place"]})
        tc = PlacementConstraint.from_dict(d)
        self.assertEqual(tc.type, PlacementConstraintType.Obstruction)
        self.assertEqual(tc.path, "path/to/placement")
        self.assertEqual(tc.x, Decimal(4))
        self.assertEqual(tc.y, Decimal(6))
        self.assertEqual(tc.width, Decimal(10))
        self.assertEqual(tc.height, Decimal(20))
        self.assertEqual(tc.orientation, "mx")
        with self.assertRaises(ValueError):
            m = {"margins": Margins.empty().to_dict()}
            # This should assert because margins are not allowed
            tc = PlacementConstraint.from_dict(add_dicts(d, m))
Beispiel #2
0
    def test_obstruction(self) -> None:
        d = {"type": "obstruction",
             "path": "path/to/placement",
             "x": Decimal(4),
             "y": Decimal(6),
             "width": Decimal(10),
             "height": Decimal(20),
             "orientation": "mx"}
        with self.assertRaises(ValueError):
            # This should assert because we are missing obs_types
            tc = PlacementConstraint.from_dict(d)

        d.update({"obs_types": ["place"]})
        tc = PlacementConstraint.from_dict(d)
        self.assertEqual(tc.type, PlacementConstraintType.Obstruction)
        self.assertEqual(tc.path, "path/to/placement")
        self.assertEqual(tc.x, Decimal(4))
        self.assertEqual(tc.y, Decimal(6))
        self.assertEqual(tc.width, Decimal(10))
        self.assertEqual(tc.height, Decimal(20))
        self.assertEqual(tc.orientation, "mx")
        with self.assertRaises(ValueError):
            m = {"margins": Margins.empty().to_dict()}
            # This should assert because margins are not allowed
            tc = PlacementConstraint.from_dict(add_dicts(d, m))
Beispiel #3
0
 def test_hierarchical(self) -> None:
     d = {
         "type": "hierarchical",
         "path": "path/to/placement",
         "x": Decimal(4),
         "y": Decimal(6),
         "master": "foo",
         "orientation": "mx"
     }
     with self.assertRaises(ValueError):
         # This should assert because width and height are missing
         tc = PlacementConstraint.from_dict(d)
     d.update({"width": Decimal(10), "height": Decimal(20)})
     tc = PlacementConstraint.from_dict(d)
     self.assertEqual(tc.type, PlacementConstraintType.Hierarchical)
     self.assertEqual(tc.path, "path/to/placement")
     self.assertEqual(tc.x, Decimal(4))
     self.assertEqual(tc.y, Decimal(6))
     self.assertEqual(tc.width, Decimal(10))
     self.assertEqual(tc.height, Decimal(20))
     self.assertEqual(tc.master, "foo")
     self.assertEqual(tc.orientation, "mx")
     with self.assertRaises(ValueError):
         m = {"margins": Margins.empty().to_dict()}
         # This should assert because margins are not allowed
         tc = PlacementConstraint.from_dict(add_dicts(d, m))
Beispiel #4
0
 def test_hierarchical(self) -> None:
     d = {"type": "hierarchical",
          "path": "path/to/placement",
          "x": Decimal(4),
          "y": Decimal(6),
          "master": "foo",
          "orientation": "mx"}
     with self.assertRaises(ValueError):
         # This should assert because width and height are missing
         tc = PlacementConstraint.from_dict(d)
     d.update({
          "width": Decimal(10),
          "height": Decimal(20)})
     tc = PlacementConstraint.from_dict(d)
     self.assertEqual(tc.type, PlacementConstraintType.Hierarchical)
     self.assertEqual(tc.path, "path/to/placement")
     self.assertEqual(tc.x, Decimal(4))
     self.assertEqual(tc.y, Decimal(6))
     self.assertEqual(tc.width, Decimal(10))
     self.assertEqual(tc.height, Decimal(20))
     self.assertEqual(tc.master, "foo")
     self.assertEqual(tc.orientation, "mx")
     with self.assertRaises(ValueError):
         m = {"margins": Margins.empty().to_dict()}
         # This should assert because margins are not allowed
         tc = PlacementConstraint.from_dict(add_dicts(d, m))
Beispiel #5
0
    def test_master_hierarchical(self) -> None:
        d = {"type": "hierarchical",
             "path": "path/to/placement",
             "x": Decimal(4),
             "y": Decimal(6),
             "master": "bar",
             "orientation": "mx"}

        masters = [MacroSize.from_setting(x) for x in [
            {"name": "foo", "library": "none", "width": "1234", "height": "2345"},
            {"name": "bar", "library": "none", "width": "2222", "height": "4444"}
        ]]

        with self.assertRaises(ValueError):
            # This should assert because width and height are missing
            tc = PlacementConstraint.from_dict(d)

        tc = PlacementConstraint.from_masters_and_dict(masters, d)
        self.assertEqual(tc.type, PlacementConstraintType.Hierarchical)
        self.assertEqual(tc.path, "path/to/placement")
        self.assertEqual(tc.x, Decimal(4))
        self.assertEqual(tc.y, Decimal(6))
        self.assertEqual(tc.width, Decimal(2222))
        self.assertEqual(tc.height, Decimal(4444))
        self.assertEqual(tc.orientation, "mx")
        self.assertEqual(tc.master, "bar")
Beispiel #6
0
    def test_master_hierarchical(self) -> None:
        d = {"type": "hierarchical",
             "path": "path/to/placement",
             "x": Decimal(4),
             "y": Decimal(6),
             "master": "bar",
             "orientation": "mx"}

        masters = [MacroSize.from_setting(x) for x in [
            {"name": "foo", "library": "none", "width": "1234", "height": "2345"},
            {"name": "bar", "library": "none", "width": "2222", "height": "4444"}
        ]]

        with self.assertRaises(ValueError):
            # This should assert because width and height are missing
            tc = PlacementConstraint.from_dict(d)

        tc = PlacementConstraint.from_masters_and_dict(masters, d)
        self.assertEqual(tc.type, PlacementConstraintType.Hierarchical)
        self.assertEqual(tc.path, "path/to/placement")
        self.assertEqual(tc.x, Decimal(4))
        self.assertEqual(tc.y, Decimal(6))
        self.assertEqual(tc.width, Decimal(2222))
        self.assertEqual(tc.height, Decimal(4444))
        self.assertEqual(tc.orientation, "mx")
        self.assertEqual(tc.master, "bar")
Beispiel #7
0
 def test_invalid(self) -> None:
     d = {"type": "foobar",
          "path": "path/to/placement",
          "x": Decimal(4),
          "y": Decimal(6),
          "width": Decimal(10),
          "height": Decimal(20),
          "orientation": "mx"}
     with self.assertRaises(ValueError):
         tc = PlacementConstraint.from_dict(d)
Beispiel #8
0
 def test_invalid(self) -> None:
     d = {"type": "foobar",
          "path": "path/to/placement",
          "x": Decimal(4),
          "y": Decimal(6),
          "width": Decimal(10),
          "height": Decimal(20),
          "orientation": "mx"}
     with self.assertRaises(ValueError):
         tc = PlacementConstraint.from_dict(d)
Beispiel #9
0
 def test_hardmacro(self) -> None:
     d = {"type": "hardmacro",
          "path": "path/to/placement",
          "x": Decimal(4),
          "y": Decimal(6),
          "width": Decimal(10),
          "height": Decimal(20),
          "orientation": "mx"}
     tc = PlacementConstraint.from_dict(d)
     self.assertEqual(tc.type, PlacementConstraintType.HardMacro)
     self.assertEqual(tc.path, "path/to/placement")
     self.assertEqual(tc.x, Decimal(4))
     self.assertEqual(tc.y, Decimal(6))
     self.assertEqual(tc.width, Decimal(10))
     self.assertEqual(tc.height, Decimal(20))
     self.assertEqual(tc.orientation, "mx")
     with self.assertRaises(ValueError):
         m = {"margins": Margins.empty().to_dict()}
         # This should assert because margins are not allowed
         tc = PlacementConstraint.from_dict(add_dicts(d, m))
Beispiel #10
0
    def test_toplevel(self) -> None:
        d = {"type": "toplevel",
             "path": "path/to/placement",
             "x": Decimal(0),
             "y": Decimal(0),
             "width": Decimal(1000),
             "height": Decimal(2000)}
        with self.assertRaises(ValueError):
            # This should assert because margins are required
            tc = PlacementConstraint.from_dict(d)

        # Add margins
        m = {"margins": Margins.empty().to_dict()}
        tc = PlacementConstraint.from_dict(add_dicts(d, m))
        self.assertEqual(tc.type, PlacementConstraintType.TopLevel)
        self.assertEqual(tc.path, "path/to/placement")
        self.assertEqual(tc.x, Decimal(0))
        self.assertEqual(tc.y, Decimal(0))
        self.assertEqual(tc.width, Decimal(1000))
        self.assertEqual(tc.height, Decimal(2000))
Beispiel #11
0
 def test_hardmacro(self) -> None:
     d = {"type": "hardmacro",
          "path": "path/to/placement",
          "x": Decimal(4),
          "y": Decimal(6),
          "width": Decimal(10),
          "height": Decimal(20),
          "orientation": "mx"}
     tc = PlacementConstraint.from_dict(d)
     self.assertEqual(tc.type, PlacementConstraintType.HardMacro)
     self.assertEqual(tc.path, "path/to/placement")
     self.assertEqual(tc.x, Decimal(4))
     self.assertEqual(tc.y, Decimal(6))
     self.assertEqual(tc.width, Decimal(10))
     self.assertEqual(tc.height, Decimal(20))
     self.assertEqual(tc.orientation, "mx")
     with self.assertRaises(ValueError):
         m = {"margins": Margins.empty().to_dict()}
         # This should assert because margins are not allowed
         tc = PlacementConstraint.from_dict(add_dicts(d, m))
Beispiel #12
0
    def test_toplevel(self) -> None:
        d = {"type": "toplevel",
             "path": "path/to/placement",
             "x": Decimal(0),
             "y": Decimal(0),
             "width": Decimal(1000),
             "height": Decimal(2000)}
        with self.assertRaises(ValueError):
            # This should assert because margins are required
            tc = PlacementConstraint.from_dict(d)

        # Add margins
        m = {"margins": Margins.empty().to_dict()}
        tc = PlacementConstraint.from_dict(add_dicts(d, m))
        self.assertEqual(tc.type, PlacementConstraintType.TopLevel)
        self.assertEqual(tc.path, "path/to/placement")
        self.assertEqual(tc.x, Decimal(0))
        self.assertEqual(tc.y, Decimal(0))
        self.assertEqual(tc.width, Decimal(1000))
        self.assertEqual(tc.height, Decimal(2000))