Chapter 4: Arithmetic and Sequential Logic
This chapter follows Lecture 4, and it has two halves. The first half is arithmetic. A circuit that adds is built from small parts, and a few changes to it give subtraction, negative numbers and a report of whether the answer fits. The second half is memory. Every circuit so far forgot its past the moment its inputs changed, and this half adds the part that remembers, the register, and the clock that tells it when to listen.
The halves meet in the middle. Counting, timers and accumulators are adders whose result is stored and fed back, so the arithmetic of the first half is what the registers of the second half keep. The chapter ends by writing sequential circuits in SystemVerilog and learning the rules that keep them predictable.
Chapter 3 taught you to test a combinational circuit and to simplify one. This chapter is the last one before state machines, which use everything in it.
What you will be able to do
Section titled “What you will be able to do”After this chapter you can:
- add and subtract binary numbers, and say what the carry out of an adder means;
- build a full adder from gates, chain adders into a ripple-carry adder, and write adders in SystemVerilog without losing a carry;
- read a bit pattern as unsigned or as two's complement, negate it, and widen it correctly;
- tell carry from overflow, find each one, and compare two numbers correctly for both readings;
- explain why a circuit needs state, and design a small circuit from registers, adders and multiplexers, starting from a block diagram;
- describe a flip-flop and a register, and say how synchronous and asynchronous reset differ;
- write a clocked circuit in SystemVerilog with the right assignments, and a testbench that drives it.
Sections
Section titled “Sections”- 4.1 Binary numbers and adders
- 4.2 Adders and parameters in SystemVerilog
- 4.3 Two's complement
- 4.4 Overflow and the adder/subtractor
- 4.5 Why circuits need state
- 4.6 Designing with registers, adders and multiplexers
- 4.7 Flip-flops and registers
- 4.8 Sequential logic in SystemVerilog
The first four sections are the arithmetic half and need only the combinational circuits of the first three chapters. Section 4.4 also finishes a job left open earlier: it repairs the guessing-game comparator that went wrong in Chapters 2 and 3. The last four sections are the memory half. They start from the question of why a circuit needs state at all, and the small timer built there comes back in later sections.