-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransistorNtk.h
More file actions
122 lines (99 loc) · 2.58 KB
/
Copy pathTransistorNtk.h
File metadata and controls
122 lines (99 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#pragma once
#ifndef __TRANSISTOR_NTK__
#define __TRANSISTOR_NTK__
#include <iostream>
#include <vector>
#include <UGraphviz/UGraphviz.hpp>
#include <sstream>
#include <fstream>
using namespace std;
using namespace Ubpa::UGraphviz;
class Switch
{
public:
Switch();
Switch(string s);
~Switch();
string name;
int val; // 0: no switch 1: has a switch
private:
};
class TransistorNode
{
public:
TransistorNode();
TransistorNode(string s, int Id);
~TransistorNode();
vector<int> neighborEdges;
int CnfVar;
vector<int> CnfVecVars;
string name;
int type; // 0: ports of transistors 1: VDD 2:Output
int id;
int TmpId; // for multi-out Ntk case
private:
};
class TransistorEdge
{
public:
TransistorEdge();
TransistorEdge(int n1, int n2, string sw, int Id);
~TransistorEdge();
int id; // edge id
int id1, id2;
int CnfVarC1, CnfVarC2; // id1->id2, id2->id1
int CnfVarF1, CnfVarF2; // id1->id2, id2->id1
int CnfVarSw;
vector<int> CnfVecVarsC1, CnfVecVarsC2;
vector<int> CnfVecVarsF1, CnfVecVarsF2;
vector<int> CnfVecVarsSw; // transistor variable
Switch s;
// new added
int CnfVarCnt; // Internal connection variable
vector<int> CnfVarInputs; // input selection variables
// version: 2023/3/22
int TmpId; // for multi-out Ntk case
//// version: 2023/4/15
//int CnfBoundVarC1, CnfBoundVarC2;
//int CnfBoundVarF1, CnfBoundVarF2;
//int CnfBoundVarSw;
private:
};
class TransistorNtk
{
public:
int nTransistors; // number of transistors in Ntk
vector<int> iTransistors; // ids of all transistor edges
vector<int> Tt;
vector<TransistorEdge> Edges;
vector<TransistorNode> Nodes;
TransistorNtk();
~TransistorNtk();
// version: 2023/03/06
string NtkName;
// version: 2023/03/15
void RemoveNode(int iNode, string newNtkName);
void DrawTransistorNtk();
// version: 2023/3/22
int nOutputs;
// version: 2023/3/26
void updateTmpID() {
for (int i = 0; i < Nodes.size(); i++)
Nodes[i].TmpId = Nodes[i].id;
for (int i = 0; i < Edges.size(); i++)
Edges[i].TmpId = Edges[i].id;
}
// version: 2023/4/22 0 1 2 3
vector<int> GetOutputNodeIDs() {
vector<int> outputIDs;
for (int i = 0; i < nOutputs; i++)
outputIDs.push_back(Nodes[Nodes.size() - nOutputs + i].id);
return outputIDs;
}
private:
};
TransistorNtk ReadTransistorNtk(string path);
TransistorNtk ConstructTransistorNtk(int nTransistors, string Name);
// version:2023/03/15
TransistorNtk ConstructMultiOutTransistorNtk(int nTransistors, int nOutputs, string Name);
#endif // !__TRANSISTOR_NTK__