0% found this document useful (0 votes)
113 views38 pages

De Report Format

This document describes the design and implementation of a Tic Tac Toe game using digital logic circuits. The key components required include logic gates like AND, OR, XOR gates and flip-flops. The game logic is developed to determine player turns, store board positions in memory and check for winning/draw conditions. The circuit is designed, simulated and tested in Proteus software. The final circuit uses logic gates and flip-flops to generate player turns, accept user input, display the board and determine the winner or a draw.

Uploaded by

Neha Goyal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
113 views38 pages

De Report Format

This document describes the design and implementation of a Tic Tac Toe game using digital logic circuits. The key components required include logic gates like AND, OR, XOR gates and flip-flops. The game logic is developed to determine player turns, store board positions in memory and check for winning/draw conditions. The circuit is designed, simulated and tested in Proteus software. The final circuit uses logic gates and flip-flops to generate player turns, accept user input, display the board and determine the winner or a draw.

Uploaded by

Neha Goyal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

TIC TAC TOE Using Digital Logic Design

Submitted
By

Navya Singla
Roll No. – 2K19/CO/242

Neha Goyal
Roll No. – 2K19/CO/245

Submitted to
Ms. Lavi Tanwar

Department of Electronics & Communication Engineering


Delhi Technological University, Delhi
Delhi-110042

May, 2021
P a g e | ii

Electronics & Communication Engg. Deptt.


DELHI TECHNOLOGICAL UNIVERSITY
(Formerly Delhi College of Engineering)
Shahbad Daulatpur, Bawana Road-Delhi-42

CERTIFICATE
I, hereby certify that the Project Dissertation titled “Tic Tac Toe using Digital Logic
Design” which is submitted by Navya Singla(2K19/CO/242) and Neha Goyal(2K19/CO/245),
Department of Electronics & Communication Engineering, Delhi Technological University,
Delhi, in fulfilment of the requirement of Mid-Term Examination is a record of the project
work carried out by the students under my supervision. To the best of my knowledge this
work has not been submitted in part or full for any Degree or Diploma to this University or
elsewhere.

Ms. Lavi Tanwar


Assistant Professor
Department of ECE
Delhi Technological University
P a g e | iii

Electronics & Communication Engg. Deptt.


DELHI TECHNOLOGICAL UNIVERSITY
(Formerly Delhi College of Engineering)
Shahbad Daulatpur, Bawana Road-Delhi-42

CANDIDATES’ DECLARATION

We, hereby, declare that the work embodied in this project entitled “Tic Tac Toe using Digital
Logic Design” submitted to the Department of Electronics & Communication Engineering,
Delhi Technological University, Delhi is an authentic record of our own bonafide work and is
correct to the best of our knowledge and belief. This work has been undertaken taking care of
engineering ethics.

Name and Signature of the Student 1: Navya Singla

Name and Signature of the Student 2: Neha Goyal


P a g e | iv

Electronics & Communication Engg. Deptt.


DELHI TECHNOLOGICAL UNIVERSITY
(Formerly Delhi College of Engineering)
Shahbad Daulatpur, Bawana Road-Delhi-42

ACKNOWLEDGMENT
The completion of this undertaking could not have been possible without the participation and
assistance of so many people whose names may not all be enumerated. Their contributions are
sincerely appreciated and gratefully acknowledged. However, the team would like to express
their deep appreciation and indebtedness particularly to the following:

We are highly indebted to DTU and especially Ms.Lavi Tanwar, our Faculty Advisor, for
their guidance and constant supervision as well as for providing necessary information
regarding the project and also for their support in completing the project. To all the parents,
relatives, friends and others, who in one way or another shared their support, either morally,
financially and physically, thank you.
Above all, to the Great Almighty, the author of knowledge and wisdom, for His countless
love.

We thank you.
Team
P age |v

TABLE OF CONTENTS

1. INTRODUCTION ..........................................................................................................................1

1.1 FUNCTIONALITIES……………………………………………………………………...1
2. OBJECTIVES ................................................................................................................................1

3. METHODOLOGY AND IMPLEMENTATION ........................................................................2

3.1 COMPONENTS REQUIRED…………………………………………...………………….1


3.1.1 2-INPUT AND GATES…………………………………………………..……..1
3.1.2 3-INPUT AND GATES……………………………………………………..…..2
3.1.3 4-INPUT AND GATES………………………………………………………....2
3.1.4 2-INPUT OR-GATES………………………………………………………...…3
3.1.5 4-INPUT OR-GATES………………………………………………………...…3
3.1.6 2-INPUT XOR GATES………………………………………………………....4
3.1.7 NOT GATES-HEX INVERTERS………………………………………...…….4
3.1.8 DUAL D-TYPE FLIP-FLOPS………………………………………………..…5
3.1.9 HEX D-TYPE POSITIVE EDGE TRIGGERED FLIP-FLOPS………………...6
3.1.10 SINGLE COLOR LEDs……………………………………………………......6
3.1.11 PUSH BUTTONS……………………………………………………………...7
3.1.12 ANALOG RESISTORS……………………………………………………......8
3.2 SOFTWARE USED………………………………………………………………………....8
3.3 GAME PLAN……………………………………………………………………………......9
3.4 LOGIC DEVELOPMENT………………………………………………………………….9
3.4.1 TURN LOGIC……………………………………………………………….....10
3.4.2 SHORTCOMING OF PUSH BUTTONS……………………………………...10
3.4.3 USAGE OF D-FLIP FLOPS……………………………………………….......11
3.4.4 WINNING AND DRAW LOGIC……………………………………………...11
4. RESULT ANALYSIS...................................................................................................................14

4.1 FINAL CIRCUIT…………………………………………………………………………..12


4.2 COMPONENTS OF CIRCUIT……………………………………………………………12
4.2.1 PLAYER TURN GENERATOR………………………………………………12
4.2.2 INPUT BLOCK………………………………………………………………...13
4.2.3 DISPLAY INPUT BLOCK………………………………………………….....14
4.2.4 FINAL OUTPUT DISPLAY BLOCK………………………………………....15
4.2.5 PUSH BUTTON TO FLIP-FLOP………………………………………….......15
P a g e | vi

4.2.6 MEMORY STORAGE


COMPONENT………………………………………..16
4.2.7 WINNING LOGIC……………………………………………………………..19
4.2.8 DRAW LOGIC………………………………………………………………....20
4.3 SIMULATION RESULTS………………………………………………………………….20
5. CONCLUSION .............................................................................................................................26

6. REFERENCES .............................................................................................................................27
P a g e | vii

LIST OF SYMBOLS

SYMBOL INFERENCE
+ Logical “OR”
. Logical “AND”
⊕ Ex-OR
X’ or 𝑋 Complement of X
P a g e | viii

LIST OF FIGURES
Figure 1: 2-input AND gate .....................................................................................................................2
Figure 2: 3-input AND gate .....................................................................................................................3
Figure 3: 4-input AND gate ....................................................................................................................3
Figure 4: 2-input OR gate.........................................................................................................................4
Figure 5: 4-input OR gate.........................................................................................................................4
Figure 6:2-input XOR gate.......................................................................................................................5
Figure 7:NOT gate ...................................................................................................................................5
Figure 8: D-Flip flop symbol ...................................................................................................................6
Figure 9: D-flip flop circuit ......................................................................................................................6
Figure 10: : Hex D-type Positive Edge Triggered Flip-Flop with Clear (74174 IC) ...............................7
Figure 11: Use of LED's for output display .............................................................................................8
Figure 12: LED symbol ............................................................................................................................8
Figure 13: Push buttons ............................................................................................................................9
Figure 14: Analog Resistor ......................................................................................................................9
Figure 15: Proteus software....................................................................................................................10
Figure 16: Block Representation of the project......................................................................................11
Figure 17: Schematic for toggling turns .................................................................................................12
Figure 18: Shortcoming of push button..................................................................................................13
Figure 19: Usage of D-flip flops in the project ......................................................................................13
Figure 20: Winning logic for tic-tac-toe ................................................................................................14
Figure 21: Final circuit ...........................................................................................................................15
Figure 22: Circuit for player turn generator ...........................................................................................15
Figure 23: Circuit for input-block ..........................................................................................................16
Figure 24: Circuit for Display input block .............................................................................................17
Figure 25:Circuit for final output display...............................................................................................17
Figure 26: Circuit to check game condition before storing input ...........................................................18
Figure 27: Circuit for memory storage using flip-flops .........................................................................19
Figure 28: Storage circuit for moves of player-1 (Red) .........................................................................20
Figure 29: : Storage circuit for moves of player-2 (Blue)......................................................................20
Figure 30: Circuit to check win for Red .................................................................................................22
Figure 31: Circuit to check win for blue ................................................................................................22
Figure 32: Circuit for draw logic............................................................................................................24
Figure 33: Simulation: player-I wins .....................................................................................................25
Figure 34: Simulation: player-II wins ....................................................................................................25
Figure 35: Simulation: game draws .......................................................................................................26
P a g e | ix

LIST OF TABLES
Table 1: 2-input AND gate truth table .....................................................................................................2
Table 2: 3-input AND gate truth table .....................................................................................................3
Table 3: 4-input AND gate truth table .....................................................................................................3
Table 4: 2-input OR gate truth table.........................................................................................................4
Table 5: 4-input OR gate truth table........................................................................................................4
Table 6: 2-input XOR gate truth table .....................................................................................................5
Table 7: NOT gate truth table ..................................................................................................................5
Table 8: D-flip flops characteristic table ..................................................................................................7
P age |x

LIST OF ABBREVIATIONS

ABBREVIATION INFERENCE
gnd Ground
LED Light Emitting Diode
CLR Clear
S SET
R RESET
CLK Clock
IC Integrated Circuit
p1, p2, p3…p9 Push buttons for 9 cells of tic-tac-toe
q1, q2, q3…q9 User inputs for 9 cells from storage component
Red1, red2, red3…red9 Move of player 1 in respective cell
Blu1, blu2, blu3…blu9 Move of player 2 in respective cell
Bu1, bu2, bu3…bu9 Cell inputs
R1, r2, r3…. r9 Inputs of player-I (red)
B1, b2, b3…b9 Inputs of player 2 (blue)
No1 Turn of player-1
No2 Turn of player-2
Redwins Player-I wins
Bluwins Player-II wins
notwin Neither player-1 nor player-2 has won
draw Game drawn
D1 Display for player-1 win (red LED)
D2 Display for player-2 win (blue LED)
D21 Game drawn (yellow LED)
D3, D5, D7…D19 Output display of player-1
D4, D6, D8…D20 Output display of player-2
P a g e | xi

ABSTRACT

Tic-Tac-Toe is a two-player game with two symbols referring to two players; usually X and O
symbols are used. Often the playing board is 3x3 squares. Each player takes a turn placing his
character (X or O) into one of the nine squares. The game finishes when a player creates a
winning pattern of his symbols or when there are no empty squares remaining. We are
simulating Tic Tac toe on Proteus software using logic gates. This design allows two players to
play a Tic-Tac-Toe game on the experiment board and a bicolor LED is used in each cell of the
board where one color represents X and other represents O. The result of the game is represented
using other 2 LED’s, where one is a bicolor LED for displaying win and other LED displays
condition for draw. For a finite number of moves in every single game of Tic-Tac-Toe, the
moves are recorded in a 3×3 matrix and the subsequent solution, or a winning combination, is
presented from the data obtained by playing the electronic game. The solution is also displayed
electronically using an LED. The circuit has been designed in a way to apply Boolean logic to
analyze player's moves and thus, give a corresponding output from the electronic game
Keywords - Tic-Tac-Toe game, electronic game, digital logic, flip-flops, Boolean algebra
--------------
P age |1

1. INTRODUCTION
Digital Logic Design can be used to implement and solve almost any logical problem. We
plan to develop a circuitry to implement Tic-Tac-Toe using Digital Logic. Tic-Tac-Toe is
a classic game for two players, X and O, who take turns marking spaces in a 3 X 3 grid.
The player who succeeds in placing three respective marks horizontally, vertically or
diagonally wins the game.
It is required to build a small Tic-Tac-Toe game. The objective of a Tic-Tac-Toe game is
to create a specific pattern of player symbols to win the game. This game is played on a
three-by-three table of squares in each square there are two different LED colors, one led
for each player, i.e.,18 LEDs arranged in 3 columns and 3 rows, each player has a three-
by-three LEDS array.
1.1 FUNCTIONALITIES
The target was to make the game Tic Tac Toe with complete functionality.
● If one player completes a line of 3 consecutive switches, he/she will win.
● The line can be vertical, horizontal or diagonal.
● Once a player has achieved the win status will be saved and the LED specified for
showing the winning status will start glowing and other player cannot win after that
even if he/she also completes the winning criteria.
● There is also a functionality of draw, if all the switches are turned on but no player has
achieved the win status, the draw function will be executed and the game will be
drawn.
● Players can also restart the game at any point in the game.

2. OBJECTIVES
The main objectives to be achieved in this project are:

● To implement using dual color LEDs- one to denote player A, other to denote player
B.
● To ensure that one player cannot override another player’s turn.
● To provide players the ability to reset the game at any point
P age |2

● To make sure that each cell of the board is marked only once.
● To lock the result state whenever a player wins the game, so that if the losing player
makes a winning move after the game is concluded, the output should not change.
● If all the switches are pressed or there is a draw condition, a separate LED should
glow.

3. METHODOLOGY AND IMPLEMENTATION


3.1 COMPONENTS REQUIRED
3.1.1 2-input AND gates (7408)
The Logic AND Gate is a type of digital logic circuit whose output goes HIGH to a
logic level 1 only when all of its inputs are HIGH. The logic or Boolean expression
given for a digital logic AND gate is that for Logical Multiplication which is denoted
by a single dot or full stop symbol, ( . ) giving us the Boolean expression of:
A.B = Q.
Table 1: 2-input AND gate truth table

Figure 1: 2-input AND gate

3.1.2 3-input AND gates (74HCT11)


If instead of two inputs there are three inputs, this changes the logical symbol and
truth table of the AND gate. All three inputs need to be high (1) to get a high output.

The logical symbol of a 3-input AND gate is represented as:


P age |3

Table 2: 3-input AND gate truth table

Figure 2: 3-input AND gate

3.1.3 4-input AND gates (4082)


It also works on the same principle, all four inputs need to be high (1) to get a high
output. The same principles apply to 5, 6,..., n input gates.

Table 3: 4-input AND gate truth table

Figure 3: 4-input AND gate

3.1.4 2-input OR gates (7432)


An OR gate is a logic gate that performs logical OR operation. A logical OR
operation has a high output (1) if one or both the inputs to the gate are high (1). If
P age |4

neither input is high, a low output (0) results. A plus (+) is used to show the OR
operation. Y= A+B

Figure 4: 2-input OR gate

Table 4: 2-input OR gate truth table

3.1.5 4-input OR gates (4072)


It also works on the same principle, any one of the four inputs need to be high (1) to
get a high output. The same principles apply to 5, 6,..., n input gates.

Table 5: 4-input OR gate truth table

Figure 5: 4-input OR gate

3.1.6 2-input XOR gates (7486)


P age |5

The 'Exclusive-OR' gate is a circuit which will give a high output if either, but not
both of its two inputs are high. An encircled plus sign (⊕) is used to show the Ex-
OR operation. Y= A⊕B

Figure 6:2-input XOR gate

Table 6: 2-input XOR gate truth table

3.1.7 NOT gates - Hex inverters(74HC04)


The NOT gate is an electronic circuit that produces an inverted version of the input at
its output. It is also known as an inverter. If the input variable is A, the inverted
output is known as NOT A. This is also shown as A' or A with a bar over the top, as
shown at the outputs. Y= A'

Figure 7:NOT gate

Table 7: NOT gate truth table

3.1.8 Dual D-type flip flops (4013)


P age |6

A D flip flop has a single data input. This type of flip flop is obtained from the SR
flip flop by connecting the R input through an inverter, and the S input is connected
directly to data input. The modified clocked SR flip-flop is known as D-flip-flop and
is shown below. From the truth table of SR flip-flop we see that the output of the SR
flip-flop is in an unpredictable state when the inputs are the same and high. In many
practical applications, these input conditions are not required. These input conditions
can be avoided by making them complement each other.

The “D flip flop” will store and output whatever logic level is applied to its data
terminal so long as the clock input is HIGH. Once the clock input goes LOW the
“set” and “reset” inputs of the flip-flop are both held at logic level “1” so it will not
change state and store whatever data was present on its output before the clock
transition occurred. In other words the output is “latched” at either logic “0” or logic
“1”.

Figure 8: D-Flip flop symbol

Figure 9: D-flip flop circuit


P age |7

Table 8: D-flip flops characteristic table

3.1.9 Hex D-type Positive Edge Triggered Flip-Flops with Clear (74174)
These positive-edge-triggered D-type flip-flops have a direct clear (CLR) input.
Information at the data (D) inputs meeting the setup time requirements is transferred
to the outputs on the positive-going edge of the clock (CLK) pulse. Clock triggering
occurs at a particular voltage level and is not directly related to the transition time of
the positive-going edge of CLK. When CLK is at either the high or low level, the D
input has no effect at the output.

Figure 10: : Hex D-type Positive Edge Triggered Flip-Flop with Clear (74174 IC)

3.1.10 Single color LEDs (Blue, Red, Yellow)


A Light Emitting Diode (LED) is a special type of PN junction diode. The light
emitting diode is specially doped and made of a special type of semiconductor. This
diode can emit light when it is in the forward biased state. Aluminum indium gallium
phosphide (AlInGaP) and indium gallium nitride (InGaN) are two of the most
commonly used semiconductors for LED technologies. When the forward biased
current IF is applied through the p-n junction of the diode, minority carrier electrons
are injected into the p-region and corresponding minority carrier electrons are
P age |8

injected into the n-region. Photon emission occurs due to electron-hole


recombination in the p-region.
Electron energy transitions across the energy gap, called radiative recombinations,
produce photons (i.e., light), while shunt energy transitions, called non-radiative
recombinations, produce phonons (i.e., heat).
LEDs are used to display the output.

Figure 11: Use of LED's for output display

Figure 12: LED symbol

3.1.11 Push buttons


Push buttons are used in applications which requires momentary ON or OFF
switching action. Normally Open Push button switches are initially in OFF state as
the contacts are not in contact with each and when pushed down the contacts gets
closed and the path established between the two terminals of the push button. When
the push button is in its normal state (not pressed), the current doesn’t flow. When
you press the push button, you allow the current to flow.
Push buttons are used to take inputs from players.
P age |9

Figure 13: Push buttons

3.1.12 Analog Resistor


A resistor is a passive two-terminal electrical component that implements electrical
resistance as a circuit element. In electronic circuits, resistors are used to reduce
current flow, adjust signal levels, to divide voltages.
The behaviour of an ideal resistor is dictated by the relationship specified by Ohm's
law:
V = I.R
Ohm's law states that the voltage (V) across a resistor is proportional to the current
(I), where the constant of proportionality is the resistance (R).

Figure 14: Analog Resistor

3.2 SOFTWARE USED


We will be building this project on Proteus Software.
The Proteus Design Suite combines ease of use with a powerful feature set to enable
the rapid design, test and layout of professional printed circuit boards. Proteus PCB
tools seamlessly combines schematic capture and PCB layout to provide a powerful,
integrated and easy to use suite of tools for professional PCB Design. It allows you
to interact with the design using on screen indicators such as LED and LCD displays
as well as actuators such as switches and buttons. Proteus VSM also provides
extensive debugging facilities including breakpoints, single stepping and variable
P a g e | 10

display for both assembly code and high level language source. It provides a very
high degree of control over the drawing appearance, in terms of line widths, fill
styles, fonts, etc. These capabilities are used to the full in providing the graphics
necessary for circuit animation.

Figure 15: Proteus software

3.3 GAME PLAN

Block representation of the project


P a g e | 11

Figure 16: Block Representation of the project

We need to use the same switches and the same LEDs for each of the two players. But
if any block is selected, it cannot be changed anymore. The result will be shown by
another two LEDs, onee for win and one for draw. If any player wins no move can be
made any more .

3.4 LOGIC DEVELOPMENT

3.4.1 Turn Logic


P a g e | 12

Figure 17: Schematic for toggling turns

The logic for deciding the player turn is implemented through XOR gates. Player
inputs are stored using Flip flops and winning or drawing condition is also checked
through Flip Flops. LEDs are connected to the flip flops and emit different lights to
indicate X’s or O’s.
XOR gates are ODD, i.e, they give high output only if odd number of inputs are high.
XOR gates are used to toggle turns between the two players. In total 8 XOR gates are
required to take input from all 9 cells of the board. Initially, all inputs are 0, so the
final output of the turn controller circuit is 0, indicating turn for player A. When player
A makes the move, one of the inputs is toggled to 1. This results in the output of 1 by
the XOR gate combination, and thus turn is given to player B.

3.4.2 Shortcoming of Push Button

The push button loses its data instantly. The moment we remove our finger from the
push button, it loses data and the LED blinks once. For this reason we needed some
mechanism to store the data.
P a g e | 13

Figure 18: Shortcoming of push button

3.4.3 Usage of D-Flip Flops

We are using a D flip-flop as our data-storing device as shown below.

Figure 19: Usage of D-flip flops in the project

We use a combination of flip flops to store the data from the push button. The two
flip-flops will store the value of two sides of the LED, so that the LED won’t go off
every time, push button is left open.

The D flip flops used here are positive edge triggered. The first flip flop U1A which
will store in the memory that the other two flip flops have had their positive edge once
and will prevent cheating in the game. When the user presses the push button, output
'0' of U1A goes from 'low' to 'High' triggering other two flip flops. Data for other two
flip flops comes from the 'Profile Generator Circuit'. Now when the push button is
pressed we have two cases: If it is Player 1's turn, output Q from U1B would go high.
If it is Player 2's turn, output Q from U2A would go high.
P a g e | 14

Each player takes a turn for only lighting the LEDs in his array. The player cannot
light a LED in a square that is already occupied by the other player (i.e. the led for the
other player is already lighted).

3.4.4 Winning and Draw Logic

Figure 20: Winning logic for tic-tac-toe

The above circuit is used to detect the winner. Since, there are 8 possible
configurations (3 rows, 3 columns, 2 diagonals) for any player to win the game, a
player is declared to be the winner if the OR of AND of each individual column, row
or diagonal gives the output of 1.

In case, the And of all the cells is 1 and the winning circuit gives an output of 0, the
game is drawn.

4. RESULT ANALYSIS
4.1 FINAL CIRCUIT
P a g e | 15

PLAYER
TURN
COMPONENT

WINNING
LOGIC FOR
DRAW LOGIC
PLAYER 1 MEMORY
STORAGE
INPUT COMPONENT
BLOCK

DISPLAY
BLOCK

WINNING
LOGIC FOR
PLAYER 2

Figure 21: Final circuit

4.2 COMPONENTS OF CIRCUIT


4.2.1 Player Turn Generator

Figure 22: Circuit for player turn generator

This circuit is used for deciding which player's turn it is and make sure that
game flow is correct and both players are playing on their own turn. The
result will be the players 2's turn. If output is 0 then a NOT is used for the
turn of player 1. Once player 1 plays, one of the inputs goes to 1, now the
P a g e | 16

overall XOR output goes to 1. This makes player 2 profile to 1 and player 1
profile to 0. This keeps happening and we get alternate player1 and player2
results. Basically, the output toggles for every input change.

q1, q2, …, q9 are user inputs for a particular cell from the memory
component of the circuit.
no1 determines the turn of player 1
no2 determines the turn of player 2
no1 = (q1 ⨁ q2) ⨁ (q3 ⨁ q4) ⨁ (q5 ⨁ q6) ⨁ (q7 ⨁ q8) ⨁ q9
no2 = ((q1 ⨁ q2) ⨁ (q3 ⨁ q4) ⨁ (q5 ⨁ q6) ⨁ (q7 ⨁ q8) ⨁ q9)’

The turns are toggled on an ODD basis.

4.2.2 Input Block

Figure 23: Circuit for input-block

This is the combination of push buttons which helps the user to play the
game. When a push button is pressed, current flows and the corresponding
other end gets a high input. This input is sent to the memory flip flop
combination where the input of the user is stored. R7 is the RESET button for
the game.
p1, p2, .., p9 are the push button inputs from the players.

4.2.3 Display Input Block


It is a combination of 18 LEDs , 9 for each player color. It helps to avoid
confusion about the inputs and makes the game more user-friendly. The LED
P a g e | 17

lights up if r i or b i is high (where i is from 1 to 9). This block has 3x3 dual
color LEDs arranged in a matrix fashion. The outputs of 'switch block' are
given to the corresponding LED.
So if the LED glows RED it means that that move was made by player 1 and
if the led glows BLUE that move was made by player 2.
r1, r2, .. r9 are the inputs for Player 1 - RED color.
b1, b2, .. b9 are the inputs for Player 2 - BLUE color.

Figure 24: Circuit for Display input block

4.2.4 Final Output Display Block

Figure 25:Circuit for final output display

This block is responsible for displaying the output of the game. Red LED
lights up if player 1 wins, BLUE LED if player 2 wins and yellow LED if the
game draws.
P a g e | 18

redwins is high if Player 1 wins


bluwins high if Player 2 wins
draw high if the game draws

4.2.5 Push Button To Flip Flop


This Circuit does not allow any player to make any move if some player has
already won the game.
notwin is high only if no player has one
p1, p2, .. p9 are push button inputs from player
bu1, bu2, .. bu9 are cell inputs.
bui = notwin . pi
Thus, cell marking is allowed only if no player has won

Figure 26: Circuit to check


game condition before
storing input
P a g e | 19

4.2.6 Memory Storage Component

Figure 27: Circuit for memory storage using flip-flops

The switches get input from the user, these are momentary micro switches, so
to know which switch was pressed, we use flip flops (D flip flop) to keep
track of input. Also we 'store' which player's move it was, below is the
schema we used to achieve this purpose. This schema is duplicated for all
nine switches.

q1, q2, .. q9 are cell markings, i.e., if the cell is marked or not.

MOVES OF PLAYER 1 - RED


P a g e | 20

Figure 28: Storage circuit for moves of player-1 (Red)

MOVES OF PLAYER 2 - BLUE

Figure 29: : Storage circuit for moves of player-2 (Blue)

The IC 74174 is Hex D-Flip Flop which has been used to reduce the
complexity of schema shown in Section 3.3.3. When the no1 or no2 is high,
the respective D-Flip Flop gets a high output and is positive edge triggered
P a g e | 21

and stores the data. This Circuit does not allow the player to cheat. The first
D- Flip flop does not allow the cell marking to change once marked.
no1 denotes the turn of player 1
no2 denotes the turn of player 2
bu1, bu2, .. bu9 are the inputs in a cell
red1, red2, .. red9 denote the move of Player 1 in the respective cell
blu1, blu2, .. blu9 denote the move of Player 2 in the respective cell

4.2.7 Winning Logic


At this stage, inputs from "Switches for Inputs" are given to a 3 input AND
gate in which different combinations of inputs are used to check whether the
player has won or not.
This circuit will make sure that there is no error in the winning of only one
player out of two and if no player has achieved the winning status and all
switches are pressed then the Draw's LED should turn on.
Now we have the inputs, we need to process and find out who won. The game
says that if a player gets any of the horizontal, vertical or diagonal lines full
(all 3 for himself) is declared the winner.

So the next task is to find out those winning combinations. For this we used 3
input AND gates whose outputs are Or'ed together.
This setup is duplicated for both Player 1 and Player2.
If the output of this block is high, it means we have a winner!
PLAYER 1 WINNING LOGIC
P a g e | 22

Figure 30: Circuit to check win for Red

PLAYER 2 WINNING LOGIC

Figure 31: Circuit to check win for blue


P a g e | 23

red1 , red2 , .. red9 denote a Player 1 move in a cell.


blu1, blu2, .. blu9 denote a Player 2 move in a cell.
redwins is high if Player 1 wins
bluwins is high if Player 2 wins

1 2 3

4 5 6

7 8 9

A player wins if the moves are placed horizontally, vertically, or diagonally

redwins = (red1. red2. red3) + (red4. red5. red6) + (red7. red8. red9) +
(red1. red4. red7) + (red2. red5. red8) + (red3. red6. red9) +
HORIZONTAL (red1. red5. red9) + (red3. red5. red7)
VERTICAL
DIAGONAL

in a line.

HORIZONTAL bluwins = (blu1. blu2. blu3) + (blu4. blu5. blu6) + (blu7. blu8. blu9) +
VERTICAL (blu1. blu4. blu7) + (blu2. blu5. blu8) + (blu3. blu6. blu9) +
DIAGONAL (blu1. blu5. blu9) + (blu3. blu5. blu7)
DE EC-262

4.2.8 Draw Logic


P a g e | 24

Figure 32: Circuit for draw logic

If all switches have been pressed, we just AND all the outputs from the
switches. When all the switches are pressed, the output of the circuit goes
high, meaning it's a draw or that a new game should be started. With this, we
also make sure that no person has won the game. If redwins or bluwins is
high, then the output of AND gate (U51) will be 0 due to the inverter and
hence draw condition will not be satisfied.
q1, q2, … q9 denote if cells are marked or not
redwins denotes Player 1 has won
bluwins denotes Player 2 has won
draw is high if the game draws

draw = (q1.q2.q3) . (q4.q5.q6) . (q7.q8.q9) . (redwins’ .


bluwins’)
All switches No player wins
pressed
DE EC-262

4.3 SIMULATION RESULTS


Player 1 wins - RED LED LIGHTS UP
P a g e | 25

Figure 33: Simulation: player-I wins

Player 2 wins - BLUE LED LIGHTS UP

Figure 34: Simulation: player-II wins

Game draws - YELLOW LED LIGHTS UP


P a g e | 26

Figure 35: Simulation: game draws

5. CONCLUSION
The project was successful and the group was able to make a functional Tic Tac Toe
game with Proteus Software. After designing and constructing even a simple game
such as TIC TAC TOE, a new found appreciation for the effort that goes into creating
digitally controlled devices was obtained. There are numerous methods and
approaches that can be taken to achieve the same goal, some simpler than others which
was a valuable lesson. Sometimes the complicated solution is not the right way to do
things. We overcame the challenges of push buttons with the help of flip flops. Another
flaw that was encountered was players were able to overwrite the other players’ past
moves. We implemented a sort of anti-overwrite circuitry; if a position was
accidentally overwritten, no change was made. Also, the LEDs showed glitches
sometimes, so we used a buffer gate using 2 inverters. Overall, the team experienced
quite the challenge while needing to design a functional circuit only from our past
experiments and knA score board would be a nice addition in future, as typically
multiple rounds are to be played and keeping track would take that responsibility away
from the player
P a g e | 27

6. REFERENCES
[1] S. Parekh and S. Prabhu, "Tic-Tac-Toe game with a new aspect," Proceedings of
3rd International Conference on Reliability, Infocom Technologies and
Optimization, 2014, pp. 1-4, doi: 10.1109/ICRITO.2014.7014696.
[2] Ciletti, M. D., Mano, M. M. (2006). Digital Design. (n.p.): Pearson College
Division.
[3] International Journal of Computer Trends and Technology (IJCTT) – volume 12
number 2 – Jun 2014, Page71, Implementation of Tic-Tac-Toe Game in LabVIEW
[4] Tic Tac Toe Game , Player Indicator,
https://electronics.stackexchange.com/questions/197620/tic-tac-toe-game-player-
indicator
[5] Tic Tac Toe using DLD, https://www.youtube.com/watch?v=uTMi8AwuqoE
[6] Digital Tic-Tac-Toe Using ATtiny85, https://www.engineersgarage.com/electronic-
projects/digital-tic-tac-toe-using-attiny85/
[7] Tic-Tac-Toe game in wikipedia, http://en.wikipedia.org/ wiki /Tic-tac-toe

You might also like