Skip to content
Snippets Groups Projects
Commit c24a8e19 authored by Martin Högstedt's avatar Martin Högstedt
Browse files

merged and added slots for mias:grx

parents ccfda717 e2821171
Branches
No related tags found
1 merge request!23Added slots to non-gui modules
Pipeline #132005 failed
...@@ -8,6 +8,11 @@ class AR(IntegerRegister, MiaBusConnector): ...@@ -8,6 +8,11 @@ class AR(IntegerRegister, MiaBusConnector):
Register for saving AlU calculations in MIA. Register for saving AlU calculations in MIA.
""" """
# Python does not allow multiple inherintence if more than one of the
# parent classes uses __slots__. Thus we also includes the __slots__
# from MiaBusConnector.
__slots__ = ("bus_id", "bus_control_s")
def __init__( def __init__(
self, self,
alu_input_signal: Signal, alu_input_signal: Signal,
......
...@@ -8,6 +8,11 @@ class HR(IntegerRegister, MiaBusConnector): ...@@ -8,6 +8,11 @@ class HR(IntegerRegister, MiaBusConnector):
Register for saving large AlU calculations in MIA. Register for saving large AlU calculations in MIA.
""" """
# Python does not allow multiple inherintence if more than one of the
# parent classes uses __slots__. Thus we also includes the __slots__
# from MiaBusConnector.
__slots__ = ("bus_id", "bus_control_s")
def __init__( def __init__(
self, self,
alu_input_signal: Signal, alu_input_signal: Signal,
......
...@@ -12,11 +12,10 @@ class IR(Module, MiaBusConnector): ...@@ -12,11 +12,10 @@ class IR(Module, MiaBusConnector):
several fields. several fields.
""" """
__slots__ = ( # Python does not allow multiple inherintence if more than one of the
("op", "grx", "m", "a", "instruction") # parent classes uses __slots__. Thus we also includes the __slots__
+ Module.__slots__ # from MiaBusConnector.
+ MiaBusConnector.__slots__ __slots__ = ("op", "grx", "m", "a", "bus_id", "instruction", "bus_control_s")
)
def __init__( def __init__(
self, self,
...@@ -30,6 +29,7 @@ class IR(Module, MiaBusConnector): ...@@ -30,6 +29,7 @@ class IR(Module, MiaBusConnector):
bus_id=0, bus_id=0,
name: str = "IR", name: str = "IR",
) -> None: ) -> None:
signals = { signals = {
"in_input": from_bus, "in_input": from_bus,
"out_output": to_bus, "out_output": to_bus,
......
...@@ -12,6 +12,9 @@ class LC(Module): ...@@ -12,6 +12,9 @@ class LC(Module):
increase by one or read from mM_uADR. increase by one or read from mM_uADR.
""" """
__slots__ = ("value", "read_from_bus", "read_from_uADR", "decrement_by_one", "bit_length", "mask")
def __init__( def __init__(
self, self,
mM_control: Signal, mM_control: Signal,
......
...@@ -9,7 +9,10 @@ class MiaBusConnector: ...@@ -9,7 +9,10 @@ class MiaBusConnector:
Has logic for controlling when to read and write to bus. Has logic for controlling when to read and write to bus.
""" """
__slots__ = ("bus_id", "bus_control_s") # Python does not allow multiple inherintence if more than one of the
# parent classes uses __slots__. Since the modules that inherit from MiaBusConnector
# also inherits from other classes we leave this class __slots__ empty.
__slots__ = ()
def __init__(self, bus_control: Signal, bus_id: int = 0) -> None: def __init__(self, bus_control: Signal, bus_id: int = 0) -> None:
# init the name # init the name
......
...@@ -14,6 +14,8 @@ class GRX(Module, MiaBusConnector): ...@@ -14,6 +14,8 @@ class GRX(Module, MiaBusConnector):
registers should be indexed by the GRx bits or the M bits. registers should be indexed by the GRx bits or the M bits.
""" """
__slots__ = ("grx_control", "m_control", "s_control", "bus_id", "registers")
def __init__( def __init__(
self, self,
to_bus: Signal, to_bus: Signal,
...@@ -25,12 +27,10 @@ class GRX(Module, MiaBusConnector): ...@@ -25,12 +27,10 @@ class GRX(Module, MiaBusConnector):
bus_id: int, bus_id: int,
name="GRx", name="GRx",
registers=[0 for _ in range(4)], registers=[0 for _ in range(4)],
bit_length=16,
) -> None: ) -> None:
# Set connection to/from bus and bus_id # Set connection to/from bus and bus_id
MiaBusConnector.__init__(self, bus_control, bus_id) MiaBusConnector.__init__(self, bus_control, bus_id)
# Other signals # Other signals
signals = { signals = {
"in_input": from_bus, "in_input": from_bus,
...@@ -45,9 +45,6 @@ class GRX(Module, MiaBusConnector): ...@@ -45,9 +45,6 @@ class GRX(Module, MiaBusConnector):
# set the registers # set the registers
self.registers = registers self.registers = registers
# set the bit_length
self.bit_length = bit_length
def update_register(self): def update_register(self):
""" """
If the module should read from the bus, update the correct If the module should read from the bus, update the correct
...@@ -98,7 +95,6 @@ class GRX(Module, MiaBusConnector): ...@@ -98,7 +95,6 @@ class GRX(Module, MiaBusConnector):
""" """
state = { state = {
"name": self.name, "name": self.name,
"bit_length": self.bit_length,
"registers": self.registers[:], "registers": self.registers[:],
} }
return state return state
...@@ -115,8 +111,6 @@ class GRX(Module, MiaBusConnector): ...@@ -115,8 +111,6 @@ class GRX(Module, MiaBusConnector):
Sets the grx state to one given in dict. Sets the grx state to one given in dict.
""" """
self.name = state["name"] self.name = state["name"]
if "bit_length" in state:
self.bit_length = state["bit_length"]
self.registers = state["registers"] self.registers = state["registers"]
def reset(self) -> None: def reset(self) -> None:
...@@ -162,8 +156,6 @@ class GRX(Module, MiaBusConnector): ...@@ -162,8 +156,6 @@ class GRX(Module, MiaBusConnector):
"\n -----", "\n -----",
"\n bus_id: ", "\n bus_id: ",
self.bus_id, self.bus_id,
"\n bit_length: ",
self.bit_length,
"\n GR0: ", "\n GR0: ",
hex(self.registers[0]), hex(self.registers[0]),
"\n GR1: ", "\n GR1: ",
...@@ -173,4 +165,3 @@ class GRX(Module, MiaBusConnector): ...@@ -173,4 +165,3 @@ class GRX(Module, MiaBusConnector):
"\n GR3: ", "\n GR3: ",
hex(self.registers[3]), hex(self.registers[3]),
) )
...@@ -11,6 +11,8 @@ class MicroPC(Module): ...@@ -11,6 +11,8 @@ class MicroPC(Module):
to read from or write to. to read from or write to.
""" """
__slots__ = ("value", "bit_length")
def __init__( def __init__(
self, self,
control_signal: Signal, control_signal: Signal,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment