Intro:
In this design, you are going to use a chain of flip-flop to implement a shifter register.
Design requirement
When reset button is pressed, LED0 is on while LED1 to LED 7 are off. When 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 need are shown as follows. You are always welcome to come up with your own design.
- Simple Shift Register
- 2- Filp-Flop with Round Shifter
Sample Codes
Here are some sample codes that you can refer to:
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
- 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
Now that you've completed this project, try these modifications:
- Will you add two switches to control how fast the LED shfits: 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.
- Instead of shifting the light on LEDs, will you create some fancy LED pattern using LEDs and/or seven segment display?