Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Bo co tun 2 (7_1_2013 -> 11_1_2013)

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

Dng hm cir AddComponent


-

Kt ni cc Component

Dng hm cir GetComponent ly Component ra.


Dng hm Component AddFain a Component mi vo Component qua fanin
-

In mch

Dng hm cir Print


Code
/*! ************************************************************************
\file main.cpp
\brief The main file of a circuit test
This file contains the main routine of our project
\author Nguyen Tung Lam
\copyright (c) Hanoi University of Technology Thu Jan 03 2013
**************************************************************************/
/*#include "../../src/circuit/circuit.h"
#include "../../src/circuit/timeframeexpansion.h"
#include <stdio.h>
#include "../../src/satlib/satI/MinisatI.h"
#include "../../src/satlib/satI/SatI.h"
#include "../../src/PslToFck/PslProperty.h"
#include "../../src/PslToFck/PslToFck.h"
#include "../../src/pslparser/PSL_Parser.h"
#include "../../src/pslparser/PSL_Exception.h"
#include <iostream>
#include <fstream>
*/
#include "../../src/pslparser/PSL_Parser.h"
#include "../../src/pslparser/PSL_Exception.h"
#include "../../src/PslToFck/PslToFck.h"
#include "../../src/circuit/circuit.h"
#include <stdio.h>
#include "../../src/circuit/timeframeexpansion.h"
#include <fstream>
/**
* This main program has 2 task
* The first one: create a circuit
* The second: using property file and check this circuit
*/

int main(int argc, char** argv)


{
// 1: create Circuit
// Create new Circuit and name it as cir.
// This Circuit has only 1 Module which Id is 0.
Circuit* cir = new Circuit();
// Instance fanins and fanouts. Caution into vector<FckId> of
fanouts.
// fanins as vector
// fanout as string

// fanins and string of

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);

// In mach lan 1 (truoc khi ket noi cac components)


std::cout << "Mch trc khi kt ni vi nhau" << std::endl;
cir -> Print();
std::cout << "\n";

// 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.

Cu trc d liu ca FCK


Xem trong bo co 3

You might also like