2008-05-28 18:17:39 +02:00
|
|
|
/*
|
|
|
|
|
* VHDL abstract syntax elements.
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2008 Nick Gasson (nick@nickg.me.uk)
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef INC_VHDL_ELEMENT_HH
|
|
|
|
|
#define INC_VHDL_ELEMENT_HH
|
|
|
|
|
|
|
|
|
|
#include <fstream>
|
2008-05-29 17:24:16 +02:00
|
|
|
#include <list>
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class vhdl_element;
|
|
|
|
|
typedef std::list<vhdl_element*> element_list_t;
|
2008-05-28 18:17:39 +02:00
|
|
|
|
|
|
|
|
class vhdl_element {
|
2008-05-31 16:28:25 +02:00
|
|
|
public:
|
|
|
|
|
virtual ~vhdl_element() {}
|
|
|
|
|
|
2008-05-29 17:24:16 +02:00
|
|
|
virtual void emit(std::ofstream &of, int level=0) const = 0;
|
|
|
|
|
|
|
|
|
|
void set_comment(std::string comment);
|
|
|
|
|
protected:
|
|
|
|
|
void emit_comment(std::ofstream &of, int level) const;
|
|
|
|
|
private:
|
|
|
|
|
std::string comment_;
|
2008-05-28 18:17:39 +02:00
|
|
|
};
|
|
|
|
|
|
2008-05-29 17:24:16 +02:00
|
|
|
class vhdl_conc_stmt : public vhdl_element {
|
2008-05-31 16:28:25 +02:00
|
|
|
public:
|
|
|
|
|
virtual ~vhdl_conc_stmt() {}
|
2008-05-29 17:24:16 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef std::list<vhdl_conc_stmt*> conc_stmt_list_t;
|
|
|
|
|
|
|
|
|
|
class vhdl_seq_stmt : public vhdl_element {
|
2008-05-31 16:28:25 +02:00
|
|
|
public:
|
|
|
|
|
virtual ~vhdl_seq_stmt() {}
|
2008-05-29 17:24:16 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef std::list<vhdl_seq_stmt*> seq_stmt_list_t;
|
|
|
|
|
|
|
|
|
|
class vhdl_process : public vhdl_conc_stmt {
|
|
|
|
|
public:
|
|
|
|
|
vhdl_process(const char *name = NULL);
|
2008-05-31 17:08:57 +02:00
|
|
|
virtual ~vhdl_process();
|
2008-05-29 17:24:16 +02:00
|
|
|
|
|
|
|
|
void emit(std::ofstream &of, int level) const;
|
|
|
|
|
void add_stmt(vhdl_seq_stmt* stmt);
|
2008-05-28 18:17:39 +02:00
|
|
|
private:
|
2008-05-29 17:24:16 +02:00
|
|
|
seq_stmt_list_t stmts_;
|
2008-05-28 18:17:39 +02:00
|
|
|
const char *name_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class vhdl_arch : public vhdl_element {
|
|
|
|
|
public:
|
|
|
|
|
vhdl_arch(const char *entity, const char *name="Behavioural");
|
2008-05-31 17:08:57 +02:00
|
|
|
virtual ~vhdl_arch();
|
2008-05-28 18:17:39 +02:00
|
|
|
|
2008-05-29 17:24:16 +02:00
|
|
|
void emit(std::ofstream &of, int level=0) const;
|
|
|
|
|
void add_stmt(vhdl_conc_stmt* stmt);
|
2008-05-28 18:17:39 +02:00
|
|
|
private:
|
2008-05-29 17:24:16 +02:00
|
|
|
conc_stmt_list_t stmts_;
|
2008-05-28 18:17:39 +02:00
|
|
|
const char *name_, *entity_;
|
|
|
|
|
};
|
|
|
|
|
|
2008-05-31 16:28:25 +02:00
|
|
|
class vhdl_entity : public vhdl_element {
|
|
|
|
|
public:
|
|
|
|
|
vhdl_entity(const char *name, vhdl_arch *arch);
|
2008-05-31 17:08:57 +02:00
|
|
|
virtual ~vhdl_entity();
|
2008-05-31 16:28:25 +02:00
|
|
|
|
|
|
|
|
void emit(std::ofstream &of, int level=0) const;
|
|
|
|
|
vhdl_arch *get_arch() const { return arch_; }
|
|
|
|
|
const char *get_name() const { return name_; }
|
|
|
|
|
private:
|
|
|
|
|
const char *name_;
|
|
|
|
|
vhdl_arch *arch_; // Entity may only have a single architecture
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef std::list<vhdl_entity*> entity_list_t;
|
|
|
|
|
|
|
|
|
|
|
2008-05-28 18:17:39 +02:00
|
|
|
#endif
|
2008-05-29 17:24:16 +02:00
|
|
|
|