InstLib.hpp
This file maintains information about instructions availabel in virtual hardware.
Enums
-
template<typename HARDWARE_T, typename ARG_T = size_t, size_t ARG_COUNT = 3>
class InstLib - #include <InstLib.hpp>
InstLib maintains a set of instructions for use in virtual hardware.
- Template Parameters:
HARDWARE_T – Type of the virtual hardware class to track instructions.
ARG_T – What types of arguments are associated with instructions.
ARG_COUNT – Max number of arguments on an instruction.
Public Types
-
using hardware_t = HARDWARE_T
-
using inst_t = typename hardware_t::inst_t
-
using fun_t = std::function<void(hardware_t&, const inst_t&)>
Public Functions
-
inline const std::string &GetName(size_t idx) const
Return the name associated with the specified instruction ID.
-
inline const fun_t &GetFunction(size_t idx) const
Return the function associated with the specified instruction ID.
-
inline size_t GetNumArgs(size_t idx) const
Return the number of arguments expected for the specified instruction ID.
-
inline const std::string &GetDesc(size_t idx) const
Return the provided description for the providxed instruction ID.
-
inline ScopeType GetScopeType(size_t idx) const
What type of scope does this instruction state? ScopeType::NONE is default.
-
inline size_t GetScopeArg(size_t idx) const
If this instruction alters scope, idxentify which argument does so.
-
inline const inst_properties_t &GetProperties(size_t idx) const
Return the set of properties for the providxed instruction ID.
-
inline char GetSymbol(size_t idx) const
-
inline bool HasProperty(size_t idx, std::string property) const
Does the given instruction ID have the given property value?
-
inline size_t GetSize() const
Get the number of instructions in this set.
-
inline bool IsInst(const std::string name) const
Returns boolean indicating whether the given string is a valid instruction.
-
inline size_t GetID(const size_t idx) const
-
inline size_t GetID(const std::string &name) const
Return the ID of the instruction that has the specified name.
-
inline size_t GetIDFromSymbol(char symbol) const
Return the ID of the instruction associated with the specified symbol.
-
inline size_t GetIndex(const std::string &name) const
Return the ID of the instruction that has the specified name.
-
inline size_t GetIndex(const size_t id) const
Return the ID of the instruction that has the specified id.
-
inline size_t GetIndexFromSymbol(char symbol) const
-
inline arg_t GetArg(const std::string &name)
Return the argument value associated with the provided keyword.
-
inline void AddInst(const std::string &name, const fun_t &fun_call, size_t num_args = 0, const std::string &desc = "", ScopeType scope_type = ScopeType::NONE, size_t scope_arg = (size_t)-1, const inst_properties_t &inst_properties = inst_properties_t(), int _id = -1)
Add a new instruction to the set.
- Parameters:
name – A unique string name for this instruction.
fun_call – The function that should be called when this instruction is executed.
num_args – How many arguments does this function require? (default=0)
desc – A description of how this function operates. (default=””)
scope_type – Type of scope does this instruction creates. (default=ScopeType::NONE)
scope_arg – If instruction changes scope, which argument specifies new scope? (default=-1)
inst_properties – Strings representing arbitrary properties associated with instruction
-
inline virtual void ProcessInst(hardware_t &hw, const inst_t &inst) const
Process a specified instruction in the provided hardware.
-
template<typename IN_HW>
inline void ProcessInst(Ptr<IN_HW> hw, const inst_t &inst) const Process a specified instruction on hardware that can be converted to the correct type.
-
inline void WriteGenome(const genome_t &genome, std::ostream &os = std::cout) const
Write out a full genome to the provided ostream.
Protected Attributes
-
std::string symbol_defaults = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*~_=,.|/\\><"
Symbols to use when representing individual instructions (80).
-
char extra_symbol = '+'
Symbol for more instructions than fit above.
-
struct InstDef
- #include <InstLib.hpp>
Public Functions
-
inline InstDef(size_t _idx, size_t _id, const std::string &_n, fun_t _fun, size_t _args, const std::string &_d, ScopeType _s_type, size_t _s_arg, const inst_properties_t &_properties = inst_properties_t(), char _sym = '?')
-
inline InstDef(size_t _idx, size_t _id, const std::string &_n, fun_t _fun, size_t _args, const std::string &_d, ScopeType _s_type, size_t _s_arg, const inst_properties_t &_properties = inst_properties_t(), char _sym = '?')
-
struct InstructionBase
- #include <InstLib.hpp>