.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "auto_examples/basic/uniquify_nmr_property_example.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        Click :ref:`here <sphx_glr_download_auto_examples_basic_uniquify_nmr_property_example.py>`
        to download the full example code

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_auto_examples_basic_uniquify_nmr_property_example.py:


Uniquify NMR Property Example
=============================

Loads in the example netlist 'b13', triplicates it, and uniquifies the value of any instance with the property 'SOFT_HLUTNM'

The properties of 'FSM_onehot_next_bit[9]_i_2_TMR_<#>' is printed before and after uniquifying the property to show what is happening.

See :ref:`uniquify_nmr_property`

.. rst-class:: sphx-glr-script-out

 Out:

 .. code-block:: none
    
    BEFORE UNIQUIFYING THE PROPERTY VALUE
            FSM_onehot_next_bit[9]_i_2_TMR_0 [{'identifier': 'INIT', 'value': "8'h7F"}, {'identifier': 'SOFT_HLUTNM', 'value': 'soft_lutpair5'}]
            FSM_onehot_next_bit[9]_i_2_TMR_1 [{'identifier': 'INIT', 'value': "8'h7F"}, {'identifier': 'SOFT_HLUTNM', 'value': 'soft_lutpair5'}]
            FSM_onehot_next_bit[9]_i_2_TMR_2 [{'identifier': 'INIT', 'value': "8'h7F"}, {'identifier': 'SOFT_HLUTNM', 'value': 'soft_lutpair5'}]

    AFTER UNIQUIFYING THE PROPERTY VALUE
            FSM_onehot_next_bit[9]_i_2_TMR_0 [{'identifier': 'INIT', 'value': "8'h7F"}, {'identifier': 'SOFT_HLUTNM', 'value': 'soft_lutpair5_TMR_0'}]
            FSM_onehot_next_bit[9]_i_2_TMR_1 [{'identifier': 'INIT', 'value': "8'h7F"}, {'identifier': 'SOFT_HLUTNM', 'value': 'soft_lutpair5_TMR_1'}]
            FSM_onehot_next_bit[9]_i_2_TMR_2 [{'identifier': 'INIT', 'value': "8'h7F"}, {'identifier': 'SOFT_HLUTNM', 'value': 'soft_lutpair5_TMR_2'}]

.. GENERATED FROM PYTHON SOURCE LINES 27-58

.. code-block:: default


    import spydrnet as sdn
    from spydrnet_tmr.transformation.replication.uniquify_nmr_property import uniquify_nmr_property
    from spydrnet.uniquify import uniquify
    from spydrnet_tmr import apply_nmr

    def run():
        netlist = sdn.load_example_netlist_by_name("b13")
        uniquify(netlist)
        hinstances_to_replicate = list(netlist.get_hinstances(recursive=True, filter=lambda x: x.item.reference.is_leaf() is True))
        instances_to_replicate = list(x.item for x in hinstances_to_replicate)
        hports_to_replicate = list(netlist.get_hports())
        ports_to_replicate = list(x.item for x in hports_to_replicate)

        replicas = apply_nmr([*instances_to_replicate, *ports_to_replicate], 3, name_suffix='TMR', rename_original=True)


        print("BEFORE UNIQUIFYING THE PROPERTY VALUE")
        for instance in netlist.get_instances():
            if 'FSM_onehot_next_bit[9]_i_2' in instance.name:
                print('\t',instance.name,instance["EDIF.properties"])


        uniquify_nmr_property(replicas, 'SOFT_HLUTNM', "TMR")


        print("\nAFTER UNIQUIFYING THE PROPERTY VALUE")
        for instance in netlist.get_instances():
            if 'FSM_onehot_next_bit[9]_i_2' in instance.name:
                print('\t',instance.name,instance["EDIF.properties"])

    run()

.. rst-class:: sphx-glr-timing

   **Total running time of the script:** ( 0 minutes  0.000 seconds)


.. _sphx_glr_download_auto_examples_basic_uniquify_nmr_property_example.py:


.. only :: html

 .. container:: sphx-glr-footer
    :class: sphx-glr-footer-example



  .. container:: sphx-glr-download sphx-glr-download-python

     :download:`Download Python source code: uniquify_nmr_property_example.py <uniquify_nmr_property_example.py>`



  .. container:: sphx-glr-download sphx-glr-download-jupyter

     :download:`Download Jupyter notebook: uniquify_nmr_property_example.ipynb <uniquify_nmr_property_example.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_