Digital Design from Gates to State Machines, in Verilog

Digital Electronics · Beginner · ~12 h

By Indicore

Learn digital design from the first logic gate to a working UART transmitter, writing and simulating real Verilog in your browser.

No background in electronics or programming is needed. Each chapter explains one idea, lets you try it in an interactive circuit or a live simulation, and ends with problems to practise on.

Contents

  1. The logic behind logic gates
    • Everything digital runs on 1s and 0s
    • What “binary” means
    • Gates that process binary information
    • Two gates in a row: AND
    • Two gates side by side: OR
    • Why they are called logic gates
    • Writing the two values as 1 and 0
    • Naming the inputs and the output
    • The NOT gate
    • Truth tables
    • Try the three gates
    • AND
    • OR
    • NOT
    • Boolean notation
    • NAND and NOR
    • NAND
    • NOR
    • XOR and XNOR
    • XOR
    • XNOR
    • Build an XOR yourself
    • Stuck? Here is one way to wire it
    • Build an XNOR yourself
    • Stuck? Here is one way to wire it
    • There has to be an easier way
    • Your XOR, written in Verilog
    • Testing without clicking
    • What the testbench produces
    • The electronics of logic gates
    • Gates made of water
    • Gates made of light
    • Why electronics won
    • The transistor: a switch worked by electricity
    • Resistor-transistor logic (RTL)
    • Transistor-transistor logic (TTL)
    • CMOS
    • Why CMOS is everywhere
    • Recap
    • Before the next chapter
  2. Logic gates and Boolean algebra 🔒 Free with an account
    • Run your first simulation
    • Three inputs, eight rows
    • Which operation goes first
    • The laws of Boolean algebra
    • How to check a law
    • De Morgan's laws
    • Build a NAND from OR and NOT
    • Stuck? Here is one way to wire it
    • From a truth table to an expression
    • Example: a majority vote
    • Simplifying an expression
    • Confirm it in simulation
    • Your turn: simplify and check
    • One kind of gate is enough
    • Stuck? Here is one way to wire it
    • Recap
    • Practice problems
    • Answers
    • Now solve these
  3. Number Systems, Base-N Arithmetic & 2's Complement Subtraction 🔒 Free with an account
    • From yes or no to how many
    • Why we need number systems
    • Why Roman numerals did not survive
    • Why hardware uses binary
    • Why engineers also use hexadecimal
    • How a base works
    • Cricket overs: base 6 in real life
    • Clocks: base 60 and base 24
    • Counting in binary and hexadecimal
    • Binary to decimal
    • Decimal to binary
    • Binary to hexadecimal and back
    • Three terms you will see everywhere
    • Arithmetic in any base
    • The two rules
    • Adding cricket overs
    • Adding in hexadecimal
    • Subtracting with a borrow
    • Adding in binary
    • One column of addition is two gates
    • From one column to a whole adder
    • When the answer does not fit
    • Turning subtraction into addition
    • A line and a wheel
    • Negative numbers on the wheel
    • Subtracting by adding
    • More than one digit
    • 2's complement in binary
    • Writing −3 with four bits
    • The 4-bit wheel
    • Subtracting with an adder
    • What this means for hardware
    • Recap
    • Practice problems
    • Working in other bases
    • Decimal complements
    • Binary and 2's complement
    • Real design situations
    • Answers
    • Now solve these
  4. Combinational building blocks 🔒 Free with an account
    • Blocks bigger than a gate
    • The multiplexer: a selector switch
    • From the description to gates
    • The multiplexer in Verilog
    • Any gate from a multiplexer
    • Build an OR from a multiplexer
    • Stuck? Here is one way to wire it
    • Choosing among more than two
    • A group of wires in Verilog
    • Building a 4:1 multiplexer from 2:1 multiplexers
    • The demultiplexer: one input, several destinations
    • The decoder: a number in, one line out
    • Build a decoder yourself
    • Stuck? Here is one way to wire it
    • The decoder in Verilog
    • The encoder: one line in, a number out
    • The priority encoder
    • The comparator: is A equal to B?
    • Equal
    • Greater
    • The comparator in Verilog
    • Putting the blocks to work: a 7-segment display
    • A small one you can operate
    • The full decoder in Verilog
    • Recap
    • Practice problems
    • Answers
    • Now solve these
  5. Arithmetic circuits 🔒 Free with an account
    • A promise to keep
    • The full adder
    • Build it from two half adders
    • Stuck? Here is one way to wire it
    • The full adder in Verilog
    • Adding whole numbers: the ripple-carry adder
    • Using a module inside a module
    • How many bits does the answer need?
    • Subtracting with the same adder
    • One circuit for both
    • Multiplying
    • A 2-bit multiplier from gates
    • How a multiplier grows
    • A harder question: why is a divider so costly?
    • What long division does
    • Why that costs so much
    • What designers do about it
    • Beyond the four operations
    • Recap
    • Practice problems
    • Answers
    • Now solve these
  6. Flip-flops and sequential circuits 🔒 Free with an account
    • Why gates alone are not enough
    • Memory from two gates
    • The problem of when
    • The clock
    • First attempt: the D latch
    • The D flip-flop
    • A flip-flop in Verilog
    • See the difference
    • Reset and enable
    • The sequential circuit
    • A first sequential circuit: counting presses
    • How fast can the clock go?
    • The family of flip-flops
    • Every type is a D flip-flop with gates in front
    • Which one is used in practice, and why
    • Then why does the JK exist?
    • And latches?
    • Recap
    • Practice problems
    • Answers
    • Now solve these
  7. Registers and counters 🔒 Free with an account
    • From one flip-flop to a register
    • The shift register
    • Why the arrow, and not the equals sign
    • Counters
    • Counting to something other than a power of 2
    • Counters made by shifting
    • Putting it all to work
    • A light that blinks once a second
    • The seconds of a digital clock
    • Sending a byte down one wire
    • What the three have in common
    • Recap
    • Practice problems
    • Answers
    • Now solve these
  8. Finite state machines 🔒 Free with an account
    • What a state is
    • A first example: the turnstile
    • A second example: the traffic light
    • From a diagram to a circuit
    • Three new pieces of Verilog
    • The turnstile, running
    • Moore and Mealy
    • The Mealy way
    • The Moore way
    • Machines that watch a stream of bits
    • Detecting a sequence: 1011
    • Your turn: three 1s in a row
    • Is the number so far divisible by 3?
    • Divisible by 3 or by 5
    • A checklist for writing a state machine
    • Recap
    • Practice problems
    • Answers
    • Now solve these
  9. A controller and its datapath 🔒 Free with an account
    • From watching to commanding
    • Slower than the clock: the tick
    • Numbers that can be changed: parameters
    • A controller at work: a pulse of chosen length
    • Writing a controller and its datapath in Verilog
    • Start and busy: a handshake
    • Where this leaves you
    • Recap
    • Practice problems
    • Answers
    • Now solve these
  10. Building a UART transmitter 🔒 Free with an account
    • What a UART is
    • Characters are bytes
    • The frame
    • How long is a bit?
    • Designing the transmitter
    • Step 1: the frame
    • Step 2: the bit timing
    • Checking it with a receiver
    • Your turn: read the message
    • Going further: a parity bit
    • From simulation to a real board
    • What you have learned
    • Recap
    • Practice problems
    • Answers
    • More to solve

← All courses