Skip to content

Commit

Permalink
Tests added, dummy par tool instantiated
Browse files Browse the repository at this point in the history
  • Loading branch information
ken_ho committed Jan 27, 2023
1 parent 4a7602d commit e32be0d
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 10 deletions.
2 changes: 1 addition & 1 deletion hammer/vlsi/hammer_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ def get_bumps(self) -> Optional[BumpsDefinition]:
assignments.append(BumpAssignment(name=name, no_connect=no_con,
x=x, y=y, group=group, custom_cell=cell))

pitch_settings = self.get_by_bump_dim_pitch()
pitch_settings = self._get_by_bump_dim_pitch()

return BumpsDefinition(
x=self.get_setting("vlsi.inputs.bumps.x"),
Expand Down
26 changes: 25 additions & 1 deletion hammer/vlsi/hammer_vlsi_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ def _get_by_bump_dim_setting(self, key: str, dim_name: str) -> Any:
except KeyError:
raise ValueError("No value set for key {}".format(default))

def get_by_bump_dim_pitch(self) -> Dict[str, float]:
def _get_by_bump_dim_pitch(self) -> Dict[str, float]:
"""
Return pitches in the x and y directions.
"""
Expand Down Expand Up @@ -892,6 +892,30 @@ def signoff_results(self) -> int:
"""
pass

class DummyParTool(HammerPlaceAndRouteTool):
"""
This is a dummy implementation of PAR tool.
"""

def fill_outputs(self) -> bool:
return True

def specify_power_straps(self, layer_name: str, bottom_via_layer_name: str, blockage_spacing: Decimal, pitch: Decimal, width: Decimal, spacing: Decimal, offset: Decimal, bbox: Optional[List[Decimal]], nets: List[str], add_pins: bool) -> List[str]:
return []

@property
def specify_std_cell_power_straps(self, blockage_spacing: Decimal, bbox: Optional[List[Decimal]], nets: List[str]) -> List[str]:
return []
def tool_config_prefix(self) -> str:
return ""

def version_number(self, version: str) -> int:
return 1

@property
def steps(self) -> List[HammerToolStep]:
return []

class HammerDRCTool(HammerSignoffTool):

def export_config_outputs(self) -> Dict[str, Any]:
Expand Down
50 changes: 42 additions & 8 deletions tests/test_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import hammer.config as hammer_config
from hammer.utils import add_dicts
from hammer.tech import MacroSize
from hammer.vlsi import DummyHammerTool
from hammer.vlsi import DummyHammerTool, DummyParTool
from hammer.vlsi.constraints import DelayConstraint, ClockPort, PinAssignment, PinAssignmentError, \
PinAssignmentSemiAutoError, PlacementConstraint, PlacementConstraintType, Margins, \
BumpAssignment, BumpsDefinition, BumpsPinNamingScheme, DecapConstraint
Expand Down Expand Up @@ -120,7 +120,7 @@ def test_bump_naming(self) -> None:
BumpAssignment(name="VDD",no_connect=False,x=Decimal(203),y=Decimal(21),group=None,custom_cell=None),
BumpAssignment(name="VSS",no_connect=False,x=Decimal(202),y=Decimal(20),group=None,custom_cell=None)
]
definition = BumpsDefinition(x=204,y=204,pitch=Decimal("1.23"),cell="bumpcell",assignments=assignments)
definition = BumpsDefinition(x=204,y=204,pitch_x=Decimal("1.23"), pitch_y=Decimal("3.14"), global_x_offset=0, global_y_offset=0, cell="bumpcell",assignments=assignments)

for a in assignments:
if a.name == "foo":
Expand Down Expand Up @@ -181,18 +181,53 @@ def test_bump_naming(self) -> None:
assignments = [
BumpAssignment(name="foo",no_connect=False,x=Decimal(1),y=Decimal(1),group=None,custom_cell=None)
]
definition = BumpsDefinition(x=420,y=420,pitch=Decimal("1.23"),cell="bumpcell",assignments=assignments)
definition = BumpsDefinition(x=420,y=420, pitch_x=Decimal("1.23"), pitch_y=Decimal("3.14"), global_x_offset=0, global_y_offset=0, cell="bumpcell",assignments=assignments)
assert BumpsPinNamingScheme.A1.name_bump(definition, assignments[0]) == "YY420"

definition = BumpsDefinition(x=421,y=421,pitch=Decimal("1.23"),cell="bumpcell",assignments=assignments)
definition = BumpsDefinition(x=421,y=421, pitch_x=Decimal("1.23"), pitch_y=Decimal("3.14"), global_x_offset=0, global_y_offset=0, cell="bumpcell",assignments=assignments)
assert BumpsPinNamingScheme.A1.name_bump(definition, assignments[0]) == "AAA421"

definition = BumpsDefinition(x=8420,y=8420,pitch=Decimal("1.23"),cell="bumpcell",assignments=assignments)
definition = BumpsDefinition(x=8420,y=8420, pitch_x=Decimal("1.23"), pitch_y=Decimal("3.14"), global_x_offset=0, global_y_offset=0, cell="bumpcell",assignments=assignments)
assert BumpsPinNamingScheme.A1.name_bump(definition, assignments[0]) == "YYY8420"

definition = BumpsDefinition(x=8421,y=8421,pitch=Decimal("1.23"),cell="bumpcell",assignments=assignments)
definition = BumpsDefinition(x=8421,y=8421, pitch_x=Decimal("1.23"), pitch_y=Decimal("3.14"), global_x_offset=0, global_y_offset=0, cell="bumpcell",assignments=assignments)
assert BumpsPinNamingScheme.A1.name_bump(definition, assignments[0]) == "AAAA8421"

def test_get_by_bump_dim_setting(self) -> None:
"""
Test that we can extract a bump related key by dimensionality.
Note that the dimension is not optional because the underlying code now requires x, y.
"""
db = hammer_config.HammerDatabase()
db.update_project([{"vlsi.inputs.bumps.pitch": 1}, {"vlsi.inputs.bumps.pitch_b_x": 2}])
tool = DummyParTool()
tool.set_database(db)

pitch_x = tool._get_by_bump_dim_setting('pitch', 'x')
assert pitch_x == 1

pitch_x = tool._get_by_bump_dim_setting('pitch_b', 'x')
assert pitch_x == 2

def test_get_by_bump_dim_pitch(self) -> None:
"""
Test the extraction of x, y, pitches.
"""
db = hammer_config.HammerDatabase()
db.update_project([{"vlsi.inputs.bumps.pitch": 1}])
tool = DummyParTool()
tool.set_database(db)

pitch_set = tool._get_by_bump_dim_pitch()
assert pitch_set == {'x': 1, 'y': 1}

db = hammer_config.HammerDatabase()
db.update_project([{"vlsi.inputs.bumps.pitch_x": 1}, {"vlsi.inputs.bumps.pitch": 2}])
tool.set_database(db)

pitch_set = tool._get_by_bump_dim_pitch()
assert pitch_set == {'x': 1, 'y': 2}

def test_bump_sort(self) -> None:
assignments = [
BumpAssignment(name="foo",no_connect=False,x=Decimal(1),y=Decimal(1),group=None,custom_cell=None),
Expand All @@ -205,7 +240,7 @@ def test_bump_sort(self) -> None:
BumpAssignment(name="VDD",no_connect=False,x=Decimal(203),y=Decimal(21),group=None,custom_cell=None),
BumpAssignment(name="VSS",no_connect=False,x=Decimal(202),y=Decimal(20),group=None,custom_cell=None)
]
definition = BumpsDefinition(x=204,y=204,pitch=Decimal("1.23"),cell="bumpcell",assignments=assignments)
definition = BumpsDefinition(x=204,y=204,pitch_x=Decimal("1.23"), pitch_y=Decimal("3.14"), global_x_offset=0, global_y_offset=0, cell="bumpcell",assignments=assignments)

idxs = [0, 3, 6, 2, 1]

Expand All @@ -215,7 +250,6 @@ def test_bump_sort(self) -> None:
sorted_assignments = BumpsPinNamingScheme.A0.sort_by_name(definition, assignments)
assert sorted_assignments == [assignments[x] for x in [4, 3, 5, 6, 7, 8, 2, 1, 0]]


class TestDelayConstraint:
def test_round_trip(self) -> None:
"""
Expand Down

0 comments on commit e32be0d

Please sign in to comment.