...
 
Commits (1)
......@@ -23,7 +23,195 @@
using namespace TRC;
/* Connection support */
/* Wires bodies */
Wires Wires::operator&&(const Wires &w) const // MIN
{
int n = size();
int m = w.size();
if(m > n)
{
n = m;
m = size();
}
Wires r(n,type());
for(int i=0;i<n;i++)
{
if(i>=m)
{
r.set(i,INVALID);
continue;
}
switch(get(i))
{
case TRUE:
case PULLUP:
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;
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;
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;
}
Wires Wires::operator||(const Wires &w) const // MAX
{
int n = size();
int m = w.size();
if(m > n)
{
n = m;
m = size();
}
Wires r(n,type());
for(int i=0;i<n;i++)
{
if(i>=m)
{
r.set(i,INVALID);
continue;
}
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;
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;
}
Wires Wires::operator~() const /* INV */
{
Wires r(size(),type());
for(int i=0;i<size();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;
default:
r.set(i,INVALID);
}
}
return r;
}
/* Connection bodies */
int Connection::apply(char a)
{
......@@ -65,7 +253,7 @@ int Connection::apply(char a)
return c[1];
}
/* System support */
/* System bodies */
std::vector<Connection*> System::v;
std::map<std::string,int> System::m;
......
This diff is collapsed.
#include <TRCMath.hpp>
//#undef DEBUG
#undef DEBUG
#include <time.h>
#include <stdio.h>
......