LamNT Bao Cao FCK 2
LamNT Bao Cao FCK 2
LamNT Bao Cao FCK 2
I.
Nhim v
-
II.
V mch n gin
In mch
Tm hiu cu trc d liu FCK
V mch
1. M hnh mch
Mch c xy dng c dng nh sau:
2. Code
Cu trc hm main
- To component
Kt ni cc Component
In mch
std::vector<FckId> fanins;
std::string fanout;
// Instance 8 fanins, and number them by id1, id2, id3, ... (original as unsigned data )
FckId id1;
// INPUT_1 : "a_in"
FckId id2;
// PS_INPUT_1 : "ps_in1"
FckId id3;
// PS_INPUT_2 : "ps_in2"
FckId id4;
// AND : "and1"
FckId id5;
// PS_OUTPUT_1 : "ps_out1"
FckId id6;
// PS_OUTPUT_2 : "ps_out2"
FckId id7;
// OR : "or1"
FckId id8;
// OUTPUT_1 : "b"
//---------------------Component 1__INPUT_1-----------------//
// Create new fanout and name it as "a_in"
fanout = "a_in";
// Vector fanins is set by { 1 }
fanins.push_back(1);
// Create new Input (as fanins) by id1
// and new fanouts as "a_in"
id1 = cir->AddComponent(INPUT,fanins,fanout,0);
//---------------------Component 2__PS_INPUT_1--------------//
fanins.clear();
// Vector fanins is { 1 }
fanins.push_back(1);
// Create new fanout and name it as "ps_in1"
fanout = "ps_in1";
id2 = cir->AddComponent(PS_INPUT,fanins,fanout,0);
//---------------------Component 3__PS_INPUT_2--------------//
fanins.clear();
// Vector fanins is { 1 }
fanins.push_back(1);
// Create new fanout and name it as "ps_in2"
fanout = "ps_in2";
id3 = cir->AddComponent(PS_INPUT,fanins,fanout,0);
//---------------------Component 4__AND----------------//
fanins.clear();
// Vector fanins is { id1, id2 }
fanins.push_back(id1);
// id1 as "a_in"
fanins.push_back(id2);
// id2 as "ps_in1"
// Create new fanout and name it as "and1"
fanout = "and1";
id4 = cir->AddComponent(AND,fanins,fanout,0);
//---------------------Component 5__PS_OUTPUT_1---------------//
fanins.clear();
// Vector fanins is { 1 }
fanins.push_back(1);
// Create new fanout and name it as "ps_out1"
fanout = "ps_out1";
id5 = cir->AddComponent(PS_OUTPUT,fanins,fanout,0);
//---------------------Component 6__PS_OUTPUT_2---------------//
fanins.clear();
// Vector fanins is { 1 }
fanins.push_back(1);
// Create new fanout and name it as "ps_out2"
fanout = "ps_out2";
id6 = cir->AddComponent(PS_OUTPUT,fanins,fanout,0);
//---------------------Component 7__OR_1---------------//
fanins.clear();
// Vector fanins is { id3, id2 }
fanins.push_back(id3);
// id3 as "ps_in2"
fanins.push_back(id2);
// id2 as "ps_in1"
// Create new fanout and name it as "or1"
fanout = "or1";
id7 = cir->AddComponent(OR,fanins,fanout,0);
//---------------------Component 8__OUTPUT_1---------------//
fanins.clear();
// Vector fanins is { id7 }
fanins.push_back(id7);
// id7 as "or1"
// Create new fanout and name it as "b"
fanout = "b";
id8 = cir->AddComponent(OUTPUT,fanins,fanout,0);
// Map
cir -> GetComponent("ps_out1",0) -> AddFanin(cir -> GetComponent("and1",0),0); // Noi cong
and1 vao ps_out1
cir -> GetComponent("ps_in1",0) -> AddFanin(cir -> GetComponent("ps_out1",0),0); // Noi
cong ps_out1 vao ps_in1
cir -> GetComponent("ps_out2",0) -> AddFanin(cir -> GetComponent("a_in",0),0);
// Noi cong a_in vao ps_out2
cir -> GetComponent("ps_in2",0) -> AddFanin(cir -> GetComponent("ps_out2",0),0); // Noi
cong ps_out2 vao ps_in2
// In mach lan 2 (sau khi ket noi cac components)
std::cout << "Mach sau khi kt ni vi nhau" << std::endl;
cir -> Print();
return 0;
}
3. Kt qu
Di y l kt qu hm main
III.