eecs270.org

Project 7: Sequential Calculator

Component Points
Autograder Checkpoint 10
Autograder Final 90
   
Total 100

Checkpoint: April 10, 2026 at 11:59 PM (ADD/SUB only) Final Due Date: April 20, 2026 at 11:59 PM

Note: There is no in-person signoff for this project. Grading is based on Autograder only.

FourFuncCalc icon

Before Starting

Starter Files

Provided helper modules (do not submit or modify these; they are built into the Autograder):

Reference Booth Multiplier implementation:

Design Specification

The calculator performs addition (+), subtraction (-), multiplication (×), and division (/) on 11-bit two’s complement integers. Operands are entered as signed-magnitude and converted internally. This project is a basic example of Register Transfer Level (RTL) design: you will implement a datapath and controller.

I/O Interface

Project 7 Interface and Datapath/Control Decomposition

Figure 1: Four-Function Calculator Interface and Datapath/Control Decomposition

Modules

Module Instantiation Graph

Figure 2: Module Instantiation Graph. You only need to implement the three bolded modules.

You implement three modules (bolded in Figure 2): Project7, TestBench7, and FourFuncCalc (plus any lower-level modules you introduce). The remaining six modules are provided. The FourFuncCalc.v starter template declares a framework for the datapath components; your job is to complete the datapath and create the controller (state encoding, transitions, and command signals).

Operation

Typical Usage Scenario

Figure 3: Typical Usage Scenario

Datapath

Calculator Datapath

Figure 4: Four-Function Calculator Datapath

Your controller must target the datapath in Figure 4, which uses a single 11-bit adder/subtractor shared across all four operations via multiplexing. A controller designed for a different datapath (e.g., using more than one add/subtract unit) will lose points.

Abstract State Transition Graph

High-Level Abstract State Transition Graph

Figure 5: High-Level Abstract State Transition Graph

Division Primer

Division is not covered in lecture. We begin by defining a few terms: Quotient = Dividend / Divisor. The Dividend is the number being divided, the Divisor is the number we are dividing by, and the Quotient is the result of the division. In this project, we round towards zero, so 7 / 2 = 3 and -7 / 2 = -3.

The algorithm used in the datapath is relatively simple: repeatedly subtract the divisor’s magnitude from the dividend’s magnitude, and keep count of how many times you need to subtract before the dividend becomes negative. This algorithm requires positive operands, so the datapath extracts magnitude and sign from an inputted signed-magnitude number and converts the result into two’s complement.

Division with only the magnitude of the operands discards information about the sign. The quotient’s sign is determined by XORing the signs of the dividend and divisor: sign(Quotient) = sign(Dividend) XOR sign(Divisor). If dividend and divisor are both negative or both positive, the sign is positive (0). If one is negative and the other is positive, the sign is negative (1).

If the divisor is zero, treat this as an overflow case.

Example: -7/2

In this case, -7 is the dividend and 2 is the divisor. We start by calculating the sign:

Sign(Quotient) = sign(-7) XOR sign(2) = 1 - The quotient will be negative.

We use the magnitudes to perform the division, so we compute 7/2:

Step Dividend Quotient
Start 7 Quotient = 0
1 7-2=5 Quotient = 1
2 5-2=3 Quotient = 2
3 3-2=1 Quotient = 3
4 1-2=-1 Stop

We stop once the dividend becomes negative. The exact quotient is 3.5, but we round towards zero to get 3. Finally, we apply the sign to get the final result of -3.

Design Notes and Hints

Deliverables

File Name Task Testing Process Grading Process
FourFuncCalc.v Implement the controller and datapath state updates for the four-function calculator ModelSim Autograder
TestBench7.v Write test cases covering all four operations, overflow, and divide-by-zero ModelSim Autograder
Project7.v Connect FourFuncCalc to the DE2-115 switches, keys, HEX displays, and LEDs LabsLand / Quartus Autograder

Do not submit the six provided helper modules (Clock_Div, Binary_to_7SEG, SM2TC, TC2SM, FullAdder, AddSub) as they are built into the Autograder. Submit only the files above plus any additional lower-level modules that you author.

No in-person signoff. The 4/10 checkpoint tests ADD/SUB via Autograder; the 4/20 final submission tests all four operations on Autograder and Quartus. Do not modify file names, module names, or interfaces of the starter files.