piel.tools.amaranth.construct
=============================

.. py:module:: piel.tools.amaranth.construct

.. autoapi-nested-parse::

   This module provides a function to construct an Amaranth module from a truth table. It converts a truth table
   into a digital logic module using the Amaranth framework.

   The supported implementation measurement are:
   - "combinatorial"
   - "sequential"
   - "memory"



Functions
---------

.. autoapisummary::

   piel.tools.amaranth.construct.construct_amaranth_module_from_truth_table


Module Contents
---------------

.. py:function:: construct_amaranth_module_from_truth_table(truth_table: piel.types.digital.TruthTable, logic_implementation_type: piel.types.digital.LogicImplementationType = 'combinatorial')

   Constructs an Amaranth module based on the provided truth table.
   # TODO implementation type

   :param truth_table: The truth table to be implemented as a TruthTable object.
   :type truth_table: TruthTable
   :param logic_implementation_type: The type of implementation.
                                     - "combinatorial": Implements the truth table as combinational logic.
                                     - "sequential": Implements the truth table as sequential logic.
                                     - "memory": Implements the truth table using memory elements.
                                     Defaults to "combinatorial".
   :type logic_implementation_type: Literal["combinatorial", "sequential", "memory"], optional

   :returns: An Amaranth module implementing the given truth table.
   :rtype: am.Module

   .. rubric:: Examples

   >>> detector_phase_truth_table = {
   >>>     "detector_in": ["00", "01", "10", "11"],
   >>>     "phase_map_out": ["00", "10", "11", "11"],
   >>> }
   >>> my_truth_table = TruthTable(
   >>>     input_ports=["detector_in"],
   >>>     output_ports=["phase_map_out"],
   >>>     **detector_phase_truth_table
   >>> )
   >>> am_module = construct_amaranth_module_from_truth_table(my_truth_table)


