iverilog/PTask.h

139 lines
3.9 KiB
C
Raw Normal View History

1999-07-03 04:12:51 +02:00
#ifndef __PTask_H
#define __PTask_H
/*
* Copyright (c) 1999-2008,2010,2012 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
2012-08-29 03:41:23 +02:00
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1999-07-03 04:12:51 +02:00
*/
# include "LineInfo.h"
# include "PScope.h"
# include "StringHeap.h"
1999-07-03 04:12:51 +02:00
# include <string>
# include <vector>
# include <list>
1999-07-03 04:12:51 +02:00
class Design;
class NetExpr;
class NetNet;
class NetScope;
1999-07-24 04:11:19 +02:00
class PWire;
1999-07-03 04:12:51 +02:00
class Statement;
class PExpr;
1999-07-03 04:12:51 +02:00
class PTaskFunc : public PScope, public LineInfo {
public:
PTaskFunc(perm_string name, LexicalScope*parent);
~PTaskFunc();
void set_ports(std::vector<pform_tf_port_t>*p);
void set_this(class_type_t*use_type, PWire*this_wire);
// If this task is a method of a class, this returns a pointer
// to the class type.
inline class_type_t* method_of() const { return this_type_; }
protected:
// Elaborate the ports list. Write into the ports vector the
// NetNet pointers for the ports, and write into the pdefs the
// default value expressions, if any.
void elaborate_sig_ports_(Design*des, NetScope*scope,
std::vector<NetNet*>&ports,
std::vector<NetExpr*>&pdefs) const;
void dump_ports_(std::ostream&out, unsigned ind) const;
private:
class_type_t*this_type_;
std::vector<pform_tf_port_t>*ports_;
};
1999-07-03 04:12:51 +02:00
/*
* The PTask holds the parsed definitions of a task.
*/
class PTask : public PTaskFunc {
1999-07-03 04:12:51 +02:00
public:
explicit PTask(perm_string name, LexicalScope*parent, bool is_auto);
1999-07-03 04:12:51 +02:00
~PTask();
2001-01-13 23:20:08 +01:00
void set_statement(Statement *s);
// 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;
// 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.
void elaborate(Design*des, NetScope*scope) const;
bool is_auto() const { return is_auto_; };
1999-07-03 04:12:51 +02:00
void dump(ostream&, unsigned) const;
private:
Statement*statement_;
bool is_auto_;
1999-07-03 04:12:51 +02:00
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.
*
* The output value is not elaborated until elaborate_sig.
1999-08-26 00:22:41 +02:00
*/
class PFunction : public PTaskFunc {
1999-08-26 00:22:41 +02:00
public:
explicit PFunction(perm_string name, LexicalScope*parent, bool is_auto);
~PFunction();
2001-01-13 23:20:08 +01:00
void set_statement(Statement *s);
void set_return(const data_type_t*t);
1999-08-26 00:22:41 +02:00
inline Statement* get_statement() { return statement_; }
void elaborate_scope(Design*des, NetScope*scope) const;
/* elaborate the ports and return value. */
void elaborate_sig(Design *des, NetScope*) const;
/* Elaborate the behavioral statement. */
void elaborate(Design *des, NetScope*) const;
bool is_auto() const { return is_auto_; };
void dump(ostream&, unsigned) const;
1999-08-26 00:22:41 +02:00
private:
const data_type_t* return_type_;
Statement *statement_;
bool is_auto_;
};
1999-07-03 04:12:51 +02:00
#endif