Add Attrib class for holding NetObj attributes.
This commit is contained in:
parent
4faec154f0
commit
4f638882c9
|
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
* Copyright (c) 2000 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
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: Attrib.cc,v 1.1 2000/12/04 17:37:03 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "Attrib.h"
|
||||
# include <assert.h>
|
||||
|
||||
Attrib::Attrib()
|
||||
{
|
||||
nlist_ = 0;
|
||||
list_ = 0;
|
||||
}
|
||||
|
||||
Attrib::~Attrib()
|
||||
{
|
||||
delete[] list_;
|
||||
}
|
||||
|
||||
void Attrib::set_attributes(const map<string,string>&attr)
|
||||
{
|
||||
assert(list_ == 0);
|
||||
|
||||
nlist_ = attr.size();
|
||||
list_ = new cell_[nlist_];
|
||||
|
||||
map<string,string>::const_iterator idx;
|
||||
unsigned jdx;
|
||||
for (idx = attr.begin(), jdx = 0 ; idx != attr.end() ; idx ++, jdx++) {
|
||||
struct cell_*tmp = list_ + jdx;
|
||||
tmp->key = (*idx).first;
|
||||
tmp->val = (*idx).second;
|
||||
}
|
||||
}
|
||||
|
||||
string Attrib::attribute(const string&key) const
|
||||
{
|
||||
for (unsigned idx = 0 ; idx < nlist_ ; idx += 1) {
|
||||
|
||||
if (key == list_[idx].key)
|
||||
return list_[idx].val;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void Attrib::attribute(const string&key, const string&value)
|
||||
{
|
||||
unsigned idx;
|
||||
|
||||
for (idx = 0 ; idx < nlist_ ; idx += 1) {
|
||||
if (key == list_[idx].key) {
|
||||
list_[idx].val = value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
struct cell_*tmp = new struct cell_[nlist_+1];
|
||||
for (idx = 0 ; idx < nlist_ ; idx += 1)
|
||||
tmp[idx] = list_[idx];
|
||||
|
||||
tmp[nlist_].key = key;
|
||||
tmp[nlist_].val = value;
|
||||
|
||||
nlist_ += 1;
|
||||
delete[]list_;
|
||||
list_ = tmp;
|
||||
}
|
||||
|
||||
bool Attrib::has_compat_attributes(const Attrib&that) const
|
||||
{
|
||||
unsigned idx;
|
||||
|
||||
for (idx = 0 ; idx < that.nlist_ ; idx += 1) {
|
||||
|
||||
string tmp = attribute(that.list_[idx].key);
|
||||
if (tmp != that.list_[idx].val)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned Attrib::size() const
|
||||
{
|
||||
return nlist_;
|
||||
}
|
||||
|
||||
string Attrib::key(unsigned idx) const
|
||||
{
|
||||
assert(idx < nlist_);
|
||||
return list_[idx].key;
|
||||
}
|
||||
|
||||
string Attrib::value(unsigned idx) const
|
||||
{
|
||||
assert(idx < nlist_);
|
||||
return list_[idx].val;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* $Log: Attrib.cc,v $
|
||||
* Revision 1.1 2000/12/04 17:37:03 steve
|
||||
* Add Attrib class for holding NetObj attributes.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
#ifndef __Attrib_H
|
||||
#define __Attrib_H
|
||||
/*
|
||||
* Copyright (c) 2000 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
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: Attrib.h,v 1.1 2000/12/04 17:37:03 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include <string>
|
||||
# include <map>
|
||||
|
||||
/*
|
||||
* This class keeps a map of key/value pairs. The map can be set from
|
||||
* an STL map, or by setting individual mappings.
|
||||
*/
|
||||
class Attrib {
|
||||
|
||||
public:
|
||||
Attrib();
|
||||
~Attrib();
|
||||
|
||||
void set_attributes(const map<string,string>&attr);
|
||||
string attribute(const string&key) const;
|
||||
void attribute(const string&key, const string&value);
|
||||
bool has_compat_attributes(const Attrib&that) const;
|
||||
|
||||
|
||||
/* Provide a means of iterating over the entries in the map. */
|
||||
unsigned size() const;
|
||||
string key(unsigned idx) const;
|
||||
string value(unsigned idx) const;
|
||||
|
||||
private:
|
||||
struct cell_ {
|
||||
string key;
|
||||
string val;
|
||||
};
|
||||
|
||||
unsigned nlist_;
|
||||
struct cell_*list_;
|
||||
|
||||
private: // not implemented
|
||||
Attrib(const Attrib&);
|
||||
Attrib& operator= (const Attrib&);
|
||||
};
|
||||
|
||||
/*
|
||||
* $Log: Attrib.h,v $
|
||||
* Revision 1.1 2000/12/04 17:37:03 steve
|
||||
* Add Attrib class for holding NetObj attributes.
|
||||
*
|
||||
*/
|
||||
#endif
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
# 59 Temple Place - Suite 330
|
||||
# Boston, MA 02111-1307, USA
|
||||
#
|
||||
#ident "$Id: Makefile.in,v 1.85 2000/12/02 05:57:46 steve Exp $"
|
||||
#ident "$Id: Makefile.in,v 1.86 2000/12/04 17:37:03 steve Exp $"
|
||||
#
|
||||
#
|
||||
SHELL = /bin/sh
|
||||
|
|
@ -95,7 +95,7 @@ pad_to_width.o \
|
|||
parse.o parse_misc.o pform.o pform_dump.o \
|
||||
set_width.o \
|
||||
verinum.o verireal.o target.o targets.o util.o \
|
||||
LineInfo.o Module.o PDelays.o PEvent.o \
|
||||
Attrib.o LineInfo.o Module.o PDelays.o PEvent.o \
|
||||
PExpr.o PGate.o \
|
||||
PTask.o PFunction.o PWire.o Statement.o \
|
||||
$(FF) $(TT)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT) && !defined(macintosh)
|
||||
#ident "$Id: design_dump.cc,v 1.104 2000/11/11 01:52:09 steve Exp $"
|
||||
#ident "$Id: design_dump.cc,v 1.105 2000/12/04 17:37:03 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -153,11 +153,10 @@ void NetObj::dump_node_pins(ostream&o, unsigned ind) const
|
|||
|
||||
void NetObj::dump_obj_attr(ostream&o, unsigned ind) const
|
||||
{
|
||||
for (map<string,string>::const_iterator idx = attributes_.begin()
|
||||
; idx != attributes_.end()
|
||||
; idx ++) {
|
||||
o << setw(ind) << "" << (*idx).first << " = \"" <<
|
||||
(*idx).second << "\"" << endl;
|
||||
unsigned idx;
|
||||
for (idx = 0 ; idx < attributes_.size() ; idx += 1) {
|
||||
o << setw(ind) << "" << attributes_.key(idx) << " = \"" <<
|
||||
attributes_.value(idx) << "\"" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -995,6 +994,9 @@ void Design::dump(ostream&o) const
|
|||
|
||||
/*
|
||||
* $Log: design_dump.cc,v $
|
||||
* Revision 1.105 2000/12/04 17:37:03 steve
|
||||
* Add Attrib class for holding NetObj attributes.
|
||||
*
|
||||
* Revision 1.104 2000/11/11 01:52:09 steve
|
||||
* change set for support of nmos, pmos, rnmos, rpmos, notif0, and notif1
|
||||
* change set to correct behavior of bufif0 and bufif1
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT) && !defined(macintosh)
|
||||
#ident "$Id: elab_sig.cc,v 1.5 2000/11/20 00:58:40 steve Exp $"
|
||||
#ident "$Id: elab_sig.cc,v 1.6 2000/12/04 17:37:04 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "Module.h"
|
||||
|
|
@ -335,7 +335,6 @@ void PWire::elaborate_sig(Design*des, NetScope*scope) const
|
|||
delete rval;
|
||||
NetMemory*sig = new NetMemory(scope, path+"."+basename,
|
||||
wid, lnum, rnum);
|
||||
sig->set_attributes(attributes);
|
||||
|
||||
} else {
|
||||
|
||||
|
|
@ -348,6 +347,9 @@ void PWire::elaborate_sig(Design*des, NetScope*scope) const
|
|||
|
||||
/*
|
||||
* $Log: elab_sig.cc,v $
|
||||
* Revision 1.6 2000/12/04 17:37:04 steve
|
||||
* Add Attrib class for holding NetObj attributes.
|
||||
*
|
||||
* Revision 1.5 2000/11/20 00:58:40 steve
|
||||
* Add support for supply nets (PR#17)
|
||||
*
|
||||
|
|
|
|||
36
netlist.cc
36
netlist.cc
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT) && !defined(macintosh)
|
||||
#ident "$Id: netlist.cc,v 1.148 2000/11/29 23:16:19 steve Exp $"
|
||||
#ident "$Id: netlist.cc,v 1.149 2000/12/04 17:37:04 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include <cassert>
|
||||
|
|
@ -209,41 +209,25 @@ const NetScope* NetObj::scope() const
|
|||
|
||||
void NetObj::set_attributes(const map<string,string>&attr)
|
||||
{
|
||||
assert(attributes_.size() == 0);
|
||||
attributes_ = attr;
|
||||
attributes_.set_attributes(attr);
|
||||
}
|
||||
|
||||
string NetObj::attribute(const string&key) const
|
||||
{
|
||||
map<string,string>::const_iterator idx = attributes_.find(key);
|
||||
if (idx == attributes_.end())
|
||||
return "";
|
||||
|
||||
return (*idx).second;
|
||||
return attributes_.attribute(key);
|
||||
}
|
||||
|
||||
void NetObj::attribute(const string&key, const string&value)
|
||||
{
|
||||
attributes_[key] = value;
|
||||
attributes_.attribute(key, value);
|
||||
}
|
||||
|
||||
bool NetObj::has_compat_attributes(const NetObj&that) const
|
||||
{
|
||||
map<string,string>::const_iterator idx;
|
||||
for (idx = that.attributes_.begin()
|
||||
; idx != that.attributes_.end() ; idx ++) {
|
||||
map<string,string>::const_iterator cur;
|
||||
cur = attributes_.find((*idx).first);
|
||||
|
||||
if (cur == attributes_.end())
|
||||
return false;
|
||||
if ((*cur).second != (*idx).second)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return attributes_.has_compat_attributes(that.attributes_);
|
||||
}
|
||||
|
||||
|
||||
Link& NetObj::pin(unsigned idx)
|
||||
{
|
||||
assert(idx < npins_);
|
||||
|
|
@ -2057,11 +2041,6 @@ unsigned NetMemory::index_to_address(long idx) const
|
|||
}
|
||||
|
||||
|
||||
void NetMemory::set_attributes(const map<string,string>&attr)
|
||||
{
|
||||
assert(attributes_.size() == 0);
|
||||
attributes_ = attr;
|
||||
}
|
||||
|
||||
NetEMemory* NetEMemory::dup_expr() const
|
||||
{
|
||||
|
|
@ -2471,6 +2450,9 @@ bool NetUDP::sequ_glob_(string input, char output)
|
|||
|
||||
/*
|
||||
* $Log: netlist.cc,v $
|
||||
* Revision 1.149 2000/12/04 17:37:04 steve
|
||||
* Add Attrib class for holding NetObj attributes.
|
||||
*
|
||||
* Revision 1.148 2000/11/29 23:16:19 steve
|
||||
* Do not delete synthesized signals used in expressions.
|
||||
*
|
||||
|
|
|
|||
12
netlist.h
12
netlist.h
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT) && !defined(macintosh)
|
||||
#ident "$Id: netlist.h,v 1.183 2000/12/02 05:08:04 steve Exp $"
|
||||
#ident "$Id: netlist.h,v 1.184 2000/12/04 17:37:04 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -33,6 +33,7 @@
|
|||
# include "verinum.h"
|
||||
# include "LineInfo.h"
|
||||
# include "svector.h"
|
||||
# include "Attrib.h"
|
||||
|
||||
class Design;
|
||||
class Link;
|
||||
|
|
@ -115,7 +116,7 @@ class NetObj {
|
|||
unsigned delay2_;
|
||||
unsigned delay3_;
|
||||
|
||||
map<string,string> attributes_;
|
||||
Attrib attributes_;
|
||||
};
|
||||
|
||||
class Link {
|
||||
|
|
@ -625,8 +626,6 @@ class NetMemory {
|
|||
// that are not zero based.
|
||||
unsigned index_to_address(long idx) const;
|
||||
|
||||
void set_attributes(const map<string,string>&a);
|
||||
|
||||
void dump(ostream&o, unsigned lm) const;
|
||||
|
||||
private:
|
||||
|
|
@ -635,8 +634,6 @@ class NetMemory {
|
|||
long idxh_;
|
||||
long idxl_;
|
||||
|
||||
map<string,string> attributes_;
|
||||
|
||||
friend class NetRamDq;
|
||||
NetRamDq* ram_list_;
|
||||
|
||||
|
|
@ -2824,6 +2821,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
|
|||
|
||||
/*
|
||||
* $Log: netlist.h,v $
|
||||
* Revision 1.184 2000/12/04 17:37:04 steve
|
||||
* Add Attrib class for holding NetObj attributes.
|
||||
*
|
||||
* Revision 1.183 2000/12/02 05:08:04 steve
|
||||
* Spelling error in comment.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue