Skip to content

Commit

Permalink
removed case insensitive naming stuff for now
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobdbrown4 committed Aug 30, 2023
1 parent e8b9834 commit 93efbf3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 37 deletions.
17 changes: 0 additions & 17 deletions spydrnet/global_state/global_flags.py

This file was deleted.

15 changes: 7 additions & 8 deletions spydrnet/parsers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import zipfile
import tempfile
from pathlib import Path
import os

"""
Init for Spydrnet. The functions below can be called directly
"""


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).
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down
14 changes: 6 additions & 8 deletions spydrnet/parsers/edif/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
6 changes: 2 additions & 4 deletions spydrnet/plugins/namespace_manager/edif_namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 93efbf3

Please sign in to comment.