Skip to content

Commit

Permalink
修复状态转移真值表显示的BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
sg-first committed Dec 30, 2020
1 parent 4a65497 commit 8327b3a
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions node.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,22 +100,27 @@ class nodeManager
vector<line*> allInput;
vector<line*> allOutput;
vector<node*> allTri;
void recuTriTrue(uint sub = 0)

string recuTriTrue(uint sub = 0)
{
string result;

tri* t=(tri*)(allTri[sub]->g);
t->setQ(0);

if(sub==allTri.size()-1)
run(true);
if(sub==allTri.size()-1) //产生一个所有触发器值的组合之后再run
result=run(true)+result;
else
recuTriTrue(sub+1);
result=recuTriTrue(sub+1)+result;

t->setQ(1);

if(sub==allTri.size()-1)
run(true);
result=run(true)+result;
else
recuTriTrue(sub+1);
result=recuTriTrue(sub+1)+result;

return result;
}

void resetChunk()
Expand Down Expand Up @@ -164,18 +169,22 @@ class nodeManager

string trueTable(uint sub = 0, bool staRecu=false)
{
if(staRecu && this->allTri.empty())
return "There is no trigger in this circuit\n";

string result;

auto conti=[&]()
{
if(sub==allInput.size()-1)
{
if(staRecu)
recuTriTrue();
result+=recuTriTrue();
else
result+=run();
}
else
trueTable(sub+1,staRecu);
result+=trueTable(sub+1,staRecu);
};

allInput[sub]->constVal=0;
Expand All @@ -200,7 +209,7 @@ class nodeManager
for(uint i=0;i<allTri.size();i++)
{
tri* t=(tri*)(allTri[i]->g);
result+="["+to_string(i)+"]"+to_string(t->getQ())<+" ";
result+="["+to_string(i)+"]"+to_string(t->getQ())+" ";
}
}

Expand Down

0 comments on commit 8327b3a

Please sign in to comment.