Lab / Wingy Wallow
Wingy Wallow
Wingy Wallow is the endless flyer I made in Verilog for the Nexys 4 DDR FPGA board. Steer the bird through the gaps between the columns; touching a column, or leaving the field, costs a life. You start with one life and collect hearts for more, up to three, and score a point for each gap and each heart; the higher the score, the faster the columns come. What you play here is a software port of the design’s Verilog, compiled to WebAssembly and running in this browser tab. It is not the FPGA, and it is not the Verilog running.
Controls
- Keyboard
- Arrow keys or W, A, S and D steer, once the game has focus (Start gives it focus).
- Space or Enter is the board’s centre button: it starts a game, and restarts one at any time.
- P pauses and resumes. Tab leaves the game as anywhere on the page; Escape leaves the full window.
- Touch and pointer
- Hold the arrow buttons under the game; several at once work. ● is the centre button.
- Restart holds the centre button for you. Enlarge fills the window: on a phone, turn it sideways first.
- Score
- —
- High score
- —
- Lives
- —
- State
- Not started
- Frame
- —
Arrow keys or W, A, S and D steer; Space or Enter is the centre button, which starts a game and restarts one. P pauses. Tab leaves the game, as anywhere on the page.
On a touch screen, hold the buttons below the game; several at once work. On a phone, turn it sideways and press Enlarge.
How it works
The original is a Verilog design for the Nexys 4 DDR board. It draws a 1440 by 900 picture for a VGA monitor, 59.998 frames a second, in 12-bit colour, and runs the game 30 times a second, on every second frame. The board’s five push buttons steer and start the game, and its seven-segment display shows the score and the high score, which starts at 13. They are not in the picture, so this page writes them out above it. Any button leaves the title screen, but only the centre button starts a game.
A simulation of the design’s Verilog, every edge of both of its clocks, runs 15 to 18 times too slowly for real time in a browser. So the game here is a port: the game logic, the three random generators and the drawing rewritten in C++ from the Verilog, keeping what decides the picture, down to the pixel clock at which each game tick lands. It was validated frame for frame against that simulation: the frame’s hash, the score, high score, lives and display digits at every frame, and the registers at every game tick. The record: 36 runs in four combinations (the original images or the new ones, with either reading of the design’s mixed assignments, below), 171,836 frames, 85,930 game ticks and 3,609,060 values at those ticks, with no mismatch. Four of the runs are of the combination this page plays, the new images and the board-order reading: 9,384 frames, 4,693 ticks and 197,106 values. Among the runs are one of 41,200 consecutive frames, in which the tick lands on every line of the frame, one reaching a score of 35, and runs with button changes part-way through frames.
What was not verified. Nothing has been run on the board itself, so the questions only the board can settle stay open for the port. The game’s repository tested the module in Node and in headless Chrome and Chromium; no phone and no other browser. Two tables were not stepped through the Verilog: the score and high score as the seven-segment display shows them (no run reaches 1,000), and the game tick from states the runs do not reach, such as speeds above 7 with the divider growing, scores near 65,535 and every change of lives with hearts; for both, the port is compared with the simulation only where the runs go. And a second, independent simulator was run only on the two original test sequences, one of them recorded in full, not on the runs made for the port.
The artwork was replaced for this version. The bird, the columns, the heart, the background and the title screen are original pictures made for it, at the same sizes and in the same format as the design’s images, whose origin could not be established. The design shows them its own way: four bits a colour channel, the background stretched twice across and four times down.
Behaviours that are as simulated and unverified against the board, because the port reproduces the simulation. After a game over the bird stays put, “as the board most plausibly behaved, unverified against the board”: the design assigns the bird’s position two ways in one block, and the simulation, following the Verilog standard, lets the bird go on moving with a direction held and the lives wrap round from 0 to 3, where synthesis most plausibly kept the later assignment. Where a column reads past the end of its image, in the 40 or so lines above each gap and in wider bands further on, the simulation reads zero and the column shows plain light green, the design’s colour for such a pixel; what the board showed there has not been checked. A frame is torn where a game tick lands part-way down it. And the gaps and the hearts’ places come from generators that step on every pixel clock and are partly held in reset while the centre button is down, so the moment you let go of it, to the pixel clock, decides the gaps that follow; on the board they also depended on timing the simulation fixes, such as the clocks’ start-up.
The page runs the design’s 59.998 frames a second on its own clock: at each of the browser’s frames it runs the game’s frames that are due, at most four, and drops any backlog beyond that rather than racing to catch up. Each press and release reaches the game at its own point in its frame. Restart holds the centre button for four frames, which always spans two game ticks, and once more if the game is then over, since a bird falling onto the floor can lose its last life on a tick that sees the button. The game pauses by itself when the tab is hidden, the window loses focus or the game scrolls out of view, and carries on only when you press Resume or P. Nothing moves until you press Start, and nothing else on the page animates; with reduced motion set on your device the game says so beside it.
Everything runs in this browser tab, and nothing is sent anywhere. The module is the game repository’s WebAssembly build from release v0.1.0, commit f21a426, compiled with Emscripten 6.0.13, about 1.3 MB and loaded only when you press Start. The repository, WingyWallowGame, is not public, so there is no link to it, and there is no case study of this project.