Remove Link::strength_t and PGate::strength_t types.

These types are useless repetition of the ivl_drive_t type.
This is also another chapter in the series to push ivl_target
generation further upstream.
This commit is contained in:
Stephen Williams 2010-03-16 15:16:53 -07:00
parent 261cfd1dae
commit 79f8b8fcfd
13 changed files with 85 additions and 252 deletions

View File

@ -30,8 +30,8 @@ PGate::PGate(perm_string name,
: name_(name), pins_(pins)
{
if (del) delay_.set_delays(del);
str0_ = STRONG;
str1_ = STRONG;
str0_ = IVL_DR_STRONG;
str1_ = IVL_DR_STRONG;
}
PGate::PGate(perm_string name,
@ -40,37 +40,37 @@ PGate::PGate(perm_string name,
: name_(name), pins_(pins)
{
if (del) delay_.set_delay(del);
str0_ = STRONG;
str1_ = STRONG;
str0_ = IVL_DR_STRONG;
str1_ = IVL_DR_STRONG;
}
PGate::PGate(perm_string name, svector<PExpr*>*pins)
: name_(name), pins_(pins)
{
str0_ = STRONG;
str1_ = STRONG;
str0_ = IVL_DR_STRONG;
str1_ = IVL_DR_STRONG;
}
PGate::~PGate()
{
}
PGate::strength_t PGate::strength0() const
ivl_drive_t PGate::strength0() const
{
return str0_;
}
void PGate::strength0(PGate::strength_t s)
void PGate::strength0(ivl_drive_t s)
{
str0_ = s;
}
PGate::strength_t PGate::strength1() const
ivl_drive_t PGate::strength1() const
{
return str1_;
}
void PGate::strength1(PGate::strength_t s)
void PGate::strength1(ivl_drive_t s)
{
str1_ = s;
}

12
PGate.h
View File

@ -48,8 +48,6 @@ class Module;
class PGate : public LineInfo {
public:
enum strength_t { HIGHZ, WEAK, PULL, STRONG, SUPPLY };
explicit PGate(perm_string name, svector<PExpr*>*pins,
const svector<PExpr*>*del);
@ -73,11 +71,11 @@ class PGate : public LineInfo {
unsigned pin_count() const { return pins_? pins_->count() : 0; }
PExpr*pin(unsigned idx) const { return (*pins_)[idx]; }
strength_t strength0() const;
strength_t strength1() const;
ivl_drive_t strength0() const;
ivl_drive_t strength1() const;
void strength0(strength_t);
void strength1(strength_t);
void strength0(ivl_drive_t);
void strength1(ivl_drive_t);
map<perm_string,PExpr*> attributes;
@ -97,7 +95,7 @@ class PGate : public LineInfo {
PDelays delay_;
svector<PExpr*>*pins_;
strength_t str0_, str1_;
ivl_drive_t str0_, str1_;
private: // not implemented
PGate(const PGate&);

View File

@ -43,22 +43,31 @@ static ostream& operator<< (ostream&o, NetBlock::Type t)
return o;
}
ostream& operator << (ostream&o, Link::strength_t str)
ostream& operator << (ostream&o, ivl_drive_t str)
{
switch (str) {
case Link::HIGHZ:
case IVL_DR_HiZ:
o << "highz";
break;
case Link::WEAK:
case IVL_DR_SMALL:
o << "small";
break;
case IVL_DR_MEDIUM:
o << "medium";
break;
case IVL_DR_WEAK:
o << "weak";
break;
case Link::PULL:
case IVL_DR_LARGE:
o << "large";
break;
case IVL_DR_PULL:
o << "pull";
break;
case Link::STRONG:
case IVL_DR_STRONG:
o << "strong";
break;
case Link::SUPPLY:
case IVL_DR_SUPPLY:
o << "supply";
break;
default:

View File

@ -1009,8 +1009,8 @@ NetNet* PWire::elaborate_sig(Design*des, NetScope*scope) const
pull = new NetLogic(scope, scope->local_symbol(),
1, pull_type, wid);
pull->set_line(*this);
pull->pin(0).drive0(Link::SUPPLY);
pull->pin(0).drive1(Link::SUPPLY);
pull->pin(0).drive0(IVL_DR_SUPPLY);
pull->pin(0).drive1(IVL_DR_SUPPLY);
des->add_node(pull);
wtype = NetNet::WIRE;

View File

@ -42,26 +42,6 @@
# include "ivl_assert.h"
static Link::strength_t drive_type(PGate::strength_t drv)
{
switch (drv) {
case PGate::HIGHZ:
return Link::HIGHZ;
case PGate::WEAK:
return Link::WEAK;
case PGate::PULL:
return Link::PULL;
case PGate::STRONG:
return Link::STRONG;
case PGate::SUPPLY:
return Link::SUPPLY;
default:
assert(0);
}
return Link::STRONG;
}
void PGate::elaborate(Design*des, NetScope*scope) const
{
cerr << "internal error: what kind of gate? " <<
@ -79,8 +59,8 @@ void PGAssign::elaborate(Design*des, NetScope*scope) const
NetExpr* rise_time, *fall_time, *decay_time;
eval_delays(des, scope, rise_time, fall_time, decay_time, true);
Link::strength_t drive0 = drive_type(strength0());
Link::strength_t drive1 = drive_type(strength1());
ivl_drive_t drive0 = strength0();
ivl_drive_t drive1 = strength1();
assert(pin(0));
assert(pin(1));
@ -192,7 +172,7 @@ void PGAssign::elaborate(Design*des, NetScope*scope) const
/* When we are given a non-default strength value and if the
* drive source is a bit, part or indexed select we need to
* add a driver (BUFZ) to convey the strength information. */
if ((drive0 != Link::STRONG || drive1 != Link::STRONG) &&
if ((drive0 != IVL_DR_STRONG || drive1 != IVL_DR_STRONG) &&
(dynamic_cast<NetESelect*>(rval_expr))) {
need_driver_flag = true;
}
@ -218,7 +198,7 @@ void PGAssign::elaborate(Design*des, NetScope*scope) const
/* Set the drive and delays for the r-val. */
if (drive0 != Link::STRONG || drive1 != Link::STRONG)
if (drive0 != IVL_DR_STRONG || drive1 != IVL_DR_STRONG)
rval->pin(0).drivers_drive(drive0, drive1);
if (rise_time || fall_time || decay_time)
@ -709,8 +689,8 @@ void PGBuiltin::elaborate(Design*des, NetScope*scope) const
log->fall_time(fall_time);
log->decay_time(decay_time);
log->pin(0).drive0(drive_type(strength0()));
log->pin(0).drive1(drive_type(strength1()));
log->pin(0).drive0(strength0());
log->pin(0).drive1(strength1());
}
cur[idx]->set_line(*this);

View File

@ -22,6 +22,7 @@
# include "ivl_target.h"
# include <inttypes.h>
# include <vector>
# include <ostream>
# include <valarray>
/*
@ -79,4 +80,6 @@ struct ivl_island_s {
std::vector<bool> flags;
};
extern std::ostream& operator << (std::ostream&o, ivl_drive_t str);
#endif

View File

@ -38,8 +38,8 @@ NetUserFunc::NetUserFunc(NetScope*s, perm_string n, NetScope*d, NetEvWait*trigge
for (unsigned idx = 1 ; idx < pin_count() ; idx += 1) {
pin(idx).set_dir(Link::INPUT);
pin(idx).drive0(Link::HIGHZ);
pin(idx).drive1(Link::HIGHZ);
pin(idx).drive0(IVL_DR_HiZ);
pin(idx).drive1(IVL_DR_HiZ);
}
}
@ -136,8 +136,8 @@ NetSysFunc::NetSysFunc(NetScope*s, perm_string n,
for (unsigned idx = 1 ; idx < pin_count() ; idx += 1) {
pin(idx).set_dir(Link::INPUT);
pin(idx).drive0(Link::HIGHZ);
pin(idx).drive1(Link::HIGHZ);
pin(idx).drive0(IVL_DR_HiZ);
pin(idx).drive1(IVL_DR_HiZ);
}
}

View File

@ -105,7 +105,7 @@ void connect(Link&l, Link&r)
}
Link::Link()
: dir_(PASSIVE), drive0_(STRONG), drive1_(STRONG),
: dir_(PASSIVE), drive0_(IVL_DR_STRONG), drive1_(IVL_DR_STRONG),
next_(0), nexus_(0)
{
}
@ -162,61 +162,32 @@ void Link::drivers_delays(NetExpr*rise, NetExpr*fall, NetExpr*decay)
find_nexus_()->drivers_delays(rise, fall, decay);
}
void Link::drivers_drive(strength_t drive0__, strength_t drive1__)
void Link::drivers_drive(ivl_drive_t drive0__, ivl_drive_t drive1__)
{
find_nexus_()->drivers_drive(drive0__, drive1__);
}
static ivl_drive_t link_to_drive(Link::strength_t dr)
{
switch (dr) {
case Link::HIGHZ:
return IVL_DR_HiZ;
case Link::WEAK:
return IVL_DR_WEAK;
case Link::PULL:
return IVL_DR_PULL;
case Link::STRONG:
return IVL_DR_STRONG;
case Link::SUPPLY:
return IVL_DR_SUPPLY;
}
assert(0);
return IVL_DR_HiZ;
}
void Link::drive0(Link::strength_t str)
void Link::drive0(ivl_drive_t str)
{
drive0_ = str;
}
void Link::drive1(Link::strength_t str)
void Link::drive1(ivl_drive_t str)
{
drive1_ = str;
}
Link::strength_t Link::drive0() const
ivl_drive_t Link::drive0() const
{
return drive0_;
}
Link::strength_t Link::drive1() const
ivl_drive_t Link::drive1() const
{
return drive1_;
}
ivl_drive_t Link::ivl_drive0() const
{
return link_to_drive(drive0_);
}
ivl_drive_t Link::ivl_drive1() const
{
return link_to_drive(drive1_);
}
void Link::cur_link(NetPins*&net, unsigned &pin)
{
net = get_obj();
@ -384,7 +355,7 @@ void Nexus::drivers_delays(NetExpr*rise, NetExpr*fall, NetExpr*decay)
}
}
void Nexus::drivers_drive(Link::strength_t drive0, Link::strength_t drive1)
void Nexus::drivers_drive(ivl_drive_t drive0, ivl_drive_t drive1)
{
for (Link*cur = first_nlink() ; cur ; cur = cur->next_nlink()) {
if (cur->get_dir() != Link::OUTPUT)

View File

@ -87,8 +87,6 @@ class Link {
public:
enum DIR { PASSIVE, INPUT, OUTPUT };
enum strength_t { HIGHZ, WEAK, PULL, STRONG, SUPPLY };
private: // Only NetPins can create/delete Link objects
Link();
~Link();
@ -104,18 +102,15 @@ class Link {
// A link has a drive strength for 0 and 1 values. The drive0
// strength is for when the link has the value 0, and drive1
// strength is for when the link has a value 1.
void drive0(strength_t);
void drive1(strength_t);
void drive0(ivl_drive_t);
void drive1(ivl_drive_t);
// This sets the drives for all drivers of this link, and not
// just the current link.
void drivers_drive(strength_t d0, strength_t d1);
void drivers_drive(ivl_drive_t d0, ivl_drive_t d1);
strength_t drive0() const;
strength_t drive1() const;
ivl_drive_t ivl_drive0() const;
ivl_drive_t ivl_drive1() const;
ivl_drive_t drive0() const;
ivl_drive_t drive1() const;
void cur_link(NetPins*&net, unsigned &pin);
void cur_link(const NetPins*&net, unsigned &pin) const;
@ -159,8 +154,8 @@ class Link {
bool pin_zero_ : 1;
DIR dir_ : 2;
strength_t drive0_ : 3;
strength_t drive1_ : 3;
ivl_drive_t drive0_ : 3;
ivl_drive_t drive1_ : 3;
private:
Nexus* find_nexus_() const;
@ -340,7 +335,7 @@ class Nexus {
const char* name() const;
void drivers_delays(NetExpr*rise, NetExpr*fall, NetExpr*decay);
void drivers_drive(Link::strength_t d0, Link::strength_t d1);
void drivers_drive(ivl_drive_t d0, ivl_drive_t d1);
Link*first_nlink();
const Link* first_nlink()const;

30
parse.y
View File

@ -87,8 +87,8 @@ static unsigned args_after_notifier;
* These are some common strength pairs that are used as defaults when
* the user is not otherwise specific.
*/
const static struct str_pair_t pull_strength = { PGate::PULL, PGate::PULL };
const static struct str_pair_t str_strength = { PGate::STRONG, PGate::STRONG };
const static struct str_pair_t pull_strength = { IVL_DR_PULL, IVL_DR_PULL };
const static struct str_pair_t str_strength = { IVL_DR_STRONG, IVL_DR_STRONG };
static list<pair<perm_string,PExpr*> >* make_port_list(char*id, PExpr*expr)
{
@ -884,39 +884,39 @@ drive_strength
}
| '(' dr_strength0 ',' K_highz1 ')'
{ $$.str0 = $2.str0;
$$.str1 = PGate::HIGHZ;
$$.str1 = IVL_DR_HiZ;
}
| '(' dr_strength1 ',' K_highz0 ')'
{ $$.str0 = PGate::HIGHZ;
{ $$.str0 = IVL_DR_HiZ;
$$.str1 = $2.str1;
}
| '(' K_highz1 ',' dr_strength0 ')'
{ $$.str0 = $4.str0;
$$.str1 = PGate::HIGHZ;
$$.str1 = IVL_DR_HiZ;
}
| '(' K_highz0 ',' dr_strength1 ')'
{ $$.str0 = PGate::HIGHZ;
{ $$.str0 = IVL_DR_HiZ;
$$.str1 = $4.str1;
}
;
drive_strength_opt
: drive_strength { $$ = $1; }
| { $$.str0 = PGate::STRONG; $$.str1 = PGate::STRONG; }
| { $$.str0 = IVL_DR_STRONG; $$.str1 = IVL_DR_STRONG; }
;
dr_strength0
: K_supply0 { $$.str0 = PGate::SUPPLY; }
| K_strong0 { $$.str0 = PGate::STRONG; }
| K_pull0 { $$.str0 = PGate::PULL; }
| K_weak0 { $$.str0 = PGate::WEAK; }
: K_supply0 { $$.str0 = IVL_DR_SUPPLY; }
| K_strong0 { $$.str0 = IVL_DR_STRONG; }
| K_pull0 { $$.str0 = IVL_DR_PULL; }
| K_weak0 { $$.str0 = IVL_DR_WEAK; }
;
dr_strength1
: K_supply1 { $$.str1 = PGate::SUPPLY; }
| K_strong1 { $$.str1 = PGate::STRONG; }
| K_pull1 { $$.str1 = PGate::PULL; }
| K_weak1 { $$.str1 = PGate::WEAK; }
: K_supply1 { $$.str1 = IVL_DR_SUPPLY; }
| K_strong1 { $$.str1 = IVL_DR_STRONG; }
| K_pull1 { $$.str1 = IVL_DR_PULL; }
| K_weak1 { $$.str1 = IVL_DR_WEAK; }
;
event_control

View File

@ -91,7 +91,7 @@ struct parmvalue_t {
svector<named_pexpr_t*>*by_name;
};
struct str_pair_t { PGate::strength_t str0, str1; };
struct str_pair_t { ivl_drive_t str0, str1; };
struct net_decl_assign_t {
perm_string name;

View File

@ -30,6 +30,7 @@
# include "PGenerate.h"
# include "PSpec.h"
# include "discipline.h"
# include "ivl_target_priv.h"
# include <iostream>
# include <iomanip>
# include <typeinfo>
@ -52,30 +53,6 @@ ostream& operator << (ostream&o, const PDelays&d)
return o;
}
ostream& operator<< (ostream&o, PGate::strength_t str)
{
switch (str) {
case PGate::HIGHZ:
o << "highz";
break;
case PGate::WEAK:
o << "weak";
break;
case PGate::PULL:
o << "pull";
break;
case PGate::STRONG:
o << "strong";
break;
case PGate::SUPPLY:
o << "supply";
break;
default:
assert(0);
}
return o;
}
ostream& operator<< (ostream&out, perm_string that)
{
out << that.str();

116
t-dll.cc
View File

@ -171,41 +171,8 @@ static perm_string make_scope_name(const hname_t&name)
static void drive_from_link(const Link&lnk, ivl_drive_t&drv0, ivl_drive_t&drv1)
{
switch (lnk.drive0()) {
case Link::HIGHZ:
drv0 = IVL_DR_HiZ;
break;
case Link::WEAK:
drv0 = IVL_DR_WEAK;
break;
case Link::PULL:
drv0 = IVL_DR_PULL;
break;
case Link::STRONG:
drv0 = IVL_DR_STRONG;
break;
case Link::SUPPLY:
drv0 = IVL_DR_SUPPLY;
break;
}
switch (lnk.drive1()) {
case Link::HIGHZ:
drv1 = IVL_DR_HiZ;
break;
case Link::WEAK:
drv1 = IVL_DR_WEAK;
break;
case Link::PULL:
drv1 = IVL_DR_PULL;
break;
case Link::STRONG:
drv1 = IVL_DR_STRONG;
break;
case Link::SUPPLY:
drv1 = IVL_DR_SUPPLY;
break;
}
drv0 = lnk.drive0();
drv1 = lnk.drive1();
}
ivl_attribute_s* dll_target::fill_in_attributes(const Attrib*net)
@ -846,42 +813,8 @@ bool dll_target::bufz(const NetBUFZ*net)
obj->pins_[0] = net->pin(0).nexus()->t_cookie();
ivl_nexus_ptr_t out_ptr = nexus_log_add(obj->pins_[0], obj, 0);
switch (net->pin(0).drive0()) {
case Link::HIGHZ:
out_ptr->drive0 = IVL_DR_HiZ;
break;
case Link::WEAK:
out_ptr->drive0 = IVL_DR_WEAK;
break;
case Link::PULL:
out_ptr->drive0 = IVL_DR_PULL;
break;
case Link::STRONG:
out_ptr->drive0 = IVL_DR_STRONG;
break;
case Link::SUPPLY:
out_ptr->drive0 = IVL_DR_SUPPLY;
break;
}
switch (net->pin(0).drive1()) {
case Link::HIGHZ:
out_ptr->drive1 = IVL_DR_HiZ;
break;
case Link::WEAK:
out_ptr->drive1 = IVL_DR_WEAK;
break;
case Link::PULL:
out_ptr->drive1 = IVL_DR_PULL;
break;
case Link::STRONG:
out_ptr->drive1 = IVL_DR_STRONG;
break;
case Link::SUPPLY:
out_ptr->drive1 = IVL_DR_SUPPLY;
break;
}
out_ptr->drive0 = net->pin(0).drive0();
out_ptr->drive1 = net->pin(0).drive1();
assert(net->pin(1).nexus()->t_cookie());
obj->pins_[1] = net->pin(1).nexus()->t_cookie();
@ -1034,41 +967,8 @@ void dll_target::logic(const NetLogic*net)
out_ptr = tmp;
}
switch (net->pin(0).drive0()) {
case Link::HIGHZ:
out_ptr->drive0 = IVL_DR_HiZ;
break;
case Link::WEAK:
out_ptr->drive0 = IVL_DR_WEAK;
break;
case Link::PULL:
out_ptr->drive0 = IVL_DR_PULL;
break;
case Link::STRONG:
out_ptr->drive0 = IVL_DR_STRONG;
break;
case Link::SUPPLY:
out_ptr->drive0 = IVL_DR_SUPPLY;
break;
}
switch (net->pin(0).drive1()) {
case Link::HIGHZ:
out_ptr->drive1 = IVL_DR_HiZ;
break;
case Link::WEAK:
out_ptr->drive1 = IVL_DR_WEAK;
break;
case Link::PULL:
out_ptr->drive1 = IVL_DR_PULL;
break;
case Link::STRONG:
out_ptr->drive1 = IVL_DR_STRONG;
break;
case Link::SUPPLY:
out_ptr->drive1 = IVL_DR_SUPPLY;
break;
}
out_ptr->drive0 = net->pin(0).drive0();
out_ptr->drive1 = net->pin(0).drive1();
assert(net->scope());
ivl_scope_t scop = find_scope(des_, net->scope());
@ -2056,8 +1956,8 @@ void dll_target::lpm_mux(const NetMux*net)
assert(nex->t_cookie());
obj->u_.mux.q = nex->t_cookie();
nexus_lpm_add(obj->u_.mux.q, obj, 0,
net->pin_Result().ivl_drive0(),
net->pin_Result().ivl_drive1());
net->pin_Result().drive0(),
net->pin_Result().drive1());
/* Connect the select bits. */
nex = net->pin_Sel().nexus();