BitFlow

Conway's Game of Life (16x16 Torus)

advanced · state_machine · 390 XP

Sign in to write your solution, run it in the simulator and submit it for grading.

Sign in or create a free account →

Problem

Conway's Game of Life — 16×16 Torus Grid Implement the full **Conway's Game of Life** on a 16×16 grid with **toroidal wrapping** (edges connect to opposite edges). Each cell updates simultaneously based on its 8 neighbors. **Rules:** - **Live cell with 2–3 neighbors:** survives - **Dead cell with exactly 3 neighbors:** born - **All other cells:** die or stay dead **Grid topology:** Torus (wrap-around): - Cell [0][0] neighbors include [15][15], [15][0], [15][1], [0][15], [0][1], [1][15], [1][0], [1][1] - Cell [15][15] neighbors include [14][14], [14][15], [14][0], [15][14], [15][0], [0][14], [0][15], [0][0] **Interface** | Port | Direction | Width | Description | |------------|-----------|-------|-----------------------------------| | `clk` | input | 1 | Clock | | `rst` | input | 1 | Sync reset (all dead) | | `load` | input | 1 | Load initial state | | `load_data`| input | 256 | 256-bit grid (packed 16×16) | | `grid_out` | output | 256 | Current grid state (packed) | | `generation`| output | 32 | Generation counter | **Packing:** `load_data[y*16 + x]` = cell state at [y][x] - 0 = dead, 1 = alive **Neighbor counting:** For each cell [y][x]: - Count alive neighbors from 8-neighborhood (with wrap-around) - Combinational logic using `generate` loops preferred **Next-state logic:** ``` next_grid[y][x] = (grid[y][x] && (neighbors==2 || neighbors==3)) || (!grid[y][x] && neighbors==3) ``` **Registers:** - `grid[15:0][15:0]` current state - `next_grid[15:0][15:0]` computed next state (combinational) - `generation[31:0]` incremented every clock On every clock: `grid <= next_grid; generation <= generation + 1` **Test patterns:** - **Blinker:** Period 2 (oscillates every 2 generations) - **Block:** Static 2×2 square (never changes) - **Glider:** Period 4, moves diagonally - **Random seed:** Evolve for 100 generations, verify no crashes This is a classic interview problem testing Verilog `generate`, parameterization, and combinational logic design.

Constraints

  • 16×16 grid with toroidal boundary conditions (wrap-around).
  • Each cell: (alive && (n==2||n==3)) || (!alive && n==3).
  • Use `generate` loops for neighbor counting (strongly preferred).
  • All cells update simultaneously (synchronous).
  • load_data: 256-bit packed array [y*16+x] = grid[y][x].

Examples

Input: Blinker (vertical line at x=5): [y=5..7][x=5] = 111

Output: Period 2: generation odd = horizontal, generation even = vertical

Oscillator

Input: Block (2×2 square): [y=0..1][x=0..1] = 1111

Output: Unchanged forever

Still life

Input: Glider at [0,0], evolves for 4 generations

Output: Returns to same pattern, translated diagonally

Spaceship

Common questions

What does the Conway's Game of Life (16x16 Torus) problem ask you to build?
Conway's Game of Life — 16×16 Torus Grid Implement the full **Conway's Game of Life** on a 16×16 grid with **toroidal wrapping** (edges connect to opposite edges). Each cell updates simultaneously based on its 8 neighbors.
What constraints does Conway's Game of Life (16x16 Torus) have?
16×16 grid with toroidal boundary conditions (wrap-around).; Each cell: (alive && (n==2||n==3)) || (!alive && n==3).; Use `generate` loops for neighbor counting (strongly preferred).; All cells update simultaneously (synchronous).; load_data: 256-bit packed array [y*16+x] = grid[y][x].
What is an example input and output for Conway's Game of Life (16x16 Torus)?
Input Blinker (vertical line at x=5): [y=5..7][x=5] = 111 gives output Period 2: generation odd = horizontal, generation even = vertical. Oscillator
Which Verilog concepts does Conway's Game of Life (16x16 Torus) practise?
state_machine, capstone, cellular-automaton, generate, interview.