From d8437249f7f56067d2273e340dee62b60d5ae4c0 Mon Sep 17 00:00:00 2001 From: Hunter Nichols Date: Wed, 6 Jan 2021 15:53:22 -0800 Subject: [PATCH] Condensed some datasheet code in lib.py --- compiler/characterizer/lib.py | 193 ++++++++++++++++------------------ compiler/options.py | 2 +- 2 files changed, 90 insertions(+), 105 deletions(-) diff --git a/compiler/characterizer/lib.py b/compiler/characterizer/lib.py index 6f1ec3ba..c49d0bd0 100644 --- a/compiler/characterizer/lib.py +++ b/compiler/characterizer/lib.py @@ -627,6 +627,78 @@ class lib: def parse_info(self,corner,lib_name): """ Copies important characterization data to datasheet.info to be added to datasheet """ + if OPTS.output_datasheet_info: + datasheet_path = OPTS.output_path + else: + datasheet_path = OPTS.openram_temp + datasheet = open(datasheet_path +'/datasheet.info', 'a+') + + self.write_inp_params_datasheet(datasheet, corner, lib_name) + self.write_signal_from_ports(datasheet, + "din{1}[{0}:0]".format(self.sram.word_size - 1, '{}'), + self.write_ports, + "setup_times_LH", + "setup_times_HL", + "hold_times_LH", + "hold_times_HL") + + # self.write_signal_from_ports(datasheet, + # "dout{1}[{0}:0]".format(self.sram.word_size - 1, '{}'), + # self.read_ports, + # "delay_lh", + # "delay_hl", + # "slew_lh", + # "slew_hl") + for port in self.all_ports: + #dout timing + if port in self.read_ports: + datasheet.write("{0},{1},{2},{3},{4},{5},{6},{7},{8},".format( + "dout{1}[{0}:0]".format(self.sram.word_size - 1, port), + min(list(map(round_time,self.char_port_results[port]["delay_lh"]))), + max(list(map(round_time,self.char_port_results[port]["delay_lh"]))), + + min(list(map(round_time,self.char_port_results[port]["delay_hl"]))), + max(list(map(round_time,self.char_port_results[port]["delay_hl"]))), + + min(list(map(round_time,self.char_port_results[port]["slew_lh"]))), + max(list(map(round_time,self.char_port_results[port]["slew_lh"]))), + + min(list(map(round_time,self.char_port_results[port]["slew_hl"]))), + max(list(map(round_time,self.char_port_results[port]["slew_hl"]))) + )) + + self.write_signal_from_ports(datasheet, + "csb{}", + self.all_ports, + "setup_times_LH", + "setup_times_HL", + "hold_times_LH", + "hold_times_HL") + + self.write_signal_from_ports(datasheet, + "addr{1}[{0}:0]".format(self.sram.addr_size - 1, '{}'), + self.all_ports, + "setup_times_LH", + "setup_times_HL", + "hold_times_LH", + "hold_times_HL") + + self.write_signal_from_ports(datasheet, + "web{}", + self.readwrite_ports, + "setup_times_LH", + "setup_times_HL", + "hold_times_LH", + "hold_times_HL") + + self.write_power_datasheet(datasheet) + + datasheet.write("{0},{1},".format('words_per_row', OPTS.words_per_row)) + datasheet.write("END\n") + datasheet.close() + + def write_inp_params_datasheet(self, datasheet, corner, lib_name): + if OPTS.is_unit_test: git_id = 'FFFFFFFFFFFFFFFFFFFF' @@ -644,14 +716,9 @@ class lib: # check if git id is valid if len(git_id) != 40: debug.warning("Failed to retrieve git id") - git_id = 'Failed to retruieve' - if OPTS.output_datasheet_info: - datasheet_path = OPTS.output_path - else: - datasheet_path = OPTS.openram_temp - datasheet = open(datasheet_path +'/datasheet.info', 'a+') - + git_id = 'Failed to retrieve' current_time = datetime.date.today() + # write static information to be parser later datasheet.write("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},".format( OPTS.output_name, @@ -679,104 +746,26 @@ class lib: # write area datasheet.write(str(self.sram.width * self.sram.height) + ',') - - # write timing information for all ports - for port in self.all_ports: - #din timings - if port in self.write_ports: - datasheet.write("{0},{1},{2},{3},{4},{5},{6},{7},{8},".format( - "din{1}[{0}:0]".format(self.sram.word_size - 1, port), - min(list(map(round_time,self.times["setup_times_LH"]))), - max(list(map(round_time,self.times["setup_times_LH"]))), - - min(list(map(round_time,self.times["setup_times_HL"]))), - max(list(map(round_time,self.times["setup_times_HL"]))), - - min(list(map(round_time,self.times["hold_times_LH"]))), - max(list(map(round_time,self.times["hold_times_LH"]))), - - min(list(map(round_time,self.times["hold_times_HL"]))), - max(list(map(round_time,self.times["hold_times_HL"]))) - - )) - - for port in self.all_ports: - #dout timing - if port in self.read_ports: - datasheet.write("{0},{1},{2},{3},{4},{5},{6},{7},{8},".format( - "dout{1}[{0}:0]".format(self.sram.word_size - 1, port), - min(list(map(round_time,self.char_port_results[port]["delay_lh"]))), - max(list(map(round_time,self.char_port_results[port]["delay_lh"]))), - - min(list(map(round_time,self.char_port_results[port]["delay_hl"]))), - max(list(map(round_time,self.char_port_results[port]["delay_hl"]))), - - min(list(map(round_time,self.char_port_results[port]["slew_lh"]))), - max(list(map(round_time,self.char_port_results[port]["slew_lh"]))), - - min(list(map(round_time,self.char_port_results[port]["slew_hl"]))), - max(list(map(round_time,self.char_port_results[port]["slew_hl"]))) - - - )) - - for port in self.all_ports: - #csb timings + + def write_signal_from_ports(self, datasheet, signal, ports, time_pos_1, time_pos_2, time_pos_3, time_pos_4): + for port in ports: datasheet.write("{0},{1},{2},{3},{4},{5},{6},{7},{8},".format( - "csb{0}".format(port), - min(list(map(round_time,self.times["setup_times_LH"]))), - max(list(map(round_time,self.times["setup_times_LH"]))), + signal.format(port), + min(list(map(round_time,self.times[time_pos_1]))), + max(list(map(round_time,self.times[time_pos_1]))), - min(list(map(round_time,self.times["setup_times_HL"]))), - max(list(map(round_time,self.times["setup_times_HL"]))), + min(list(map(round_time,self.times[time_pos_2]))), + max(list(map(round_time,self.times[time_pos_2]))), - min(list(map(round_time,self.times["hold_times_LH"]))), - max(list(map(round_time,self.times["hold_times_LH"]))), + min(list(map(round_time,self.times[time_pos_3]))), + max(list(map(round_time,self.times[time_pos_3]))), - min(list(map(round_time,self.times["hold_times_HL"]))), - max(list(map(round_time,self.times["hold_times_HL"]))) + min(list(map(round_time,self.times[time_pos_4]))), + max(list(map(round_time,self.times[time_pos_4]))) )) - - for port in self.all_ports: - #addr timings - datasheet.write("{0},{1},{2},{3},{4},{5},{6},{7},{8},".format( - "addr{1}[{0}:0]".format(self.sram.addr_size - 1, port), - min(list(map(round_time,self.times["setup_times_LH"]))), - max(list(map(round_time,self.times["setup_times_LH"]))), - - min(list(map(round_time,self.times["setup_times_HL"]))), - max(list(map(round_time,self.times["setup_times_HL"]))), - - min(list(map(round_time,self.times["hold_times_LH"]))), - max(list(map(round_time,self.times["hold_times_LH"]))), - - min(list(map(round_time,self.times["hold_times_HL"]))), - max(list(map(round_time,self.times["hold_times_HL"]))) - - )) - - - for port in self.all_ports: - if port in self.readwrite_ports: - - #web timings - datasheet.write("{0},{1},{2},{3},{4},{5},{6},{7},{8},".format( - "web{0}".format(port), - min(list(map(round_time,self.times["setup_times_LH"]))), - max(list(map(round_time,self.times["setup_times_LH"]))), - - min(list(map(round_time,self.times["setup_times_HL"]))), - max(list(map(round_time,self.times["setup_times_HL"]))), - - min(list(map(round_time,self.times["hold_times_LH"]))), - max(list(map(round_time,self.times["hold_times_LH"]))), - - min(list(map(round_time,self.times["hold_times_HL"]))), - max(list(map(round_time,self.times["hold_times_HL"]))) - - )) - + + def write_power_datasheet(self, datasheet): # write power information for port in self.all_ports: name = '' @@ -814,8 +803,4 @@ class lib: for i in range(1, self.total_port_num): control_str += ' & csb{0}'.format(i) - datasheet.write("{0},{1},{2},".format('leak', control_str, self.char_sram_results["leakage_power"])) - - datasheet.write("{0},{1},".format('words_per_row', OPTS.words_per_row)) - datasheet.write("END\n") - datasheet.close() + datasheet.write("{0},{1},{2},".format('leak', control_str, self.char_sram_results["leakage_power"])) \ No newline at end of file diff --git a/compiler/options.py b/compiler/options.py index 712b96d0..a7323580 100644 --- a/compiler/options.py +++ b/compiler/options.py @@ -106,7 +106,7 @@ class options(optparse.Values): # Output config with all options output_extended_config = False # Output temporary file used to format HTML page - output_datasheet_info = True + output_datasheet_info = False # Determines which analytical model to use. # Available Models: elmore, linear_regression model_name = "elmore"