4 * Copyright (c) 2006 Stephen Williams (steve@icarus.com)
6 * This source code is free software; you can redistribute it
7 * and/or modify it in source code form under the terms of the GNU
8 * General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
22 #ident "$Id: PGenerate.h,v 1.4 2007/06/02 03:42:12 steve Exp $"
25 # include "LineInfo.h"
26 # include "StringHeap.h"
30 # include "pform_types.h"
40 * This represents a generate scheme.
42 class PGenerate
: public LineInfo
{
45 PGenerate(unsigned id_number
);
48 // Generate schemes have an ID number, for when the scope is
50 const unsigned id_number
;
51 perm_string scope_name
;
53 enum scheme_t
{GS_NONE
, GS_LOOP
, GS_CONDIT
, GS_ELSE
};
56 // generate loops have an index variable and three
57 // expressions: for (index = <init>; <test>; index=<step>)
58 perm_string loop_index
;
63 map
<pform_name_t
,PWire
*>wires
;
64 PWire
* add_wire(PWire
*);
65 PWire
* get_wire(const pform_name_t
&name
) const;
68 void add_gate(PGate
*);
70 list
<PProcess
*> behaviors
;
71 void add_behavior(PProcess
*behave
);
73 list
<PGenerate
*> generates
;
76 // This method is called by the elaboration of a module to
77 // generate scopes. the container is the scope that is to
78 // contain the generated scope.
79 bool generate_scope(Design
*des
, NetScope
*container
);
81 // Elaborate signals within any of the generated scopes that
82 // were made by this generate block within the given container scope.
83 bool elaborate_sig(Design
*des
, NetScope
*container
) const;
84 bool elaborate(Design
*des
, NetScope
*container
) const;
86 void dump(ostream
&out
, unsigned indent
) const;
89 bool generate_scope_loop_(Design
*des
, NetScope
*container
);
90 bool generate_scope_condit_(Design
*des
, NetScope
*container
, bool else_flag
);
92 // Elaborate_scope within a generated scope.
93 void elaborate_subscope_(Design
*des
, NetScope
*scope
);
95 // These are the scopes created by generate_scope.
96 list
<NetScope
*>scope_list_
;
97 // internal function called on each scope generated by this scheme.
98 bool elaborate_sig_(Design
*des
, NetScope
*scope
) const;
99 bool elaborate_(Design
*des
, NetScope
*scope
) const;
101 private: // not implemented
102 PGenerate(const PGenerate
&);
103 PGenerate
& operator= (const PGenerate
&);