From efd6da5300ae5c347582791f5becccfc115311c3 Mon Sep 17 00:00:00 2001 From: Bugra Onal Date: Thu, 18 Aug 2022 12:54:39 -0700 Subject: [PATCH] Parse pins from HTML --- compiler/characterizer/fake_sram.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/compiler/characterizer/fake_sram.py b/compiler/characterizer/fake_sram.py index 7eb1deb4..223f6868 100644 --- a/compiler/characterizer/fake_sram.py +++ b/compiler/characterizer/fake_sram.py @@ -48,6 +48,7 @@ class fake_sram(sram_config): self.words_per_row = words_per_row self.compute_sizes() + self.pins = ['vdd', 'gnd', 'clk0'] # TODO: remove clk def setup_multiport_constants(self): """ @@ -90,6 +91,13 @@ class fake_sram(sram_config): self.readonly_ports.append(port_number) port_number += 1 + def str_to_pins(self, s): + pinsRE = re.compile(r'^(\w+)\[(\d+):(\d+)\]') + match = pinsRE.match(s) + port, start, end = match.group(1, 2, 3) + pins = [port + '[' + str(p) + ']' for p in range(int(start) - int(end) + 1)] + return pins + def parse_html(self, filename): """ Parse the HTML file generated from previous SRAM generation @@ -98,8 +106,8 @@ class fake_sram(sram_config): with open(filename, 'r') as html: for line in html: if 'Ports and Configuration' in line: - tableRE = re.compile(r'(\w*)(\w*)') - values = tableRE.finditer(line) + configRE = re.compile(r'(\w*)(\w*)') + values = configRE.finditer(line) for val in values: if val.group(1) == 'WORD_SIZE': self.word_size = int(val.group(2)) @@ -116,4 +124,15 @@ class fake_sram(sram_config): elif val.group(1) == 'Area (µm2)': self.height = int(val.group(2) ** 0.5) self.width = int(val.group(2) ** 0.5) - break + if 'Timing Data' in line: + timingRE = re.compile(r'([\w\[\]:]*) \w* \w*[\w\.]*[\w\.]*\w*') + values = timingRE.finditer(line) + for val in values: + if '[' in val.group(1): + pins = self.str_to_pins(val.group(1)) + for pin in pins: + if pin not in self.pins: + self.pins.append(pin) + else: + if val.group(1) not in self.pins: + self.pins.append(val.group(1))