Signed divide of 32bit values
[iverilog.git] / PGenerate.h
blob39be19f47391e238fd7fecf0f4eca96e9c8ac857
1 #ifndef __PGenerate_H
2 #define __PGenerate_H
3 /*
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)
10 * any later version.
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
21 #ifdef HAVE_CVS_IDENT
22 #ident "$Id: PGenerate.h,v 1.4 2007/06/02 03:42:12 steve Exp $"
23 #endif
25 # include "LineInfo.h"
26 # include "StringHeap.h"
27 # include "HName.h"
28 # include <list>
29 # include <map>
30 # include "pform_types.h"
32 class Design;
33 class NetScope;
34 class PExpr;
35 class PProcess;
36 class PGate;
37 class PWire;
40 * This represents a generate scheme.
42 class PGenerate : public LineInfo {
44 public:
45 PGenerate(unsigned id_number);
46 ~PGenerate();
48 // Generate schemes have an ID number, for when the scope is
49 // implicit.
50 const unsigned id_number;
51 perm_string scope_name;
53 enum scheme_t {GS_NONE, GS_LOOP, GS_CONDIT, GS_ELSE};
54 scheme_t scheme_type;
56 // generate loops have an index variable and three
57 // expressions: for (index = <init>; <test>; index=<step>)
58 perm_string loop_index;
59 PExpr*loop_init;
60 PExpr*loop_test;
61 PExpr*loop_step;
63 map<pform_name_t,PWire*>wires;
64 PWire* add_wire(PWire*);
65 PWire* get_wire(const pform_name_t&name) const;
67 list<PGate*> gates;
68 void add_gate(PGate*);
70 list<PProcess*> behaviors;
71 void add_behavior(PProcess*behave);
73 list<PGenerate*> generates;
74 PGenerate*parent;
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;
88 private:
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&);
106 #endif