From 93efbf3bd46a9ee6f1131721832888463898c431 Mon Sep 17 00:00:00 2001 From: Jacob Brown Date: Wed, 30 Aug 2023 16:43:58 -0600 Subject: [PATCH] removed case insensitive naming stuff for now --- spydrnet/global_state/global_flags.py | 17 ----------------- spydrnet/parsers/__init__.py | 15 +++++++-------- spydrnet/parsers/edif/parser.py | 14 ++++++-------- .../plugins/namespace_manager/edif_namespace.py | 6 ++---- 4 files changed, 15 insertions(+), 37 deletions(-) delete mode 100644 spydrnet/global_state/global_flags.py diff --git a/spydrnet/global_state/global_flags.py b/spydrnet/global_state/global_flags.py deleted file mode 100644 index f5c121bb..00000000 --- a/spydrnet/global_state/global_flags.py +++ /dev/null @@ -1,17 +0,0 @@ - -_global_flags = { - 'use_case_sensitive_naming' : True -} - -def _get_global_flag(name): - return _global_flags[name] - -def _set_global_flag(name, value): - global _global_flags - _global_flags[name] = value - -def use_case_sensitive_naming(): - return _get_global_flag('use_case_sensitive_naming') - -def set_use_case_sensitive_naming(use_case_sensitive_naming): - _set_global_flag('use_case_sensitive_naming', use_case_sensitive_naming) diff --git a/spydrnet/parsers/__init__.py b/spydrnet/parsers/__init__.py index 447684a0..b781dbe4 100644 --- a/spydrnet/parsers/__init__.py +++ b/spydrnet/parsers/__init__.py @@ -1,7 +1,6 @@ import zipfile import tempfile from pathlib import Path -import os """ Init for Spydrnet. The functions below can be called directly @@ -9,7 +8,7 @@ """ -def parse(filename, **kwArgs): +def parse(filename, architecture=None): """ The parse function is able to parse an EDIF (.edf) file, a Verilog file (.v), or an EBLIF file (.eblif). @@ -54,16 +53,16 @@ def parse(filename, **kwArgs): zip.extract(basename_less_final_extension, tempdirname) # filename = Path(tempdirname).joinpath(basename_less_final_extension) filename = Path(tempdirname, basename_less_final_extension) - return _parse(filename, **kwArgs) + return _parse(filename, architecture) - return _parse(filename, **kwArgs) + return _parse(filename, architecture) -def _parse(filename, **kwArgs): +def _parse(filename, architecture): extension = get_lowercase_extension(filename) if extension in [".edf", ".edif", ".edn"]: from spydrnet.parsers.edif.parser import EdifParser - parser = EdifParser.from_filename(filename, **kwArgs) + parser = EdifParser.from_filename(filename) elif extension in [".v", ".vh", ".vm"]: from spydrnet.parsers.verilog.parser import VerilogParser @@ -76,8 +75,8 @@ def _parse(filename, **kwArgs): raise RuntimeError("Extension {} not recognized.".format(extension)) parser.parse() - if 'architecture' in kwArgs: - read_primitive_library(kwArgs["architecture"], parser.netlist) + if architecture: + read_primitive_library(architecture, parser.netlist) if extension in [".eblif",".blif"]: set_eblif_names(parser.netlist) return parser.netlist diff --git a/spydrnet/parsers/edif/parser.py b/spydrnet/parsers/edif/parser.py index ab2c91ae..756cdf5f 100644 --- a/spydrnet/parsers/edif/parser.py +++ b/spydrnet/parsers/edif/parser.py @@ -2,7 +2,6 @@ from spydrnet.parsers.edif.edif_tokens import * from spydrnet.ir import Netlist, Library, Definition, Port, Cable, Instance from spydrnet.plugins import namespace_manager -from spydrnet.global_state import global_flags from functools import reduce import re @@ -16,24 +15,23 @@ def parse_construct(self, construct_parser): return result @staticmethod - def from_filename(filename, **kwArgs): - parser = EdifParser(**kwArgs) + def from_filename(filename): + parser = EdifParser() parser.filename = filename return parser @staticmethod - def from_file_handle(file_handle, **kwArgs): - parser = EdifParser(**kwArgs) + def from_file_handle(file_handle): + parser = EdifParser() parser.file_handle = file_handle return parser - def __init__(self, **kwArgs): - self.edif_identifier_namespace = dict() # class -> object -> subclass -> identifier -> object + def __init__(self): + self.edif_identifier_namespace = {} # class -> object -> subclass -> identifier -> object self.filename = None self.file_handle = None self.elements = [] self.tokenizer = None - global_flags.set_use_case_sensitive_naming('case_sensitive_naming' not in kwArgs or kwArgs['case_sensitive_naming']) def parse(self): self.initialize_tokenizer() diff --git a/spydrnet/plugins/namespace_manager/edif_namespace.py b/spydrnet/plugins/namespace_manager/edif_namespace.py index 99051fe0..e3982417 100644 --- a/spydrnet/plugins/namespace_manager/edif_namespace.py +++ b/spydrnet/plugins/namespace_manager/edif_namespace.py @@ -2,7 +2,6 @@ from spydrnet.ir import Netlist, Library, Definition import re from spydrnet.plugins.namespace_manager.default_namespace import DefaultNamespace -from spydrnet.global_state import global_flags class EdifNamespace(DefaultNamespace): @@ -137,9 +136,8 @@ def no_conflict(self, element, key, value): namespace = self.edif_namespaces[element_type] value_lower = value.lower() if value_lower in namespace: - if global_flags.use_case_sensitive_naming() or value_lower != element.name.lower(): - if namespace[value_lower] != element: - return False + if namespace[value_lower] != element: + return False return True def update(self, element, key, value):