Examples of programs here is same with the previous example, just added the option of delay using combination of switchs. Consists of two switches that are used to select the delays. The combination switch will determine a constant delay that is stored in the ROM table as a reference delay at this time.
The line by line explanations of vhdl codes as follow:
- Lines 1-4 is the definition of libraries used.
- Lines 6-12 is the definition of I/O channels used. STOP is input channel for stopping leds flashing or all leds will turned off. DLY_OPT is used to select the time of delay that held in ROM tables called as romdelay. Q_LED is array channel outputs for driving 8 leds. CLK50MHZ as oscillator clock.
- Line 16 is the definition of type_romdelay as integer in range 0 to 100000000 or 0 to 2 second.
- Line 18 is the definition of dly and dly_buff variable as integer in range 0 to 100000000. dly for delay counter and dly_buff as comparing delay assign from romdelay table based on DLY_OPT.
- Lines 21-27 is the table of delay selections. 100000000 is 2 second, 50000000 is 1 second, 25000000 is 0.5 second, 12500000 is 0.25 second.
- Lines 31-50 is the block of process.
- Lines 34-39, increment dly as delay counter, if same with dly_buff will read new delay from table, dly reset to zero, make toggle flag_blink.
- Lines 41-49, turned on leds if STOP=0 and flag_blink=1, if not it leds will turned off.
Last updated byat .