Implementation of revlib_processor to construct a circuit. More...
Public Member Functions | |
circuit_processor (circuit &circ) | |
Default constructor. | |
virtual | ~circuit_processor () |
Default deconstructor. | |
Protected Member Functions | |
virtual void | on_comment (const std::string &comment) const |
Called when parsing comments. | |
virtual void | on_numvars (unsigned numvars) const |
Called when parsing .numvars command. | |
virtual void | on_inputs (std::vector< std::string >::const_iterator first, std::vector< std::string >::const_iterator last) const |
Called when parsing .inputs command. | |
virtual void | on_outputs (std::vector< std::string >::const_iterator first, std::vector< std::string >::const_iterator last) const |
Called when parsing .outputs command. | |
virtual void | on_constants (std::vector< constant >::const_iterator first, std::vector< constant >::const_iterator last) const |
Called when parsing the .constants command. | |
virtual void | on_garbage (std::vector< bool >::const_iterator first, std::vector< bool >::const_iterator last) const |
Called when parsing .garbage command. | |
virtual void | on_inputbus (const std::string &name, const std::vector< unsigned > &line_indices) const |
Called when parsing .inputbus command. | |
virtual void | on_outputbus (const std::string &name, const std::vector< unsigned > &line_indices) const |
Called when parsing .outputbus command. | |
virtual void | on_state (const std::string &name, const std::vector< unsigned > &line_indices, unsigned initial_value) const |
Called when parsing .state command. | |
virtual void | on_module (const std::string &name, const boost::optional< std::string > &filename) const |
Called when parsing .module command. | |
virtual void | on_gate (const boost::any &target_type, const std::vector< unsigned > &line_indices) const |
Called when a gate is parsed. | |
virtual void | on_end () const |
Called when parsing .end command. |
Implementation of revlib_processor to construct a circuit.
This class inherits from revlib_processor and constructs a circuit when parsing a realization file.
For convinience the function read_realization(circuit&, const std::string&, std::string*) wraps the use of this class to read circuits from a file.
circuit_processor | ( | circuit & | circ | ) | [explicit] |
Default constructor.
Initializes private data
circ | An empty circuit which will be constructed and filled with gates while parsing the circuit |
virtual ~circuit_processor | ( | ) | [virtual] |
Default deconstructor.
Clears private data
virtual void on_comment | ( | const std::string & | comment | ) | const [protected, virtual] |
Called when parsing comments.
This method is called when a comment (starting with a #) is parsed. The comment (text after the #) is stored in the parameter comment
.
comment | Comment (single line) |
Reimplemented from revlib_processor.
virtual void on_constants | ( | std::vector< constant >::const_iterator | first, |
std::vector< constant >::const_iterator | last | ||
) | const [protected, virtual] |
Called when parsing the .constants command.
This method is called when a .constants command is parsed. The constant in a std::vector can be accessed via their first
and last
iterator. A optional boolean value indicates whether the line is constant or not and in case it is constant, which constant line is represented.
first | Begin iterator of constants vector |
last | End iterator of constants vector |
Reimplemented from revlib_processor.
virtual void on_end | ( | ) | const [protected, virtual] |
Called when parsing .end command.
This method is called when a .end command is parsed.
Reimplemented from revlib_processor.
virtual void on_garbage | ( | std::vector< bool >::const_iterator | first, |
std::vector< bool >::const_iterator | last | ||
) | const [protected, virtual] |
Called when parsing .garbage command.
This method is called when a .garbage command is parsed. The garbage in a std::vector can be accessed via their first
and last
iterator. A boolean value indicates whether the line has a garbage output or not.
first | Begin iterator of garbage vector |
last | End iterator of garbage vector |
Reimplemented from revlib_processor.
virtual void on_gate | ( | const boost::any & | target_type, |
const std::vector< unsigned > & | line_indices | ||
) | const [protected, virtual] |
Called when a gate is parsed.
This method is called when a gate is parsed providing the gate type in parameter target_type
and all connected line via their zero-index indices.
The last indices in the list line_indices
are the target lines. The number of target lines depends on the corresponding gate type.
target_type | Target type of the target line(s). |
line_indices | All connected lines, both control and target lines. |
Reimplemented from revlib_processor.
virtual void on_inputbus | ( | const std::string & | name, |
const std::vector< unsigned > & | line_indices | ||
) | const [protected, virtual] |
Called when parsing .inputbus command.
This method is called when a .inputbus command is parsed. The first parameter name
is the name of the bus, whereas the corresponding variables can be accessed via the second parameter line_indices
, which already contains the indices rather than the variable names.
name | Name of the bus |
line_indices | Line indices of the variables of the bus |
Reimplemented from revlib_processor.
virtual void on_inputs | ( | std::vector< std::string >::const_iterator | first, |
std::vector< std::string >::const_iterator | last | ||
) | const [protected, virtual] |
Called when parsing .inputs command.
This method is called when a .inputs command is parsed. The inputs in a std::vector can be accessed via their first
and last
iterator.
first | Begin iterator of inputs vector |
last | End iterator of inputs vector |
Reimplemented from revlib_processor.
virtual void on_module | ( | const std::string & | name, |
const boost::optional< std::string > & | filename | ||
) | const [protected, virtual] |
Called when parsing .module command.
This method is called when a .module command is parsed.
name | Name of the module (used later to add gates) |
filename | File-name of the module circuit |
Reimplemented from revlib_processor.
virtual void on_numvars | ( | unsigned | numvars | ) | const [protected, virtual] |
Called when parsing .numvars command.
This method is called when a .numvars command is parsed. The number of variables is stored in the parameter numvars
.
numvars | Number of variables |
Reimplemented from revlib_processor.
virtual void on_outputbus | ( | const std::string & | name, |
const std::vector< unsigned > & | line_indices | ||
) | const [protected, virtual] |
Called when parsing .outputbus command.
This method is called when a .outputbus command is parsed. The first parameter name
is the name of the bus, whereas the corresponding variables can be accessed via the second parameter line_indices
, which already contains the indices rather than the variable names.
name | Name of the bus |
line_indices | Line indices of the variables of the bus |
Reimplemented from revlib_processor.
virtual void on_outputs | ( | std::vector< std::string >::const_iterator | first, |
std::vector< std::string >::const_iterator | last | ||
) | const [protected, virtual] |
Called when parsing .outputs command.
This method is called when a .outputs command is parsed. The outputs in a std::vector can be accessed via their first
and last
iterator.
first | Begin iterator of outputs vector |
last | End iterator of outputs vector |
Reimplemented from revlib_processor.
virtual void on_state | ( | const std::string & | name, |
const std::vector< unsigned > & | line_indices, | ||
unsigned | initial_value | ||
) | const [protected, virtual] |
Called when parsing .state command.
This method is called when a .state command is parsed. The first parameter name
is the name of the state (bus), whereas the corresponding variables can be accessed via the second parameter line_indices
, which already contains the indices rather than the variable names.
A .state command is modeled like a bus since it can contain more than one line index. Even if the state contains only one signal, this pattern is used.
name | Name of the state (bus) |
line_indices | Line indices of the variables of the state (bus) |
initial_value | Initial value for the state signal |
Reimplemented from revlib_processor.