BitFlow

Shift register

Pins run out fast. A 74HC595 shift register turns three pins into eight outputs: put a bit on sr_data and pulse sr_clk to shift it in, eight times, then pulse sr_latch to show all eight at once. The first bit you send ends up on the far end, Q7.

Show an 8-bit counter on the register's LEDs, going up by one every quarter second.

lab.v
drag to turn · scroll to zoom

Loading the board…

Press Run on the board: your Verilog is turned into gates in this browser and runs here, cycle by cycle.

Goals

  • ○The register's LEDs show a number that counts up by one
  • ○Four steps a second
Hints
  1. Send the most significant bit first, so it travels all the way to Q7.
  2. A small state machine: for each of 8 bits, set sr_data, raise sr_clk, lower it; then raise and lower sr_latch.

Pin log

Run the design to see its outputs change.

Put it on a real board

  • The Sipeed Tang Nano 9K (Gowin GW1NR-9) has no a shift register: those ports go to header pins, where you can wire them.
  • The clock is set to the board's 27 MHz, and its active-low buttons and LEDs are flipped for you.
Waveform