2011-03-22 17:16:20 +01:00
|
|
|
#ifndef __vsignal_H
|
|
|
|
|
#define __vsignal_H
|
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2011 Stephen Williams (steve@icarus.com)
|
|
|
|
|
*
|
|
|
|
|
* 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 "StringHeap.h"
|
|
|
|
|
# include "LineInfo.h"
|
2011-08-18 05:19:15 +02:00
|
|
|
# include "vtype.h"
|
2011-03-22 17:16:20 +01:00
|
|
|
|
2011-03-27 21:01:58 +02:00
|
|
|
class Architecture;
|
|
|
|
|
class Entity;
|
2011-10-30 02:06:40 +02:00
|
|
|
class Expression;
|
2011-03-22 17:16:20 +01:00
|
|
|
|
2011-08-18 05:19:15 +02:00
|
|
|
class SigVarBase : public LineInfo {
|
2011-03-22 17:16:20 +01:00
|
|
|
|
|
|
|
|
public:
|
2011-10-30 02:06:40 +02:00
|
|
|
SigVarBase(perm_string name, const VType*type, Expression*init_expr);
|
2011-08-18 05:19:15 +02:00
|
|
|
virtual ~SigVarBase();
|
2011-03-22 17:16:20 +01:00
|
|
|
|
2011-05-31 04:17:40 +02:00
|
|
|
const VType* peek_type(void) const { return type_; }
|
|
|
|
|
|
2011-06-13 00:38:03 +02:00
|
|
|
// Call this method for each occasion where this signal is the
|
|
|
|
|
// l-value of a sequential assignment.
|
|
|
|
|
void count_ref_sequ();
|
|
|
|
|
|
2011-04-06 17:27:58 +02:00
|
|
|
void dump(ostream&out, int indent = 0) const;
|
2011-03-22 17:16:20 +01:00
|
|
|
|
2011-08-18 05:19:15 +02:00
|
|
|
protected:
|
|
|
|
|
perm_string peek_name_() const { return name_; }
|
|
|
|
|
unsigned peek_refcnt_sequ_() const { return refcnt_sequ_; }
|
|
|
|
|
|
|
|
|
|
void type_elaborate_(VType::decl_t&decl);
|
|
|
|
|
|
2011-10-30 02:06:40 +02:00
|
|
|
Expression* peek_init_expr() const { return init_expr_; }
|
|
|
|
|
|
2011-03-22 17:16:20 +01:00
|
|
|
private:
|
|
|
|
|
perm_string name_;
|
|
|
|
|
const VType*type_;
|
2011-10-30 02:06:40 +02:00
|
|
|
Expression*init_expr_;
|
2011-03-22 17:16:20 +01:00
|
|
|
|
2011-06-13 00:38:03 +02:00
|
|
|
unsigned refcnt_sequ_;
|
|
|
|
|
|
2011-03-22 17:16:20 +01:00
|
|
|
private: // Not implemented
|
2011-08-18 05:19:15 +02:00
|
|
|
SigVarBase(const SigVarBase&);
|
|
|
|
|
SigVarBase& operator = (const SigVarBase&);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class Signal : public SigVarBase {
|
|
|
|
|
|
|
|
|
|
public:
|
2011-10-30 02:06:40 +02:00
|
|
|
Signal(perm_string name, const VType*type, Expression*init_expr);
|
2011-08-18 05:19:15 +02:00
|
|
|
|
|
|
|
|
int emit(ostream&out, Entity*ent, Architecture*arc);
|
2011-03-22 17:16:20 +01:00
|
|
|
};
|
|
|
|
|
|
2011-08-18 05:19:15 +02:00
|
|
|
class Variable : public SigVarBase {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
Variable(perm_string name, const VType*type);
|
|
|
|
|
|
|
|
|
|
int emit(ostream&out, Entity*ent, Architecture*arc);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
inline void SigVarBase::count_ref_sequ()
|
2011-06-13 00:38:03 +02:00
|
|
|
{
|
|
|
|
|
refcnt_sequ_ += 1;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-30 02:06:40 +02:00
|
|
|
inline Signal::Signal(perm_string name, const VType*type, Expression*init_expr)
|
|
|
|
|
: SigVarBase(name, type, init_expr)
|
2011-08-18 05:19:15 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline Variable::Variable(perm_string name, const VType*type)
|
2011-10-30 02:06:40 +02:00
|
|
|
: SigVarBase(name, type, 0)
|
2011-08-18 05:19:15 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-22 17:16:20 +01:00
|
|
|
#endif
|