-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathNOT.cpp
More file actions
90 lines (75 loc) · 1.65 KB
/
Copy pathNOT.cpp
File metadata and controls
90 lines (75 loc) · 1.65 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
#include "NOT.h"
#include <fstream>
NOT::NOT(const GraphicsInfo& r_GfxInfo, int r_FanOut) :Gate(1, r_FanOut)
{
Set_noOfConnectedPins(4);
m_GfxInfo.x1 = r_GfxInfo.x1;
m_GfxInfo.y1 = r_GfxInfo.y1;
m_GfxInfo.x2 = r_GfxInfo.x2;
m_GfxInfo.y2 = r_GfxInfo.y2;
m_InputPins[0].SetConnected(false);
m_Inputs = 1;
m_Label = "ignore";
}
void NOT::Operate()
{
//caclulate the output status as the ORing of the two input pins
if (m_InputPins[0].getStatus() == LOW)
{
m_OutputPin.setStatus(HIGH);
}
else {
m_OutputPin.setStatus(LOW);
}
//Add you code here
}
// Function Draw
// Draws 2-input OR gate
void NOT::Draw(Output* pOut)
{
//Call output class and pass gate drawing info to it.
pOut->DrawNOT(m_GfxInfo,m_Selected);
}
void NOT::Draw(GraphicsInfo GInfo, bool m_selected, Output* pOut)
{
pOut->DrawNOT(GInfo, m_Selected);
}
OutputPin& NOT::Get_OutputPin()
{
return m_OutputPin;
}
InputPin *NOT::Get_InputPin()
{
return m_InputPins;
}
int NOT::GetInputs()
{
return m_Inputs;
}
//returns status of outputpin
int NOT::GetOutPinStatus()
{
return m_OutputPin.getStatus();
}
//returns status of Inputpin #n
int NOT::GetInputPinStatus(int n)
{
return m_InputPins[n - 1].getStatus(); //n starts from 1 but array index starts from 0.
}
//Set status of an input pin ot HIGH or LOW
void NOT::setInputPinStatus(int n, STATUS s)
{
m_InputPins[n - 1].setStatus(s);
}
int NOT::no()
{
return m_ConnectedPins;
}
void NOT::Set_noOfConnectedPins(int x)
{
m_ConnectedPins = (x <= 4) ? x : m_ConnectedPins;
}
void NOT::save(ofstream &file)
{
file << "NOT" << " " << ( m_GfxInfo.x1 + m_GfxInfo.x2 ) / 2 << " " << ( m_GfxInfo.y1 + m_GfxInfo.y2 ) / 2 << endl << m_Label << endl;
}