forked from Khaliddxx/CMOS_SpiceGen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Source.cpp
70 lines (49 loc) · 1.62 KB
/
Source.cpp
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
#include <iostream>
#include <string>
#include "initialize.h" //File that has functions to give seperate values for PMOS and NMOS
#include "output.h" //File that contains struct for CMOS and functions to produce the output
using namespace std;
int main() {
vector<CMOS> deck;
vector<char> output_chars;
vector<string> expressions;
vector<char> pun, pdn;
pun.resize(10000);
string input;
string output;
/* User input */
cout << "Enter valid boolean expressions separated by ';':" << endl;
cin >> input;
cout << endl;
/* Generating postfix expressions*/
output_chars = extract_output(input);
expressions = calculate_Priority(input);
for (int i = 0; i < expressions.size(); i++) {
string first = expressions[i];
/* Generating separate expressions for both pun and pdn*/
for (int i = 0; i < first.length(); i++)
pun.push_back(first[i]);
pdn= negate_exp(expressions[i]);
/* for testing,this code ptints the postfix expressions for pun and pdn */
//for (int i = 0; i < pun.size(); i++)
// cout << pun[i];
// cout << endl;
// for (int i = 0; i < pdn.size(); i++)
// cout << pdn[i];
// cout << endl;
/* Construction of the pun and pdn*/
bool flag = false;
output = output_chars[i];
run(pun, &deck, output, "VDD", PMOS, flag);
flag = false;
run(pdn, &deck, output, "0", NMOS, flag);
}
/* Netlist output*/
CMOS decks;
for (int i = 0; i < deck.size(); i++) {
decks = deck[i];
cout << decks.m_name << " " << decks.drain << " " << decks.gate << " "
<< decks.source << " " << decks.body << " "
<< (decks.type == PMOS ? "PMOS" : "NMOS") << endl;
}
}