2011-01-24 05:26:27 +01:00
|
|
|
#ifndef __architec_H
|
|
|
|
|
#define __architec_H
|
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2011Stephen Williams (steve@icarus.com)
|
|
|
|
|
*
|
|
|
|
|
* This source code is free software; you can redistribute it
|
|
|
|
|
* and/or modify it in source code form 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
# include "StringHeap.h"
|
|
|
|
|
# include "LineInfo.h"
|
2011-04-14 03:30:00 +02:00
|
|
|
# include "scope.h"
|
2011-01-27 05:38:20 +01:00
|
|
|
# include <list>
|
2011-03-22 17:16:20 +01:00
|
|
|
# include <map>
|
2011-01-24 05:26:27 +01:00
|
|
|
|
2011-03-22 17:16:20 +01:00
|
|
|
class ComponentBase;
|
2011-01-31 20:16:14 +01:00
|
|
|
class Entity;
|
2011-01-30 02:27:30 +01:00
|
|
|
class Expression;
|
2011-03-27 21:01:58 +02:00
|
|
|
class ExpName;
|
2011-03-22 17:16:20 +01:00
|
|
|
class Signal;
|
2011-04-01 03:50:48 +02:00
|
|
|
class named_expr_t;
|
2011-01-30 02:27:30 +01:00
|
|
|
|
2011-01-27 05:38:20 +01:00
|
|
|
/*
|
|
|
|
|
* The Architecture class carries the contents (name, statements,
|
|
|
|
|
* etc.) of a parsed VHDL architecture. These objects are ultimately
|
|
|
|
|
* put into entities.
|
|
|
|
|
*/
|
2011-04-14 03:30:00 +02:00
|
|
|
class Architecture : public Scope, public LineInfo {
|
2011-01-24 05:26:27 +01:00
|
|
|
|
|
|
|
|
public:
|
2011-01-27 05:38:20 +01:00
|
|
|
// Architectures contain concurrent statements, that are
|
|
|
|
|
// derived from this nested class.
|
|
|
|
|
class Statement : public LineInfo {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
Statement();
|
|
|
|
|
virtual ~Statement() =0;
|
|
|
|
|
|
2011-04-10 18:42:22 +02:00
|
|
|
virtual int elaborate(Entity*ent, Architecture*arc);
|
2011-01-31 20:16:14 +01:00
|
|
|
virtual int emit(ostream&out, Entity*ent, Architecture*arc);
|
2011-01-27 05:38:20 +01:00
|
|
|
virtual void dump(ostream&out) const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
private: // Not implemented
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// Create an architecture from its name and its statements.
|
|
|
|
|
// NOTE: The statement list passed in is emptied.
|
2011-03-22 17:16:20 +01:00
|
|
|
Architecture(perm_string name, std::map<perm_string,Signal*>&sigs,
|
|
|
|
|
std::map<perm_string,ComponentBase*>&comps,
|
|
|
|
|
std::list<Architecture::Statement*>&s);
|
2011-01-24 05:26:27 +01:00
|
|
|
~Architecture();
|
|
|
|
|
|
|
|
|
|
perm_string get_name() const { return name_; }
|
|
|
|
|
|
2011-03-27 21:01:58 +02:00
|
|
|
// Elaborate this architecture in the context of the given entity.
|
|
|
|
|
int elaborate(Entity*entity);
|
|
|
|
|
|
2011-01-31 20:16:14 +01:00
|
|
|
// Emit this architecture to the given out file in the context
|
|
|
|
|
// of the specified entity. This method is used by the
|
|
|
|
|
// elaborate code to display generated code to the specified
|
|
|
|
|
// output.
|
|
|
|
|
int emit(ostream&out, Entity*entity);
|
|
|
|
|
|
|
|
|
|
// The dump method writes a debug display to the given output.
|
2011-01-24 05:26:27 +01:00
|
|
|
void dump(ostream&out, perm_string of_entity) const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
perm_string name_;
|
2011-03-22 17:16:20 +01:00
|
|
|
// Signals declared local to this architecture
|
|
|
|
|
std::map<perm_string,Signal*> signals_;
|
|
|
|
|
// Concurrent statements local to this architecture
|
2011-01-27 05:38:20 +01:00
|
|
|
std::list<Architecture::Statement*> statements_;
|
|
|
|
|
|
2011-01-24 05:26:27 +01:00
|
|
|
private: // Not implemented
|
|
|
|
|
};
|
|
|
|
|
|
2011-01-27 05:38:20 +01:00
|
|
|
/*
|
|
|
|
|
* The SignalAssignment class represents the
|
|
|
|
|
* concurrent_signal_assignment that is placed in an architecture.
|
|
|
|
|
*/
|
|
|
|
|
class SignalAssignment : public Architecture::Statement {
|
|
|
|
|
|
|
|
|
|
public:
|
2011-03-27 21:01:58 +02:00
|
|
|
SignalAssignment(ExpName*target, std::list<Expression*>&rval);
|
2011-01-27 05:38:20 +01:00
|
|
|
~SignalAssignment();
|
|
|
|
|
|
2011-04-10 18:42:22 +02:00
|
|
|
virtual int emit(ostream&out, Entity*entity, Architecture*arc);
|
2011-01-27 05:38:20 +01:00
|
|
|
virtual void dump(ostream&out) const;
|
|
|
|
|
|
|
|
|
|
private:
|
2011-03-27 21:01:58 +02:00
|
|
|
ExpName*lval_;
|
2011-01-30 02:27:30 +01:00
|
|
|
std::list<Expression*> rval_;
|
2011-01-27 05:38:20 +01:00
|
|
|
};
|
|
|
|
|
|
2011-04-01 03:50:48 +02:00
|
|
|
class ComponentInstantiation : public Architecture::Statement {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
ComponentInstantiation(perm_string iname, perm_string cname,
|
|
|
|
|
std::list<named_expr_t*>*ports);
|
|
|
|
|
~ComponentInstantiation();
|
|
|
|
|
|
2011-04-10 18:42:22 +02:00
|
|
|
virtual int elaborate(Entity*ent, Architecture*arc);
|
|
|
|
|
virtual int emit(ostream&out, Entity*entity, Architecture*arc);
|
2011-04-01 03:50:48 +02:00
|
|
|
virtual void dump(ostream&out) const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
perm_string iname_;
|
|
|
|
|
perm_string cname_;
|
|
|
|
|
|
|
|
|
|
std::map<perm_string,Expression*> port_map_;
|
|
|
|
|
};
|
|
|
|
|
|
2011-01-24 05:26:27 +01:00
|
|
|
#endif
|