#ifndef OPENFPGA_PORT_PARSER_H #define OPENFPGA_PORT_PARSER_H /******************************************************************** * Include header files that are required by data structure declaration *******************************************************************/ #include #include #include "vtr_ndmatrix.h" #include "vtr_geometry.h" #include "openfpga_port.h" #include "openfpga_tokenizer.h" /************************************************************************ * This file includes parsers for port definition in the architecture XML * language. Note that it is also compatiable to Verilog syntax. * It means we may reuse this for constructing a structural Verilog parser ***********************************************************************/ /* namespace openfpga begins */ namespace openfpga { /************************************************************************ * Class PortParser: single port parser * Supported port definition: * 1. [:] * 2. [:] * 3. [] * 4. [] * 5. * In case 4 and 5, we will assign (-1,-1) for LSB and MSB ***********************************************************************/ class PortParser{ public : /* Constructors*/ PortParser (const std::string& data); public : /* Public Accessors */ std::string data() const; BasicPort port() const; public : /* Public Mutators */ void set_data(const std::string& data); private : /* Private Mutators */ void parse(); void set_default_bracket(); void set_default_delim(); private: /* Internal data */ std::string data_; /* Lines to be splited */ vtr::Point bracket_; char delim_; BasicPort port_; }; /************************************************************************ * MultiPortParser: a parser for multiple ports in one line ***********************************************************************/ class MultiPortParser { public : /* Constructors*/ MultiPortParser (const std::string& data); public : /* Public Accessors */ std::string data() const; std::vector ports() const; public : /* Public Mutators */ void set_data(const std::string& data); private : /* Private Mutators */ void parse(); void set_default_delim(); void clear(); private: /* Internal data */ std::string data_; /* Lines to be splited */ char delim_; std::vector ports_; }; /************************************************************************ * PortDelayParser: a parser for 2D delay matrix ***********************************************************************/ class PortDelayParser { public : /* Constructors*/ PortDelayParser (const std::string& data); public : /* Public Accessors */ std::string data() const; size_t height() const; size_t width() const; vtr::Point delay_size() const; float delay(size_t x, size_t y) const; public : /* Public Mutators */ void set_data(const std::string& data); private : /* Private Mutators */ void parse(); void set_default_element_delim(); void set_default_line_delim(); void clear(); private: /* Internal data */ std::string data_; /* Lines to be splited */ std::vector element_delim_; std::vector line_delim_; vtr::Matrix delay_matrix_; }; } /* namespace openfpga ends */ #endif