CEG3155 hub, Laboratories
Laboratory 2 · CEG 3155 · uOttawa · Fall 2026

Fixed-point arithmetic

What the laboratory asks for, what the hardware does, and the order to do the work in. Ten minutes of reading.

Pre-lab

Due before you arrive

A four-bit signed adder and subtractor, built, simulated and brought with you.

  1. Four bits, signed, two's complement. Range −8 to +7. Subtraction is addition of the two's complement, which the circuit forms by inverting every bit of y and setting the carry in to 1, both from the same Add / Sub line.
  2. Overflow. The unit has to report it. In two's complement it is the carry into the sign bit against the carry out of it, so OverflowOut = c4 ⊕ c3, and it cannot be read off the carry out alone.
  3. Code it in RTL and structural VHDL. Section 3.2 walks the design, section 8 holds the coding rules.
  4. Simulate it, showing several pairs added and several subtracted, each giving the right answer, and at least one pair that overflows.
  5. Present and explain it to the teaching assistant at the start of the session. Expect questions.
  6. Keep the signed sheet. It is handed in with the final report.
Four bit adder and subtractor Four full adder cells in a row. Each y input passes through an exclusive OR gate driven by the Add or Subtract control, which also supplies the carry into the least significant cell. Carries pass right to left as c1, c2 and c3, and c4 leaves the most significant cell. y3 x3 s3 full adder y2 x2 s2 full adder y1 x1 s1 full adder y0 x0 s0 full adder c1 c2 c3 c4 c0 Add / Sub
Figure 6 of the handout at four bits. Add / Sub low adds, high subtracts: it inverts every bit of y through the exclusive OR gates and supplies the carry in, which together make the two's complement of y.

Lab

The marks live here

Two ASM designs, then an ALU built around them.

The five stages of Laboratory 1, run twice, once for the signed multiplier and once for the signed divider. Each gets its own pseudocode, chart, datapath, detailed chart and control logic.

  1. Write the algorithm as pseudocode. Nothing is supplied this time. Laboratory 1 handed you the pseudocode and asked you to close its gaps. Here you write it from the problem, for each of the two units.
  2. Turn the pseudocode into an ASM chart. Rectangles for states, one clock step each, diamonds for tests. Every register the design needs is decided here.
  3. Draw the datapath. Registers, the paths between them, a device wherever a value is transformed on the way, and a selector wherever a register is fed from more than one place. This stage produces the control signal names.
  4. Redraw it as the detailed ASM chart, with every movement of data replaced by the control signals that cause it.
  5. Design the control logic by the one flip flop per state method.

Then the ALU around them, which is where the points that are easy to miss live.

  • All four operations behind one output. OperationSelect[1..0] chooses what reaches MuxOut[7..0], in the pairing Table 4 of the handout gives.
  • Three status outputs. CarryOut, ZeroOut and OverflowOut, all three brought out of the ALU.
  • The seven-segment display. All eight digits on the board share one set of cathodes, so a display controller clocked from CLK100MHZ multiplexes them in time, driving seg[6..0] and an[7..0].
  • Four-bit arithmetic, wider registers. Every operation is four bits so the result fits the display, but some registers have to be eight, the product register being the obvious one.
  • Signed all the way through. You may not flip a negative operand positive, multiply or divide, and repair the sign afterwards. The handout closes that route in bold.

A report that shows a working display and skips the charts loses most of the marks.

1. The gist

A four-bit arithmetic logic unit for signed numbers. It takes two four-bit operands and a two-bit operation select, performs one of four operations on them, and shows the result on the board's seven-segment display.

Four operations, chosen by two switches
OperationSelectResult on MuxOut[7..0]Where it comes from
00four-bit sumthe pre-lab adder
01four-bit differencethe pre-lab subtractor
10eight-bit productthe multiplier you design
11four-bit quotient and remainderthe divider you design

Three status lights come out alongside the result: CarryOut for a carry or borrow, ZeroOut when the result is zero, and OverflowOut when the operation overflowed.

The operands are signed, and the handout closes the easy route explicitly. You may not detect a negative operand, flip it positive, multiply or divide, and fix the sign afterwards. The multiplier and the divider have to handle signed values directly. That single sentence is what makes this laboratory harder than it looks.

Lecture 6 is the one worked example in the course of all five ASM stages on a single problem. Its subject is a floating point adder, which is not the arithmetic of this laboratory, so take the method from it and not the mathematics: how the pseudocode became a chart, how the chart produced a datapath, and how the detailed chart produced the control logic. Laboratory 2 asks for that sequence twice over.

Lecture 8 is the closest to the work itself, carrying multiplication, division and signed multiplication and division, along with the carry lookahead adder that the bonus asks for. Lecture 7 covers signed and unsigned numbers, addition and subtraction, and arithmetic overflow, which is the pre-lab and the OverflowOut status signal.

2. The kit

What the laboratory runs on
BoardDigilent Nexys A7-100T, Xilinx Artix-7
SoftwareXilinx Vivado, Windows or Linux x86 only
Arithmeticfour bits, so the result fits the seven-segment display
Teamtwo people
DueWednesday 14 October, midnight, Brightspace

GClock is a push button. Laboratory 1 divided the 100 MHz clock down to about one step per second, and here you supply each edge yourself. Here you step the circuit by hand, and the Nexys A7 buttons are active high and not debounced, so one press can register as several edges. The multiplier and the divider each need a fixed number of steps before the answer is valid, so press deliberately and count.

CLK100MHZ is still there, and it drives the display only. The seven-segment digits share one set of cathodes, so a supplied display controller refreshes them in turn from the oscillator. It is not the clock your arithmetic runs on.

3. What is happening inside

Four arithmetic units, one output multiplexer and a display controller.

Because the multiplier and divider take several steps, each needs a Done state, and the result is only valid once it is reached. That is a difference from Laboratory 1, where every step produced a finished answer.

4. What the reset does

GReset forces every flip flop in the design to a known value, so the circuit starts from a defined state. The fabric powers up in an arbitrary one. It reaches every functional block, and section 8 requires that.

Like GClock it is a push button on the board, so the demonstration starts by pressing reset and then stepping.

5. The rules that cost marks

Five bonus marks are on offer. Replace the ripple carry adder with a four-bit carry lookahead adder. The handout asks for the modifications discussed, with no need to redraw every component, and the new design demonstrated to the teaching assistant. Section 5.4.1 of the textbook covers the design.

6. How to approach it

The pre-lab comes first and it is a gate. It has to exist, simulate correctly and be explained before the session begins, so it is the first thing to build, whatever order the report ends up in.

Then the two algorithms, on paper, before any VHDL. Signed multiplication and signed division are where the thinking is, and the ban on converting to positive first is the constraint that shapes both. Work them as pseudocode until you can run them by hand on a negative operand.

Then the ASM stages for each unit, in order. Chart, datapath, detailed chart, control logic. Each reads its input off the one before it, so a wrong chart costs everything after it.

Then the VHDL, from the bottom up, testing each block on its own before wiring it into the next. The adder from the pre-lab is already done and tested, which is a working foundation for the other three.

Integration last, then the output multiplexer, then the board.

7. What goes in the report

The structure is fixed by the report guidelines: cover page, objectives, problem and solution discussion, verification, lab discussion, conclusion and appendices. The marking scheme puts the weight on the algorithmic solution, the components, the simulation and the demonstration.

Twenty five pages maximum, including cover page, contents and appendices, losing a mark for every page over. With two full ASM designs to present, this binds on Laboratory 2 in a way it did not on Laboratory 1.