Repository: LovetheFrogs/PyCircTools (language: python)

Issue:
Package documentation



Discussion / hints:

Fix patch:
diff --git a/.idea/CTools.iml b/.idea/CTools.iml
index 74d515a..026e652 100644
--- a/.idea/CTools.iml
+++ b/.idea/CTools.iml
@@ -4,7 +4,7 @@
     <content url="file://$MODULE_DIR$">
       <excludeFolder url="file://$MODULE_DIR$/venv" />
     </content>
-    <orderEntry type="inheritedJdk" />
+    <orderEntry type="jdk" jdkName="Python 3.10 (PyCircTools) (2)" jdkType="Python SDK" />
     <orderEntry type="sourceFolder" forTests="false" />
   </component>
 </module>
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 1a43427..a952dba 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,4 +1,4 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
-  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (BinaryTools)" project-jdk-type="Python SDK" />
+  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (PyCircTools) (2)" project-jdk-type="Python SDK" />
 </project>
\ No newline at end of file
diff --git a/CTools/Exceptions/__init__.py b/CTools/Exceptions/__init__.py
deleted file mode 100644
index 76b9bc5..0000000
--- a/CTools/Exceptions/__init__.py
+++ /dev/null
@@ -1,6 +0,0 @@
-"""
-CTools custom exceptions.
-"""
-
-from CTools.Exceptions.CircuitToolsExceptions import *
-from CTools.Exceptions.LogicGateExceptions import *
diff --git a/CTools/LogicGates/__init__.py b/CTools/LogicGates/__init__.py
deleted file mode 100644
index 56825f1..0000000
--- a/CTools/LogicGates/__init__.py
+++ /dev/null
@@ -1,13 +0,0 @@
-"""
-CTools Logic Gates package.
-
-This package includes the  **NOT, AND, NAND, OR, XOR, NOR** logic gates.
-"""
-
-
-from CTools.LogicGates.Not import *
-from CTools.LogicGates.And import *
-from CTools.LogicGates.Nand import *
-from CTools.LogicGates.Or import *
-from CTools.LogicGates.Xor import *
-from CTools.LogicGates.Nor import *
diff --git a/CTools/Multiplexers/__init__.py b/CTools/Multiplexers/__init__.py
deleted file mode 100644
index 8365d73..0000000
--- a/CTools/Multiplexers/__init__.py
+++ /dev/null
@@ -1,10 +0,0 @@
-"""
-PyCircTools Multiplexers package.
-
-This package includes some Multiplexers and Demultiplexers (from 1 to 2 to 1 to 16)
-"""
-
-from CTools.Multiplexers.Mux2to1 import *
-from CTools.Multiplexers.Mux4to1 import *
-from CTools.Multiplexers.Mux8to1 import *
-from CTools.Multiplexers.Mux16to1 import *
diff --git a/CTools/__init__.py b/CTools/__init__.py
deleted file mode 100644
index e326bfd..0000000
--- a/CTools/__init__.py
+++ /dev/null
@@ -1,7 +0,0 @@
-"""
-CTools is a python 3 package that provides the user with common circuit elements. It aims to help the implementation of
-circuits using code, serving as an alternative to programs like ModelSIM.
-"""
-
-from CTools.Exceptions import *
-from CTools.LogicGates import *
diff --git a/CTools/Exceptions/CircuitToolsExceptions.py b/PyCircTools/Exceptions/CircuitToolsExceptions.py
similarity index 81%
rename from CTools/Exceptions/CircuitToolsExceptions.py
rename to PyCircTools/Exceptions/CircuitToolsExceptions.py
index 9e6c573..47dc2c1 100644
--- a/CTools/Exceptions/CircuitToolsExceptions.py
+++ b/PyCircTools/Exceptions/CircuitToolsExceptions.py
@@ -1,11 +1,11 @@
 """
-General CTools exceptions.
+General PyCircTools exceptions.
 """
 
 
 class CircuitToolsException(Exception):
     """
-    Parent Exception class. All general CTools exceptions inherit from this class.
+    Parent Exception class. All general PyCircTools exceptions inherit from this class.
     """
     def __init__(self, msg="CircuitTools Exception."):
         self.msg = msg
diff --git a/PyCircTools/Exceptions/LatchesExceptions.py b/PyCircTools/Exceptions/LatchesExceptions.py
new file mode 100644
index 0000000..32873e4
--- /dev/null
+++ b/PyCircTools/Exceptions/LatchesExceptions.py
@@ -0,0 +1,3 @@
+"""
+PyCircTools Latches package Exceptions
+"""
\ No newline at end of file
diff --git a/CTools/Exceptions/LogicGateExceptions.py b/PyCircTools/Exceptions/LogicGateExceptions.py
similarity index 84%
rename from CTools/Exceptions/LogicGateExceptions.py
rename to PyCircTools/Exceptions/LogicGateExceptions.py
index f1efd14..9fa55b8 100644
--- a/CTools/Exceptions/LogicGateExceptions.py
+++ b/PyCircTools/Exceptions/LogicGateExceptions.py
@@ -1,11 +1,11 @@
 """
-CTools LogicGates module Exceptions.
+PyCircTools LogicGates module Exceptions.
 """
 
 
 class LogicGateException(Exception):
     """
-    LogicGateException is the parent Exception class for all CTools.LogicGates related Exceptions
+    LogicGateException is the parent Exception class for all PyCircTools.LogicGates related Exceptions
     """
     def __init__(self, msg="Logic gate Exception."):
         self.msg = msg
diff --git a/CTools/Exceptions/MultiplexersExceptions.py b/PyCircTools/Exceptions/MultiplexersExceptions.py
similarity index 100%
rename from CTools/Exceptions/MultiplexersExceptions.py
rename to PyCircTools/Exceptions/MultiplexersExceptions.py
diff --git a/PyCircTools/Exceptions/__init__.py b/PyCircTools/Exceptions/__init__.py
new file mode 100644
index 0000000..124a40d
--- /dev/null
+++ b/PyCircTools/Exceptions/__init__.py
@@ -0,0 +1,7 @@
+"""
+PyCircTools custom exceptions.
+"""
+
+from PyCircTools.Exceptions.CircuitToolsExceptions import *
+from PyCircTools.Exceptions.LogicGateExceptions import *
+from PyCircTools.Exceptions.LatchesExceptions import *
diff --git a/PyCircTools/Latches/DFlipflop.py b/PyCircTools/Latches/DFlipflop.py
new file mode 100644
index 0000000..46f4644
--- /dev/null
+++ b/PyCircTools/Latches/DFlipflop.py
@@ -0,0 +1,102 @@
+from PyCircTools.Exceptions.CircuitToolsExceptions import NotTruthValue
+from PyCircTools.LogicGates import And, Nor, Not
+
+
+class DFlipflop:
+    """
+    D-Flipflop module. Takes 2 inputs (Data and Clock).
+    """
+    def __init__(self):
+        """
+        DFlipflop class constructor. Initialises all inputs and outputs to False, except Qp.
+        """
+        self.D = False
+        self.clock = False
+        self.Q = False
+        self.Qp = True
+
+    def get_D(self):
+        """
+        Method get_D gets the value of the Data input.
+
+        :return: Value of the flip-flop's Data input.
+        :rtype: bool
+        """
+        return self.D
+
+    def get_enable(self):
+        """
+        Method get_enable gets the value of the clock input.
+
+        :return: Value of the flip-flop's Enable input.
+        :rtype: bool
+        """
+        return self.clock
+
+    def get_Q(self):
+        """
+        Method get_Q returns the value of the Q output.
+
+        :return: Value of the flip-flop's Q output.
+        :rtype: bool
+        """
+        return self.Q
+
+    def get_Qp(self):
+        """
+        Method get_Qp returns the value of the Qp output.
+
+        :return: Value of the flip-flop's Qp output.
+        :rtype: bool
+        """
+        return self.Qp
+
+    def set_D(self, value):
+        """
+        Method set_D sets the value of the Data input to the bool value.
+
+        :param value: Desired value of the flip-flop's Data input.
+        :type value: bool
+        :raises NotTruthValue: Raised when a variable type is not bool.
+        """
+        if type(value) is not bool:
+            raise NotTruthValue
+
+        self.D = value
+        self.__calculate_output()
+        return self
+
+    def set_enable(self, value):
+        """
+        Method set_enable sets the value of Clock to the bool value.
+
+        :param value: Desired value of the flip-flop's Clock input.
+        :type value: bool
+        :raises NotTruthValue: Raised when a variable type is not bool.
+        """
+        if type(value) is not bool:
+            raise NotTruthValue
+
+        self.clock = value
+        self.__calculate_output()
+        return self
+
+    def __calculate_output(self):
+        """
+        Method __calculate_output calculates the output of both the Q and Qp signals.
+        """
+        if not self.clock:
+            return self
+        else:
+            and_d = And().set_input(0, self.clock).set_input(1, self.D)
+            not_d = Not().set_input(self.D)
+            and_not_d = And().set_input(0, not_d.get_output()).set_input(1, self.clock)
+
+            if not self.D:
+                self.Q = Nor().set_input(0, and_not_d.get_output()).set_input(1, self.Qp).get_output()
+                self.Qp = Nor().set_input(0, and_d.get_output()).set_input(1, self.Q).get_output()
+            else:
+                self.Qp = Nor().set_input(0, and_d.get_output()).set_input(1, self.Q).get_output()
+                self.Q = Nor().set_input(0, and_not_d.get_output()).set_input(1, self.Qp).get_output()
+
+        return self
diff --git a/PyCircTools/Latches/DLatch.py b/PyCircTools/Latches/DLatch.py
new file mode 100644
index 0000000..c8f8ecd
--- /dev/null
+++ b/PyCircTools/Latches/DLatch.py
@@ -0,0 +1,102 @@
+from PyCircTools.Exceptions.CircuitToolsExceptions import NotTruthValue
+from PyCircTools.LogicGates import And, Nor, Not
+
+
+class DLatch:
+    """
+    D-Latch module. Takes 2 inputs (Data and enable).
+    """
+    def __init__(self):
+        """
+        DLatch class constructor. Initialises all inputs and outputs to False, except Qp.
+        """
+        self.D = False
+        self.enable = False
+        self.Q = False
+        self.Qp = True
+
+    def get_D(self):
+        """
+        Method get_D gets the value of the Data input.
+
+        :return: Value of the latch's Data input.
+        :rtype: bool
+        """
+        return self.D
+
+    def get_enable(self):
+        """
+        Method get_enable gets the value of the enable input.
+
+        :return: Value of the latch's Enable input.
+        :rtype: bool
+        """
+        return self.enable
+
+    def get_Q(self):
+        """
+        Method get_Q returns the value of the Q output.
+
+        :return: Value of the latch's Q output.
+        :rtype: bool
+        """
+        return self.Q
+
+    def get_Qp(self):
+        """
+        Method get_Qp returns the value of the Qp output.
+
+        :return: Value of the latch's Qp output.
+        :rtype: bool
+        """
+        return self.Qp
+
+    def set_D(self, value):
+        """
+        Method set_D sets the value of the Data input to the bool value.
+
+        :param value: Desired value of the latch's Data input.
+        :type value: bool
+        :raises NotTruthValue: Raised when a variable type is not bool.
+        """
+        if type(value) is not bool:
+            raise NotTruthValue
+
+        self.D = value
+        self.__calculate_output()
+        return self
+
+    def set_enable(self, value):
+        """
+        Method set_enable sets the value of Enable to the bool value.
+
+        :param value: Desired value of the latch's Enable input.
+        :type value: bool
+        :raises NotTruthValue: Raised when a variable type is not bool.
+        """
+        if type(value) is not bool:
+            raise NotTruthValue
+
+        self.enable = value
+        self.__calculate_output()
+        return self
+
+    def __calculate_output(self):
+        """
+        Method __calculate_output calculates the output of both the Q and Qp signals.
+        """
+        if not self.enable:
+            return self
+        else:
+            and_d = And().set_input(0, self.enable).set_input(1, self.D)
+            not_d = Not().set_input(self.D)
+            and_not_d = And().set_input(0, not_d.get_output()).set_input(1, self.enable)
+
+            if not self.D:
+                self.Q = Nor().set_input(0, and_not_d.get_output()).set_input(1, self.Qp).get_output()
+                self.Qp = Nor().set_input(0, and_d.get_output()).set_input(1, self.Q).get_output()
+            else:
+                self.Qp = Nor().set_input(0, and_d.get_output()).set_input(1, self.Q).get_output()
+                self.Q = Nor().set_input(0, and_not_d.get_output()).set_input(1, self.Qp).get_output()
+
+        return self
diff --git a/PyCircTools/Latches/JKFlipflop.py b/PyCircTools/Latches/JKFlipflop.py
new file mode 100644
index 0000000..6ba8274
--- /dev/null
+++ b/PyCircTools/Latches/JKFlipflop.py
@@ -0,0 +1,125 @@
+from PyCircTools import NotTruthValue
+from PyCircTools.LogicGates import And, Or
+
+
+class JKFlipflop:
+    """
+    JK-Flipflop module. Takes 3 inputs (J, K and Clock).
+    """
+    def __init__(self):
+        """
+        JKFlipflop class constructor. Initialises all inputs and outputs to False.
+        """
+        self.K = False
+        self.J = False
+        self.clock = False
+        self.Q = False
+        self.Qp = False
+
+    def get_K(self):
+        """
+        Method get_K gets the value of the K input.
+
+        :return: Value of the flip-flop's K input.
+        :rtype: bool
+        """
+        return self.K
+
+    def get_J(self):
+        """
+        Method get_J gets the value of the J input.
+
+        :return: Value of the flip-flop J input.
+        :rtype: bool
+        """
+        return self.J
+
+    def get_clock(self):
+        """
+        Method get_clock gets the value of clock input.
+
+        :return: Value of the flip-flop's Clock input.
+        :rtype: bool
+        """
+        return self.clock
+
+    def get_Q(self):
+        """
+        Method get_Q gets the value of the Q output.
+
+        :return: Value of the flip-flop's Q output.
+        :rtype: bool
+        """
+        return self.Q
+
+    def get_Qp(self):
+        """
+        Method get_Qp gets the value of the Qp output.
+
+        :return: Value of the flip-flop's Qp output.
+        :rtype: bool
+        """
+        return self.Qp
+
+    def set_K(self, value):
+        """
+        Method set_K sets the value of the K input to the bool value.
+
+        :param value: Desired value of the flip-flop's K input.
+        :type value: bool
+        :raises NotTruthValue: Raised when a variable type is not bool.
+        """
+        if type(value) is not bool:
+            raise NotTruthValue
+
+        self.K = value
+        self.__calculate_output()
+        return self
+
+    def set_J(self, value):
+        """
+        Method set_J sets the value of the J input to the bool value.
+
+        :param value: Desired value of the flip-flop's J input.
+        :type value: bool
+        :raises NotTruthValue: Raised when a variable type is not bool.
+        """
+        if type(value) is not bool:
+            raise NotTruthValue
+
+        self.J = value
+        self.__calculate_output()
+        return self
+
+    def set_clock(self, value):
+        """
+        Method set_clock sets the value of Clock to the bool value.
+
+        :param value: Desired value of the flip-flop's Clock input.
+        :type value: bool
+        :raises NotTruthValue: Raised when a variable type is not bool.
+        """
+        if type(value) is not bool:
+            raise NotTruthValue
+
+        self.clock = value
+        self.__calculate_output()
+        return self
+
+    def __calculate_output(self):
+        """
+        Method __calculate_output calculates the value of both the Q and the Qp signal.
+        """
+        if not self.clock:
+            return self
+        else:
+            q_aux = self.Q
+            qp_aux = self.Qp
+
+            and1 = And(3).set_input(0, self.J).set_input(1, qp_aux).set_input(2, self.clock)
+            and2 = And(3).set_input(0, not self.K).set_input(1, q_aux).set_input(2, self.clock)
+
+            self.Q = Or().set_input(0, and1.get_output()).set_input(1, and2.get_output()).get_output()
+            self.Qp = not self.Q
+
+            return self
diff --git a/PyCircTools/Latches/README.md b/PyCircTools/Latches/README.md
new file mode 100644
index 0000000..ee968c8
--- /dev/null
+++ b/PyCircTools/Latches/README.md
@@ -0,0 +1,253 @@
+# Latches Module.
+
+Here is an in-depth explanation for the PyCircTools.Latches module. Latches adds implementation for the most used latches and flip-flops.
+Check this README for further reference.
+
+# Table of contents.
+
+- [1. SR latch](#sr-latch)
+    + [1.1. Attributes](#sr-attributes)
+    + [1.2. Constructor](#sr-constructor)
+    + [1.3. Methods](#sr-methods)
+- [2. D latch](#d-latch)
+    + [2.1. Attributes](#d-attributes)
+    + [2.2. Constructor](#d-constructor)
+    + [2.3. Methods](#d-methods)
+- [3. SR flip-flop](#sr-flipflop)
+- [4. D flip-flop](#d-flipflop)
+- [5. JK flip-flop](#jk-flipflop)
+    + [5.1. Attributes](#jk-attributes)
+    + [5.2. Constructor](#jk-constructor)
+    + [5.3. Methods](#jk-methods)
+- [6. T flip-flop](#t-flipflop)
+    + [6.1. Attributes](#t-attributes)
+    + [6.2. Constructor](#t-constructor)
+    + [6.3. Methods](#t-methods)
+
+<a name="sr-latch"></a>
+## SR Latch
+
+The **SR latch** is also called as Set Reset Latch. This latch affects the outputs as long as the enable is maintained at ‘1’.
+
+<a name="sr-attributes"></a>
+### Attributes
+
+The SR latch has the following attributes.
+
+| Name | Description | Type |
+| - | - | - |
+| **S** | Set input signal | bool |
+| **R** | Reset input signal | bool |
+| **enable** | Enables the latch | bool |
+| **Q** | Output of the latch | bool |
+| **Qp** | Complementary of the latch's output | bool |
+
+<a name="sr-constructor"></a>
+### Constructor
+
+The constructor of the SR latch has the following format: <br>
+
+<p align="center" style="bold" ><b>SRLatch()</b></p>
+Which doesn't take any parameters and returns an SR latch with its inputs and outputs set to False.
+
+<a name="sr-methods"></a>
+### Methods
+
+The SR latch has the following methods:
+
+- **get_S():**
+Gets the value of the Set input signal. It returns a bool containing the requested value.
+
+- **get_R():**
+Gets the value of the Reset input signal. It returns a bool containing the requested value.
+
+- **get_enable():**
+Gets the value of the Enable input signal. It returns a bool containing the requested value.
+
+- **get_Q():**
+Gets the value of the Q output signal. It returns a bool containing the requested value.
+
+- **get_Qp():**
+Gets the value of the Qp output signal. It returns a bool containing the requested value.
+
+- **set_R(bool _value_):**
+Sets the Reset signal of the latch to the truth value _'value'_, which is passed as a parameter.
+
+- **set_S(bool _value_):**
+Sets the Set signal of the latch to the truth value _'value'_, which is passed as a parameter.
+
+- **set_enable(bool _value_):**
+Sets the Enable signal of the latch to the truth value _'value'_, which is passed as a parameter.
+
+- **__calculate_output():**
+Private method which calculates both the Q and Qp output of the latch.
+
+<a name="d-latch"></a>
+## D Latch
+
+The **D latch** it is also called as Data latch. There is one drawback of SR Latch. That is the next state value can’t be predicted when both the inputs S & R are one. So, we can overcome this difficulty by D latch.
+
+<a name="d-attributes"></a>
+### Attributes
+
+The D latch has the following attributes.
+
+| Name | Description | Type |
+| - | - | - |
+| **D** | Data input signal | bool |
+| **enable** | Enables the latch | bool |
+| **Q** | Output of the latch | bool |
+| **Qp** | Complementary of the latch's output | bool |
+
+<a name="d-constructor"></a>
+### Constructor
+
+The constructor of the D latch has the following format: <br>
+
+<p align="center" style="bold" ><b>DLatch()</b></p>
+Which doesn't take any parameters and returns a D latch with its inputs and outputs set to False.
+
+<a name="d-methods"></a>
+### Methods
+
+The D latch has the following methods:
+
+- **get_D():**
+Gets the value of the Data input signal. It returns a bool containing the requested value.
+
+- **get_enable():**
+Gets the value of the Enable input signal. It returns a bool containing the requested value.
+
+- **get_Q():**
+Gets the value of the Q output signal. It returns a bool containing the requested value.
+
+- **get_Qp():**
+Gets the value of the Qp output signal. It returns a bool containing the requested value.
+
+- **set_D(bool _value_):**
+Sets the Data signal of the latch to the truth value _'value'_, which is passed as a parameter.
+
+- **set_enable(bool _value_):**
+Sets the Enable signal of the latch to the truth value _'value'_, which is passed as a parameter.
+
+- **__calculate_output():**
+Private method which calculates both the Q and Qp output of the latch.
+
+<a name="sr-flipflop"></a>
+## SR Flip-flop
+
+The **SR flip-flop** is similar to an SR latch. The difference is that it works with a clock signal, but code implementation is nearly the same. You should refer to the SR latch documentation to get information about its methods and attributes.
+
+<a name="d-flipflop"></a>
+## D Flip-flop
+
+The **D flip-flop** is similar to a D latch. The difference is that it works with a clock signal, but code implementation is nearly the same. You should refer to the D latch documentation to get information about its methods and attributes.
+
+<a name="jk-flipflop"></a>
+## JK Flip-flop
+
+The **JK Flip-flop** is the modified version of SR flip-flop. It operates with only positive clock transitions or negative clock transitions.
+
+<a name="jk-attributes"></a>
+### Attributes
+
+The JK flip-flop has the following attributes.
+
+| Name | Description | Type |
+| - | - | - |
+| **J** | J input signal | bool |
+| **K** | K input signal | bool |
+| **clock** | Enables the latch | bool |
+| **Q** | Output of the latch | bool |
+| **Qp** | Complementary of the latch's output | bool |
+
+<a name="jk-constructor"></a>
+### Constructor
+
+The constructor of the JK flip-flop has the following format: <br>
+
+<p align="center" style="bold" ><b>JKFlipflop()</b></p>
+Which doesn't take any parameters and returns a JK flip-flop with its inputs and outputs set to False.
+
+<a name="jk-methods"></a>
+### Methods
+
+The JK flip-flop has the following methods:
+
+- **get_J():**
+Gets the value of the J input signal. It returns a bool containing the requested value.
+
+- **get_K():**
+Gets the value of the K input signal. It returns a bool containing the requested value.
+
+- **get_clock():**
+Gets the value of the clock. It returns a bool containing the requested value.
+
+- **get_Q():**
+Gets the value of the Q output signal. It returns a bool containing the requested value.
+
+- **get_Qp():**
+Gets the value of the Qp output signal. It returns a bool containing the requested value.
+
+- **set_J(bool _value_):**
+Sets the J signal of the flip-flop to the truth value _'value'_, which is passed as a parameter.
+
+- **set_K(bool _value_):**
+Sets the K signal of the flip-flop to the truth value _'value'_, which is passed as a parameter.
+
+- **set_clock(bool _value_):**
+Sets the clock to the truth value _'value'_, which is passed as a parameter.
+
+- **__calculate_output():**
+Private method which calculates both the Q and Qp output of the flip-flop.
+
+<a name="t-flipflop"></a>
+## T Flip-flop
+
+The **T Flip-flop** is the simplified version of JK flip-flop. It is obtained by connecting the same input ‘T’ to both inputs of JK flip-flop. 
+
+<a name="t-attributes"></a>
+### Attributes
+
+The T flip-flop has the following attributes.
+
+| Name | Description | Type |
+| - | - | - |
+| **T** | T input signal | bool |
+| **clock** | Enables the latch | bool |
+| **Q** | Output of the latch | bool |
+| **Qp** | Complementary of the latch's output | bool |
+
+<a name="t-constructor"></a>
+### Constructor
+
+The constructor of the T flip-flop has the following format: <br>
+
+<p align="center" style="bold" ><b>TFlipflop()</b></p>
+Which doesn't take any parameters and returns a T flip-flop with its inputs and outputs set to False.
+
+<a name="t-methods"></a>
+### Methods
+
+The T flip-flop has the following methods:
+
+- **get_T():**
+Gets the value of the T input signal. It returns a bool containing the requested value.
+
+- **get_clock():**
+Gets the value of the clock. It returns a bool containing the requested value.
+
+- **get_Q():**
+Gets the value of the Q output signal. It returns a bool containing the requested value.
+
+- **get_Qp():**
+Gets the value of the Qp output signal. It returns a bool containing the requested value.
+
+- **set_T(bool _value_):**
+Sets the T signal of the flip-flop to the truth value _'value'_, which is passed as a parameter.
+
+- **set_clock(bool _value_):**
+Sets the clock to the truth value _'value'_, which is passed as a parameter.
+
+- **__calculate_output():**
+Private method which calculates both the Q and Qp output of the flip-flop.
diff --git a/PyCircTools/Latches/SRFlipflop.py b/PyCircTools/Latches/SRFlipflop.py
new file mode 100644
index 0000000..1644c19
--- /dev/null
+++ b/PyCircTools/Latches/SRFlipflop.py
@@ -0,0 +1,122 @@
+from PyCircTools.Exceptions.CircuitToolsExceptions import NotTruthValue
+from PyCircTools.LogicGates import And, Nor
+
+
+class SRFlipflop:
+    """
+    SR-Flipflop module. Takes 3 inputs (Reset, Set and Clock).
+    """
+    def __init__(self):
+        """
+        SRFlipflop class constructor. Initialises all inputs and outputs to False, except Qp.
+        """
+        self.R = False
+        self.S = False
+        self.clock = False
+        self.Q = False
+        self.Qp = True
+
+    def get_R(self):
+        """
+        Method get_R gets the value of the Reset input.
+
+        :return: Value of the flip-flop's Reset input.
+        :rtype: bool
+        """
+        return self.R
+
+    def get_S(self):
+        """
+        Method get_S gets the value of the S input.
+
+        :return: Value of the flip-flop's Set input.
+        :rtype: bool
+        """
+        return self.S
+
+    def get_clock(self):
+        """
+        Method get_clock gets the value of clock input.
+
+        :return: Value of the flip-flop's Clock input.
+        :rtype: bool
+        """
+        return self.clock
+
+    def get_Q(self):
+        """
+        Method get_Q gets the value of the Q output.
+
+        :return: Value of the flip-flop's Q output.
+        :rtype: bool
+        """
+        return self.Q
+
+    def get_Qp(self):
+        """
+        Method get_Qp gets the value of the Qp output.
+
+        :return: Value of the flip-flop's Qp output.
+        :rtype: bool
+        """
+        return self.Qp
+
+    def set_R(self, value):
+        """
+        Method set_R sets the value of the Reset input to the bool value.
+
+        :param value: Desired value of the flip-flop's Reset input.
+        :type value: bool
+        :raises NotTruthValue: Raised when a variable type is not bool.
+        """
+        if type(value) is not bool:
+            raise NotTruthValue
+
+        self.R = value
+        self.__calculate_output()
+        return self
+
+    def set_S(self, value):
+        """
+        Method set_S sets the value of the Set input to the bool value.
+
+        :param value: Desired value of the flip-flop's Set input.
+        :type value: bool
+        :raises NotTruthValue: Raised when a variable type is not bool.
+        """
+        if type(value) is not bool:
+            raise NotTruthValue
+
+        self.S = value
+        self.__calculate_output()
+        return self
+
+    def set_clock(self, value):
+        """
+        Method set_clock sets the value of Clock to the bool value.
+
+        :param value: Desired value of the flip-flop's Clock input.
+        :type value: bool
+        :raises NotTruthValue: Raised when a variable type is not bool.
+        """
+        if type(value) is not bool:
+            raise NotTruthValue
+
+        self.clock = value
+        self.__calculate_output()
+        return self
+
+    def __calculate_output(self):
+        """
+        Method __calculate_output calculates the value of both the Q and the Qp signal.
+        """
+        if not self.clock:
+            return self
+        else:
+            and_r = And().set_input(0, self.R).set_input(1, self.clock)
+            and_s = And().set_input(0, self.S).set_input(1, self.clock)
+
+            self.Qp = Nor().set_input(0, and_s.get_output()).set_input(1, self.Q).get_output()
+            self.Q = Nor().set_input(0, and_r.get_output()).set_input(1, self.Qp).get_output()
+
+            return self
diff --git a/PyCircTools/Latches/SRLatch.py b/PyCircTools/Latches/SRLatch.py
new file mode 100644
index 0000000..3ec805a
--- /dev/null
+++ b/PyCircTools/Latches/SRLatch.py
@@ -0,0 +1,122 @@
+from PyCircTools.Exceptions.CircuitToolsExceptions import NotTruthValue
+from PyCircTools.LogicGates import And, Nor
+
+
+class SRLatch:
+    """
+    SR-Latch module. Takes 3 inputs (Reset, Set and Enable).
+    """
+    def __init__(self):
+        """
+        SRLatch class constructor. Initialises all inputs and outputs to False, except Qp.
+        """
+        self.R = False
+        self.S = False
+        self.enable = False
+        self.Q = False
+        self.Qp = True
+
+    def get_R(self):
+        """
+        Method get_R gets the value of the Reset input.
+
+        :return: Value of the latch's Reset input.
+        :rtype: bool
+        """
+        return self.R
+
+    def get_S(self):
+        """
+        Method get_S gets the value of the S input.
+
+        :return: Value of the latch's Set input.
+        :rtype: bool
+        """
+        return self.S
+
+    def get_enable(self):
+        """
+        Method get_enable gets the value of enable input.
+
+        :return: Value of the latch's Enable input.
+        :rtype: bool
+        """
+        return self.enable
+
+    def get_Q(self):
+        """
+        Method get_Q gets the value of the Q output.
+
+        :return: Value of the latch's Q output.
+        :rtype: bool
+        """
+        return self.Q
+
+    def get_Qp(self):
+        """
+        Method get_Qp gets the value of the Qp output.
+
+        :return: Value of the latch's Qp output.
+        :rtype: bool
+        """
+        return self.Qp
+
+    def set_R(self, value):
+        """
+        Method set_R sets the value of the Reset input to the bool value.
+
+        :param value: Desired value of the latch's Reset input.
+        :type value: bool
+        :raises NotTruthValue: Raised when a variable type is not bool.
+        """
+        if type(value) is not bool:
+            raise NotTruthValue
+
+        self.R = value
+        self.__calculate_output()
+        return self
+
+    def set_S(self, value):
+        """
+        Method set_S sets the value of the Set input to the bool value.
+
+        :param value: Desired value of the latch's Set input.
+        :type value: bool
+        :raises NotTruthValue: Raised when a variable type is not bool.
+        """
+        if type(value) is not bool:
+            raise NotTruthValue
+
+        self.S = value
+        self.__calculate_output()
+        return self
+
+    def set_enable(self, value):
+        """
+        Method set_enable sets the value of Enable to the bool value.
+
+        :param value: Desired value of the latch's Enable input.
+        :type value: bool
+        :raises NotTruthValue: Raised when a variable type is not bool.
+        """
+        if type(value) is not bool:
+            raise NotTruthValue
+
+        self.enable = value
+        self.__calculate_output()
+        return self
+
+    def __calculate_output(self):
+        """
+        Method __calculate_output calculates the value of both the Q and the Qp signal.
+        """
+        if not self.enable:
+            return self
+        else:
+            and_r = And().set_input(0, self.R).set_input(1, self.enable)
+            and_s = And().set_input(0, self.S).set_input(1, self.enable)
+
+            self.Qp = Nor().set_input(0, and_s.get_output()).set_input(1, self.Q).get_output()
+            self.Q = Nor().set_input(0, and_r.get_output()).set_input(1, self.Qp).get_output()
+
+            return self
diff --git a/PyCircTools/Latches/TFlipflop.py b/PyCircTools/Latches/TFlipflop.py
new file mode 100644
index 0000000..56d64ee
--- /dev/null
+++ b/PyCircTools/Latches/TFlipflop.py
@@ -0,0 +1,95 @@
+from PyCircTools import NotTruthValue, Xor, Not
+
+
+class TFlipflop:
+    """
+    T-Flipflop module. Takes 2 inputs (T and Clock).
+    """
+    def __init__(self):
+        """
+        TFlipflop class constructor. Initialises all inputs and outputs to False.
+        """
+        self.T = False
+        self.clock = False
+        self.Q = False
+        self.Qp = False
+
+    def get_T(self):
+        """
+        Method get_T gets the value of the T input.
+
+        :return: Value of the flip-flop's T input.
+        :rtype: bool
+        """
+        return self.T
+
+    def get_clock(self):
+        """
+        Method get_clock gets the value of clock input.
+
+        :return: Value of the flip-flop's Clock input.
+        :rtype: bool
+        """
+        return self.clock
+
+    def get_Q(self):
+        """
+        Method get_Q gets the value of the Q output.
+
+        :return: Value of the flip-flop's Q output.
+        :rtype: bool
+        """
+        return self.Q
+
+    def get_Qp(self):
+        """
+        Method get_Qp gets the value of the Qp output.
+
+        :return: Value of the flip-flop's Qp output.
+        :rtype: bool
+        """
+        return self.Qp
+
+    def set_T(self, value):
+        """
+        Method set_T sets the value of the T input to the bool value.
+
+        :param value: Desired value of the flip-flop's T input.
+        :type value: bool
+        :raises NotTruthValue: Raised when a variable type is not bool.
+        """
+        if type(value) is not bool:
+            raise NotTruthValue
+
+        self.T = value
+        self.__calculate_output()
+        return self
+
+    def set_clock(self, value):
+        """
+        Method set_clock sets the value of Clock to the bool value.
+
+        :param value: Desired value of the flip-flop's Clock input.
+        :type value: bool
+        :raises NotTruthValue: Raised when a variable type is not bool.
+        """
+        if type(value) is not bool:
+            raise NotTruthValue
+
+        self.clock = value
+        self.__calculate_output()
+        return self
+
+    def __calculate_output(self):
+        """
+        Method __calculate_output calculates the value of both the Q and the Qp signal.
+        """
+        if not self.clock:
+            return self
+        else:
+            q_aux = self.Q
+
+            self.Q = Xor().set_input(0, self.T).set_input(1, q_aux).get_output()
+            self.Qp = Not().set_input(self.Q).get_output()
+
+            return self
diff --git a/PyCircTools/Latches/__init__.py b/PyCircTools/Latches/__init__.py
new file mode 100644
index 0000000..04e386f
--- /dev/null
+++ b/PyCircTools/Latches/__init__.py
@@ -0,0 +1,12 @@
+"""
+PyCircTools Latches package.
+
+This package includes **** latches.
+"""
+
+from PyCircTools.Latches.SRLatch import *
+from PyCircTools.Latches.DLatch import *
+from PyCircTools.Latches.SRFlipflop import *
+from PyCircTools.Latches.DFlipflop import *
+from PyCircTools.Latches.JKFlipflop import *
+from PyCircTools.Latches.TFlipflop import *
diff --git a/CTools/LogicGates/And.py b/PyCircTools/LogicGates/And.py
similarity index 94%
rename from CTools/LogicGates/And.py
rename to PyCircTools/LogicGates/And.py
index 22ad8cb..50b1c0c 100644
--- a/CTools/LogicGates/And.py
+++ b/PyCircTools/LogicGates/And.py
@@ -1,5 +1,5 @@
-from CTools.Exceptions.CircuitToolsExceptions import NotTruthValue
-from CTools.Exceptions.LogicGateExceptions import NonPositiveInput, NotAnInput
+from PyCircTools.Exceptions.CircuitToolsExceptions import NotTruthValue
+from PyCircTools.Exceptions.LogicGateExceptions import NonPositiveInput, NotAnInput
 
 
 class And:
diff --git a/CTools/LogicGates/Nand.py b/PyCircTools/LogicGates/Nand.py
similarity index 94%
rename from CTools/LogicGates/Nand.py
rename to PyCircTools/LogicGates/Nand.py
index d690195..db4c78c 100644
--- a/CTools/LogicGates/Nand.py
+++ b/PyCircTools/LogicGates/Nand.py
@@ -1,5 +1,5 @@
-from CTools.Exceptions.CircuitToolsExceptions import NotTruthValue
-from CTools.Exceptions.LogicGateExceptions import NonPositiveInput, NotAnInput
+from PyCircTools.Exceptions.CircuitToolsExceptions import NotTruthValue
+from PyCircTools.Exceptions.LogicGateExceptions import NonPositiveInput, NotAnInput
 
 
 class Nand:
diff --git a/CTools/LogicGates/Nor.py b/PyCircTools/LogicGates/Nor.py
similarity index 94%
rename from CTools/LogicGates/Nor.py
rename to PyCircTools/LogicGates/Nor.py
index 034106e..3ba1d85 100644
--- a/CTools/LogicGates/Nor.py
+++ b/PyCircTools/LogicGates/Nor.py
@@ -1,5 +1,5 @@
-from CTools.Exceptions.CircuitToolsExceptions import NotTruthValue
-from CTools.Exceptions.LogicGateExceptions import NonPositiveInput, NotAnInput
+from PyCircTools.Exceptions.CircuitToolsExceptions import NotTruthValue
+from PyCircTools.Exceptions.LogicGateExceptions import NonPositiveInput, NotAnInput
 
 
 class Nor:
diff --git a/CTools/LogicGates/Not.py b/PyCircTools/LogicGates/Not.py
similarity index 94%
rename from CTools/LogicGates/Not.py
rename to PyCircTools/LogicGates/Not.py
index fd958ed..8011104 100644
--- a/CTools/LogicGates/Not.py
+++ b/PyCircTools/LogicGates/Not.py
@@ -1,4 +1,4 @@
-from CTools.Exceptions.CircuitToolsExceptions import NotTruthValue
+from PyCircTools.Exceptions.CircuitToolsExceptions import NotTruthValue
 
 
 class Not:
diff --git a/CTools/LogicGates/Or.py b/PyCircTools/LogicGates/Or.py
similarity index 94%
rename from CTools/LogicGates/Or.py
rename to PyCircTools/LogicGates/Or.py
index df03411..ac9605e 100644
--- a/CTools/LogicGates/Or.py
+++ b/PyCircTools/LogicGates/Or.py
@@ -1,5 +1,5 @@
-from CTools.Exceptions.CircuitToolsExceptions import NotTruthValue
-from CTools.Exceptions.LogicGateExceptions import NonPositiveInput, NotAnInput
+from PyCircTools.Exceptions.CircuitToolsExceptions import NotTruthValue
+from PyCircTools.Exceptions.LogicGateExceptions import NonPositiveInput, NotAnInput
 
 
 class Or:
diff --git a/CTools/LogicGates/Xor.py b/PyCircTools/LogicGates/Xor.py
similarity index 94%
rename from CTools/LogicGates/Xor.py
rename to PyCircTools/LogicGates/Xor.py
index 472277f..057ec24 100644
--- a/CTools/LogicGates/Xor.py
+++ b/PyCircTools/LogicGates/Xor.py
@@ -1,5 +1,5 @@
-from CTools.Exceptions.CircuitToolsExceptions import NotTruthValue
-from CTools.Exceptions.LogicGateExceptions import NonPositiveInput, NotAnInput
+from PyCircTools.Exceptions.CircuitToolsExceptions import NotTruthValue
+from PyCircTools.Exceptions.LogicGateExceptions import NonPositiveInput, NotAnInput
 
 
 class Xor:
diff --git a/PyCircTools/LogicGates/__init__.py b/PyCircTools/LogicGates/__init__.py
new file mode 100644
index 0000000..c7697cf
--- /dev/null
+++ b/PyCircTools/LogicGates/__init__.py
@@ -0,0 +1,13 @@
+"""
+PyCircTools Logic Gates package.
+
+This package includes the  **NOT, AND, NAND, OR, XOR, NOR** logic gates.
+"""
+
+
+from PyCircTools.LogicGates.Not import *
+from PyCircTools.LogicGates.And import *
+from PyCircTools.LogicGates.Nand import *
+from PyCircTools.LogicGates.Or import *
+from PyCircTools.LogicGates.Xor import *
+from PyCircTools.LogicGates.Nor import *
diff --git a/CTools/Multiplexers/Mux16to1.py b/PyCircTools/Multiplexers/Mux16to1.py
similarity index 96%
rename from CTools/Multiplexers/Mux16to1.py
rename to PyCircTools/Multiplexers/Mux16to1.py
index 3e135f1..59915e1 100644
--- a/CTools/Multiplexers/Mux16to1.py
+++ b/PyCircTools/Multiplexers/Mux16to1.py
@@ -1,5 +1,5 @@
-from CTools.Exceptions.MultiplexersExceptions import NonExistingInput, NonExistingControlSignal
-from CTools.Exceptions.CircuitToolsExceptions import NotTruthValue
+from PyCircTools.Exceptions.MultiplexersExceptions import NonExistingInput, NonExistingControlSignal
+from PyCircTools.Exceptions.CircuitToolsExceptions import NotTruthValue
 
 
 class Mux16to1:
diff --git a/CTools/Multiplexers/Mux2to1.py b/PyCircTools/Multiplexers/Mux2to1.py
similarity index 94%
rename from CTools/Multiplexers/Mux2to1.py
rename to PyCircTools/Multiplexers/Mux2to1.py
index 4114ced..735ba59 100644
--- a/CTools/Multiplexers/Mux2to1.py
+++ b/PyCircTools/Multiplexers/Mux2to1.py
@@ -1,5 +1,5 @@
-from CTools.Exceptions.MultiplexersExceptions import NonExistingInput
-from CTools.Exceptions.CircuitToolsExceptions import NotTruthValue
+from PyCircTools.Exceptions.MultiplexersExceptions import NonExistingInput
+from PyCircTools.Exceptions.CircuitToolsExceptions import NotTruthValue
 
 
 class Mux2to1:
diff --git a/CTools/Multiplexers/Mux4to1.py b/PyCircTools/Multiplexers/Mux4to1.py
similarity index 95%
rename from CTools/Multiplexers/Mux4to1.py
rename to PyCircTools/Multiplexers/Mux4to1.py
index 9473b88..982b32d 100644
--- a/CTools/Multiplexers/Mux4to1.py
+++ b/PyCircTools/Multiplexers/Mux4to1.py
@@ -1,5 +1,5 @@
-from CTools.Exceptions.MultiplexersExceptions import NonExistingInput, NonExistingControlSignal
-from CTools.Exceptions.CircuitToolsExceptions import NotTruthValue
+from PyCircTools.Exceptions.MultiplexersExceptions import NonExistingInput, NonExistingControlSignal
+from PyCircTools.Exceptions.CircuitToolsExceptions import NotTruthValue
 
 
 class Mux4to1:
diff --git a/CTools/Multiplexers/Mux8to1.py b/PyCircTools/Multiplexers/Mux8to1.py
similarity index 95%
rename from CTools/Multiplexers/Mux8to1.py
rename to PyCircTools/Multiplexers/Mux8to1.py
index 46b3389..b5d87cc 100644
--- a/CTools/Multiplexers/Mux8to1.py
+++ b/PyCircTools/Multiplexers/Mux8to1.py
@@ -1,5 +1,5 @@
-from CTools.Exceptions.MultiplexersExceptions import NonExistingInput, NonExistingControlSignal
-from CTools.Exceptions.CircuitToolsExceptions import NotTruthValue
+from PyCircTools.Exceptions.MultiplexersExceptions import NonExistingInput, NonExistingControlSignal
+from PyCircTools.Exceptions.CircuitToolsExceptions import NotTruthValue
 
 
 class Mux8to1:
diff --git a/PyCircTools/Multiplexers/__init__.py b/PyCircTools/Multiplexers/__init__.py
new file mode 100644
index 0000000..2caae35
--- /dev/null
+++ b/PyCircTools/Multiplexers/__init__.py
@@ -0,0 +1,10 @@
+"""
+PyCircTools Multiplexers package.
+
+This package includes some Multiplexers and Demultiplexers (from 1 to 2 to 1 to 16)
+"""
+
+from PyCircTools.Multiplexers.Mux2to1 import *
+from PyCircTools.Multiplexers.Mux4to1 import *
+from PyCircTools.Multiplexers.Mux8to1 import *
+from PyCircTools.Multiplexers.Mux16to1 import *
diff --git a/PyCircTools/__init__.py b/PyCircTools/__init__.py
new file mode 100644
index 0000000..b1bd0bd
--- /dev/null
+++ b/PyCircTools/__init__.py
@@ -0,0 +1,8 @@
+"""
+PyCircTools is a python 3 package that provides the user with common circuit elements. It aims to help the implementation of
+circuits using code, serving as an alternative to programs like ModelSIM.
+"""
+
+from PyCircTools.Exceptions import *
+from PyCircTools.LogicGates import *
+from PyCircTools.Latches import *


Test patch:
diff --git a/CTools/Modules/__init__.py b/tests/Latches_tests/__init__.py
similarity index 100%
rename from CTools/Modules/__init__.py
rename to tests/Latches_tests/__init__.py
diff --git a/tests/Latches_tests/test_DFlipflop.py b/tests/Latches_tests/test_DFlipflop.py
new file mode 100644
index 0000000..2a3ea66
--- /dev/null
+++ b/tests/Latches_tests/test_DFlipflop.py
@@ -0,0 +1,24 @@
+from PyCircTools.Latches import DFlipflop
+
+
+def test_DFlipflop():
+    errors = []
+    latch = DFlipflop()
+
+    if latch.get_Q() and not latch.get_Qp():
+        errors.append("Outputs at start value test not passed!")
+
+    if latch.set_D(True).get_Q() and not latch.get_Qp():
+        errors.append("Outputs changed when enable is still False!")
+
+    if not latch.set_enable(True).set_D(False).get_Q() and latch.get_Qp():
+        pass
+    else:
+        errors.append("Data False does not give back expected output!")
+
+    if latch.set_D(True).get_Q() and not latch.get_Qp():
+        pass
+    else:
+        errors.append("Data True does not give back expected output!")
+
+    assert not errors, "errors occured:\n{}".format("\n".join(errors))
diff --git a/tests/Latches_tests/test_DLatch.py b/tests/Latches_tests/test_DLatch.py
new file mode 100644
index 0000000..bd4d4db
--- /dev/null
+++ b/tests/Latches_tests/test_DLatch.py
@@ -0,0 +1,24 @@
+from PyCircTools.Latches import DLatch
+
+
+def test_DLatch():
+    errors = []
+    latch = DLatch()
+
+    if latch.get_Q() and not latch.get_Qp():
+        errors.append("Outputs at start value test not passed!")
+
+    if latch.set_D(True).get_Q() and not latch.get_Qp():
+        errors.append("Outputs changed when enable is still False!")
+
+    if not latch.set_enable(True).set_D(False).get_Q() and latch.get_Qp():
+        pass
+    else:
+        errors.append("Data False does not give back expected output!")
+
+    if latch.set_D(True).get_Q() and not latch.get_Qp():
+        pass
+    else:
+        errors.append("Data True does not give back expected output!")
+
+    assert not errors, "errors occured:\n{}".format("\n".join(errors))
diff --git a/tests/Latches_tests/test_JKFlipflop.py b/tests/Latches_tests/test_JKFlipflop.py
new file mode 100644
index 0000000..56b50f5
--- /dev/null
+++ b/tests/Latches_tests/test_JKFlipflop.py
@@ -0,0 +1,36 @@
+from PyCircTools.Latches import JKFlipflop
+
+
+def test_JKFlipflop():
+    errors = []
+    flipflop = JKFlipflop()
+
+    if flipflop.get_Q():
+        errors.append("Q output when created flipflop is not False!")
+
+    if flipflop.set_J(True).get_Q():
+        errors.append("Operation done when clock is False!")
+
+    if not flipflop.set_clock(True).set_J(False).set_K(True).get_Q() and flipflop.get_Qp():
+        pass
+    else:
+        errors.append("Not J and K test not passed!")
+
+    if flipflop.set_J(True).set_K(False).get_Q() and not flipflop.get_Qp():
+        pass
+    else:
+        errors.append("J and not K test not passed!")
+
+    previous = [flipflop.get_Q(), flipflop.get_Qp()]
+    if flipflop.set_K(True).get_Q() == previous[1] and flipflop.get_Qp() == previous[0]:
+        pass
+    else:
+        errors.append("J and K test not passed!")
+
+    previous = [flipflop.get_Q(), flipflop.get_Qp()]
+    if flipflop.set_J(False).set_K(False).get_Q() == previous[0] and flipflop.get_Qp() == previous[1]:
+        pass
+    else:
+        errors.append("Not J and not K test not passed!")
+
+    assert not errors, "errors occured:\n{}".format("\n".join(errors))
diff --git a/tests/Latches_tests/test_SRFlipflop.py b/tests/Latches_tests/test_SRFlipflop.py
new file mode 100644
index 0000000..3f7f5ca
--- /dev/null
+++ b/tests/Latches_tests/test_SRFlipflop.py
@@ -0,0 +1,28 @@
+from PyCircTools.Latches import SRFlipflop
+
+
+def test_SRFlipflop():
+    errors = []
+    latch = SRFlipflop()
+
+    if latch.get_Q():
+        errors.append("Q output when generated test not passed!")
+
+    if latch.set_R(True).get_Q():
+        errors.append("Operation when enable is False!")
+
+    previous = [latch.get_Q(), latch.get_Qp()]
+    if latch.set_clock(True).set_R(False).get_Q() != previous[0] and latch.get_Qp() != previous[1]:
+        errors.append("Set and all False test not passed!")
+
+    if not latch.set_R(True).get_Q() and latch.get_Qp():
+        pass
+    else:
+        errors.append("R and not S test not passed!")
+
+    if latch.set_R(False).set_S(True).get_Q() and not latch.get_Qp():
+        pass
+    else:
+        errors.append("not R and S test not passed!")
+
+    assert not errors, "errors occured:\n{}".format("\n".join(errors))
diff --git a/tests/Latches_tests/test_SRLatch.py b/tests/Latches_tests/test_SRLatch.py
new file mode 100644
index 0000000..75269b4
--- /dev/null
+++ b/tests/Latches_tests/test_SRLatch.py
@@ -0,0 +1,28 @@
+from PyCircTools.Latches import SRLatch
+
+
+def test_SRLatch():
+    errors = []
+    latch = SRLatch()
+
+    if latch.get_Q():
+        errors.append("Q output when generated test not passed!")
+
+    if latch.set_R(True).get_Q():
+        errors.append("Operation when enable is False!")
+
+    previous = [latch.get_Q(), latch.get_Qp()]
+    if latch.set_enable(True).set_R(False).get_Q() != previous[0] and latch.get_Qp() != previous[1]:
+        errors.append("Set and all False test not passed!")
+
+    if not latch.set_R(True).get_Q() and latch.get_Qp():
+        pass
+    else:
+        errors.append("R and not S test not passed!")
+
+    if latch.set_R(False).set_S(True).get_Q() and not latch.get_Qp():
+        pass
+    else:
+        errors.append("not R and S test not passed!")
+
+    assert not errors, "errors occured:\n{}".format("\n".join(errors))
diff --git a/tests/Latches_tests/test_TFlipflop.py b/tests/Latches_tests/test_TFlipflop.py
new file mode 100644
index 0000000..1a06c70
--- /dev/null
+++ b/tests/Latches_tests/test_TFlipflop.py
@@ -0,0 +1,39 @@
+from PyCircTools.Latches import TFlipflop
+
+
+def test_TFlipflop():
+    errors = []
+    flipflop = TFlipflop()
+
+    if flipflop.get_Q():
+        errors.append("Q output when created flipflop is not False!")
+
+    if flipflop.set_T(True).get_Q():
+        errors.append("Operation done when clock is False!")
+
+    if not flipflop.set_T(False).set_clock(True).get_Q() and flipflop.get_Qp():
+        pass
+    else:
+        errors.append("Clock tests not passed!")
+
+    if flipflop.set_T(True).get_Q() and not flipflop.get_Qp():
+        pass
+    else:
+        errors.append("False then T test not passed!")
+
+    if not flipflop.set_T(True).get_Q() and flipflop.get_Qp():
+        pass
+    else:
+        errors.append("True then not T test not passed!")
+
+    if not flipflop.set_T(False).get_Q() and flipflop.get_Qp():
+        pass
+    else:
+        errors.append("False then not T test not passed!")
+
+    if flipflop.set_T(True).get_Q() and not flipflop.get_Qp():
+        pass
+    else:
+        errors.append("False then not T test not passed!")
+
+    assert not errors, "errors occured:\n{}".format("\n".join(errors))
diff --git a/tests/LogicGates_tests/test_and.py b/tests/LogicGates_tests/test_and.py
index cf52bfb..1870279 100644
--- a/tests/LogicGates_tests/test_and.py
+++ b/tests/LogicGates_tests/test_and.py
@@ -1,4 +1,4 @@
-from CTools.LogicGates import And
+from PyCircTools.LogicGates import And
 
 
 def test_and_gate():
diff --git a/tests/LogicGates_tests/test_nand.py b/tests/LogicGates_tests/test_nand.py
index 2277d01..64ad821 100644
--- a/tests/LogicGates_tests/test_nand.py
+++ b/tests/LogicGates_tests/test_nand.py
@@ -1,4 +1,4 @@
-from CTools.LogicGates import Nand
+from PyCircTools.LogicGates import Nand
 
 
 def test_and_gate():
diff --git a/tests/LogicGates_tests/test_nor.py b/tests/LogicGates_tests/test_nor.py
index 3b2adc8..1707ae7 100644
--- a/tests/LogicGates_tests/test_nor.py
+++ b/tests/LogicGates_tests/test_nor.py
@@ -1,4 +1,4 @@
-from CTools.LogicGates import Nor
+from PyCircTools.LogicGates import Nor
 
 
 def test_or_gate():
diff --git a/tests/LogicGates_tests/test_not.py b/tests/LogicGates_tests/test_not.py
index a2f1aed..7e18ace 100644
--- a/tests/LogicGates_tests/test_not.py
+++ b/tests/LogicGates_tests/test_not.py
@@ -1,4 +1,4 @@
-from CTools.LogicGates import Not
+from PyCircTools.LogicGates import Not
 
 
 def test_not_gate():
diff --git a/tests/LogicGates_tests/test_or.py b/tests/LogicGates_tests/test_or.py
index 601778a..f861244 100644
--- a/tests/LogicGates_tests/test_or.py
+++ b/tests/LogicGates_tests/test_or.py
@@ -1,4 +1,4 @@
-from CTools.LogicGates import Or
+from PyCircTools.LogicGates import Or
 
 
 def test_or_gate():
diff --git a/tests/LogicGates_tests/test_xor.py b/tests/LogicGates_tests/test_xor.py
index e0bce95..6b261fc 100644
--- a/tests/LogicGates_tests/test_xor.py
+++ b/tests/LogicGates_tests/test_xor.py
@@ -1,4 +1,4 @@
-from CTools.LogicGates import Xor
+from PyCircTools.LogicGates import Xor
 
 
 def test_or_gate():
diff --git a/tests/Multiplexers_tests/__init__.py b/tests/Multiplexers_tests/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/tests/Multiplexers_tests/test_Mux16to1.py b/tests/Multiplexers_tests/test_Mux16to1.py
index 107d347..f2382e0 100644
--- a/tests/Multiplexers_tests/test_Mux16to1.py
+++ b/tests/Multiplexers_tests/test_Mux16to1.py
@@ -1,7 +1,7 @@
 import itertools
 
-from CTools import NotTruthValue, NonExistingControlSignal, NonExistingInput
-from CTools.Multiplexers import Mux16to1
+from PyCircTools import NotTruthValue, NonExistingControlSignal, NonExistingInput
+from PyCircTools.Multiplexers import Mux16to1
 
 
 def generate_inputs(num):
diff --git a/tests/Multiplexers_tests/test_Mux4to1.py b/tests/Multiplexers_tests/test_Mux4to1.py
index e9cba7c..7d9f9e6 100644
--- a/tests/Multiplexers_tests/test_Mux4to1.py
+++ b/tests/Multiplexers_tests/test_Mux4to1.py
@@ -1,5 +1,5 @@
-from CTools import NotTruthValue, NonExistingControlSignal, NonExistingInput
-from CTools.Multiplexers import Mux4to1
+from PyCircTools import NotTruthValue, NonExistingControlSignal, NonExistingInput
+from PyCircTools.Multiplexers import Mux4to1
 
 
 def to_bool(value):
diff --git a/tests/Multiplexers_tests/test_Mux8to1.py b/tests/Multiplexers_tests/test_Mux8to1.py
index 84d9e1c..acd7848 100644
--- a/tests/Multiplexers_tests/test_Mux8to1.py
+++ b/tests/Multiplexers_tests/test_Mux8to1.py
@@ -1,7 +1,7 @@
 import itertools
 
-from CTools import NotTruthValue, NonExistingControlSignal, NonExistingInput
-from CTools.Multiplexers import Mux8to1
+from PyCircTools import NotTruthValue, NonExistingControlSignal, NonExistingInput
+from PyCircTools.Multiplexers import Mux8to1
 
 
 def generate_inputs(num):