Add a make_const_0() function to create an all-zero constant net.
Factor out the common code with make_const_x() and make_const_z().
This commit is contained in:
parent
01e64861da
commit
d0af41442b
30
netmisc.cc
30
netmisc.cc
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2021 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2001-2024 Stephen Williams (steve@icarus.com)
|
||||||
*
|
*
|
||||||
* This source code is free software; you can redistribute it
|
* This source code is free software; you can redistribute it
|
||||||
* and/or modify it in source code form under the terms of the GNU
|
* and/or modify it in source code form under the terms of the GNU
|
||||||
|
|
@ -765,13 +765,12 @@ NetEConst* make_const_val_s(long value)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetNet* make_const_x(Design*des, NetScope*scope, unsigned long wid)
|
static NetNet* make_const_net(Design*des, NetScope*scope, verinum val)
|
||||||
{
|
{
|
||||||
verinum xxx (verinum::Vx, wid);
|
NetConst*res = new NetConst(scope, scope->local_symbol(), val);
|
||||||
NetConst*res = new NetConst(scope, scope->local_symbol(), xxx);
|
|
||||||
des->add_node(res);
|
des->add_node(res);
|
||||||
|
|
||||||
netvector_t*sig_vec = new netvector_t(IVL_VT_LOGIC, wid-1, 0);
|
netvector_t*sig_vec = new netvector_t(IVL_VT_LOGIC, val.len() - 1, 0);
|
||||||
NetNet*sig = new NetNet(scope, scope->local_symbol(), NetNet::WIRE, sig_vec);
|
NetNet*sig = new NetNet(scope, scope->local_symbol(), NetNet::WIRE, sig_vec);
|
||||||
sig->local_flag(true);
|
sig->local_flag(true);
|
||||||
|
|
||||||
|
|
@ -779,18 +778,19 @@ NetNet* make_const_x(Design*des, NetScope*scope, unsigned long wid)
|
||||||
return sig;
|
return sig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NetNet* make_const_0(Design*des, NetScope*scope, unsigned long wid)
|
||||||
|
{
|
||||||
|
return make_const_net(des, scope, verinum(verinum::V0, wid));
|
||||||
|
}
|
||||||
|
|
||||||
|
NetNet* make_const_x(Design*des, NetScope*scope, unsigned long wid)
|
||||||
|
{
|
||||||
|
return make_const_net(des, scope, verinum(verinum::Vx, wid));
|
||||||
|
}
|
||||||
|
|
||||||
NetNet* make_const_z(Design*des, NetScope*scope, unsigned long wid)
|
NetNet* make_const_z(Design*des, NetScope*scope, unsigned long wid)
|
||||||
{
|
{
|
||||||
verinum xxx (verinum::Vz, wid);
|
return make_const_net(des, scope, verinum(verinum::Vz, wid));
|
||||||
NetConst*res = new NetConst(scope, scope->local_symbol(), xxx);
|
|
||||||
des->add_node(res);
|
|
||||||
|
|
||||||
netvector_t*sig_vec = new netvector_t(IVL_VT_LOGIC, wid-1, 0);
|
|
||||||
NetNet*sig = new NetNet(scope, scope->local_symbol(), NetNet::WIRE, sig_vec);
|
|
||||||
sig->local_flag(true);
|
|
||||||
|
|
||||||
connect(sig->pin(0), res->pin(0));
|
|
||||||
return sig;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NetExpr* condition_reduce(NetExpr*expr)
|
NetExpr* condition_reduce(NetExpr*expr)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef IVL_netmisc_H
|
#ifndef IVL_netmisc_H
|
||||||
#define IVL_netmisc_H
|
#define IVL_netmisc_H
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1999-2021 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 1999-2024 Stephen Williams (steve@icarus.com)
|
||||||
*
|
*
|
||||||
* This source code is free software; you can redistribute it
|
* This source code is free software; you can redistribute it
|
||||||
* and/or modify it in source code form under the terms of the GNU
|
* and/or modify it in source code form under the terms of the GNU
|
||||||
|
|
@ -330,8 +330,9 @@ extern NetEConst*make_const_val(unsigned long val);
|
||||||
extern NetEConst*make_const_val_s(long val);
|
extern NetEConst*make_const_val_s(long val);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make A const net
|
* Make a const net.
|
||||||
*/
|
*/
|
||||||
|
extern NetNet* make_const_0(Design*des, NetScope*scope, unsigned long wid);
|
||||||
extern NetNet* make_const_x(Design*des, NetScope*scope, unsigned long wid);
|
extern NetNet* make_const_x(Design*des, NetScope*scope, unsigned long wid);
|
||||||
extern NetNet* make_const_z(Design*des, NetScope*scope, unsigned long wid);
|
extern NetNet* make_const_z(Design*des, NetScope*scope, unsigned long wid);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue