mirror of https://github.com/VLSIDA/OpenRAM.git
Small fix to tech and config over-rides
This commit is contained in:
parent
be4893839b
commit
2a9129ef45
|
|
@ -6,8 +6,6 @@
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
from globals import OPTS
|
from globals import OPTS
|
||||||
from tech import tech_modules
|
|
||||||
|
|
||||||
|
|
||||||
class sram_factory:
|
class sram_factory:
|
||||||
"""
|
"""
|
||||||
|
|
@ -38,8 +36,8 @@ class sram_factory:
|
||||||
A generic function to create a module with a given module_type.
|
A generic function to create a module with a given module_type.
|
||||||
The args are passed directly to the module constructor.
|
The args are passed directly to the module constructor.
|
||||||
"""
|
"""
|
||||||
|
from tech import tech_modules
|
||||||
module_type = tech_modules[module_type]
|
real_module_type = tech_modules[module_type]
|
||||||
# if name!="":
|
# if name!="":
|
||||||
# # This is a special case where the name and type don't match
|
# # This is a special case where the name and type don't match
|
||||||
# # Can't be overridden in the config file
|
# # Can't be overridden in the config file
|
||||||
|
|
@ -47,21 +45,21 @@ class sram_factory:
|
||||||
if hasattr(OPTS, module_type):
|
if hasattr(OPTS, module_type):
|
||||||
# Retrieve the name from OPTS if it exists,
|
# Retrieve the name from OPTS if it exists,
|
||||||
# otherwise just use the name
|
# otherwise just use the name
|
||||||
module_type = getattr(OPTS, module_type)
|
real_module_type = getattr(OPTS, module_type)
|
||||||
|
|
||||||
# Either retrieve the already loaded module or load it
|
# Either retrieve the already loaded module or load it
|
||||||
try:
|
try:
|
||||||
mod = self.modules[module_type]
|
mod = self.modules[real_module_type]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
import importlib
|
import importlib
|
||||||
c = importlib.reload(__import__(module_type))
|
c = importlib.reload(__import__(real_module_type))
|
||||||
mod = getattr(c, module_type)
|
mod = getattr(c, real_module_type)
|
||||||
self.modules[module_type] = mod
|
self.modules[real_module_type] = mod
|
||||||
self.module_indices[module_type] = 0
|
self.module_indices[real_module_type] = 0
|
||||||
self.objects[module_type] = []
|
self.objects[real_module_type] = []
|
||||||
|
|
||||||
# Either retreive a previous object or create a new one
|
# Either retreive a previous object or create a new one
|
||||||
for obj in self.objects[module_type]:
|
for obj in self.objects[real_module_type]:
|
||||||
(obj_kwargs, obj_item) = obj
|
(obj_kwargs, obj_item) = obj
|
||||||
# Must have the same dictionary exactly (conservative)
|
# Must have the same dictionary exactly (conservative)
|
||||||
if obj_kwargs == kwargs:
|
if obj_kwargs == kwargs:
|
||||||
|
|
@ -72,19 +70,19 @@ class sram_factory:
|
||||||
# spice and gds files can be found.
|
# spice and gds files can be found.
|
||||||
if len(kwargs) > 0:
|
if len(kwargs) > 0:
|
||||||
# Create a unique name and increment the index
|
# Create a unique name and increment the index
|
||||||
module_name = "{0}_{1}".format(module_type,
|
module_name = "{0}_{1}".format(real_module_type,
|
||||||
self.module_indices[module_type])
|
self.module_indices[real_module_type])
|
||||||
self.module_indices[module_type] += 1
|
self.module_indices[real_module_type] += 1
|
||||||
else:
|
else:
|
||||||
module_name = module_type
|
module_name = real_module_type
|
||||||
|
|
||||||
# type_str = "type={}".format(module_type)
|
# type_str = "type={}".format(real_module_type)
|
||||||
# name_str = "name={}".format(module_name)
|
# name_str = "name={}".format(module_name)
|
||||||
# kwargs_str = "kwargs={}".format(str(kwargs))
|
# kwargs_str = "kwargs={}".format(str(kwargs))
|
||||||
# import debug
|
# import debug
|
||||||
# debug.info(0, "New module:" + type_str + name_str + kwargs_str)
|
# debug.info(0, "New module:" + type_str + name_str + kwargs_str)
|
||||||
obj = mod(name=module_name, **kwargs)
|
obj = mod(name=module_name, **kwargs)
|
||||||
self.objects[module_type].append((kwargs, obj))
|
self.objects[real_module_type].append((kwargs, obj))
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
def get_mods(self, module_type):
|
def get_mods(self, module_type):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue