Skip to content

Commit 4ad1599

Browse files
committed
dual port sram from spreadsheet support
Signed-off-by: Jeff Ng <jeffng@precisioninno.com>
1 parent e6431ac commit 4ad1599

File tree

10 files changed

+4812
-124
lines changed

10 files changed

+4812
-124
lines changed

spreadsheet_ram.py

Lines changed: 27 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
from utils.run_utils import RunUtils
1313
from utils.rw_port_group import RWPortGroup
1414
from utils.ss_port_creator import SSPortCreator
15+
from utils.ss_port_organizer import SSPortOrganizer
1516
from utils.single_port_ssram import SinglePortSSRAM
1617

1718
# TODO
18-
# support dual port
1919
# support reg file
2020

2121
#
@@ -103,22 +103,13 @@ def _import_custom_mappings(self, file_name):
103103
self._pin_type_map = self._util_module.get_pin_type_map()
104104
self._key_map = self._util_module.get_key_map()
105105

106-
def classify_pin(self, pin_name):
107-
"""
108-
Returns the pin classification to help identify whether the pin or bus
109-
is the address, data in, data out, write enable, clock or power pin or
110-
bus
111-
"""
112-
if pin_name in self._pin_type_map:
113-
return self._pin_type_map[pin_name]
114-
return None
115-
116106
def create_memory(self, mem_config, physical):
117107
"""Extracts the data from the CSV files and returns the memory object"""
118108

119109
# Get the physical data and organize it
120110
phys_data = self.read_physical_file(physical)
121-
pins = self.organize_pins(phys_data)
111+
pin_org = SSPortOrganizer(self._pin_type_map)
112+
pin_org.organize_ports(phys_data)
122113
num_pins = len(phys_data["pin_data"])
123114

124115
# Get the metrics data and organize it
@@ -127,7 +118,7 @@ def create_memory(self, mem_config, physical):
127118
mem_config = MemoryConfig.from_json(macro_metrics)
128119

129120
mem = SinglePortSSRAM(mem_config, self._process, timing_data, num_pins)
130-
self.set_logical_pins(mem, pins)
121+
self.set_logical_pins(mem, pin_org)
131122
port_creator = SSPortCreator(mem, self._pin_type_map)
132123
port_creator.create_ports(phys_data["pin_data"])
133124
if "obs" in phys_data:
@@ -194,36 +185,6 @@ def read_physical_file(self, file_name):
194185
)
195186
return macro_data
196187

197-
def organize_pins(self, macro_data):
198-
"""
199-
Iterates through the macro_data and creates a pin dictionary that
200-
maps the pin or bus name to a dictionary that includes the pin name,
201-
msb, lsb, and type
202-
"""
203-
204-
pins = {}
205-
bus_name_re = re.compile("^(\S+)\[(\d+)\]")
206-
for pin_name, pin_data in macro_data["pin_data"].items():
207-
result = bus_name_re.match(pin_name)
208-
if result:
209-
bus_name = result.group(1)
210-
bit_num = int(result.group(2))
211-
if bus_name in pins:
212-
pins[bus_name]["lsb"] = min(bit_num, pins[bus_name]["lsb"])
213-
pins[bus_name]["msb"] = max(bit_num, pins[bus_name]["msb"])
214-
else:
215-
pins[bus_name] = {
216-
"name": bus_name,
217-
"msb": bit_num,
218-
"lsb": bit_num,
219-
"type": self.classify_pin(bus_name),
220-
}
221-
else:
222-
if pin_name in pins: # pragma: no cover
223-
raise Exception(f"pin {pin_name} appears twice")
224-
pins[pin_name] = {"name": pin_name, "type": self.classify_pin(pin_name)}
225-
226-
return pins
227188

228189
def get_size_keys(self):
229190
"""Returns the keys that map to depth and width"""
@@ -270,30 +231,30 @@ def read_metrics_file(self, file_name, macro_name):
270231
)
271232
return macro_metrics
272233

273-
def set_logical_pins(self, mem, pins):
234+
def set_logical_pins(self, mem, pin_org):
274235
"""Sets the pins to be used for Verilog and Liberty output"""
275-
rw_port_group = RWPortGroup()
276-
mem.add_rw_port_group(rw_port_group)
277-
for pin_name, pin_data in pins.items():
278-
pin_type = pin_data["type"]
279-
if pin_type == "clock":
280-
rw_port_group.set_clock_name(pin_name)
281-
elif pin_type in ["power", "ground"]:
282-
# skip
283-
pass
284-
elif pin_type == "address_bus":
285-
rw_port_group.set_address_bus_name(pin_name)
286-
elif pin_type == "data_bus":
287-
rw_port_group.set_data_input_bus_name(pin_name)
288-
elif pin_type == "output_bus":
289-
rw_port_group.set_data_output_bus_name(pin_name)
290-
elif pin_type == "write_enable":
291-
rw_port_group.set_write_enable_name(pin_name)
292-
elif "msb" in pin_data:
293-
bus = {"name": pin_name, "msb": pin_data["msb"], "lsb": pin_data["lsb"]}
294-
mem.add_misc_bus(bus)
295-
else:
296-
mem.add_misc_port(pin_name)
236+
237+
for suffix,src in pin_org.get_rw_groups().items():
238+
rw_port_group = RWPortGroup()
239+
rw_port_group.set_suffix(suffix)
240+
for pin_type,port_data in src.items():
241+
pin_name = port_data["name"]
242+
if pin_type == "clock":
243+
rw_port_group.set_clock_name(pin_name)
244+
elif pin_type == "address_bus":
245+
rw_port_group.set_address_bus_name(pin_name)
246+
elif pin_type == "data_bus":
247+
rw_port_group.set_data_input_bus_name(pin_name)
248+
elif pin_type == "output_bus":
249+
rw_port_group.set_data_output_bus_name(pin_name)
250+
elif pin_type == "write_enable":
251+
rw_port_group.set_write_enable_name(pin_name)
252+
mem.add_rw_port_group(rw_port_group)
253+
for src in pin_org.get_misc_busses():
254+
mem.add_misc_bus(src)
255+
for src in pin_org.get_misc_ports():
256+
if src["type"] not in ["power", "ground"]:
257+
mem.add_misc_port(src["name"])
297258

298259
@staticmethod
299260
def main():

0 commit comments

Comments
 (0)