2011-01-24 05:26:27 +01:00
|
|
|
#ifndef __architec_H
|
|
|
|
|
#define __architec_H
|
|
|
|
|
/*
|
2011-07-04 22:19:37 +02:00
|
|
|
* Copyright (c) 2011 Stephen Williams (steve@icarus.com)
|
2011-01-24 05:26:27 +01:00
|
|
|
*
|
|
|
|
|
* 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
|
2012-08-29 03:41:23 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2011-01-24 05:26:27 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
# 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;
|
2012-09-08 00:14:48 +02:00
|
|
|
class GenerateStatement;
|
2011-05-15 20:07:42 +02:00
|
|
|
class SequentialStmt;
|
2011-03-22 17:16:20 +01:00
|
|
|
class Signal;
|
2011-04-01 03:50:48 +02:00
|
|
|
class named_expr_t;
|
2011-11-05 23:55:17 +01:00
|
|
|
class prange_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-04-06 17:27:58 +02:00
|
|
|
virtual void dump(ostream&out, int indent = 0) const;
|
2011-01-27 05:38:20 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
private: // Not implemented
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// Create an architecture from its name and its statements.
|
|
|
|
|
// NOTE: The statement list passed in is emptied.
|
2013-05-13 04:17:12 +02:00
|
|
|
Architecture(perm_string name, const ActiveScope&ref,
|
2011-03-22 17:16:20 +01:00
|
|
|
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);
|
|
|
|
|
|
2012-09-08 00:14:48 +02:00
|
|
|
// These methods are used while in the scope of a generate
|
|
|
|
|
// block to mark that a name is a genvar at this point.
|
|
|
|
|
const VType* probe_genvar_type(perm_string);
|
|
|
|
|
void push_genvar_type(perm_string gname, const VType*gtype);
|
|
|
|
|
void pop_genvar_type(void);
|
|
|
|
|
|
|
|
|
|
// These methods are used during EMIT to check for names that
|
|
|
|
|
// are genvar names.
|
|
|
|
|
const GenerateStatement* probe_genvar_emit(perm_string);
|
|
|
|
|
void push_genvar_emit(perm_string gname, const GenerateStatement*);
|
|
|
|
|
void pop_genvar_emit(void);
|
|
|
|
|
|
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-04-06 17:27:58 +02:00
|
|
|
void dump(ostream&out, perm_string of_entity, int indent = 0) const;
|
2011-01-24 05:26:27 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
perm_string name_;
|
2011-03-22 17:16:20 +01:00
|
|
|
// Concurrent statements local to this architecture
|
2011-01-27 05:38:20 +01:00
|
|
|
std::list<Architecture::Statement*> statements_;
|
|
|
|
|
|
2012-09-08 00:14:48 +02:00
|
|
|
struct genvar_type_t {
|
|
|
|
|
perm_string name;
|
|
|
|
|
const VType*vtype;
|
|
|
|
|
};
|
|
|
|
|
std::list<genvar_type_t> genvar_type_stack_;
|
|
|
|
|
|
|
|
|
|
struct genvar_emit_t {
|
|
|
|
|
perm_string name;
|
|
|
|
|
const GenerateStatement*gen;
|
|
|
|
|
};
|
|
|
|
|
std::list<genvar_emit_t> genvar_emit_stack_;
|
|
|
|
|
|
2011-01-24 05:26:27 +01:00
|
|
|
private: // Not implemented
|
|
|
|
|
};
|
|
|
|
|
|
2011-10-31 01:10:19 +01:00
|
|
|
/*
|
|
|
|
|
* This is a base class for various generate statement types. It holds
|
|
|
|
|
* the generate statement name, and a list of substatements.
|
|
|
|
|
*/
|
|
|
|
|
class GenerateStatement : public Architecture::Statement {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
GenerateStatement(perm_string gname, std::list<Architecture::Statement*>&s);
|
|
|
|
|
~GenerateStatement();
|
|
|
|
|
|
2012-09-08 00:14:48 +02:00
|
|
|
inline perm_string get_name() const { return name_; }
|
2011-10-31 01:10:19 +01:00
|
|
|
|
2012-09-08 00:14:48 +02:00
|
|
|
protected:
|
2011-10-31 01:10:19 +01:00
|
|
|
int elaborate_statements(Entity*ent, Architecture*arc);
|
|
|
|
|
int emit_statements(ostream&out, Entity*ent, Architecture*arc);
|
|
|
|
|
void dump_statements(ostream&out, int indent) const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
perm_string name_;
|
|
|
|
|
std::list<Architecture::Statement*> statements_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ForGenerate : public GenerateStatement {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
ForGenerate(perm_string gname, perm_string genvar,
|
2011-11-05 23:55:17 +01:00
|
|
|
prange_t*rang, std::list<Architecture::Statement*>&s);
|
2011-10-31 01:10:19 +01:00
|
|
|
~ForGenerate();
|
|
|
|
|
|
|
|
|
|
int elaborate(Entity*ent, Architecture*arc);
|
|
|
|
|
int emit(ostream&out, Entity*entity, Architecture*arc);
|
|
|
|
|
void dump(ostream&out, int ident =0) const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
perm_string genvar_;
|
|
|
|
|
Expression*lsb_;
|
|
|
|
|
Expression*msb_;
|
|
|
|
|
};
|
|
|
|
|
|
2012-03-19 01:37:19 +01:00
|
|
|
class IfGenerate : public GenerateStatement {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
IfGenerate(perm_string gname, Expression*cond,
|
|
|
|
|
std::list<Architecture::Statement*>&s);
|
|
|
|
|
~IfGenerate();
|
|
|
|
|
|
|
|
|
|
int elaborate(Entity*ent, Architecture*arc);
|
|
|
|
|
int emit(ostream&out, Entity*entity, Architecture*arc);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
Expression*cond_;
|
|
|
|
|
};
|
2011-10-31 01:10:19 +01:00
|
|
|
|
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-06-12 19:51:31 +02:00
|
|
|
SignalAssignment(ExpName*target, Expression*rval);
|
2011-01-27 05:38:20 +01:00
|
|
|
~SignalAssignment();
|
|
|
|
|
|
2011-06-12 19:51:31 +02:00
|
|
|
virtual int elaborate(Entity*ent, Architecture*arc);
|
2011-04-10 18:42:22 +02:00
|
|
|
virtual int emit(ostream&out, Entity*entity, Architecture*arc);
|
2011-04-14 04:09:51 +02:00
|
|
|
virtual void dump(ostream&out, int ident =0) const;
|
2011-01-27 05:38:20 +01:00
|
|
|
|
|
|
|
|
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,
|
2011-10-24 02:08:48 +02:00
|
|
|
std::list<named_expr_t*>*parms,
|
2011-04-01 03:50:48 +02:00
|
|
|
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-14 04:09:51 +02:00
|
|
|
virtual void dump(ostream&out, int indent =0) const;
|
2011-04-01 03:50:48 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
perm_string iname_;
|
|
|
|
|
perm_string cname_;
|
|
|
|
|
|
2011-10-24 02:08:48 +02:00
|
|
|
std::map<perm_string,Expression*> generic_map_;
|
|
|
|
|
std::map<perm_string,Expression*> port_map_;
|
2011-04-01 03:50:48 +02:00
|
|
|
};
|
|
|
|
|
|
2011-05-09 01:40:35 +02:00
|
|
|
class ProcessStatement : public Architecture::Statement {
|
|
|
|
|
|
|
|
|
|
public:
|
2011-05-15 20:07:42 +02:00
|
|
|
ProcessStatement(perm_string iname,
|
|
|
|
|
std::list<Expression*>*sensitivity_list,
|
|
|
|
|
std::list<SequentialStmt*>*statement_list);
|
2011-05-09 01:40:35 +02:00
|
|
|
~ProcessStatement();
|
|
|
|
|
|
2011-05-15 17:57:19 +02:00
|
|
|
virtual int elaborate(Entity*ent, Architecture*arc);
|
2011-05-15 20:07:42 +02:00
|
|
|
virtual int emit(ostream&out, Entity*entity, Architecture*arc);
|
2011-05-15 17:57:19 +02:00
|
|
|
virtual void dump(ostream&out, int indent =0) const;
|
|
|
|
|
|
2011-05-28 19:49:33 +02:00
|
|
|
private:
|
|
|
|
|
int rewrite_as_always_edge_(Entity*ent, Architecture*arc);
|
2011-07-04 22:19:37 +02:00
|
|
|
int extract_anyedge_(Entity*ent, Architecture*arc);
|
2011-05-28 19:49:33 +02:00
|
|
|
|
2011-05-09 01:40:35 +02:00
|
|
|
private:
|
|
|
|
|
perm_string iname_;
|
|
|
|
|
|
2011-05-15 20:07:42 +02:00
|
|
|
std::list<Expression*> sensitivity_list_;
|
|
|
|
|
std::list<SequentialStmt*> statements_list_;
|
|
|
|
|
|
2011-05-09 01:40:35 +02:00
|
|
|
};
|
|
|
|
|
|
2011-01-24 05:26:27 +01:00
|
|
|
#endif
|