Updated generation of hierarchical circuits to allow proper naming consistency between the subcomponent modules and their corresponding invocations.
This commit is contained in:
parent
5d41997560
commit
f582ee729e
@ -127,15 +127,19 @@ class GeneralCircuit():
|
|||||||
return multi_bit_comps
|
return multi_bit_comps
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_unique_types(components: list):
|
def get_unique_types(components: list, multi_bit: bool = False):
|
||||||
"""Retrieves just the unique representatives of class types present inside the provided components list.
|
"""Retrieves just the unique representatives of class types present inside the provided components list.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
components (list): List of components to be filtered.
|
components (list): List of components to be filtered.
|
||||||
|
multi_bit (bool): Specifies whether the provided components list is composed of multi bit type circuits. Defaults to False.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
list: List of unique composite class types.
|
list: List of unique composite class types.
|
||||||
"""
|
"""
|
||||||
|
if multi_bit is True:
|
||||||
|
return list({(type(c), c.N): c for c in components}.values())
|
||||||
|
else:
|
||||||
return list({type(c): c for c in components}.values())
|
return list({type(c): c for c in components}.values())
|
||||||
|
|
||||||
def get_component_types(self):
|
def get_component_types(self):
|
||||||
@ -150,7 +154,7 @@ class GeneralCircuit():
|
|||||||
one_bit_comps = self.get_unique_types(
|
one_bit_comps = self.get_unique_types(
|
||||||
components=self.get_one_bit_components())
|
components=self.get_one_bit_components())
|
||||||
multi_bit_comps = self.get_unique_types(
|
multi_bit_comps = self.get_unique_types(
|
||||||
components=self.get_multi_bit_components())
|
components=self.get_multi_bit_components(), multi_bit=True)
|
||||||
|
|
||||||
all_components = gate_comps + one_bit_comps + multi_bit_comps
|
all_components = gate_comps + one_bit_comps + multi_bit_comps
|
||||||
return all_components
|
return all_components
|
||||||
@ -407,7 +411,7 @@ class GeneralCircuit():
|
|||||||
str: Hierarchical C code of subcomponent's C function invocation and output assignment.
|
str: Hierarchical C code of subcomponent's C function invocation and output assignment.
|
||||||
"""
|
"""
|
||||||
# Getting name of circuit type for proper C code generation without affecting actual generated composition
|
# Getting name of circuit type for proper C code generation without affecting actual generated composition
|
||||||
circuit_type = self.prefix.replace(circuit_prefix+"_", "")
|
circuit_type = self.__class__(a=Bus("a"), b=Bus("b")).prefix + str(self.N)
|
||||||
return self.a.return_bus_wires_values_c_hier() + self.b.return_bus_wires_values_c_hier() + \
|
return self.a.return_bus_wires_values_c_hier() + self.b.return_bus_wires_values_c_hier() + \
|
||||||
f" {self.out.prefix} = {circuit_type}({self.a.prefix}, {self.b.prefix});\n"
|
f" {self.out.prefix} = {circuit_type}({self.a.prefix}, {self.b.prefix});\n"
|
||||||
|
|
||||||
@ -559,13 +563,9 @@ class GeneralCircuit():
|
|||||||
str: Hierarchical Verilog code of subcomponent's module invocation and output assignment.
|
str: Hierarchical Verilog code of subcomponent's module invocation and output assignment.
|
||||||
"""
|
"""
|
||||||
# Getting name of circuit type and insitu copying out bus for proper Verilog code generation without affecting actual generated composition
|
# Getting name of circuit type and insitu copying out bus for proper Verilog code generation without affecting actual generated composition
|
||||||
circuit_type = self.prefix.replace(circuit_prefix+"_", "")
|
circuit_type = self.__class__(a=Bus("a"), b=Bus("b")).prefix + str(self.N)
|
||||||
|
|
||||||
# Obtain proper circuit name with its bit width
|
|
||||||
circuit_prefix = self.__class__(
|
|
||||||
a=Bus("a"), b=Bus("b")).prefix + str(self.N)
|
|
||||||
circuit_block = self.__class__(a=Bus(N=self.N, prefix="a"), b=Bus(
|
circuit_block = self.__class__(a=Bus(N=self.N, prefix="a"), b=Bus(
|
||||||
N=self.N, prefix="b"), name=circuit_prefix)
|
N=self.N, prefix="b"), name=circuit_type)
|
||||||
return self.a.return_bus_wires_values_v_hier() + self.b.return_bus_wires_values_v_hier() + \
|
return self.a.return_bus_wires_values_v_hier() + self.b.return_bus_wires_values_v_hier() + \
|
||||||
f" {circuit_type} {circuit_type}_{self.out.prefix}(.{circuit_block.a.prefix}({self.a.prefix}), .{circuit_block.b.prefix}({self.b.prefix}), .{circuit_block.out.prefix}({self.out.prefix}));\n"
|
f" {circuit_type} {circuit_type}_{self.out.prefix}(.{circuit_block.a.prefix}({self.a.prefix}), .{circuit_block.b.prefix}({self.b.prefix}), .{circuit_block.out.prefix}({self.out.prefix}));\n"
|
||||||
|
|
||||||
@ -671,7 +671,7 @@ class GeneralCircuit():
|
|||||||
str: Hierarchical Blif code of subcomponent's model invocation and output assignment.
|
str: Hierarchical Blif code of subcomponent's model invocation and output assignment.
|
||||||
"""
|
"""
|
||||||
# Getting name of circuit type for proper Blif code generation without affecting actual generated composition
|
# Getting name of circuit type for proper Blif code generation without affecting actual generated composition
|
||||||
circuit_type = self.prefix.replace(circuit_prefix+"_", "")
|
circuit_type = self.__class__(a=Bus("a"), b=Bus("b")).prefix + str(self.N)
|
||||||
return f"{self.a.get_wire_assign_blif(output=True)}" + \
|
return f"{self.a.get_wire_assign_blif(output=True)}" + \
|
||||||
f"{self.b.get_wire_assign_blif(output=True)}" + \
|
f"{self.b.get_wire_assign_blif(output=True)}" + \
|
||||||
f".subckt {circuit_type}" + \
|
f".subckt {circuit_type}" + \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user