List of all members | Public Member Functions
core_gate_simulation Struct Reference

A gate simulation implementation of gate_simulation_func. More...

Public Member Functions

boost::dynamic_bitset & operator() (const gate &g, boost::dynamic_bitset<> &input) const
 Simulation for a single gate g. More...
 

Detailed Description

A gate simulation implementation of gate_simulation_func.

This functor performs simulation on a boost::dynamic_bitset<> for Toffoli, Fredkin, and Peres gates for binary values only.

When adding new simulation functors, you can make use of this one, for example when extending the gate library. Note, that you do not have to derive from this class for this purpose, but can use the following:

// somewhere a new target tag
struct my_gate_tag {};
bool is_my_gate( const gate& g )
{
return is_type<my_gate>( g.type() );
}
// ...
// extend simulation
struct extended_gate_simulation
{
boost::dynamic_bitset<>& operator()( const gate& g, boost::dynamic_bitset<>& input ) const
{
if ( is_my_gate( g )
{
// change input according to the semantics of the new gate type
// ...
// and return it finally
return input;
}
else
{
// it is a core gate
return core_simulation( g, input );
}
}
private:
core_gate_simulation core_simulation;
};
// use it somewhere
circuit circ( ... ); // some circuit with my_gate gates
boost::dynamic_bitset<> output;
boost::dynamic_bitset<> input( 4, 10 ); // value 1010
properties::ptr settings( new properties() );
settings.set( "gate_simulation", extended_gate_simulation() );
simple_simulation( output, circ, input, settings );
Author
RevKit
Since
1.0

Member Function Documentation

boost::dynamic_bitset& operator() ( const gate g,
boost::dynamic_bitset<> &  input 
) const

Simulation for a single gate g.

This operator performs simulation for a single gate and is called by simple_simulation.

Important: The return value always has to be input, and the operator should modify input directly.

Parameters
gThe gate to be simulated
inputAn input pattern
Returns
Returns a output pattern, it will be the same reference as input
Author
RevKit
Since
1.0

The documentation for this struct was generated from the following file:

Generated on Tue Apr 16 2013 08:12:02 for RevKit by doxygen 1.8.3.1