Merge branch 'master' into verilog-ams
[sverilog.git] / PTask.h
blob4d9c24e9c4ace31924c5304e32d078942049147e
1 #ifndef __PTask_H
2 #define __PTask_H
3 /*
4 * Copyright (c) 1999-2008 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
22 # include "LineInfo.h"
23 # include "PScope.h"
24 # include "svector.h"
25 # include "StringHeap.h"
26 # include <string>
27 class Design;
28 class NetScope;
29 class PWire;
30 class Statement;
31 class PExpr;
33 enum PTaskFuncEnum {
34 PTF_NONE,
35 PTF_REG,
36 PTF_REG_S,
37 PTF_INTEGER,
38 PTF_REAL,
39 PTF_REALTIME,
40 PTF_TIME
43 struct PTaskFuncArg {
44 PTaskFuncEnum type;
45 svector<PExpr*>*range;
49 * The PTask holds the parsed definitions of a task.
51 class PTask : public PScope, public LineInfo {
53 public:
54 explicit PTask(perm_string name, PScope*parent);
55 ~PTask();
57 void set_ports(svector<PWire *>*p);
58 void set_statement(Statement *s);
60 // Tasks introduce scope, to need to be handled during the
61 // scope elaboration pass. The scope passed is my scope,
62 // created by the containing scope. I fill it in with stuff if
63 // I need to.
64 void elaborate_scope(Design*des, NetScope*scope) const;
66 // Bind the ports to the regs that are the ports.
67 void elaborate_sig(Design*des, NetScope*scope) const;
69 // Elaborate the statement to finish off the task definition.
70 void elaborate(Design*des, NetScope*scope) const;
72 void dump(ostream&, unsigned) const;
74 private:
75 svector<PWire*>*ports_;
76 Statement*statement_;
78 private: // Not implemented
79 PTask(const PTask&);
80 PTask& operator=(const PTask&);
84 * The function is similar to a task (in this context) but there is a
85 * single output port and a set of input ports. The output port is the
86 * function return value.
88 * The output value is not elaborated until elaborate_sig.
90 class PFunction : public PScope, public LineInfo {
92 public:
93 explicit PFunction(perm_string name, PScope*parent);
94 ~PFunction();
96 void set_ports(svector<PWire *>*p);
97 void set_statement(Statement *s);
98 void set_return(PTaskFuncArg t);
100 void elaborate_scope(Design*des, NetScope*scope) const;
102 /* elaborate the ports and return value. */
103 void elaborate_sig(Design *des, NetScope*) const;
105 /* Elaborate the behavioral statement. */
106 void elaborate(Design *des, NetScope*) const;
108 void dump(ostream&, unsigned) const;
110 private:
111 PTaskFuncArg return_type_;
112 svector<PWire *> *ports_;
113 Statement *statement_;
116 #endif