Altera_Forum
Honored Contributor
12 years agotic tac toe
Hi to all,
A homework task I got is to implement a synchronous program that checks a tic tac toe board, which is of n*n size. The program detects if there is a winner ( Are all the elements in a row or column the same) and if so, who is the winner. the information of the content of the board is given by "D_in": 00- blank cell; 01- X; 10- O; 11- end of line The information is inserted in the shift-register method- row by row ( left to right), and when a row ends there's 11/ end of the whole board is represented by "Rst_n" being '0'. The output of the program is given by "Stts: 00- waiting; 01- X wins; 10- O wins; 11- draw The way I chose to implement the exercise is as follows: - final state machine (of D_in) for the row check. - XOR of a last row memory with the current D_in for the column check. The program includes a testbench which checks the following options: - O row win; X row win; O column win; X column win; draw for some reason which I don't manage to get hold of the program doesn't get the output which it is supposed to. any idea why? Attached above is a sketch of the code and the block diagram of the program and the FSM. thanks in advance, Amitai PS I had a simulation error which pointed that there's a problem in the main loop of the program. I decided temporally to get rid of it by changing in line 69 from "C < n" to "C < n-1". (although I didn't manage to understand why is "C < n" out of range)