1998-11-04 00:28:49 +01:00
|
|
|
#ifndef __PWire_H
|
|
|
|
|
#define __PWire_H
|
|
|
|
|
/*
|
2012-02-05 01:19:27 +01:00
|
|
|
* Copyright (c) 1998-2009,2012 Stephen Williams (steve@icarus.com)
|
1998-11-04 00:28:49 +01: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.
|
1998-11-04 00:28:49 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
# include "netlist.h"
|
1999-06-02 17:38:46 +02:00
|
|
|
# include "LineInfo.h"
|
2012-02-05 01:19:27 +01:00
|
|
|
# include <list>
|
2001-01-16 03:44:17 +01:00
|
|
|
# include <map>
|
2007-04-26 05:06:21 +02:00
|
|
|
# include "StringHeap.h"
|
2001-01-16 03:44:17 +01:00
|
|
|
|
|
|
|
|
#ifdef HAVE_IOSFWD
|
|
|
|
|
# include <iosfwd>
|
|
|
|
|
#else
|
1998-11-04 00:28:49 +01:00
|
|
|
class ostream;
|
2001-01-16 03:44:17 +01:00
|
|
|
#endif
|
|
|
|
|
|
1998-11-04 00:28:49 +01:00
|
|
|
class PExpr;
|
|
|
|
|
class Design;
|
2012-07-14 03:41:41 +02:00
|
|
|
class netdarray_t;
|
1998-11-04 00:28:49 +01:00
|
|
|
|
2007-08-22 04:52:42 +02:00
|
|
|
/*
|
|
|
|
|
* The different type of PWire::set_range() calls.
|
|
|
|
|
*/
|
|
|
|
|
enum PWSRType {SR_PORT, SR_NET, SR_BOTH};
|
|
|
|
|
|
1998-11-04 00:28:49 +01:00
|
|
|
/*
|
|
|
|
|
* Wires include nets, registers and ports. A net or register becomes
|
2003-01-30 17:23:07 +01:00
|
|
|
* a port by declaration, so ports are not separate. The module
|
1998-11-04 00:28:49 +01:00
|
|
|
* identifies a port by keeping it in its port list.
|
2001-12-03 05:47:14 +01:00
|
|
|
*
|
|
|
|
|
* The hname parameter to the constructor is a hierarchical name. It
|
2007-05-24 06:07:11 +02:00
|
|
|
* is the name of the wire within a module, so does not include the
|
|
|
|
|
* current scope or any instances. Modules contain all the wires, so
|
|
|
|
|
* from that perspective, sub-scopes within the module are a part of
|
|
|
|
|
* the wire name.
|
1998-11-04 00:28:49 +01:00
|
|
|
*/
|
1999-06-02 17:38:46 +02:00
|
|
|
class PWire : public LineInfo {
|
1998-11-04 00:28:49 +01:00
|
|
|
|
|
|
|
|
public:
|
2008-02-25 04:40:54 +01:00
|
|
|
PWire(perm_string name,
|
2005-07-07 18:22:49 +02:00
|
|
|
NetNet::Type t,
|
|
|
|
|
NetNet::PortType pt,
|
|
|
|
|
ivl_variable_type_t dt);
|
1998-11-04 00:28:49 +01:00
|
|
|
|
2001-12-03 05:47:14 +01:00
|
|
|
// Return a hierarchical name.
|
2008-02-25 04:40:54 +01:00
|
|
|
perm_string basename() const;
|
1998-11-04 00:28:49 +01:00
|
|
|
|
1999-06-17 07:34:42 +02:00
|
|
|
NetNet::Type get_wire_type() const;
|
|
|
|
|
bool set_wire_type(NetNet::Type);
|
|
|
|
|
|
|
|
|
|
NetNet::PortType get_port_type() const;
|
|
|
|
|
bool set_port_type(NetNet::PortType);
|
|
|
|
|
|
2000-12-11 01:31:43 +01:00
|
|
|
void set_signed(bool flag);
|
|
|
|
|
bool get_signed() const;
|
2002-06-21 06:59:35 +02:00
|
|
|
bool get_isint() const;
|
2009-04-15 01:08:27 +02:00
|
|
|
bool get_scalar() const;
|
2000-12-11 01:31:43 +01:00
|
|
|
|
2005-07-07 18:22:49 +02:00
|
|
|
bool set_data_type(ivl_variable_type_t dt);
|
|
|
|
|
ivl_variable_type_t get_data_type() const;
|
|
|
|
|
|
2012-02-05 01:19:27 +01:00
|
|
|
void set_range_scalar(PWSRType type);
|
2012-04-10 23:29:28 +02:00
|
|
|
void set_range(const std::list<pform_range_t>&ranges, PWSRType type);
|
1999-06-17 07:34:42 +02:00
|
|
|
|
2012-05-26 00:58:29 +02:00
|
|
|
void set_unpacked_idx(const std::list<pform_range_t>&ranges);
|
1999-04-19 03:59:36 +02:00
|
|
|
|
2012-11-12 02:42:31 +01:00
|
|
|
void set_data_type(data_type_t*type);
|
2010-10-31 19:26:09 +01:00
|
|
|
|
2008-11-02 17:10:41 +01:00
|
|
|
void set_discipline(ivl_discipline_t);
|
|
|
|
|
ivl_discipline_t get_discipline(void) const;
|
2008-05-12 02:30:33 +02:00
|
|
|
|
2004-02-20 19:53:33 +01:00
|
|
|
map<perm_string,PExpr*> attributes;
|
1998-11-23 01:20:22 +01:00
|
|
|
|
1998-11-04 00:28:49 +01:00
|
|
|
// Write myself to the specified stream.
|
2006-04-10 02:37:42 +02:00
|
|
|
void dump(ostream&out, unsigned ind=4) const;
|
1998-11-04 00:28:49 +01:00
|
|
|
|
2007-05-24 06:07:11 +02:00
|
|
|
NetNet* elaborate_sig(Design*, NetScope*scope) const;
|
1998-11-04 00:28:49 +01:00
|
|
|
|
1999-06-17 07:34:42 +02:00
|
|
|
private:
|
2008-02-25 04:40:54 +01:00
|
|
|
perm_string name_;
|
1999-06-17 07:34:42 +02:00
|
|
|
NetNet::Type type_;
|
|
|
|
|
NetNet::PortType port_type_;
|
2005-07-07 18:22:49 +02:00
|
|
|
ivl_variable_type_t data_type_;
|
2000-12-11 01:31:43 +01:00
|
|
|
bool signed_;
|
2002-06-21 06:59:35 +02:00
|
|
|
bool isint_; // original type of integer
|
1999-06-17 07:34:42 +02:00
|
|
|
|
|
|
|
|
// These members hold expressions for the bit width of the
|
2012-02-05 01:19:27 +01:00
|
|
|
// wire. If they do not exist, the wire is 1 bit wide. If they
|
|
|
|
|
// do exist, they represent the packed dimensions of the
|
|
|
|
|
// bit. The first item in the list is the first range, and so
|
|
|
|
|
// on. For example "reg [3:0][7:0] ..." will contains the
|
|
|
|
|
// range_t object for [3:0] first and [7:0] last.
|
2012-04-10 23:29:28 +02:00
|
|
|
std::list<pform_range_t>port_;
|
2007-08-22 04:52:42 +02:00
|
|
|
bool port_set_;
|
2012-04-10 23:29:28 +02:00
|
|
|
std::list<pform_range_t>net_;
|
2007-08-22 04:52:42 +02:00
|
|
|
bool net_set_;
|
2009-04-15 01:08:27 +02:00
|
|
|
bool is_scalar_;
|
2007-08-22 04:52:42 +02:00
|
|
|
unsigned error_cnt_;
|
1999-06-17 07:34:42 +02:00
|
|
|
|
|
|
|
|
// If this wire is actually a memory, these indices will give
|
2012-05-26 00:58:29 +02:00
|
|
|
// me the size and address ranges of the memory.
|
|
|
|
|
std::list<pform_range_t>unpacked_;
|
1999-06-17 07:34:42 +02:00
|
|
|
|
2012-11-12 02:42:31 +01:00
|
|
|
// This is the complex type of the wire. the data_type_ may
|
|
|
|
|
// modify how this is interpreted.
|
2012-08-03 05:14:55 +02:00
|
|
|
data_type_t*set_data_type_;
|
2010-10-31 19:26:09 +01:00
|
|
|
|
2008-11-02 17:10:41 +01:00
|
|
|
ivl_discipline_t discipline_;
|
2008-05-12 02:30:33 +02:00
|
|
|
|
1998-11-04 00:28:49 +01:00
|
|
|
private: // not implemented
|
|
|
|
|
PWire(const PWire&);
|
|
|
|
|
PWire& operator= (const PWire&);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|