Fix for pr1833776.
[iverilog.git] / PTask.h
blob596cdc59da21fdb3dbb0ebbbbc77e0241cc53593
1 #ifndef __PTask_H
2 #define __PTask_H
3 /*
4 * Copyright (c) 1999-2000 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: PTask.h,v 1.14 2007/03/06 05:22:49 steve Exp $"
23 #endif
25 # include "LineInfo.h"
26 # include "svector.h"
27 # include "StringHeap.h"
28 # include <string>
29 class Design;
30 class NetScope;
31 class PWire;
32 class Statement;
33 class PExpr;
35 enum PTaskFuncEnum {
36 PTF_NONE,
37 PTF_REG,
38 PTF_REG_S,
39 PTF_INTEGER,
40 PTF_REAL,
41 PTF_REALTIME,
42 PTF_TIME
45 struct PTaskFuncArg {
46 PTaskFuncEnum type;
47 svector<PExpr*>*range;
51 * The PTask holds the parsed definitions of a task.
53 class PTask : public LineInfo {
55 public:
56 explicit PTask();
57 ~PTask();
59 void set_ports(svector<PWire *>*p);
60 void set_statement(Statement *s);
62 // Tasks introduce scope, to need to be handled during the
63 // scope elaboration pass. The scope passed is my scope,
64 // created by the containing scope. I fill it in with stuff if
65 // I need to.
66 void elaborate_scope(Design*des, NetScope*scope) const;
68 // Bind the ports to the regs that are the ports.
69 void elaborate_sig(Design*des, NetScope*scope) const;
71 // Elaborate the statement to finish off the task definition.
72 void elaborate(Design*des, NetScope*scope) const;
74 void dump(ostream&, unsigned) const;
76 private:
77 svector<PWire*>*ports_;
78 Statement*statement_;
80 private: // Not implemented
81 PTask(const PTask&);
82 PTask& operator=(const PTask&);
86 * The function is similar to a task (in this context) but there is a
87 * single output port and a set of input ports. The output port is the
88 * function return value.
90 * The output value is not elaborated until elaborate_sig.
92 class PFunction : public LineInfo {
94 public:
95 explicit PFunction(perm_string name);
96 ~PFunction();
98 void set_ports(svector<PWire *>*p);
99 void set_statement(Statement *s);
100 void set_return(PTaskFuncArg t);
102 void elaborate_scope(Design*des, NetScope*scope) const;
104 /* elaborate the ports and return value. */
105 void elaborate_sig(Design *des, NetScope*) const;
107 /* Elaborate the behavioral statement. */
108 void elaborate(Design *des, NetScope*) const;
110 void dump(ostream&, unsigned) const;
112 private:
113 perm_string name_;
114 PTaskFuncArg return_type_;
115 svector<PWire *> *ports_;
116 Statement *statement_;
120 * $Log: PTask.h,v $
121 * Revision 1.14 2007/03/06 05:22:49 steve
122 * Support signed function return values.
124 * Revision 1.13 2004/05/31 23:34:36 steve
125 * Rewire/generalize parsing an elaboration of
126 * function return values to allow for better
127 * speed and more type support.
129 * Revision 1.12 2002/08/12 01:34:58 steve
130 * conditional ident string using autoconfig.
132 * Revision 1.11 2001/11/22 06:20:59 steve
133 * Use NetScope instead of string for scope path.
135 * Revision 1.10 2001/01/13 22:20:08 steve
136 * Parse parameters within nested scopes.
138 * Revision 1.9 2000/07/30 18:25:43 steve
139 * Rearrange task and function elaboration so that the
140 * NetTaskDef and NetFuncDef functions are created during
141 * signal enaboration, and carry these objects in the
142 * NetScope class instead of the extra, useless map in
143 * the Design class.
145 * Revision 1.8 2000/03/08 04:36:53 steve
146 * Redesign the implementation of scopes and parameters.
147 * I now generate the scopes and notice the parameters
148 * in a separate pass over the pform. Once the scopes
149 * are generated, I can process overrides and evalutate
150 * paremeters before elaboration begins.
152 * Revision 1.7 2000/02/23 02:56:53 steve
153 * Macintosh compilers do not support ident.
155 * Revision 1.6 1999/09/30 21:28:34 steve
156 * Handle mutual reference of tasks by elaborating
157 * task definitions in two passes, like functions.
159 * Revision 1.5 1999/09/01 20:46:19 steve
160 * Handle recursive functions and arbitrary function
161 * references to other functions, properly pass
162 * function parameters and save function results.
164 * Revision 1.4 1999/08/25 22:22:41 steve
165 * elaborate some aspects of functions.
167 * Revision 1.3 1999/07/31 19:14:47 steve
168 * Add functions up to elaboration (Ed Carter)
170 * Revision 1.2 1999/07/24 02:11:19 steve
171 * Elaborate task input ports.
173 * Revision 1.1 1999/07/03 02:12:51 steve
174 * Elaborate user defined tasks.
177 #endif