Verilog · FPGA · Digital Design

Simultaneous
Equation Solver

A standalone hardware calculator for solving systems of two or three linear equations, implemented in Verilog on a Digilent Basys 3 FPGA and operated through switches, buttons and an OLED display.

2–3unknown variables
Cramer'sRule solver
3 d.p.decimal display
S ⇔ Dfraction / decimal
01 · Project overview

Solving equations directly in hardware.

The goal was to build more than an arithmetic module: I wanted the FPGA to behave like a self-contained calculator. The user chooses a two- or three-variable system, enters each coefficient using physical switches, follows prompts on the OLED, and receives the calculated solution without a PC-side application.

Interactive input

The OLED presents the equation and prompts for coefficients one at a time. The active coefficient is highlighted in a different colour, creating a cursor-like interface. LEDs mirror the switch state to give immediate physical feedback.

Result presentation

Solutions are first shown in exact rational form. Once a result is available, the centre button changes role from ENTER to an S⇔D control, allowing the user to switch between fraction and decimal representations.

02 · Demonstration

From switches to solution.

Collage showing the OLED interface, equation entry, rational and decimal results, and fault states
Original project demonstration collage. Replace this file with your higher-resolution individual screenshots when ready.
Full demonstration of the simultaneous equation solver running on the Basys 3 FPGA.
1. SelectChoose 2 or 3 unknowns
2. EnterSet each coefficient with switches
3. ConfirmBTNC stores the current input
4. SolveCramer's Rule calculates the result
5. DisplayToggle fraction ⇔ decimal
03 · Algorithm selection

Why I moved from RREF to Cramer's Rule.

My initial plan was Reduced Row Echelon Form. It is a natural mathematical method, but implementing row reduction in RTL introduced more control complexity than expected. The design needs to manage operations such as pivot handling, repeated row transformations and intermediate values explicitly in hardware.

Initial approach

RREF / Row Reduction

Flexible and mathematically familiar, but procedural. A hardware implementation must coordinate a sequence of matrix operations and account for data-dependent cases.

→
Final approach

Cramer's Rule

For a fixed 2×2 or 3×3 problem, determinant calculations have a predictable structure. This made the arithmetic easier to map into a purpose-built datapath.

For a 3-variable system:

Δ = det(A)    Δx = det(Ax)    Δy = det(Ay)    Δz = det(Az)

x = Δx / Δ     y = Δy / Δ     z = Δz / Δ

The key lesson was that choosing an FPGA algorithm is not only about whether the mathematics works — its structure also determines the hardware that must be created.

04 · Architecture

A calculator built from cooperating hardware blocks.

The project combines user-input handling, control logic, coefficient storage, arithmetic and display formatting into one standalone system.

Switches & ButtonsSigned coefficient selection, ENTER and RESET
Control LogicTracks the current input and calculation stage
Coefficient StorageStores the entered equation values
Cramer's SolverDeterminants, solution and fault conditions
OLED OutputPrompts, equations, fractions and decimals

Two-variable mode

A₁X + B₁Y = D₁
A₂X + B₂Y = D₂

The interface requests A₁ → B₁ → D₁ → A₂ → B₂ → D₂ before calculating X and Y.

Three-variable mode

A₁X + B₁Y + C₁Z = D₁
A₂X + B₂Y + C₂Z = D₂
A₃X + B₃Y + C₃Z = D₃

The same interaction scales to twelve entered coefficients before X, Y and Z are calculated.

05 · Result handling

Exact fractions when possible. Decimals when useful.

The solver keeps the result available as a rational numerator/denominator pair, which naturally fits Cramer's Rule. The OLED can therefore show an exact fraction before presenting a decimal representation to three decimal places.

47 / 200    ⇔    0.235

The S⇔D interaction was inspired by scientific calculators: after solving, BTNC toggles the presentation without requiring the user to re-enter the equations.

Fault states

Cramer's Rule requires a non-zero determinant for a unique solution. The calculator detects non-unique/unsolvable conditions rather than attempting an invalid division, and the OLED reports states such as INF or NO SOL.

Δ ≠ 0 → unique solution
Δ = 0 → no unique solution
06 · Engineering challenges

The difficult parts became the most useful lessons.

01 / ALGORITHM

Translating mathematics into RTL

Solving the equations mathematically was only the beginning. The operations also had to be expressed as finite digital hardware with signed values and intermediate arithmetic.

02 / ARCHITECTURE

Finding a hardware-friendly method

RREF was my first approach. Moving to Cramer's Rule simplified the structure for the fixed 2×2 and 3×3 systems required by the project.

03 / RESOURCES

Reducing LUT utilisation

As the design grew, LUT usage became a constraint. I had to revisit how the Verilog was structured and reduce unnecessary logic so the complete design could fit within the FPGA's resources.

04 / INTERACTION

Designing with limited controls

With no keyboard, switches and buttons had to cover coefficient entry, confirmation, reset and result-format switching. OLED highlighting made the current input state clear.

This project changed how I viewed Verilog: the goal is not simply to write code that produces the right answer, but to understand what hardware that description asks the FPGA to build.

07 · Technology

Built around digital hardware.

VerilogDigilent Basys 3Xilinx FPGAVivadoCramer's RuleRTL DesignOLEDSigned ArithmeticLUT OptimisationDigital Logic