...
 
Commits (1)
......@@ -23,13 +23,6 @@
using namespace TRC;
/* Signal operators */
Signal TRC::operator&(const Signal &a, const Signal &b)
{
return a && b;
}
/* Connection support */
int Connection::apply(char a)
......@@ -37,7 +30,7 @@ int Connection::apply(char a)
#ifdef DEBUG_APPLY
std::cout << "Apply " << a << " on " << c[1];
#endif
if(a==INVALID) c[1] = INVALID;
if(a==INVALID || a==ANYBIT || a==ANYTRIT) c[1] = INVALID;
else
switch(c[1])
{
......@@ -52,12 +45,17 @@ int Connection::apply(char a)
break;
case PULLUP:
case PULLDOWN:
case PULLMID:
if(a==TRUE || a==MAYBE || a==FALSE) c[1] = a;
break;
case NC:
c[1] = a;
break;
/*
case ANYBIT:
case ANYTRIT:
case INVALID:
*/
default:
c[1] = INVALID;
}
......
......@@ -223,57 +223,145 @@ namespace TRC
r.set(i,TRUE);
break;
case MAYBE:
case PULLMID:
r.set(i,MAYBE);
break;
case FALSE:
case PULLDOWN:
r.set(i,FALSE);
break;
case NC:
case INVALID:
default:
r.set(i,INVALID);
}
break;
case MAYBE:
case PULLMID:
switch(w.get(i))
{
case TRUE:
case PULLUP:
case MAYBE:
case PULLMID:
r.set(i,MAYBE);
break;
case FALSE:
case PULLDOWN:
r.set(i,FALSE);
break;
case NC:
case INVALID:
default:
r.set(i,INVALID);
}
break;
case FALSE:
case PULLDOWN:
switch(w.get(i))
{
case TRUE:
case PULLUP:
case MAYBE:
case PULLMID:
case FALSE:
case PULLDOWN:
r.set(i,FALSE);
break;
default:
r.set(i,INVALID);
}
break;
default:
r.set(i,INVALID);
}
}
return r;
}
Wire<N> operator||(const Wire<N> &w) const
{
Wire<N> r(type());
for(int i=0;i<N;i++)
{
switch(get(i))
{
case FALSE:
case PULLDOWN:
switch(w.get(i))
{
case TRUE:
case PULLUP:
r.set(i,TRUE);
break;
case MAYBE:
case PULLMID:
r.set(i,MAYBE);
break;
case FALSE:
case PULLDOWN:
r.set(i,FALSE);
break;
case NC:
case INVALID:
default:
r.set(i,INVALID);
}
break;
case MAYBE:
case PULLMID:
switch(w.get(i))
{
case TRUE:
case PULLUP:
r.set(i,TRUE);
break;
case MAYBE:
case PULLMID:
case FALSE:
case PULLDOWN:
r.set(i,MAYBE);
break;
default:
r.set(i,INVALID);
}
break;
case TRUE:
case PULLUP:
switch(w.get(i))
{
case TRUE:
case PULLUP:
case MAYBE:
case PULLMID:
case FALSE:
case PULLDOWN:
r.set(i,TRUE);
break;
default:
r.set(i,INVALID);
}
break;
default:
r.set(i,INVALID);
}
}
return r;
}
Wire<N> operator~() const
{
Wire<N> r(type());
for(int i=0;i<N;i++)
{
switch(get(i))
{
case FALSE:
case PULLDOWN:
r.set(i,TRUE);
break;
case MAYBE:
case PULLMID:
r.set(i,MAYBE);
break;
case TRUE:
case PULLUP:
r.set(i,FALSE);
break;
case NC:
case INVALID:
default:
r.set(i,INVALID);
}
......@@ -293,7 +381,20 @@ namespace TRC
typedef Wire<1> Signal;
Signal operator&(const Signal &a, const Signal &b);
inline Signal operator&(const Signal &a, const Signal &b)
{
return a && b;
}
inline Signal operator|(const Signal &a, const Signal &b)
{
return a || b;
}
inline Signal operator!(const Signal &a)
{
return ~a;
}
// class Uint<N> (unsigned N-bit integer)
......