A Tic-tac-toe board can be represented by a binary matrix where the ones and zeros represent the and marks, respectively. The following board represents a possible final configuration after playing the game.
| 1 | 0 | 1 |
|---|---|---|
| 1 | 1 | 0 |
| 0 | 0 | 1 |
We can represent the board with a 9-bit vector, with the indices of the vector representing the board locations as follows:
| 8 | 7 | 6 |
|---|---|---|
| 5 | 4 | 3 |
| 2 | 1 | 0 |
Thus, the previous board would be represented with the bit-vector
101110001. Note that a board may contain more than one row
of ones and more than one row of zeros.
Design a circuit that receives a board description and generates two outputs. One output will be activated when there is at least one row of ones (vertical, horizontal or diagonal). The other output will be activated when there is at least one row of zeros.
module tictactoe(board, row1, row0);
input [8:0] board;
output row0, row1;Try to minimize the effort by reusing the design of some module in the same circuit.
board is a 9-bit vector describing a Tic-tac-toe
board.
row1 is the output indicating whether there is a row
of ones.
row0 is the output indicating whether there is a row
of zeros.