Question

In: Electrical Engineering

Implement four blinking LEDs on your DE2 board. Your code should blink four LEDs at 100...

Implement four blinking LEDs on your DE2 board. Your code should blink four LEDs at 100 Hz, 10 Hz, 2 Hz and 1 Hz respectively. For each of the blink frequencies, the LED should be set to a 50% duty cycle (ON for half of the time). This design should be made in Quartus as a behavioral VHDL design.

Solutions

Expert Solution

VHDL Code is given below

library ieee;

use ieee.std_logic_1164.all;

use ieee.numeric_std.all;

entity tutorial_led_blink is

  port (

    i_clock      : in std_logic;

    i_enable     : in std_logic;

    i_switch_1   : in std_logic;

    i_switch_2   : in std_logic;

    o_led_drive : out std_logic

    );

end tutorial_led_blink;

architecture rtl of tutorial_led_blink is

  -- Constants to create the frequencies needed:

  -- Formula is: (25 MHz / 100 Hz * 50% duty cycle)

  -- So for 100 Hz: 25,000,000 / 100 * 0.5 = 125,000

  constant c_CNT_100HZ : natural := 125000;

  constant c_CNT_2HZ : natural := 6250000;

  constant c_CNT_10HZ : natural := 1250000;

  constant c_CNT_1HZ   : natural := 12500000;

  -- These signals will be the counters:

  signal r_CNT_100HZ : natural range 0 to c_CNT_100HZ;

  signal r_CNT_2HZ : natural range 0 to c_CNT_2HZ;

  signal r_CNT_10HZ : natural range 0 to c_CNT_10HZ;

  signal r_CNT_1HZ   : natural range 0 to c_CNT_1HZ;

   

  -- These signals will toggle at the frequencies needed:

  signal r_TOGGLE_100HZ : std_logic := '0';

  signal r_TOGGLE_2HZ : std_logic := '0';

  signal r_TOGGLE_10HZ : std_logic := '0';

  signal r_TOGGLE_1HZ   : std_logic := '0';

  -- One bit select wire.

  signal w_LED_SELECT : std_logic;

   

begin

  -- All processes toggle a specific signal at a different frequency.

  -- They all run continuously even if the switches are

  -- not selecting their particular output.

   

  p_100_HZ : process (i_clock) is

  begin

    if rising_edge(i_clock) then

      if r_CNT_100HZ = c_CNT_100HZ-1 then -- -1, since counter starts at 0

        r_TOGGLE_100HZ <= not r_TOGGLE_100HZ;

        r_CNT_100HZ    <= 0;

      else

        r_CNT_100HZ <= r_CNT_100HZ + 1;

      end if;

    end if;

  end process p_100_HZ;

  p_2_HZ : process (i_clock) is

  begin

    if rising_edge(i_clock) then

      if r_CNT_2HZ = c_CNT_2HZ-1 then -- -1, since counter starts at 0

        r_TOGGLE_2HZ <= not r_TOGGLE_2HZ;

        r_CNT_2HZ    <= 0;

      else

        r_CNT_2HZ <= r_CNT_2HZ + 1;

      end if;

    end if;

  end process p_2_HZ;

   

  p_10_HZ : process (i_clock) is

  begin

    if rising_edge(i_clock) then

      if r_CNT_10HZ = c_CNT_10HZ-1 then -- -1, since counter starts at 0

        r_TOGGLE_10HZ <= not r_TOGGLE_10HZ;

        r_CNT_10HZ    <= 0;

      else

        r_CNT_10HZ <= r_CNT_10HZ + 1;

      end if;

    end if;

  end process p_10_HZ;

   

  p_1_HZ : process (i_clock) is

  begin

    if rising_edge(i_clock) then

      if r_CNT_1HZ = c_CNT_1HZ-1 then -- -1, since counter starts at 0

        r_TOGGLE_1HZ <= not r_TOGGLE_1HZ;

        r_CNT_1HZ    <= 0;

      else

        r_CNT_1HZ <= r_CNT_1HZ + 1;

      end if;

    end if;

  end process p_1_HZ;

   

  -- Create a multiplexor based on switch inputs

  w_LED_SELECT <= r_TOGGLE_100HZ when (i_switch_1 = '0' and i_switch_2 = '0') else

                  r_TOGGLE_2HZ when (i_switch_1 = '0' and i_switch_2 = '1') else

                  r_TOGGLE_10HZ when (i_switch_1 = '1' and i_switch_2 = '0') else

                  r_TOGGLE_1HZ;

   

  -- Only allow o_led_drive to drive when i_enable is high (and gate).

  o_led_drive <= w_LED_SELECT and i_enable;

end rtl;

Hope You Get It:)

Thank You:):)

Please Give a Thumps up:):)


Related Solutions

Write a C program to blink two LEDs connected to Raspberry pi. One must blink at...
Write a C program to blink two LEDs connected to Raspberry pi. One must blink at a rate of 1 Hz and the other at a rate of 2 HZ.
Arduino Project - Part 1 • Connect 3 LEDs on 3 digital pins • Blink LEDs...
Arduino Project - Part 1 • Connect 3 LEDs on 3 digital pins • Blink LEDs at: – 1 at 1 Hz – 2 at 4 Hz – 3 at 5 Hz • Blink LEDs at: – 1 Hz – 3 Hz – 5 Hz 36 What to submit • 2 Arduino files – one for 1,4,5 Hz blinking – one for 1,3,5 Hz blinking
I need a Verilog code that makes the LEDs on the FPGA board works like this....
I need a Verilog code that makes the LEDs on the FPGA board works like this. https://image.ibb.co/mu5tnS/6.gif There are 16 LEDs in the FPGA board
Using Arduino to blink an LED in morse code. Morse code is used as one of...
Using Arduino to blink an LED in morse code. Morse code is used as one of the methods for communications. It consists of a series of “dit” and “dah” symbols. (i) Develop an Arduino program to produce a Morse code to express the phrase “We are students” using Pin #13 (connect an LED that is in series with a 220-Ω resistor to Pins #13 to view the information sent via the Morse code). Express one “dit” with LED on for...
Assemby language - MIPS Your assembly should implement the C code directly – i.e.,do not ’optimize’...
Assemby language - MIPS Your assembly should implement the C code directly – i.e.,do not ’optimize’ the C code to change the order of operations or reduce computations. Write MIPS assembly code implementing the following C/C++ statement: y = 13 - 11*x; One way of doing the multiply without a multiply instruction is by using many add instructions (x+x+...+x). For this problem you should do it with fewer additions. Hint: We know how to express any integer as a sum...
Build a circuit for arcade game. You have 3 LEDS and 1 button. the LEDs should...
Build a circuit for arcade game. You have 3 LEDS and 1 button. the LEDs should recycle through 000,100,110,111,011, 001(back to 000). The user needs to hit the button during the 111 cycle 3 times in a row to win. The win is shown as an LED which is HIGH if the user won the last attempt of 3 presses. The win LED will be LOW otherwise
1. IN C LANGUAGE: Write a code that makes the MSP430 blink the red LED and...
1. IN C LANGUAGE: Write a code that makes the MSP430 blink the red LED and the green LED at the same time. The two LEDs should be on at the same time and then off at the same time
1. Write a code that makes the MSP430 blink the red LED and the green LED...
1. Write a code that makes the MSP430 blink the red LED and the green LED at the same time. The two LEDs should be on at the same time and then off at the same time
Design a combinational circuit that implements a Binary-to-Grey Code converter. Your input should be a four-bit...
Design a combinational circuit that implements a Binary-to-Grey Code converter. Your input should be a four-bit binary number, and your output should be the equivalent four-bit Grey Code value. First, design the circuit using NAND gates only. Next, design the circuit using a minimal number of 2-input XOR gates.
FOR ARDUINO PROGRAMMING NEED TO HAVE ALL LEDS FLASH 5 TIMES WHEN THE BOARD STARTS.
FOR ARDUINO PROGRAMMING NEED TO HAVE ALL LEDS FLASH 5 TIMES WHEN THE BOARD STARTS.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT