Skip to content

ashkan-khd/conways-game-of-life-verilog

Repository files navigation

Conway's Game Of Life

The Game of Life is a cellular automaton devised by the British mathematician John Horton Conway in 1970. It is a zero-player game, meaning that its evolution is determined by its initial state, requiring no further input.

Rules

The universe of the Game of Life is an infinite, two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, live or dead. Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:

  • A cell will be alive in the next generation if it has exactly 3 live neighbors (due to reproduction).
  • If a cell was live in the previous generation it has more possibility to be live in the next generation. So besides the previous case, the cell will survive if it has exactly 2 live neighbors.

Design Specifications

Demands

  1. Automation must work like a big shift register. if run=1 the game must be played, otherwise it reads from or writes data into the register serially depending on write_read_not.
  2. Game board dimensions must be parameterized.
  3. The game board must be borderless.
  4. For testing the automation use famous patterns of the game.

Files

game_of_life.v It has the module, GameOfLife. parameters:

  • ROW
  • COLUMN

inputs:

  • init_board: the module gets a board as the initializing board and after one clock it starts the game. One clock for each generation.
  • start: the game starts and will be run as long as this input is set.
  • clk

outputs:

  • game_board: the universe of the game after updating each generation.

How To Run In order to simulate this module there has been generated a testbench file for it which puts Glider pattern (see WikiPedia) inside the grid and watches over it through more than 40 generations. You can simulate TestGameOfLife in test_game_of_life.v with ModelSim. You can also write your own benchmark for it and use my testbench to understand how to evaluate the module inputs and show the result grid into modelsim terminal.

game_of_life_interface.v This file has the module GameOfLifeInterface. It satisfies the demands of the design. it works like a big shift register which has the ability to serial in the data or read it from serial out. This module uses GameOfLife module when no one wants to read or write the data and the game must be run. parameters:

  • ROW
  • COLUMN

inputs:

  • run: if set the game will be running.
  • write_read_not: if run is not set this signal is used to write or read data.
  • serial_in: for writing data serially.
  • clk

outputs:

  • serial_out: due to reading data from the register serially.

How To Run There has been written a testbench for this module named TestGameOfLifeInterface.v in the test_game_of_life_interface.v file. it easily test Blinker pattern (see WikiPedia) in the automation. if you want to see more dynamic patterns simulate TestGameOfLife module not this one.