Control logic
The file mockturtle/generators/control.hpp implements several functions to
generate control logic networks.
-
template<class Ntk>
inline std::vector<signal<Ntk>> mockturtle::constant_word(Ntk &ntk, uint64_t value, uint32_t bitwidth) Creates a word from a constant.
Creates a vector of
bitwidthconstants that represent the positive numbervalue.
-
template<class Ntk>
inline std::vector<signal<Ntk>> mockturtle::zero_extend(Ntk &ntk, std::vector<signal<Ntk>> const &a, uint32_t bitwidth) Extends a word by leading zeros.
Adds leading zeros as most-significant bits to word
a. The size ofamust be smaller or equal tobitwidth, which is the width of the resulting word.
-
template<class Ntk>
inline void mockturtle::mux_inplace(Ntk &ntk, signal<Ntk> const &cond, std::vector<signal<Ntk>> &t, std::vector<signal<Ntk>> const &e) Creates a 2k-k MUX (array of k 2-1 MUXes).
This creates k MUXes using
condas condition signal andtfor the then signals andefor the else signals. The method works in-place and writes the outputs of the networ intot.
-
template<class Ntk>
std::vector<signal<Ntk>> mockturtle::binary_decoder(Ntk &ntk, std::vector<signal<Ntk>> const &xs) Creates k-to-2^k binary decoder.
Given k signals
xs, this function creates 2^k signals of which exactly one input is 1, for each of the 2^k input assignments toxs.
-
template<class Ntk>
signal<Ntk> mockturtle::binary_mux(Ntk &ntk, std::vector<signal<Ntk>> const &sel, std::vector<signal<Ntk>> data) Creates 2^k MUX.
Given k select signals
seland 2^k data signalsdata, this function creates a logic network that outputsdata[i]wheniis the encoded assignment ofsel.This is an iterative construction based on MUX gates. A more efficient method may be provided by the Klein-Paterson variant
binary_mux_klein_paterson.
-
template<class Ntk>
signal<Ntk> mockturtle::binary_mux_klein_paterson(Ntk &ntk, std::vector<signal<Ntk>> const &sel, std::vector<signal<Ntk>> const &data) Creates 2^k MUX.
Given k select signals
seland 2^k data signalsdata, this function creates a logic network that outputsdata[i]wheniis the encoded assignment ofsel.This Klein-Paterson variant uses fewer gates than the direct method
binary_mux(see Klein, & Paterson. (1980). Asymptotically Optimal Circuit for a Storage Access Function. IEEE Transactions on Computers, C-29(8), 737–738. doi:10.1109/tc.1980.1675657 )