From 0879ef2932eeb9f23ad9da71171c5c511e89f26e Mon Sep 17 00:00:00 2001 From: Jeff Ng Date: Thu, 5 Jun 2025 22:17:23 +0000 Subject: [PATCH] Switched to use dict.get() Signed-off-by: Jeff Ng --- run.py | 16 ++-------------- utils/class_process.py | 7 ++----- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/run.py b/run.py index 731c2a0..4c68b21 100755 --- a/run.py +++ b/run.py @@ -30,26 +30,14 @@ def get_args() -> argparse.Namespace: return parser.parse_args() -def get_memory_type(json_data): - if "memory_type" in json_data: - return json_data["memory_type"] - return "RAM" - - -def get_port_config(json_data): - if "port_configuration" in json_data: - return json_data["port_configuration"] - return "SP" - - def main(args: argparse.Namespace): json_data = RunUtils.get_config(args.config) # Create a process object (shared by all srams) process = Process(json_data) timing_data = TimingData(json_data) - memory_type = get_memory_type(json_data) - port_config = get_port_config(json_data) + memory_type = json_data.get("memory_type", "RAM") + port_config = json_data.get("port_configuration", "SP") # Go through each sram and generate the lib, lef and v files for sram_data in json_data["srams"]: diff --git a/utils/class_process.py b/utils/class_process.py index bceedfc..00c4fcd 100644 --- a/utils/class_process.py +++ b/utils/class_process.py @@ -63,11 +63,8 @@ def __init__(self, json_data): + (self.pin_width_um / 2.0) ) - if "bitcell_width_um" in json_data and "bitcell_height_um" in json_data: - self.bitcell_width_um = float(json_data["bitcell_width_um"]) - self.bitcell_height_um = float(json_data["bitcell_height_um"]) - else: - self.bitcell_width_um = self.bitcell_height_um = None + self.bitcell_width_um = json_data.get("bitcell_width_um", None) + self.bitcell_height_um = json_data.get("bitcell_height_um", None) def has_defined_bitcell_size(self): return self.bitcell_width_um and self.bitcell_height_um