================================== How to use the ``soclib_desc`` API ================================== Let's do a step-by-step use of the :py:mod:`soclib_desc` API:: >>> from soclib_desc import description_files Let's take a ``vci_xcache_wrapper`` module from the index, and put it in a variable:: >>> vci_xcache_mod = description_files.get_module("caba:vci_xcache_wrapper") Object pointed by ``vci_xcache_mod`` implements the :py:class:`~soclib_desc.module.ModuleInterface` protocol. We can list template parameters to specify in order to create a `Specialization`:: >>> for p in vci_xcache_mod.get_template_parameters(): ... print p ... We can create the specialization:: >>> vci_xcache_spec = vci_xcache_mod.specialize( ... cell_size = 4, plen_size = 8, addr_size = 32, rerror_size = 1, ... clen_size = 1, rflag_size = 1, srcid_size = 8, pktid_size = 4, ... trdid_size = 4, wrplen_size = 1, ... iss_t = "common:mips32el") >>> vci_xcache_spec.__class__ ``vci_xcache_spec`` implements the :py:class:`~soclib_desc.specialization.SpecializationInterface` protocol:: >>> vci_xcache_spec.get_entity_name() 'soclib::caba::VciXcacheWrapper ,soclib::common::Mips32ElIss > ' >>> for spec in vci_xcache_spec.get_used_modules(): ... print spec.get_entity_name() ... soclib::common::AddressDecodingTable soclib::WriteBuffer soclib::common::Iss2 soclib::common::AddressDecodingTable soclib::common::AddressMaskingTable sc_core::sc_in > sc_core::sc_in > soclib::common::AddressDecodingTable sc_core::sc_in soclib::caba::VciXcacheWrapper ,soclib::common::Mips32ElIss > sc_core::sc_out sc_core::sc_in > soclib::common::AddressMaskingTable soclib::common::IntTab soclib::GenericCache soclib::common::MappingTable soclib::caba::BaseModule soclib::common::Mips32Iss soclib::caba::VciInitiator > soclib::common::BaseModule sc_core::sc_in > soclib::common::AddressDecodingTable sc_core::sc_in > soclib::common::Segment soclib::caba::VciParams<4,8,32,1,1,1,8,4,4,1 > soclib::common::Mips32ElIss sc_core::sc_in And finally we can get the :py:class:`builder `, its results :py:class:`~soclib_builder.bblock.BBlock` objects, and the associated :py:class:`~soclib_builder.action.Action`:: >>> b = vci_xcache_spec.builder() >>> for r in b.results(): ... print r.generator ... _,soclib::common::Mips32ElIss_>__vci_xcache_wrapper.cpp}'] -> ['{caba:vci_xcache_wrapper_7759636b764157b_soclib::caba::VciXcacheWrapper_,soclib::common::Mips32ElIss_>__vci_xcache_wrapper.o}'] + []> We can also list the ports of the `Specialization`:: >>> pl = vci_xcache_spec.port_list() >>> for name, portdecl in pl.items(): ... print name, portdecl.specialization.get_entity_name() ... p_vci soclib::caba::VciInitiator > p_clk sc_core::sc_in p_resetn sc_core::sc_in p_irq sc_core::sc_in And retrieve the corresponding headers:: >>> for f in vci_xcache_spec.get_header_files(): ... print f /soclib/soclib/module/internal_component/vci_xcache_wrapper/caba/source/include/vci_xcache_wrapper.h Or get the instance parameter list:: >>> for p in vci_xcache_spec.get_instance_parameters(): ... print p ...