2011-05-09 01:40:35 +02:00
|
|
|
#ifndef __sequential_H
|
|
|
|
|
#define __sequential_H
|
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2011 Stephen 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 "LineInfo.h"
|
|
|
|
|
# include <list>
|
|
|
|
|
|
2011-05-15 20:07:42 +02:00
|
|
|
class Architecture;
|
|
|
|
|
class Entity;
|
2011-05-09 01:40:35 +02:00
|
|
|
class Expression;
|
|
|
|
|
|
|
|
|
|
class SequentialStmt : public LineInfo {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
SequentialStmt();
|
2011-05-15 20:07:42 +02:00
|
|
|
virtual ~SequentialStmt() =0;
|
2011-05-09 01:40:35 +02:00
|
|
|
|
2011-05-15 20:07:42 +02:00
|
|
|
public:
|
2011-05-16 01:17:51 +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);
|
|
|
|
|
virtual void dump(ostream&out, int indent) const;
|
2011-05-09 01:40:35 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class IfSequential : public SequentialStmt {
|
|
|
|
|
|
2011-06-12 19:51:31 +02:00
|
|
|
public:
|
|
|
|
|
class Elsif : public LineInfo {
|
|
|
|
|
public:
|
|
|
|
|
Elsif(Expression*cond, std::list<SequentialStmt*>*tr);
|
|
|
|
|
~Elsif();
|
|
|
|
|
|
2011-06-23 03:13:40 +02:00
|
|
|
int elaborate(Entity*entity, Architecture*arc);
|
|
|
|
|
int condition_emit(ostream&out, Entity*entity, Architecture*arc);
|
|
|
|
|
int statement_emit(ostream&out, Entity*entity, Architecture*arc);
|
|
|
|
|
|
2011-06-12 19:51:31 +02:00
|
|
|
void dump(ostream&out, int indent) const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
Expression*cond_;
|
|
|
|
|
std::list<SequentialStmt*>if_;
|
|
|
|
|
private: // not implemented
|
|
|
|
|
Elsif(const Elsif&);
|
|
|
|
|
Elsif& operator =(const Elsif&);
|
|
|
|
|
};
|
|
|
|
|
|
2011-05-09 01:40:35 +02:00
|
|
|
public:
|
|
|
|
|
IfSequential(Expression*cond, std::list<SequentialStmt*>*tr,
|
2011-06-12 19:51:31 +02:00
|
|
|
std::list<IfSequential::Elsif*>*elsif,
|
2011-05-09 01:40:35 +02:00
|
|
|
std::list<SequentialStmt*>*fa);
|
|
|
|
|
~IfSequential();
|
|
|
|
|
|
2011-05-15 20:07:42 +02:00
|
|
|
public:
|
2011-05-16 01:17:51 +02:00
|
|
|
int elaborate(Entity*ent, Architecture*arc);
|
2011-05-15 20:07:42 +02:00
|
|
|
int emit(ostream&out, Entity*entity, Architecture*arc);
|
|
|
|
|
void dump(ostream&out, int indent) const;
|
|
|
|
|
|
2011-05-28 19:49:33 +02:00
|
|
|
const Expression*peek_condition() const { return cond_; }
|
|
|
|
|
|
2011-06-12 19:51:31 +02:00
|
|
|
size_t false_size() const { return else_.size(); }
|
|
|
|
|
|
2011-05-28 19:49:33 +02:00
|
|
|
// These method extract (and remove) the sub-statements from
|
|
|
|
|
// the true or false clause.
|
|
|
|
|
void extract_true(std::list<SequentialStmt*>&that);
|
|
|
|
|
void extract_false(std::list<SequentialStmt*>&that);
|
|
|
|
|
|
2011-05-09 01:40:35 +02:00
|
|
|
private:
|
|
|
|
|
Expression*cond_;
|
|
|
|
|
std::list<SequentialStmt*> if_;
|
2011-06-12 19:51:31 +02:00
|
|
|
std::list<IfSequential::Elsif*> elsif_;
|
2011-05-09 01:40:35 +02:00
|
|
|
std::list<SequentialStmt*> else_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class SignalSeqAssignment : public SequentialStmt {
|
|
|
|
|
public:
|
|
|
|
|
SignalSeqAssignment(Expression*sig, std::list<Expression*>*wav);
|
|
|
|
|
~SignalSeqAssignment();
|
|
|
|
|
|
2011-05-15 20:07:42 +02:00
|
|
|
public:
|
2011-05-16 01:17:51 +02:00
|
|
|
int elaborate(Entity*ent, Architecture*arc);
|
2011-05-15 20:07:42 +02:00
|
|
|
int emit(ostream&out, Entity*entity, Architecture*arc);
|
|
|
|
|
void dump(ostream&out, int indent) const;
|
|
|
|
|
|
2011-05-09 01:40:35 +02:00
|
|
|
private:
|
|
|
|
|
Expression*lval_;
|
|
|
|
|
std::list<Expression*> waveform_;
|
|
|
|
|
};
|
|
|
|
|
|
2011-06-29 11:33:46 +02:00
|
|
|
class CaseSeqStmt : public SequentialStmt {
|
|
|
|
|
public:
|
|
|
|
|
class CaseStmtAlternative : public LineInfo {
|
|
|
|
|
public:
|
|
|
|
|
CaseStmtAlternative(Expression* exp, list<SequentialStmt*>* stmts);
|
|
|
|
|
~CaseStmtAlternative();
|
|
|
|
|
void dump(ostream& out, int indent) const;
|
|
|
|
|
|
|
|
|
|
//TODO: implement the following:
|
|
|
|
|
//int elaborate(Entity*ent, Architecture*arc);
|
|
|
|
|
//int emit(ostream&out, Entity*entity, Architecture*arc);
|
|
|
|
|
private:
|
|
|
|
|
Expression* exp_;
|
|
|
|
|
list<SequentialStmt*> stmts_;
|
|
|
|
|
private: // not implemented
|
|
|
|
|
CaseStmtAlternative(const CaseStmtAlternative&);
|
|
|
|
|
CaseStmtAlternative& operator =(const CaseStmtAlternative&);
|
|
|
|
|
};
|
|
|
|
|
CaseSeqStmt(Expression*cond,
|
|
|
|
|
list<CaseStmtAlternative*>*sp);
|
|
|
|
|
~CaseSeqStmt();
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
void dump(ostream&out, int indent) const;
|
|
|
|
|
//TODO: implement the following:
|
|
|
|
|
//int elaborate(Entity*ent, Architecture*arc);
|
|
|
|
|
//int emit(ostream&out, Entity*entity, Architecture*arc);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
Expression* cond_;
|
|
|
|
|
std::list<CaseStmtAlternative*> alt_;
|
|
|
|
|
};
|
2011-05-09 01:40:35 +02:00
|
|
|
#endif
|