2006-04-10 04:40:18 +02:00
|
|
|
#ifndef __PGenerate_H
|
|
|
|
|
#define __PGenerate_H
|
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2006 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
|
|
|
|
|
*/
|
|
|
|
|
#ifdef HAVE_CVS_IDENT
|
2007-06-02 05:42:12 +02:00
|
|
|
#ident "$Id: PGenerate.h,v 1.4 2007/06/02 03:42:12 steve Exp $"
|
2006-04-10 04:40:18 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
# include "LineInfo.h"
|
|
|
|
|
# include "StringHeap.h"
|
|
|
|
|
# include "HName.h"
|
|
|
|
|
# include <list>
|
|
|
|
|
# include <map>
|
2007-05-24 06:07:11 +02:00
|
|
|
# include "pform_types.h"
|
2006-04-10 04:40:18 +02:00
|
|
|
|
|
|
|
|
class Design;
|
|
|
|
|
class NetScope;
|
|
|
|
|
class PExpr;
|
2007-03-05 06:59:10 +01:00
|
|
|
class PProcess;
|
2006-04-10 04:40:18 +02:00
|
|
|
class PGate;
|
|
|
|
|
class PWire;
|
|
|
|
|
|
|
|
|
|
/*
|
2008-02-10 07:19:42 +01:00
|
|
|
* This represents a generate scheme. The interpretation of the
|
|
|
|
|
* members depends on the scheme_type.
|
|
|
|
|
*
|
|
|
|
|
* GS_LOOP
|
|
|
|
|
*
|
|
|
|
|
* GS_CASE
|
|
|
|
|
* loop_test is the expression to be compared.
|
|
|
|
|
* generates contains only GS_CASE_ITEM schemes.
|
|
|
|
|
* GS_CASE_ITEM
|
|
|
|
|
* The parent points to the GS_CASE that contains this item.
|
|
|
|
|
* the loop_test is compared with the parent->loop_test expression.
|
2006-04-10 04:40:18 +02:00
|
|
|
*/
|
|
|
|
|
class PGenerate : public LineInfo {
|
|
|
|
|
|
|
|
|
|
public:
|
2008-06-18 06:45:37 +02:00
|
|
|
explicit PGenerate(unsigned id_number);
|
2006-04-10 04:40:18 +02:00
|
|
|
~PGenerate();
|
|
|
|
|
|
|
|
|
|
// Generate schemes have an ID number, for when the scope is
|
|
|
|
|
// implicit.
|
|
|
|
|
const unsigned id_number;
|
|
|
|
|
perm_string scope_name;
|
|
|
|
|
|
2008-02-10 07:19:42 +01:00
|
|
|
enum scheme_t {GS_NONE, GS_LOOP, GS_CONDIT, GS_ELSE,
|
|
|
|
|
GS_CASE, GS_CASE_ITEM};
|
2006-04-10 04:40:18 +02:00
|
|
|
scheme_t scheme_type;
|
|
|
|
|
|
|
|
|
|
// generate loops have an index variable and three
|
|
|
|
|
// expressions: for (index = <init>; <test>; index=<step>)
|
|
|
|
|
perm_string loop_index;
|
|
|
|
|
PExpr*loop_init;
|
|
|
|
|
PExpr*loop_test;
|
|
|
|
|
PExpr*loop_step;
|
|
|
|
|
|
2008-02-25 04:40:54 +01:00
|
|
|
map<perm_string,PWire*>wires;
|
|
|
|
|
PWire* get_wire(perm_string name) const;
|
2006-04-10 04:40:18 +02:00
|
|
|
|
|
|
|
|
list<PGate*> gates;
|
|
|
|
|
void add_gate(PGate*);
|
|
|
|
|
|
2007-03-05 06:59:10 +01:00
|
|
|
list<PProcess*> behaviors;
|
|
|
|
|
|
2008-06-18 06:45:37 +02:00
|
|
|
// Generate schemes can contain further generate schemes.
|
|
|
|
|
list<PGenerate*> generate_schemes;
|
2007-06-02 05:42:12 +02:00
|
|
|
PGenerate*parent;
|
|
|
|
|
|
2006-04-10 04:40:18 +02:00
|
|
|
// This method is called by the elaboration of a module to
|
|
|
|
|
// generate scopes. the container is the scope that is to
|
|
|
|
|
// contain the generated scope.
|
|
|
|
|
bool generate_scope(Design*des, NetScope*container);
|
|
|
|
|
|
2007-06-22 04:04:48 +02:00
|
|
|
// Elaborate signals within any of the generated scopes that
|
|
|
|
|
// were made by this generate block within the given container scope.
|
|
|
|
|
bool elaborate_sig(Design*des, NetScope*container) const;
|
|
|
|
|
bool elaborate(Design*des, NetScope*container) const;
|
2006-04-10 04:40:18 +02:00
|
|
|
|
2007-06-02 05:42:12 +02:00
|
|
|
void dump(ostream&out, unsigned indent) const;
|
2006-04-10 04:40:18 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
bool generate_scope_loop_(Design*des, NetScope*container);
|
2007-06-22 04:04:48 +02:00
|
|
|
bool generate_scope_condit_(Design*des, NetScope*container, bool else_flag);
|
2008-02-10 07:19:42 +01:00
|
|
|
bool generate_scope_case_(Design*des, NetScope*container);
|
2007-06-22 04:04:48 +02:00
|
|
|
|
|
|
|
|
// Elaborate_scope within a generated scope.
|
|
|
|
|
void elaborate_subscope_(Design*des, NetScope*scope);
|
2006-04-10 04:40:18 +02:00
|
|
|
|
|
|
|
|
// These are the scopes created by generate_scope.
|
|
|
|
|
list<NetScope*>scope_list_;
|
|
|
|
|
// internal function called on each scope generated by this scheme.
|
|
|
|
|
bool elaborate_sig_(Design*des, NetScope*scope) const;
|
|
|
|
|
bool elaborate_(Design*des, NetScope*scope) const;
|
|
|
|
|
|
|
|
|
|
private: // not implemented
|
|
|
|
|
PGenerate(const PGenerate&);
|
|
|
|
|
PGenerate& operator= (const PGenerate&);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|