Skip to content

Commit

Permalink
refactors QnnDevice + hTron to be true extension of Device
Browse files Browse the repository at this point in the history
  • Loading branch information
emmakbat committed Oct 30, 2024
1 parent e34c42e commit 5d853f5
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 28 deletions.
4 changes: 2 additions & 2 deletions src/qnngds/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def device_cell(
max_y_num = max(num_pads_e, num_pads_w)

if text is None:
text = f"{device[0].device.name}"
text = f"{device[0].name}"
cell_text = text.replace(" \n", ", ")

DIE = Device(f"CELL.{cell_text}")
Expand All @@ -355,7 +355,7 @@ def device_cell(
USER_DEVICES = Device(f"{cell_text}")
refs = []
for dev in device:
ref = USER_DEVICES << dev.device
ref = USER_DEVICES << dev
refs.append(ref)

FULL_DEVICES << USER_DEVICES
Expand Down
36 changes: 19 additions & 17 deletions src/qnngds/devices/htron.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,6 @@ def planar_hTron(wire_width: Union[int, float]= 0.3,

HTRON = Device('hTron')

htron_padplace = PadPlacement(
cell_scaling_factor_x= 1,
num_pads_n=2,
num_pads_s=2,
port_map_x={
0:("S", 2),
1:("N", 2),
2:("S", 1),
3:("N", 1)
}
)

ports = []
for direction,width,length in ((1,channel_width, channel_length), (-1,gate_width, gate_length)):
W = Device('wire')
Expand All @@ -87,10 +75,24 @@ def planar_hTron(wire_width: Union[int, float]= 0.3,
HTRON << W

HTRON = pg.union(HTRON)

final_HTRON = QnnDevice('hTron')
final_HTRON.set_pads(PadPlacement(
cell_scaling_factor_x= 1,
num_pads_n=2,
num_pads_s=2,
port_map_x={
0:("S", 2),
1:("N", 2),
2:("S", 1),
3:("N", 1)
}
))
final_HTRON << HTRON
for p, port in enumerate(ports):
HTRON.add_port(name=p, port=port)
final_HTRON.add_port(name=p, port=port)

HTRON.center = [0,0]
HTRON.name = f"HTRON.planar(w={wire_width:.2f})"
HTRON.simplify(1e-3)
return QnnDevice(HTRON, htron_padplace)
final_HTRON.center = [0,0]
final_HTRON.name = f"HTRON.planar(w={wire_width:.2f})"
final_HTRON.simplify(1e-3)
return final_HTRON
10 changes: 6 additions & 4 deletions src/qnngds/devices/nanowire.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def spot(

nw_padplace = PadPlacement()

NANOWIRE = Device()
NANOWIRE = QnnDevice()
NANOWIRE.set_pads(nw_padplace)
wire = pg.optimal_step(channel_w, source_w, symmetric=True, num_pts=num_pts)
source = NANOWIRE << wire
gnd = NANOWIRE << wire
Expand All @@ -42,7 +43,7 @@ def spot(
NANOWIRE.move(NANOWIRE.center, (0, 0))
NANOWIRE.name = f"NANOWIRE.SPOT(w={channel_w})"

return QnnDevice(NANOWIRE, nw_padplace)
return NANOWIRE


def variable_length(
Expand Down Expand Up @@ -77,7 +78,8 @@ def variable_length(
}
)

NANOWIRE = Device()
NANOWIRE = QnnDevice()
NANOWIRE.set_pads(nw_padplace)
wire = pg.optimal_step(channel_w, source_w, symmetric=True, num_pts=num_pts)
line = pg.rectangle((constr_length, channel_w), layer=layer)
line.center = [0, 0]
Expand Down Expand Up @@ -109,4 +111,4 @@ def variable_length(
NANOWIRE.move(NANOWIRE.center, (0, 0))
NANOWIRE.name = f"NANOWIRE.VAR(w={channel_w} l={constr_length})"

return QnnDevice(NANOWIRE, nw_padplace)
return NANOWIRE
7 changes: 2 additions & 5 deletions src/qnngds/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,8 @@ def __init__(self,
self.port_map_x = port_map_x
self.port_map_y = port_map_y

class QnnDevice:
def __init__(self,
device: Device,
pads: PadPlacement):
self.device = device
class QnnDevice(Device):
def set_pads(self, pads: PadPlacement = PadPlacement()):
self.pads = pads

def die_cell(
Expand Down

0 comments on commit 5d853f5

Please sign in to comment.