|
degate 0.1.1
|
00001 /* -*-c++-*- 00002 00003 This file is part of the IC reverse engineering tool degate. 00004 00005 Copyright 2008, 2009, 2010 by Martin Schobert 00006 00007 Degate is free software: you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation, either version 3 of the License, or 00010 any later version. 00011 00012 Degate is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with degate. If not, see <http://www.gnu.org/licenses/>. 00019 00020 */ 00021 00022 #ifndef __VHDLCODETEMPLATEGENERATOR_H__ 00023 #define __VHDLCODETEMPLATEGENERATOR_H__ 00024 00025 #include <degate.h> 00026 #include <tr1/memory> 00027 #include <cctype> 00028 00029 #include <CodeTemplateGenerator.h> 00030 #include <boost/foreach.hpp> 00031 00032 namespace degate { 00033 00034 /** 00035 * A code template generator for VHDL. 00036 */ 00037 00038 class VHDLCodeTemplateGenerator : public CodeTemplateGenerator { 00039 public: 00040 00041 VHDLCodeTemplateGenerator(std::string const& entity_name, 00042 std::string const& description, 00043 std::string const& logic_class); 00044 00045 virtual ~VHDLCodeTemplateGenerator(); 00046 00047 virtual std::string generate() const; 00048 00049 typedef std::map<std::string, std::string> port_map_type; 00050 00051 protected: 00052 00053 virtual std::string generate_header() const; 00054 00055 virtual std::string generate_port_description() const; 00056 00057 virtual std::string generate_entity(std::string const& entity_name, 00058 std::string const& port_description = "") const; 00059 00060 virtual std::string generate_component(std::string const& entity_name, 00061 std::string const& port_description) const; 00062 00063 virtual std::string generate_architecture(std::string const& entity_name, 00064 std::string const& header, 00065 std::string const& impl) const; 00066 00067 virtual std::string generate_impl(std::string const& logic_class) const; 00068 00069 00070 virtual std::string generate_instance(std::string const& instance_name, 00071 std::string const& instance_type, 00072 port_map_type const& port_map) const; 00073 00074 /** 00075 * Generate a VHDL complient identifier from a string. 00076 * 00077 * VHDL identifier: 00078 * 00079 * - Must begin with alphabetic characters (a-z or A-Z) 00080 * - Can contain alphanumeric (a-z, A-Z, 0-9) or underscore (_) characters 00081 * - Can be up to 1024 characters long 00082 * - Cannot contain white space 00083 * - are not case sensitive. 00084 */ 00085 virtual std::string generate_identifier(std::string const& name, 00086 std::string const& prefix = "") const; 00087 00088 using CodeTemplateGenerator::generate_identifier; 00089 00090 }; 00091 00092 typedef std::tr1::shared_ptr<VHDLCodeTemplateGenerator> VHDLCodeTemplateGenerator_shptr; 00093 00094 } 00095 00096 #endif
1.7.4