Question

In: Electrical Engineering

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

Solutions

Expert Solution

VERILOG CODE TO BLINK LED's ON FPGA:

module tutorial_led_blink(i_clock,i_enable,i_switch_1,i_switch_2,o_led_drive );

  input i_clock;

  input i_enable;

  input i_switch_1;

  input i_switch_2;

  output o_led_drive;     // Constants (parameters) to create the frequencies needed:

  // Input clock is 25 kHz, chosen arbitrarily.

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

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

  parameter c_CNT_100HZ = 125;

  parameter c_CNT_50HZ = 250;

  parameter c_CNT_10HZ = 1250;

  parameter c_CNT_1HZ   = 12500;

  // These signals will be the counters:

  reg [31:0] r_CNT_100HZ = 0;

  reg [31:0] r_CNT_50HZ = 0;

  reg [31:0] r_CNT_10HZ = 0;

  reg [31:0] r_CNT_1HZ = 0;

   

  // These signals will toggle at the frequencies needed:

  reg        r_TOGGLE_100HZ = 1'b0;

  reg        r_TOGGLE_50HZ = 1'b0;

  reg        r_TOGGLE_10HZ = 1'b0;

  reg        r_TOGGLE_1HZ   = 1'b0;

   

  // One bit select

  reg        r_LED_SELECT;

  wire       w_LED_SELECT;

begin

  // All always blocks toggle a specific signal at a different frequency.

  // They all run continuously even if the switches are

  // not selecting their particular output.

  always @ (posedge i_clock)

    begin

      if (r_CNT_100HZ == c_CNT_100HZ-1) // -1, since counter starts at 0

        begin        

          r_TOGGLE_100HZ <= !r_TOGGLE_100HZ;

          r_CNT_100HZ    <= 0;

        end

      else

        r_CNT_100HZ <= r_CNT_100HZ + 1;

    end

  always @ (posedge i_clock)

    begin

      if (r_CNT_50HZ == c_CNT_50HZ-1) // -1, since counter starts at 0

        begin        

          r_TOGGLE_50HZ <= !r_TOGGLE_50HZ;

          r_CNT_50HZ    <= 0;

        end

      else

        r_CNT_50HZ <= r_CNT_50HZ + 1;

    end

  always @ (posedge i_clock)

    begin

      if (r_CNT_10HZ == c_CNT_10HZ-1) // -1, since counter starts at 0

        begin        

          r_TOGGLE_10HZ <= !r_TOGGLE_10HZ;

          r_CNT_10HZ    <= 0;

        end

      else

        r_CNT_10HZ <= r_CNT_10HZ + 1;

    end

  always @ (posedge i_clock)

    begin

      if (r_CNT_1HZ == c_CNT_1HZ-1) // -1, since counter starts at 0

        begin        

          r_TOGGLE_1HZ <= !r_TOGGLE_1HZ;

          r_CNT_1HZ    <= 0;

        end

      else

        r_CNT_1HZ <= r_CNT_1HZ + 1;

    end

  // Create a multiplexer based on switch inputs

  always @ (*)

  begin

    case ({i_switch_1, i_switch_2}) // Concatenation Operator { }

      2'b11 : r_LED_SELECT <= r_TOGGLE_1HZ;

      2'b10 : r_LED_SELECT <= r_TOGGLE_10HZ;

      2'b01 : r_LED_SELECT <= r_TOGGLE_50HZ;

      2'b00 : r_LED_SELECT <= r_TOGGLE_100HZ;

    endcase     

  end

  assign o_led_drive = r_LED_SELECT & i_enable;

  // Alternative way to design multiplexer (same as above):

  // More compact, but harder to read, especially to those new to Verilog

  // assign w_LED_SELECT = i_switch_1 ? (i_switch_2 ? r_TOGGLE_1HZ : r_TOGGLE_10HZ) :

                                        (i_switch_2 ? r_TOGGLE_50HZ : r_TOGGLE_100HZ);

  // assign o_led_drive = w_LED_SELECT & i_enable;

end

endmodule

Here we have to take 5 different frequencies and 5 different switches and have to give some specified delay for every 5 LED's.


Related Solutions

Write a verilog code for digital clock and display it’s seven segment using fpga?
Write a verilog code for digital clock and display it’s seven segment using fpga?
I need to develop a VHDL code for a FPGA basys 3, 4 digit 7 segment...
I need to develop a VHDL code for a FPGA basys 3, 4 digit 7 segment display. So when binary 0, 1 ,and 2 are inputted the display says bad. When binary 3,4,5,6, the display says good.
I need to develop a VHDL code for a FPGA basys 3, 4 digit 7 segment...
I need to develop a VHDL code for a FPGA basys 3, 4 digit 7 segment display. So when binary 0, 1 ,and 2 are inputted the display says bad. When binary 3,4,5,6, the display says good.
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.
Verilog code for Traffic light controller. Need a block diagram, Verilog codes used with testbench, and...
Verilog code for Traffic light controller. Need a block diagram, Verilog codes used with testbench, and the waveforms screen-prints.
I need a synthesizable Verilog code/module implementing the IEEE 754 Floating Point multiplication and a corresponding...
I need a synthesizable Verilog code/module implementing the IEEE 754 Floating Point multiplication and a corresponding test bench. It should set a flag for underflow and overflow conditions if they arise during the multiplication for the output. It would be greatly appreciated if someone could write this floating point multiplication code in Verilog with some comment lines so i could understand the functioning too with a test bench module ! I have tried to explain everything as clearly as possible...
Here is my java code. It works and has the correct output, but I need to...
Here is my java code. It works and has the correct output, but I need to add a file and I am not sure how. I cannot use the FileNotFoundException. Please help! import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class Exercise { public static void main(String[] args) { Scanner input=new Scanner(System.in); int[] WordsCharsLetters = {0,0,0}; while(input.hasNext()) { String sentence=input.nextLine(); if(sentence!=null&&sentence.length()>0){ WordsCharsLetters[0] += calculateAndPrintChars(sentence)[0]; WordsCharsLetters[1] += calculateAndPrintChars(sentence)[1]; WordsCharsLetters[2] += calculateAndPrintChars(sentence)[2]; } else break; } input.close(); System.out.println("Words: " + WordsCharsLetters[0]); System.out.println("Characters: "...
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.
I need the output of the code like this in java First we create a new...
I need the output of the code like this in java First we create a new building and display the result: This building has no apartments. Press enter to continue......................... Now we add some apartments to the building and display the result: This building has the following apartments: Unit 1 3 Bedroom Rent $450 per month Currently unavailable Unit 2 2 Bedroom Rent $400 per month Currently available Unit 3 4 Bedroom Rent $1000 per month Currently unavailable Unit 4...
How do I implement Image Processing using VHDL for FPGA? Please provide VHDL code
How do I implement Image Processing using VHDL for FPGA? Please provide VHDL code
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT