SlideShare a Scribd company logo
#include
#include
#include
using namespace std;
void sm(int scl, int sda);
enum states {
s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14,
s15, s16
};
struct i2c {
int scl;
int sda;
int item;
};
struct i2c traces[1000];
int trace_length;
int main()
{
int item, scl, sda, index;
string trace0;
ifstream myfile; /* Naming the file to open*/
string myline;
char read_write_mode = 'R';
bool ack = false;
int read_count = 0;
int write_count = 0;
int ack_count = 0;
int nack_count = 0;
trace0 = "t0.txt"; /* Choosing the file trace*/
myfile.open(trace0.c_str()); /* Open file c_str is for the
first line*/
getline(myfile, myline); /* First line*/
index = 0;
while (!myfile.eof()) /* Assigning the clock and data from
file to code*/
{
myfile >> item >> scl >> sda;
traces[index].item = item;
traces[index].scl = scl;
traces[index].sda = sda;
index++;
}
trace_length = index; /* to count traces*/
myfile.close();
for (index = 0; index < trace_length; index++)
{
sm(traces[index].scl, traces[index].sda);
}
if ((scl == 0 && sda == 0) && (scl == 1 && sda == 0) &&
(scl == 0 && sda == 0))
{
ack_count++;
}
else
nack_count++;
cout << "ack = " << ack_count << endl;
cout << "nack = " << nack_count << endl;
system("pause");
}
void sm(int scl, int sda)
{
static int ps = 0;
static int ns = 0;
static int address;
static int r_w;
static int temp;
static int k;
static int index;
static bool ack;
static bool nack;
ps = ns;
cout << "ps " << ps << endl;
cout << "scl " << scl << " " << "sda " << sda << endl;
cout << "Address = " << temp << endl;
switch (ps)
{
case s0: if ((scl == 1) && (sda == 0)) /* IDLE*/
ns = s1;
else
ns = s0;
break;
case s1: if (scl == 1) /* START*/
ns = s1;
else
ns = s2;
k = 0;
temp = 0;
break;
case s2: if (scl == 0)
ns = s2;
else
ns = s3;
break;
case s3: if (scl == 1)
ns = s3;
else
ns = s4;
temp = temp << 1;
temp = temp + sda;
k = k + 1;
break;
case s4: if (k != 8)
ns = s2;
else {
ns = s5;
address = temp >> 1;
r_w = temp & 1;
cout << "address = " << hex << address <<
endl;
}
break;
case s5: if (scl == 0)
ns = s5;
else
ns = s6;
break;
case s6: if (scl == 1) /*ACK = 0, NACK = 1 */
ns = s6;
else
ns = s7;
break;
case s7: if (ack == false)
ns = s0;
else
ns = s8;
break;
case s8: if (scl == 0)
ns = s8;
else
ns = s9;
break;
case s9: if (scl == 1)
ns = s9;
else
ns = s10;
break;
case s10: if (k != 8)
ns = s8;
else
ns = s11;
break;
case s11: if (scl == 0)
ns = s11;
else
ns = s12;
break;
case s12: if (scl == 1)
ns = s12;
else
ns = s13;
break;
case s13: if (ack == false)
ns = s0;
else
ns = s14;
break;
case s14: if (scl == 0 && sda == 0)
ns = s15;
else
ns = s14;
break;
case s15: if (scl == 0 && sda == 0)
ns = s15;
else
ns = s16;
break;
case s16: if (scl == 1 && sda == 0)
ns = s16;
else
ns = s0;
break;
}
}
#include #include #include using namespace std;v

More Related Content

Similar to #include #include #include using namespace std;v

Please finish the int LLInsert function.typedef struct STUDENT {.pdf
Please finish the int LLInsert function.typedef struct STUDENT {.pdfPlease finish the int LLInsert function.typedef struct STUDENT {.pdf
Please finish the int LLInsert function.typedef struct STUDENT {.pdf
fortmdu
 
C++ Strings.ppt
C++ Strings.pptC++ Strings.ppt
C++ Strings.ppt
DilanAlmsa
 
SENDER It is a helmet that contains a sensor for gases, vital s.pdf
SENDER  It is a helmet that contains a sensor for gases, vital s.pdfSENDER  It is a helmet that contains a sensor for gases, vital s.pdf
SENDER It is a helmet that contains a sensor for gases, vital s.pdf
alertshoeshingkimand
 
Code
CodeCode
Senior design project code for PPG
Senior design project code for PPGSenior design project code for PPG
Senior design project code for PPG
FrankDin1
 
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdfHow do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
footstatus
 
write the TODO part of the program.docx
write the TODO part of the program.docxwrite the TODO part of the program.docx
write the TODO part of the program.docx
annetnash8266
 
Arp
ArpArp
Computer Programming- Lecture 6
Computer Programming- Lecture 6Computer Programming- Lecture 6
Computer Programming- Lecture 6
Dr. Md. Shohel Sayeed
 
13. string, io streams
13. string, io streams13. string, io streams
13. string, io streams
Vahid Heidari
 
Arduino coding class part ii
Arduino coding class part iiArduino coding class part ii
Arduino coding class part ii
Jonah Marrs
 
Data structure doubly linked list programs
Data structure doubly linked list programsData structure doubly linked list programs
Data structure doubly linked list programs
iCreateWorld
 
Explain the following ASM code in detail, giving the reasons for the .pdf
Explain the following ASM code in detail, giving the reasons for the .pdfExplain the following ASM code in detail, giving the reasons for the .pdf
Explain the following ASM code in detail, giving the reasons for the .pdf
pigsleypeyno82989
 
Arduino
ArduinoArduino
Asssignment2
Asssignment2 Asssignment2
Asssignment2
AnnamalikAnnamalik
 
Udp socket programming(Florian)
Udp socket programming(Florian)Udp socket programming(Florian)
Udp socket programming(Florian)
Flor Ian
 

Similar to #include #include #include using namespace std;v (16)

Please finish the int LLInsert function.typedef struct STUDENT {.pdf
Please finish the int LLInsert function.typedef struct STUDENT {.pdfPlease finish the int LLInsert function.typedef struct STUDENT {.pdf
Please finish the int LLInsert function.typedef struct STUDENT {.pdf
 
C++ Strings.ppt
C++ Strings.pptC++ Strings.ppt
C++ Strings.ppt
 
SENDER It is a helmet that contains a sensor for gases, vital s.pdf
SENDER  It is a helmet that contains a sensor for gases, vital s.pdfSENDER  It is a helmet that contains a sensor for gases, vital s.pdf
SENDER It is a helmet that contains a sensor for gases, vital s.pdf
 
Code
CodeCode
Code
 
Senior design project code for PPG
Senior design project code for PPGSenior design project code for PPG
Senior design project code for PPG
 
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdfHow do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
 
write the TODO part of the program.docx
write the TODO part of the program.docxwrite the TODO part of the program.docx
write the TODO part of the program.docx
 
Arp
ArpArp
Arp
 
Computer Programming- Lecture 6
Computer Programming- Lecture 6Computer Programming- Lecture 6
Computer Programming- Lecture 6
 
13. string, io streams
13. string, io streams13. string, io streams
13. string, io streams
 
Arduino coding class part ii
Arduino coding class part iiArduino coding class part ii
Arduino coding class part ii
 
Data structure doubly linked list programs
Data structure doubly linked list programsData structure doubly linked list programs
Data structure doubly linked list programs
 
Explain the following ASM code in detail, giving the reasons for the .pdf
Explain the following ASM code in detail, giving the reasons for the .pdfExplain the following ASM code in detail, giving the reasons for the .pdf
Explain the following ASM code in detail, giving the reasons for the .pdf
 
Arduino
ArduinoArduino
Arduino
 
Asssignment2
Asssignment2 Asssignment2
Asssignment2
 
Udp socket programming(Florian)
Udp socket programming(Florian)Udp socket programming(Florian)
Udp socket programming(Florian)
 

More from hirstcruz

AristotleBelow is the second assignment for your assistance.  Th.docx
AristotleBelow is the second assignment for your assistance.  Th.docxAristotleBelow is the second assignment for your assistance.  Th.docx
AristotleBelow is the second assignment for your assistance.  Th.docx
hirstcruz
 
Argument and Persuasion is a somewhat more challenging rhetorica.docx
Argument and Persuasion is a somewhat more challenging rhetorica.docxArgument and Persuasion is a somewhat more challenging rhetorica.docx
Argument and Persuasion is a somewhat more challenging rhetorica.docx
hirstcruz
 
Argumentative Synthesis AssignmentThis assignment creates an opp.docx
Argumentative Synthesis AssignmentThis assignment creates an opp.docxArgumentative Synthesis AssignmentThis assignment creates an opp.docx
Argumentative Synthesis AssignmentThis assignment creates an opp.docx
hirstcruz
 
Argumentative EssayThis writing assignment involves .docx
Argumentative EssayThis writing assignment involves .docxArgumentative EssayThis writing assignment involves .docx
Argumentative EssayThis writing assignment involves .docx
hirstcruz
 
Are we civilizing these nations, or making them conform to our belie.docx
Are we civilizing these nations, or making them conform to our belie.docxAre we civilizing these nations, or making them conform to our belie.docx
Are we civilizing these nations, or making them conform to our belie.docx
hirstcruz
 
Are humans experiencing microevolution due to natural selection I.docx
Are humans experiencing microevolution due to natural selection I.docxAre humans experiencing microevolution due to natural selection I.docx
Are humans experiencing microevolution due to natural selection I.docx
hirstcruz
 
Appraise the effectiveness of the Integrated Marketing Communication.docx
Appraise the effectiveness of the Integrated Marketing Communication.docxAppraise the effectiveness of the Integrated Marketing Communication.docx
Appraise the effectiveness of the Integrated Marketing Communication.docx
hirstcruz
 
Apply the reading on the MyArtsLab Closer Look at Édouard Manet, .docx
Apply the reading on the MyArtsLab Closer Look at Édouard Manet, .docxApply the reading on the MyArtsLab Closer Look at Édouard Manet, .docx
Apply the reading on the MyArtsLab Closer Look at Édouard Manet, .docx
hirstcruz
 
APPLY THE CONCEPTS LIFO inventory calculationClick here to re.docx
APPLY THE CONCEPTS LIFO inventory calculationClick here to re.docxAPPLY THE CONCEPTS LIFO inventory calculationClick here to re.docx
APPLY THE CONCEPTS LIFO inventory calculationClick here to re.docx
hirstcruz
 
Apply a sociological perspective to the social world.Analyze conte.docx
Apply a sociological perspective to the social world.Analyze conte.docxApply a sociological perspective to the social world.Analyze conte.docx
Apply a sociological perspective to the social world.Analyze conte.docx
hirstcruz
 
Applied social psychology is a field unto itself and provides rese.docx
Applied social psychology is a field unto itself and provides rese.docxApplied social psychology is a field unto itself and provides rese.docx
Applied social psychology is a field unto itself and provides rese.docx
hirstcruz
 
ApplicationVolunteers Roles and RelationshipsBoard Governanc.docx
ApplicationVolunteers Roles and RelationshipsBoard Governanc.docxApplicationVolunteers Roles and RelationshipsBoard Governanc.docx
ApplicationVolunteers Roles and RelationshipsBoard Governanc.docx
hirstcruz
 
ApplicationIncorporating a Nonprofit OrganizationIntroduction.docx
ApplicationIncorporating a Nonprofit OrganizationIntroduction.docxApplicationIncorporating a Nonprofit OrganizationIntroduction.docx
ApplicationIncorporating a Nonprofit OrganizationIntroduction.docx
hirstcruz
 
ApplicationKnowing When to Make a ReferralSupporting the develo.docx
ApplicationKnowing When to Make a ReferralSupporting the develo.docxApplicationKnowing When to Make a ReferralSupporting the develo.docx
ApplicationKnowing When to Make a ReferralSupporting the develo.docx
hirstcruz
 
Application Special Needs From a Variety of PerspectivesThroughou.docx
Application Special Needs From a Variety of PerspectivesThroughou.docxApplication Special Needs From a Variety of PerspectivesThroughou.docx
Application Special Needs From a Variety of PerspectivesThroughou.docx
hirstcruz
 
Application Theoretical FrameworksEarlier weeks have focused on t.docx
Application Theoretical FrameworksEarlier weeks have focused on t.docxApplication Theoretical FrameworksEarlier weeks have focused on t.docx
Application Theoretical FrameworksEarlier weeks have focused on t.docx
hirstcruz
 
Application The Civil Service SystemHow do public adminis.docx
Application The Civil Service SystemHow do public adminis.docxApplication The Civil Service SystemHow do public adminis.docx
Application The Civil Service SystemHow do public adminis.docx
hirstcruz
 
Application Public Versus Private AdministratorsReflect o.docx
Application Public Versus Private AdministratorsReflect o.docxApplication Public Versus Private AdministratorsReflect o.docx
Application Public Versus Private AdministratorsReflect o.docx
hirstcruz
 
Application Health Promotion organizations, non-profits, and agenci.docx
Application Health Promotion organizations, non-profits, and agenci.docxApplication Health Promotion organizations, non-profits, and agenci.docx
Application Health Promotion organizations, non-profits, and agenci.docx
hirstcruz
 
Application Emergency Preparedness and Disaster ResponseIn thi.docx
Application Emergency Preparedness and Disaster ResponseIn thi.docxApplication Emergency Preparedness and Disaster ResponseIn thi.docx
Application Emergency Preparedness and Disaster ResponseIn thi.docx
hirstcruz
 

More from hirstcruz (20)

AristotleBelow is the second assignment for your assistance.  Th.docx
AristotleBelow is the second assignment for your assistance.  Th.docxAristotleBelow is the second assignment for your assistance.  Th.docx
AristotleBelow is the second assignment for your assistance.  Th.docx
 
Argument and Persuasion is a somewhat more challenging rhetorica.docx
Argument and Persuasion is a somewhat more challenging rhetorica.docxArgument and Persuasion is a somewhat more challenging rhetorica.docx
Argument and Persuasion is a somewhat more challenging rhetorica.docx
 
Argumentative Synthesis AssignmentThis assignment creates an opp.docx
Argumentative Synthesis AssignmentThis assignment creates an opp.docxArgumentative Synthesis AssignmentThis assignment creates an opp.docx
Argumentative Synthesis AssignmentThis assignment creates an opp.docx
 
Argumentative EssayThis writing assignment involves .docx
Argumentative EssayThis writing assignment involves .docxArgumentative EssayThis writing assignment involves .docx
Argumentative EssayThis writing assignment involves .docx
 
Are we civilizing these nations, or making them conform to our belie.docx
Are we civilizing these nations, or making them conform to our belie.docxAre we civilizing these nations, or making them conform to our belie.docx
Are we civilizing these nations, or making them conform to our belie.docx
 
Are humans experiencing microevolution due to natural selection I.docx
Are humans experiencing microevolution due to natural selection I.docxAre humans experiencing microevolution due to natural selection I.docx
Are humans experiencing microevolution due to natural selection I.docx
 
Appraise the effectiveness of the Integrated Marketing Communication.docx
Appraise the effectiveness of the Integrated Marketing Communication.docxAppraise the effectiveness of the Integrated Marketing Communication.docx
Appraise the effectiveness of the Integrated Marketing Communication.docx
 
Apply the reading on the MyArtsLab Closer Look at Édouard Manet, .docx
Apply the reading on the MyArtsLab Closer Look at Édouard Manet, .docxApply the reading on the MyArtsLab Closer Look at Édouard Manet, .docx
Apply the reading on the MyArtsLab Closer Look at Édouard Manet, .docx
 
APPLY THE CONCEPTS LIFO inventory calculationClick here to re.docx
APPLY THE CONCEPTS LIFO inventory calculationClick here to re.docxAPPLY THE CONCEPTS LIFO inventory calculationClick here to re.docx
APPLY THE CONCEPTS LIFO inventory calculationClick here to re.docx
 
Apply a sociological perspective to the social world.Analyze conte.docx
Apply a sociological perspective to the social world.Analyze conte.docxApply a sociological perspective to the social world.Analyze conte.docx
Apply a sociological perspective to the social world.Analyze conte.docx
 
Applied social psychology is a field unto itself and provides rese.docx
Applied social psychology is a field unto itself and provides rese.docxApplied social psychology is a field unto itself and provides rese.docx
Applied social psychology is a field unto itself and provides rese.docx
 
ApplicationVolunteers Roles and RelationshipsBoard Governanc.docx
ApplicationVolunteers Roles and RelationshipsBoard Governanc.docxApplicationVolunteers Roles and RelationshipsBoard Governanc.docx
ApplicationVolunteers Roles and RelationshipsBoard Governanc.docx
 
ApplicationIncorporating a Nonprofit OrganizationIntroduction.docx
ApplicationIncorporating a Nonprofit OrganizationIntroduction.docxApplicationIncorporating a Nonprofit OrganizationIntroduction.docx
ApplicationIncorporating a Nonprofit OrganizationIntroduction.docx
 
ApplicationKnowing When to Make a ReferralSupporting the develo.docx
ApplicationKnowing When to Make a ReferralSupporting the develo.docxApplicationKnowing When to Make a ReferralSupporting the develo.docx
ApplicationKnowing When to Make a ReferralSupporting the develo.docx
 
Application Special Needs From a Variety of PerspectivesThroughou.docx
Application Special Needs From a Variety of PerspectivesThroughou.docxApplication Special Needs From a Variety of PerspectivesThroughou.docx
Application Special Needs From a Variety of PerspectivesThroughou.docx
 
Application Theoretical FrameworksEarlier weeks have focused on t.docx
Application Theoretical FrameworksEarlier weeks have focused on t.docxApplication Theoretical FrameworksEarlier weeks have focused on t.docx
Application Theoretical FrameworksEarlier weeks have focused on t.docx
 
Application The Civil Service SystemHow do public adminis.docx
Application The Civil Service SystemHow do public adminis.docxApplication The Civil Service SystemHow do public adminis.docx
Application The Civil Service SystemHow do public adminis.docx
 
Application Public Versus Private AdministratorsReflect o.docx
Application Public Versus Private AdministratorsReflect o.docxApplication Public Versus Private AdministratorsReflect o.docx
Application Public Versus Private AdministratorsReflect o.docx
 
Application Health Promotion organizations, non-profits, and agenci.docx
Application Health Promotion organizations, non-profits, and agenci.docxApplication Health Promotion organizations, non-profits, and agenci.docx
Application Health Promotion organizations, non-profits, and agenci.docx
 
Application Emergency Preparedness and Disaster ResponseIn thi.docx
Application Emergency Preparedness and Disaster ResponseIn thi.docxApplication Emergency Preparedness and Disaster ResponseIn thi.docx
Application Emergency Preparedness and Disaster ResponseIn thi.docx
 

Recently uploaded

Accounting for Restricted Grants When and How To Record Properly
Accounting for Restricted Grants  When and How To Record ProperlyAccounting for Restricted Grants  When and How To Record Properly
Accounting for Restricted Grants When and How To Record Properly
TechSoup
 
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptxCapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapitolTechU
 
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
EduSkills OECD
 
Simple-Present-Tense xxxxxxxxxxxxxxxxxxx
Simple-Present-Tense xxxxxxxxxxxxxxxxxxxSimple-Present-Tense xxxxxxxxxxxxxxxxxxx
Simple-Present-Tense xxxxxxxxxxxxxxxxxxx
RandolphRadicy
 
MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025
khuleseema60
 
Contiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptxContiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptx
Kalna College
 
Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
RamseyBerglund
 
Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
Prof. Dr. K. Adisesha
 
Juneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School DistrictJuneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School District
David Douglas School District
 
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
Nguyen Thanh Tu Collection
 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
giancarloi8888
 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
zuzanka
 
220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx
Kalna College
 
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
سمير بسيوني
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
deepaannamalai16
 
How to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in useHow to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in use
Celine George
 
Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10
nitinpv4ai
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
PsychoTech Services
 
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
TechSoup
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
Iris Thiele Isip-Tan
 

Recently uploaded (20)

Accounting for Restricted Grants When and How To Record Properly
Accounting for Restricted Grants  When and How To Record ProperlyAccounting for Restricted Grants  When and How To Record Properly
Accounting for Restricted Grants When and How To Record Properly
 
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptxCapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
 
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
 
Simple-Present-Tense xxxxxxxxxxxxxxxxxxx
Simple-Present-Tense xxxxxxxxxxxxxxxxxxxSimple-Present-Tense xxxxxxxxxxxxxxxxxxx
Simple-Present-Tense xxxxxxxxxxxxxxxxxxx
 
MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025
 
Contiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptxContiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptx
 
Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
 
Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
 
Juneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School DistrictJuneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School District
 
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
 
220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx
 
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
 
How to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in useHow to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in use
 
Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
 
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
 

#include #include #include using namespace std;v

  • 1. #include #include #include using namespace std; void sm(int scl, int sda); enum states { s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16 }; struct i2c { int scl; int sda; int item; }; struct i2c traces[1000];
  • 2. int trace_length; int main() { int item, scl, sda, index; string trace0; ifstream myfile; /* Naming the file to open*/ string myline; char read_write_mode = 'R'; bool ack = false; int read_count = 0; int write_count = 0; int ack_count = 0; int nack_count = 0; trace0 = "t0.txt"; /* Choosing the file trace*/
  • 3. myfile.open(trace0.c_str()); /* Open file c_str is for the first line*/ getline(myfile, myline); /* First line*/ index = 0; while (!myfile.eof()) /* Assigning the clock and data from file to code*/ { myfile >> item >> scl >> sda; traces[index].item = item; traces[index].scl = scl; traces[index].sda = sda; index++; } trace_length = index; /* to count traces*/ myfile.close(); for (index = 0; index < trace_length; index++) {
  • 4. sm(traces[index].scl, traces[index].sda); } if ((scl == 0 && sda == 0) && (scl == 1 && sda == 0) && (scl == 0 && sda == 0)) { ack_count++; } else nack_count++; cout << "ack = " << ack_count << endl; cout << "nack = " << nack_count << endl; system("pause"); } void sm(int scl, int sda) {
  • 5. static int ps = 0; static int ns = 0; static int address; static int r_w; static int temp; static int k; static int index; static bool ack; static bool nack; ps = ns; cout << "ps " << ps << endl; cout << "scl " << scl << " " << "sda " << sda << endl; cout << "Address = " << temp << endl; switch (ps) { case s0: if ((scl == 1) && (sda == 0)) /* IDLE*/
  • 6. ns = s1; else ns = s0; break; case s1: if (scl == 1) /* START*/ ns = s1; else ns = s2; k = 0; temp = 0; break; case s2: if (scl == 0) ns = s2; else ns = s3;
  • 7. break; case s3: if (scl == 1) ns = s3; else ns = s4; temp = temp << 1; temp = temp + sda; k = k + 1; break; case s4: if (k != 8) ns = s2; else { ns = s5; address = temp >> 1; r_w = temp & 1; cout << "address = " << hex << address << endl; }
  • 8. break; case s5: if (scl == 0) ns = s5; else ns = s6; break; case s6: if (scl == 1) /*ACK = 0, NACK = 1 */ ns = s6; else ns = s7; break; case s7: if (ack == false) ns = s0; else ns = s8; break;
  • 9. case s8: if (scl == 0) ns = s8; else ns = s9; break; case s9: if (scl == 1) ns = s9; else ns = s10; break; case s10: if (k != 8) ns = s8; else ns = s11; break; case s11: if (scl == 0)
  • 10. ns = s11; else ns = s12; break; case s12: if (scl == 1) ns = s12; else ns = s13; break; case s13: if (ack == false) ns = s0; else ns = s14; break; case s14: if (scl == 0 && sda == 0) ns = s15; else
  • 11. ns = s14; break; case s15: if (scl == 0 && sda == 0) ns = s15; else ns = s16; break; case s16: if (scl == 1 && sda == 0) ns = s16; else ns = s0; break; } }