...
 
Commits (1)
......@@ -79,19 +79,25 @@ int System::attach(Entity* e, const char* n, unsigned short k, char c)
{
oo = -1;
std::string name(n);
if(*n=='.')
{
name = e->name() + name;
}
if(k>1)
{
name += "[";
name += std::to_string(i);
name += "]";
}
#if 1
std::cout << name << std::endl;
#endif
auto a = m.find(name);
if(a==m.end())
{
v.push_back(new Connection(name.c_str()));
oo = v.size()-1;
m[name] = oo;
v.push_back(new Connection(name.c_str()));
oo = v.size()-1;
m[name] = oo;
}
else oo = a->second;
v[oo]->entity(e,c);
......
......@@ -411,15 +411,15 @@ namespace TRC
std::string *n;
Entity()
Entity(const char* s)
{
sys = System::getInstance();
n = nullptr;
n = new std::string(s);
}
virtual ~Entity()
{
if(n!=nullptr) delete n;
delete n;
}
const std::string & name()
......@@ -427,12 +427,6 @@ namespace TRC
return *n;
}
void name(const char* s)
{
if(n!=nullptr) delete n;
n = new std::string(s);
}
int at(const char* n, unsigned short k = 1, char c = NC)
{
return sys->attach(this,n,k,c);
......
......@@ -4,7 +4,7 @@ using namespace std;
using namespace TRC;
class Unit1 : public Entity
class MyUnit : public Entity
{
protected:
......@@ -17,10 +17,10 @@ class Unit1 : public Entity
public:
Unit1()
MyUnit(const char* s) : Entity(s)
{
i0 = at("bus",8,PULLUP);
i1 = at("network",8);
i1 = at(".network",8);
i2 = at("single");
}
......@@ -31,14 +31,14 @@ class Unit1 : public Entity
sig[0] = TRUE;
io(i0) << sig[0];
io(i0+1) << sig[0];
io(i2) << sig[0];
if(posedge(i1+5))
{
}
io(i0) << sig[0];
io(i0+1) << sig[0];
io(i2) << sig[0];
}
};
......@@ -66,7 +66,14 @@ int main()
cout << "s=" << s << endl;
System *sys = System::getInstance();
Unit1 u1;
class Unit1 : public MyUnit
{
public:
Unit1() : MyUnit("Unit1")
{
i2 = at("single2");
}
} u1;
sys->clean();
u1.step();
}