1999-09-29 02:42:50 +02:00
|
|
|
/*
|
2000-02-23 03:56:53 +01:00
|
|
|
* Copyright (c) 1999-2000 Stephen Williams (steve@icarus.com)
|
1999-09-29 02:42:50 +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
|
|
|
|
|
*/
|
2000-02-23 03:56:53 +01:00
|
|
|
#if !defined(WINNT) && !defined(macintosh)
|
2001-07-25 05:10:48 +02:00
|
|
|
#ident "$Id: pad_to_width.cc,v 1.8 2001/07/25 03:10:49 steve Exp $"
|
1999-09-29 02:42:50 +02:00
|
|
|
#endif
|
|
|
|
|
|
2001-07-25 05:10:48 +02:00
|
|
|
# include "config.h"
|
|
|
|
|
|
1999-09-29 02:42:50 +02:00
|
|
|
# include "netlist.h"
|
|
|
|
|
# include "netmisc.h"
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This funciton transforms an expression by padding the high bits
|
|
|
|
|
* with V0 until the expression has the desired width. This may mean
|
|
|
|
|
* not transforming the expression at all, if it is already wide
|
|
|
|
|
* enough.
|
|
|
|
|
*/
|
|
|
|
|
NetExpr*pad_to_width(NetExpr*expr, unsigned wid)
|
|
|
|
|
{
|
|
|
|
|
if (wid > expr->expr_width()) {
|
|
|
|
|
verinum pad(verinum::V0, wid - expr->expr_width());
|
|
|
|
|
NetEConst*co = new NetEConst(pad);
|
2000-01-01 07:17:25 +01:00
|
|
|
co->set_line(*expr);
|
1999-09-29 02:42:50 +02:00
|
|
|
NetEConcat*cc = new NetEConcat(2);
|
2000-01-01 07:17:25 +01:00
|
|
|
cc->set_line(*expr);
|
1999-09-29 02:42:50 +02:00
|
|
|
cc->set(0, co);
|
|
|
|
|
cc->set(1, expr);
|
|
|
|
|
cc->set_width(wid);
|
|
|
|
|
expr = cc;
|
|
|
|
|
}
|
|
|
|
|
return expr;
|
|
|
|
|
}
|
|
|
|
|
|
2001-02-15 07:59:35 +01:00
|
|
|
NetNet*pad_to_width(Design*des, NetNet*net, unsigned wid)
|
2000-02-16 04:58:27 +01:00
|
|
|
{
|
2001-02-15 07:59:35 +01:00
|
|
|
NetScope*scope = net->scope();
|
|
|
|
|
const string path = scope->name();
|
2000-05-02 02:58:11 +02:00
|
|
|
assert(scope);
|
|
|
|
|
|
2000-02-16 04:58:27 +01:00
|
|
|
if (net->pin_count() >= wid)
|
|
|
|
|
return net;
|
|
|
|
|
|
|
|
|
|
verinum pad(verinum::V0, wid - net->pin_count());
|
2001-02-16 04:25:09 +01:00
|
|
|
NetConst*con = new NetConst(path + "." + scope->local_symbol(), pad);
|
2000-02-16 04:58:27 +01:00
|
|
|
des->add_node(con);
|
|
|
|
|
|
2001-02-16 04:25:09 +01:00
|
|
|
NetNet*tmp = new NetNet(scope, path + "." + scope->local_symbol(),
|
2000-05-02 02:58:11 +02:00
|
|
|
NetNet::WIRE, wid);
|
2000-02-16 04:58:27 +01:00
|
|
|
tmp->local_flag(true);
|
|
|
|
|
|
|
|
|
|
for (unsigned idx = 0 ; idx < net->pin_count() ; idx += 1)
|
|
|
|
|
connect(tmp->pin(idx), net->pin(idx));
|
|
|
|
|
for (unsigned idx = net->pin_count() ; idx < wid ; idx += 1)
|
|
|
|
|
connect(tmp->pin(idx), con->pin(idx-net->pin_count()));
|
|
|
|
|
|
|
|
|
|
return tmp;
|
|
|
|
|
}
|
1999-09-29 02:42:50 +02:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* $Log: pad_to_width.cc,v $
|
2001-07-25 05:10:48 +02:00
|
|
|
* Revision 1.8 2001/07/25 03:10:49 steve
|
|
|
|
|
* Create a config.h.in file to hold all the config
|
|
|
|
|
* junk, and support gcc 3.0. (Stephan Boettcher)
|
|
|
|
|
*
|
2001-02-16 04:25:09 +01:00
|
|
|
* Revision 1.7 2001/02/16 03:25:09 steve
|
|
|
|
|
* Missing . in names generated from scope locals.
|
|
|
|
|
*
|
2001-02-15 07:59:35 +01:00
|
|
|
* Revision 1.6 2001/02/15 06:59:36 steve
|
|
|
|
|
* FreeBSD port has a maintainer now.
|
|
|
|
|
*
|
2000-05-02 02:58:11 +02:00
|
|
|
* Revision 1.5 2000/05/02 00:58:12 steve
|
|
|
|
|
* Move signal tables to the NetScope class.
|
|
|
|
|
*
|
2000-02-23 03:56:53 +01:00
|
|
|
* Revision 1.4 2000/02/23 02:56:55 steve
|
|
|
|
|
* Macintosh compilers do not support ident.
|
|
|
|
|
*
|
2000-02-16 04:58:27 +01:00
|
|
|
* Revision 1.3 2000/02/16 03:58:27 steve
|
|
|
|
|
* Fix up width matching in structural bitwise operators.
|
|
|
|
|
*
|
2000-01-01 07:17:25 +01:00
|
|
|
* Revision 1.2 2000/01/01 06:17:25 steve
|
|
|
|
|
* Propogate line number information when expanding expressions.
|
|
|
|
|
*
|
1999-09-29 02:42:50 +02:00
|
|
|
* Revision 1.1 1999/09/29 00:42:51 steve
|
|
|
|
|
* Allow expanding of additive operators.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|