- ahmad alhayek

USE QUARTUS TO WRITE THE CODE.

1- Objective
The objective is to use algorithmic state machine integrated (ASM) with a Datapath to
design circuit that outputs the maximum length of equal ones and zeros in a number.
2- circuit
It is circuit which counts the maximum length of equal zeros and ones.

2.1 C++ Code

NOTE: TEMP is not required. (Line 15)

1 2 HM0NM 4 5 6 7 #include ciostream> #include <string.h> using nanespace std; Clint main() { string s; cout << enter string

2.2- Sample Output

2.2 Sample Output enter string10101111 string s = 10101111 resultwhere equal no. of ones and zeros =1010 max= 4 C:\Users\ghenter string11111111 string s =11111111 resultwhere equal no. of ones and zeros max= 0 C:\Users\ghade\source\repos\Project23- Required Tasks
3.1- Datapath ASM
Design Algorithmic state machine (ASM) for Datapath.
3.2- Datapath circuit
Design circuit for Datapath based on the ASM you designed in 3.1.
3.3- Controller ASM
Design Algorithmic state machine (ASM) for Controller.
3.4- Coding
Implement using VHDL the controller and the Datapath.

Show transcribed image text

Expert Answer


General guidance

The answer provided below has been developed in a clear step by step manner.
FIRST STEP | ALL STEPS | ANSWER ONLY

Step-by-step

Step 1 of 1

#include <iostream> #include <string.h> using namespace std; int main() { //cout<<"Hello World"; string s; cout << "enter string"; cin >> s; string temp,result; int max=0; for(int i=0;i<s.size();i++){ temp=s[i]; int fr[2]={ 0 }; if(s[i] == '0') fr[0]++; else fr[1]++; for(int j=i+1;j<s.size();j++){ temp+=s[j]; if(s[j] == '0') fr[0]++; else fr[1]++; if(fr[0] == fr[1]){ if(max < j- i + 1){ max=j-i+1; result=temp; } } } } cout<< "string s =" << s <<endl; cout<< "result where equal no. of ones and zeros " << result << endl; cout<<"max" << max << endl; return 0; }
​output for the above program:
enter stringhelo102
string s =helo102
result where equal no. of ones and zeros 10
max2


Flow chat

Flow chat

Explanation
Please refer to solution in this step.

ليست هناك تعليقات:

إرسال تعليق

ahmad alhayek تصميم ahmad alhayek جميع الحقوق محفوظة 2016

صور المظاهر بواسطة sndr. يتم التشغيل بواسطة Blogger.