1999-07-03 04:12:51 +02:00
|
|
|
#ifndef __PTask_H
|
|
|
|
|
#define __PTask_H
|
|
|
|
|
/*
|
2008-02-14 04:59:05 +01:00
|
|
|
* Copyright (c) 1999-2008 Stephen Williams (steve@icarus.com)
|
1999-07-03 04:12:51 +02:00
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
# include "LineInfo.h"
|
2008-02-14 04:59:05 +01:00
|
|
|
# include "PScope.h"
|
1999-07-24 04:11:19 +02:00
|
|
|
# include "svector.h"
|
2004-06-01 01:34:36 +02:00
|
|
|
# include "StringHeap.h"
|
1999-07-03 04:12:51 +02:00
|
|
|
# include <string>
|
|
|
|
|
class Design;
|
2000-03-08 05:36:53 +01:00
|
|
|
class NetScope;
|
1999-07-24 04:11:19 +02:00
|
|
|
class PWire;
|
1999-07-03 04:12:51 +02:00
|
|
|
class Statement;
|
2004-06-01 01:34:36 +02:00
|
|
|
class PExpr;
|
|
|
|
|
|
|
|
|
|
enum PTaskFuncEnum {
|
|
|
|
|
PTF_NONE,
|
|
|
|
|
PTF_REG,
|
2007-03-06 06:22:49 +01:00
|
|
|
PTF_REG_S,
|
2004-06-01 01:34:36 +02:00
|
|
|
PTF_INTEGER,
|
|
|
|
|
PTF_REAL,
|
|
|
|
|
PTF_REALTIME,
|
|
|
|
|
PTF_TIME
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct PTaskFuncArg {
|
|
|
|
|
PTaskFuncEnum type;
|
|
|
|
|
svector<PExpr*>*range;
|
|
|
|
|
};
|
1999-07-03 04:12:51 +02:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* The PTask holds the parsed definitions of a task.
|
|
|
|
|
*/
|
2008-02-14 04:59:05 +01:00
|
|
|
class PTask : public PScope, public LineInfo {
|
1999-07-03 04:12:51 +02:00
|
|
|
|
|
|
|
|
public:
|
2008-02-16 06:20:24 +01:00
|
|
|
explicit PTask(perm_string name, PScope*parent);
|
1999-07-03 04:12:51 +02:00
|
|
|
~PTask();
|
|
|
|
|
|
2001-01-13 23:20:08 +01:00
|
|
|
void set_ports(svector<PWire *>*p);
|
|
|
|
|
void set_statement(Statement *s);
|
|
|
|
|
|
2000-03-08 05:36:53 +01:00
|
|
|
// Tasks introduce scope, to need to be handled during the
|
|
|
|
|
// scope elaboration pass. The scope passed is my scope,
|
|
|
|
|
// created by the containing scope. I fill it in with stuff if
|
|
|
|
|
// I need to.
|
|
|
|
|
void elaborate_scope(Design*des, NetScope*scope) const;
|
|
|
|
|
|
2000-07-30 20:25:43 +02:00
|
|
|
// Bind the ports to the regs that are the ports.
|
|
|
|
|
void elaborate_sig(Design*des, NetScope*scope) const;
|
|
|
|
|
|
|
|
|
|
// Elaborate the statement to finish off the task definition.
|
2001-11-22 07:20:59 +01:00
|
|
|
void elaborate(Design*des, NetScope*scope) const;
|
1999-09-30 23:28:34 +02:00
|
|
|
|
1999-07-03 04:12:51 +02:00
|
|
|
void dump(ostream&, unsigned) const;
|
|
|
|
|
|
|
|
|
|
private:
|
1999-07-24 04:11:19 +02:00
|
|
|
svector<PWire*>*ports_;
|
1999-07-03 04:12:51 +02:00
|
|
|
Statement*statement_;
|
|
|
|
|
|
|
|
|
|
private: // Not implemented
|
|
|
|
|
PTask(const PTask&);
|
|
|
|
|
PTask& operator=(const PTask&);
|
|
|
|
|
};
|
|
|
|
|
|
1999-08-26 00:22:41 +02:00
|
|
|
/*
|
|
|
|
|
* The function is similar to a task (in this context) but there is a
|
|
|
|
|
* single output port and a set of input ports. The output port is the
|
|
|
|
|
* function return value.
|
2004-06-01 01:34:36 +02:00
|
|
|
*
|
|
|
|
|
* The output value is not elaborated until elaborate_sig.
|
1999-08-26 00:22:41 +02:00
|
|
|
*/
|
2008-02-14 04:59:05 +01:00
|
|
|
class PFunction : public PScope, public LineInfo {
|
1999-08-26 00:22:41 +02:00
|
|
|
|
|
|
|
|
public:
|
2008-02-16 06:20:24 +01:00
|
|
|
explicit PFunction(perm_string name, PScope*parent);
|
1999-07-31 21:14:47 +02:00
|
|
|
~PFunction();
|
|
|
|
|
|
2001-01-13 23:20:08 +01:00
|
|
|
void set_ports(svector<PWire *>*p);
|
|
|
|
|
void set_statement(Statement *s);
|
2004-06-01 01:34:36 +02:00
|
|
|
void set_return(PTaskFuncArg t);
|
1999-08-26 00:22:41 +02:00
|
|
|
|
2000-03-08 05:36:53 +01:00
|
|
|
void elaborate_scope(Design*des, NetScope*scope) const;
|
|
|
|
|
|
2000-07-30 20:25:43 +02:00
|
|
|
/* elaborate the ports and return value. */
|
|
|
|
|
void elaborate_sig(Design *des, NetScope*) const;
|
|
|
|
|
|
|
|
|
|
/* Elaborate the behavioral statement. */
|
|
|
|
|
void elaborate(Design *des, NetScope*) const;
|
1999-09-01 22:46:19 +02:00
|
|
|
|
1999-07-31 21:14:47 +02:00
|
|
|
void dump(ostream&, unsigned) const;
|
|
|
|
|
|
1999-08-26 00:22:41 +02:00
|
|
|
private:
|
2004-06-01 01:34:36 +02:00
|
|
|
PTaskFuncArg return_type_;
|
1999-07-31 21:14:47 +02:00
|
|
|
svector<PWire *> *ports_;
|
|
|
|
|
Statement *statement_;
|
|
|
|
|
};
|
|
|
|
|
|
1999-07-03 04:12:51 +02:00
|
|
|
#endif
|