# Design Challenge:

## Introduction

In this design, you are going to use a chain of flip-flops to implement a shifter register. The shifter register will be clocked using the clock divider you built in previous projects.

##### Before you begin, you should:
• Have the Xilinx® ISE WebPACK™ installed.
• Have your FPGA board set up.
• Understand the functionality of D Flip-Flops and how to implement a D Flip-Flop in Verilog HDL.
##### After you're done, you should:
• Be able to describe flip-flops using always blocks in Verilog.

## Inventory:

Qty Description
1 Digilent® Nexys™4, Nexys™3, Nexys™2, or Basys™2 FPGA Board
1 Xilinx ISE Design Suite: WebPACK (14.6 Recommended)

## Design Requirement

When the reset button is pressed, LED0 is on while LED1 to LED7 are off. When the reset button is released, the light keeps shifting from LED0 all the way to LED7 and back to LED0 at a frequency of 0.74Hz.

## Hints

There are different ways to design the system. Two block diagrams of the system that fulfills the requirements are shown in Figs. 1 and 2 below. You are always welcome to come up with your own design.

1. Simple Shift Register
2. Filp-Flop with Round Shifter

## Sample Codes

Here are some sample codes that you can refer to:

1. Flip-flop with Asynchronous Reset:
						always @ (posedge(clk), posedge(rst))
begin
if (rst == 1)
Q <= 1'b0;	// Q is reset to 0
else
Q <= D;
end

2. Flip-flop with Combinational Logic:
						always @ (posedge(clk), posedge(rst))
begin
if (rst == 1)
Q <= 1'b0;	// Q is reset to 0
else
Q <= (A & B);
end


## Test Your Knowledge!

Now that you've completed this challenge, try these modifications:

1. Can you add two switches to control how fast the LED shifts? Say, if switch[1:0] is 0, LED shift frequency is 0.745Hz; if switch[1:0] is 1, LED shift frequency is 1.49Hz; if switch[1:0] is 2, LED shift frequency is 2.98Hz; if switch[1:0] is 3, LED shift frequency is 5.96Hz.
2. Instead of shifting the light on LEDs, can you create some fancy LED pattern using LEDs and/or a seven-segment display?

• Other product and company names mentioned herein are trademarks or trade names of their respective companies. © 2014 Digilent Inc. All rights reserved.