You are on page 1of 24

  


   

 

 

cPage
‘
{ 
À     
  3
  3
  4
   5
 6 -13
  14 Ȃ 23
  24

  24

MPage
  
The goal of this project is to design and implement a simulator for logic
gates (AND, OR, NOT, NOR and XOR). Each logical gate except inverter can
have various numbers of inputs and outputs can later be re-used as inputs to
the other logical gates.

A user can decide to choose any type circuit from a simple o to a


complicated one. And then this circuit can further be implemented in this
program.

This simulator is implemented in C++ using Microsoft Visual Studio.Net


frame. Linked Lists using Pointers are used in implementing this project.

 
The general goal of this project is to apply the programming techniques
with data structures of C++ to make a complete program learnt from
ECE 302 course.
These techniques are applied to the assigned project to design a
simulator for the logical gates. It helped us to apply and practice the
programming techniques and data structures in the field of
engineering.

Page
 
This program first generates user friendly menu with commands to the
user and allows entering inputs of his choice. But beside that it restricts the
user to enter only binary number inputs in form of zero or one (0 or 1). Then
program allows the user to add more logic gates in the first cycle which gives
the outputs and then the results of first cycle can be repeated as inputs in
the second cycle of choosing more logic gates and so on.
This project helped us in integrating the concepts of digital circuit system
course with the programming course, which made us confident in seeing the
applications of one course in another.

We implemented different techniques of this course like linked list, pointers,


do while loop, and if else statements. Linked lists helped us to display data
members in the forward direction. We used Do while loop to check the
condition before executing any of its statement. And we used If-else
statement to enable a test for any condition.

Page
  
1-The program shows a message with instructions for the user.

2- The logic gates of different types are displayed on the black screen.

3-The user is prompted to choose a gate of his choice.

4- Then asked to enter the inputs.

6- User is asked if he/she wants to choose more gates in this cycle.

7- If the answer is Dzyesdz, logic gates with different types are displayed on the
black screen and the user is asked to choose the gate and all previous
processes are displayed again.

8-And if the answer is Dznodz the outputs of all tries are displayed and the user
is asked if he/she wants to add any of these outputs to other gate, if entered
Dz yesdz the gates are displayed and all previous processes are start over again
and If the answer is Dznodz a thanking massage is displayed on the screen.
‘
‘
‘
‘
‘
‘
‘
‘
‘
‘
‘
‘
‘
‘
JPage
À  
å‘ ‘ 
 ‘
å‘ ‘ ‘
å‘ ‘
‘‘
 ‘   ‘
‘
‘


‘ ‘

‘ 
‘‘
‘ 
‘‘‘
‘  

‘
‘
 ‘ 
‘

 
‘
‘
‘  ‘

‘ ‘
 ‘
‘  
!
‘"‘#$%%‘
‘ & 
!‘
‘
‘  ‘ 
 
‘'(‘ 
‘)!‘
‘ ‘
‘ 
‘#*+ !‘
‘ 
‘,#- !‘
‘ 
‘*. !‘
‘ 
‘#*. !‘
‘ 
‘/*. !‘
‘ ‘
‘
‘
 ‘ 
 
 
‘'(‘ 
‘)!‘

‘  ‘‘0 ‘"‘0‘ ‘
‘ ‘ 0 ‘"'‘
‘ ‘ 0 ‘")‘
‘ ‘ 0 
‘"‘#$%%‘
‘
‘ ‘ ‘ 
‘""‘#$%%!‘
‘ ‘ ‘ 
"0 ‘
‘ ‘  ‘
‘ ‘ ‘
‘ ‘ ‘  ‘‘ 
‘"‘

‘ ‘ ‘ 0 ‘  

‘1"‘#$%%!‘
‘ ‘ ‘ ‘  
‘"‘ 


‘ ‘ ‘ ‘
‘ ‘ ‘  

‘"‘0 ‘
‘ ‘ ‘

‘

‘ 
‘#*+ !‘

‘  ‘‘ 
‘"‘

xPage
‘
‘ 0 ‘  

‘1"‘#$%%!‘
‘ ‘  
‘"‘ 


‘
‘ ‘  
""2!‘
‘ ‘ 
 ‘'‘
‘  ‘
‘ ‘ 
 ‘2‘
‘

‘

‘ 
‘‘,#- !‘

‘  ‘‘ 
‘"‘

‘
‘ 0 ‘  

‘1"‘#$%%!‘
‘ ‘  
‘"‘ 


‘ ‘ ‘‘‘
‘ ‘‘ ‘  
""'!33  
""'!!‘
‘ ‘ 
 ‘'‘
‘  ‘
‘ ‘ 
 ‘2‘

‘ ‘
‘

‘ 
*. !‘

‘  ‘‘ 
‘"‘

‘
‘ 0 ‘  

‘1"‘#$%%!‘
‘ ‘  
‘"‘ 


‘
‘ ‘  
""'!44  
""'!!‘
‘ ‘ 
 ‘'‘
‘  ‘
‘ ‘ 
 ‘2‘
‘

‘

‘ 
#*. !‘

‘  ‘‘ 
‘"‘

‘
‘ 0 ‘  

‘1"‘#$%%!‘
‘ ‘  
‘"‘ 


‘
‘ ‘  
""'!44  
""'!!‘
‘ ‘ 
 ‘2‘
‘  ‘
‘ ‘ 
 ‘'‘
‘

‘

‘ 
/*. !‘

‘  ‘‘ 
‘"‘

‘

rPage
‘ 0 ‘  

‘1"‘#$%%!‘
‘ ‘  
‘"‘ 


‘
‘ ‘  
"" 
!‘
‘ ‘ 
 ‘2‘
‘  ‘
‘ ‘ 
 ‘'‘
‘

‘
 
& 

‘ ‘
‘ ‘  ‘‘ 
‘"‘

‘ ‘ 0 ‘  
‘1"‘#$%%!‘
‘ ‘ ‘ ‘
‘ ‘ ‘ ‘  ‘
 "‘ 

‘ ‘ ‘ ‘  
‘"‘ 


‘ ‘ ‘ ‘ 

 ‘
‘ ‘ ‘‘‘‘‘
‘ ‘
‘

‘  !‘

‘‘  ‘‘
‘ 
‘ 
'(‘ 
)(‘5
'(5
)‘
‘  
‘‘
‘ 
‘

6'27‘
‘ 
‘
‘
‘  ‘('‘
‘  ‘)"88‘
‘ 
‘ "2‘
‘ ‘'"
‘
‘
‘
6'27‘
‘‘
‘
‘ 
9‘:;%<*=;‘+*‘+>;?5=$%,+*.‘%*@5<‘@,+;?‘
9‘
‘ 
9,++;#+5*#A‘‘  ‘
 ‘
 ‘‘2‘ ‘'‘A‘‘ ‘

 8
‘
‘  ‘
 ‘)‘ 
‘
‘‘9‘
‘ ‘
‘ ‘
‘ ‘
‘ ‘
‘ 
‘9 ‘ ‘
9‘
‘ 
‘9‘'!#*+‘A‘)!,#-‘A‘B!*.‘A‘C!#*.‘A‘D!/*.9‘
‘  ‘
‘
‘  EE‘
‘ ‘
‘#*+‘@,+;‘
‘
‘ ‘ 
""'!‘
‘ ‘
‘ ‘
6 7"9#*+‘
‘9‘
‘ ‘ 
9
9‘
‘ ‘ 
‘9
‘9 9‘!‘ ‘
 ‘'‘ 
‘ ‘
‘#*+‘

9‘

·Page
‘ ‘  '""
!‘
‘ ‘   
'‘
‘ ‘  ‘
‘ ‘ ‘
‘ ‘ ‘ 
9 ‘
 ‘'‘‘
‘   ‘

‘  ‘
‘‘

‘ 
‘ ‘
 ‘
9‘
‘ ‘ ‘  5
'‘
‘ ‘ ‘ 
'"

65
'7‘
‘
‘ ‘ ‘
‘ ‘
‘ ‘  
 
'(#$%%!‘
‘ ‘ ‘
‘ ‘ 

6 7"#*+ !‘
‘  ‘‘
‘,#-‘@,+;‘
‘
‘ ‘  
"")!‘
‘ ‘ ‘
‘ ‘
6 7"9,#-‘
‘9‘
‘ ‘ 
9
9‘
‘ ‘ 
9
‘9 9! ‘
 ‘)‘ 
‘ ‘
‘,#-9‘
‘ ‘  '""
!‘
‘ ‘   
' 
)‘
‘ ‘  ‘
‘ ‘ ‘
‘ ‘ ‘ 
9 ‘;
 ‘‘‘
‘   ‘

‘  ‘

  !‘
‘‘ ‘
‘A‘ 
‘ ‘
 ‘
A9‘
‘ ‘ ‘  5
'‘
‘ ‘ ‘ 
'"

65
'7‘
‘ ‘ ‘   )!‘
‘ ‘ ‘ ‘
‘ ‘ ‘ 
9
9‘
‘ ‘ ‘ 
9‘‘0 
‘ ‘ ‘ 
‘
‘‘‘‘
‘
   ‘

FF‘A9‘
‘ ‘ ‘  )‘
‘ ‘ ‘ ‘
‘
‘ ‘ ‘  )""88!‘
‘ ‘ ‘ ‘
‘ ‘ ‘ ‘ 
9
9‘
‘ ‘ ‘ ‘ 
9 ‘;
 ‘‘‘
‘   ‘

‘  ‘

‘  !‘
‘‘ ‘ ‘ 
‘ ‘
 ‘
A9‘
‘ ‘ ‘ ‘  5
)‘
‘ ‘ ‘ ‘ 
)"

65
)7‘
‘ ‘ ‘ ‘ ‘
‘ ‘ ‘ ‘
‘ ‘ ‘  ‘
‘ ‘ ‘ ‘
‘ ‘ ‘ ‘ 
9
9‘
‘ ‘ ‘ ‘ 
9 ‘
 ‘ ‘0‘ 
‘ ‘ ‘ ‘ 
‘

 ‘
A9‘
‘ ‘ ‘ ‘   
)‘

UPage
‘ ‘ ‘ ‘
‘ ‘ ‘
‘ ‘ ‘
‘ ‘  
 
'(‘ 
)!‘
‘ ‘ 

6 7",#- !‘
‘ ‘ ‘
‘ ‘  ‘
‘*.‘@,+;‘
‘
‘ ‘ ‘ ‘ 
""B!‘
‘ ‘ ‘ ‘
‘ ‘
6 7"9*.‘
‘9‘
‘ ‘ 
9
9‘
‘ ‘ 
‘9
‘9 9! ‘
 ‘)‘ 
‘ ‘
‘*.9‘
‘ ‘  '""
!‘
‘ ‘   
' 
)‘
‘ ‘  ‘
‘ ‘ ‘
‘ ‘ ‘ 
9
9‘
‘ ‘ ‘ 
9 ‘;
 ‘‘‘
‘   ‘

‘  ‘

  !‘
‘‘ ‘
‘A‘ 
‘ ‘
 ‘
A9‘
‘ ‘ ‘  5
'‘
‘ ‘ ‘ 
'"

65
'7‘
‘
‘ ‘ ‘   )!‘
‘ ‘ ‘ ‘
‘ ‘ ‘ 
9
9‘
‘ ‘ ‘ 
9‘‘0 
‘ ‘ ‘ 
‘
‘‘‘‘
‘
   ‘

FF‘A9‘
‘ ‘ ‘  )‘
‘ ‘ ‘ ‘
‘
‘ ‘ ‘  )""88!‘
‘ ‘ ‘ ‘
‘ ‘ ‘ ‘ 
9
9‘
‘ ‘ ‘ ‘ 
9 ‘;
 ‘‘‘
‘   ‘

‘  ‘

‘  !‘
‘‘ ‘ ‘ 
‘ ‘
 ‘
A9‘
‘ ‘ ‘ ‘  5
)‘
‘ ‘ ‘ ‘ 
)"

65
)7‘
‘ ‘ ‘ ‘
‘ ‘ ‘  ‘
‘ ‘ ‘ ‘
‘ ‘ ‘ ‘ 
9
9‘
‘ ‘ ‘ ‘ 
9 ‘
 ‘ ‘0‘ 
‘ ‘ ‘ ‘ 
‘

 ‘
A9‘
‘ ‘ ‘ ‘   
)‘
‘ ‘ ‘ ‘
‘ ‘ ‘
‘ ‘ ‘
‘ ‘  
 
'(‘ 
)!‘
‘ ‘ 

6 7"*. !‘
‘ ‘ ‘  ‘

c  P a g e
‘#*.‘@,+;‘
‘
‘ ‘ ‘ ‘ ‘‘ 
""C!‘
‘ ‘ ‘ ‘ ‘
‘ ‘
6 7"9#*.‘
‘9‘
‘ ‘ 
9
9‘
‘ ‘ 
9
‘9 9! ‘
 ‘)‘ 
‘ ‘
‘#*.9‘
‘ ‘  '""
!‘
‘ ‘   
' 
)‘
‘ ‘  ‘
‘ ‘ ‘
‘ ‘ ‘ 
9
9‘
‘ ‘ ‘ 
9 ‘;
 ‘‘‘
‘   ‘

‘  ‘

  !‘
‘‘ ‘
‘A‘ 
‘ ‘
 ‘
A9‘
‘ ‘ ‘  5
'‘
‘ ‘ ‘ 
'"

65
'7‘
‘
‘ ‘ ‘   )!‘
‘ ‘ ‘ ‘
‘ ‘ ‘ 
9
9‘
‘ ‘ ‘ 
9‘‘0 
‘ ‘ ‘ 
‘
‘‘‘‘
‘
   ‘

‘FF‘  "#"!A9‘
‘ ‘ ‘  )‘
‘ ‘ ‘ ‘
‘
‘ ‘ ‘  )""88!‘
‘ ‘ ‘ ‘
‘ ‘ ‘ ‘ 
9 ‘;
 ‘‘‘
‘   ‘

‘  ‘

‘  !‘
‘‘ ‘ ‘ 
‘ ‘
 ‘
A9‘
‘ ‘ ‘ ‘  5
)‘
‘ ‘ ‘ ‘ 
)"

65
)7‘
‘ ‘ ‘ ‘
‘ ‘ ‘  ‘
‘ ‘ ‘ ‘
‘ ‘ ‘ ‘ 
9
9‘
‘ ‘ ‘ ‘ 
9 ‘
 ‘ ‘0‘ 
‘ ‘ ‘ ‘ 
‘

 ‘
A9‘
‘ ‘ ‘ ‘   
)‘
‘ ‘ ‘ ‘
‘ ‘ ‘
‘
‘ ‘  
 
'(‘ 
)!‘
‘ ‘ 

6 7"#*. !‘
‘ ‘ ‘ ‘ ‘
‘ ‘ ‘ ‘  ‘
‘/*.‘@,+;‘
‘
‘ ‘ ‘ ‘ ‘ ‘ 
""D!‘
‘ ‘ ‘ ‘ ‘ ‘
‘ ‘ ‘ ‘ ‘ ‘
6 7"9/*.‘
‘9‘
‘ ‘ 
9
9‘
‘ ‘ 
9
‘9 9! ‘
 ‘)‘ 
‘ ‘
‘/*.9‘

cc  P a g e
‘ ‘  '""
!‘
‘ ‘   
' 
)‘
‘ ‘  ‘
‘ ‘ ‘
‘ ‘ ‘ 
9
9‘
‘ ‘ ‘ 
9 ‘;
 ‘‘‘
‘   ‘

‘  ‘

  !‘
‘‘ ‘
‘A‘ 
‘ ‘
 ‘
A9‘
‘ ‘ ‘  5
'‘
‘ ‘ ‘ 
'"

65
'7‘
‘
‘ ‘ ‘   )!‘
‘ ‘ ‘ ‘
‘ ‘ ‘ 
9
9‘
‘ ‘ ‘ 
9‘‘0 
‘ ‘ ‘ 
‘
‘‘‘‘
‘
   ‘

‘  "#"!FF‘A9‘
‘ ‘ ‘  )‘
‘ ‘ ‘ ‘
‘
‘ ‘ ‘  )""88!‘
‘ ‘ ‘ ‘
‘ ‘ ‘ ‘ 
9
9‘
‘ ‘ ‘ ‘ 
9 ‘;
 ‘‘‘
‘   ‘

‘  ‘

‘  !‘
‘‘ ‘ ‘ 
‘ ‘
 ‘
A9‘
‘ ‘ ‘ ‘  5
)‘
‘ ‘ ‘ ‘ 
)"

65
)7‘
‘ ‘ ‘ ‘
‘ ‘ ‘  ‘
‘ ‘ ‘ ‘
‘ ‘ ‘ ‘ 
9
9‘
‘ ‘ ‘ ‘ 
9 ‘
 ‘ ‘0‘ 
‘ ‘ ‘ ‘ 
‘

 ‘
A9‘
‘ ‘ ‘ ‘   
)‘
‘ ‘ ‘ ‘
‘ ‘ ‘
‘
‘ ‘  
 
'(‘ 
)!‘
‘ ‘ 

6 7"/*. !‘
‘
‘ ‘ ‘ ‘ ‘ ‘
‘ ‘ ‘ ‘ ‘  ‘
‘ ‘ 
‘9  ‘ ‘ ‘'()(B‘ ‘C9‘
‘
‘
‘
‘ 
9
9‘
‘ 
‘9‘‘0 
‘
‘ ‘
 ‘
‘ ‘
 ‘‘F‘
 "#"!9‘
‘  ‘
‘ 
9
9‘
‘
‘ 0 ‘ ""88!‘

cM  P a g e
‘ ‘
‘  
‘ "'‘ " ‘ EE!‘
‘ ‘
‘ ‘ 
9+‘

‘ ‘ 9 9!‘‘9
6 79‘ ‘
9

6 7‘
‘ ‘
‘ 
9
9‘
‘ 
‘9‘‘0 
‘
‘ ‘
 ‘



‘  ‘0
‘
 ‘
 ‘
FF‘  "#"!9‘
‘  ‘'‘‘
‘ 
9
9‘
‘
‘ ‘ '""88!‘ ‘
‘ ‘ '"  ‘
‘
‘
‘ 0  '""88!‘
‘
‘ 
9+ ‘‘GHGA9‘
‘ 
9-‘‘=  ‘# ‘(‘> ‘I 0  ‘GHG9‘
‘

 !‘

‘
‘
‘
‘
‘‘
‘
‘
‘‘
‘
‘‘
‘
‘‘
‘
‘‘
‘
‘‘
‘
‘‘
‘
‘‘
‘
‘
‘

c  P a g e
  
‘
‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘


 ‘ ‘‘

¬  
  
  
  
  
‘
‘
 ‘ ‘‘ ‘‘ ‘‘
‘‘

‘
‘
‘
‘

c  P a g e
‘
‘‘‘‘

‘

 ‘ ‘‘

¬  
  
  
  
  
‘
‘
‘
‘
‘
 ‘ ‘‘‘‘ ‘‘
‘‘

‘
‘
‘
‘
cJ  P a g e
‘
‘
‘
‘
‘‘‘

‘
‘

 ‘ ‘‘‘

 

 
 
‘
 ‘ ‘‘‘‘

‘‘‘
‘

cx  P a g e
‘
‘‘‘

‘

 ‘ ‘‘‘

¬  
  
  
  
  

 ‘ ‘‘‘‘‘

‘
‘

cr  P a g e
‘
‘‘‘

‘

 ‘ ‘‘

‘
‘
¬  
‘
   ‘
   ‘
  
   ‘
‘
 ‘ ‘‘‘‘‘

‘
‘
‘

c·  P a g e
‘‘ ‘ ‘‘
‘

‘

 ‘ ‘‘

Ú  
    
 
     
     
     
     

‘
‘
‘
‘
‘
‘
‘
‘
‘
‘
‘
‘
‘
cU  P a g e
 ‘ ‘‘ ‘ ‘ ‘‘
‘

‘
‘
‘
‘
‘
‘
‘
‘
‘
‘
‘
‘
‘

M  P a g e
‘
‘
‘
‘
‘
‘
‘
‘
‘
‘
‘
‘
‘

Mc  P a g e
‘

‘
‘
‘
‘
‘
‘
‘
‘
‘
‘
‘
‘
‘
‘
‘
‘

MM  P a g e
‘
‘
‘
‘
‘
‘
‘
‘
‘
‘
‘
‘
‘

M  P a g e
  
‘

 
This project is improved by adding many logic gates to construct any
logic gate diagram.


With time this program can be enhanced for allowing the user to enter
more than two inputs. We can also show the diagrams of the logical
gates and circuits. This was not done due short time.

 
This program was tested and verified against all possible inputs and
outputs. A truth table is mentioned above to verify all the possible
combinations. We gained enough knowledge and experience in testing,
debugging of code and the arrangement of statement in the test part. It
also helped me to apply the programming concepts in other systems
such as electronics.

M  P a g e

You might also like