.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/basic/plot_xilinx_generic_tmr.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_basic_plot_xilinx_generic_tmr.py: Xilinx TMR =========== This is a xilinx TMR example using SpyDrNet TMR The number of times each primitive is instanced before and after triplicating will be printed. .. GENERATED FROM PYTHON SOURCE LINES 8-95 .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Identified 4 insertion points for reduction voters. {(, ), (, ), (, ), (, )} Primitive count before and after TMR: BUFG : 1 --> 3 IBUF : 4 --> 12 LUT1 : 1 --> 3 LUT3 : 1 --> 7 LUT4 : 1 --> 3 LUT5 : 1 --> 3 OBUF : 4 --> 12 FDCE : 4 --> 12 INV : 0 --> 0 | .. code-block:: default import spydrnet as sdn from spydrnet.uniquify import uniquify from spydrnet_tmr import apply_nmr, insert_organs from spydrnet_tmr.support_files.vendor_names import XILINX from spydrnet_tmr.apply_tmr_to_netlist import apply_tmr_to_netlist from spydrnet_tmr.analysis.voter_insertion.find_reduction_voter_points import find_reduction_voter_points from spydrnet_tmr.transformation.replication.organ import XilinxTMRVoter # set_property design_mode GateLvl [current_fileset] # set_property edif_top_file [current_fileset] # link_design -part -mode out_of_context netlist = sdn.load_example_netlist_by_name( "fourBitCounter" ) # loading an example, use `sdn.parse()` otherwise # uniquify is called to insure that non-leaf definitions are instanced only once, prevents unintended transformations. uniquify(netlist) # set instances_to_replicate [get_cells -hierarchical -filter {PRIMITIVE_LEVEL==LEAF||PRIMITIVE_LEVEL==MACRO}] hinstances_to_replicate = list( netlist.get_hinstances( recursive=True, filter=lambda x: x.item.reference.is_leaf() is True ) ) # set ports_to_replicate [get_ports] hports_to_replicate = list( netlist.get_hports(filter=lambda x: x.item.direction is sdn.IN) ) instances_to_replicate = list(x.item for x in hinstances_to_replicate) ports_to_replicate = list(x.item for x in hports_to_replicate) # valid_voter_point_dict = dict() # valid_voter_point_dict["reduction"] = [ # *netlist.get_hports(), # *hinstances_to_replicate, # ] # # find out where to insert reduction voters # netlist = apply_tmr_to_netlist( # netlist, # XILINX, # hinstances_and_hports_to_replicate=[ # *hports_to_replicate, # *hinstances_to_replicate, # ], # valid_voter_point_dict=valid_voter_point_dict, insertion_points = find_reduction_voter_points(netlist, [*hinstances_to_replicate, *hports_to_replicate], XILINX ) replicas = apply_nmr( [*instances_to_replicate, *ports_to_replicate], 3, name_suffix="TMR", rename_original=True, ) print(insertion_points) voters = insert_organs(replicas, insertion_points, XilinxTMRVoter(), "VOTER") # ) # print the number of times each primitive is instanced def instance_count(original_netlist, new_netlist): print("\nPrimitive count before and after TMR:") primitives_library = next( new_netlist.get_libraries("hdi_primitives"), None ) for primitive in primitives_library.get_definitions(): i = 0 j = 0 for instance in original_netlist.get_instances(): if primitive.name == instance.reference.name: i += 1 for instance in new_netlist.get_instances(): if primitive.name == instance.reference.name: j += 1 print("\t", primitive.name, ": ", i, " --> ", j) instance_count(sdn.load_example_netlist_by_name("fourBitCounter"), netlist) .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.017 seconds) .. _sphx_glr_download_auto_examples_basic_plot_xilinx_generic_tmr.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: plot_xilinx_generic_tmr.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_xilinx_generic_tmr.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_