Question

Write the following program to be executed on the FPGA board. 1. Write a VHDL model for a code detector as shown in the Figur
1 0
Add a comment Improve this question Transcribed image text
Answer #1

CODE DETECTOR

START So DOOR START +b S5 SI DOOR DOOR htb b tb S4 DOOR S2 DOOR h S3 DOOR MOORE STATE MACHINE--VHDL CODE

library ieee;
use ieee.std_logic_1164.all;

entity code_detector is
   port (   clock   : in std_logic;
       reset   : in std_logic;
       r   : in std_logic;
       g   : in std_logic;
       b   : in std_logic;
       door_lock   : out std_logic
   );
end code_detector;

architecture arch of code_detector is

type state is (S0, S1, S2, S3, S4, S5);

signal current_state, next_state : state;

begin

process (clock)

begin

   if rising_edge (clock) then

       current_state <= next_state;

   end if;

end process;

process (current_state, reset, r, g, b)

begin

   case (current_state) is

       when S0=>    if (reset = '1') then
                   next_state <= S1;
               elsif (r = '1' or g = '1' or b = '1') then
                   next_state <= S0;
               end if;
               door_lock <= '0';

       when S1=>    if (r = '1') then
                   next_state <= S2;
               elsif (reset = '1' or g = '1' or b = '1') then
                   next_state <= S0;
               end if;
               door_lock <= '0';

       when S2=>    if (g = '1') then
                   next_state <= S3;
               elsif (reset = '1' or r = '1' or b = '1') then
                   next_state <= S0;
               end if;
               door_lock <= '0';

       when S3=>    if (r = '1') then
                   next_state <= S4;
               elsif (reset = '1' or g = '1' or b = '1') then
                   next_state <= S0;
               end if;
               door_lock <= '0';

       when S4=>    if (b = '1') then
                   next_state <= S5;
               elsif (reset = '1' or r = '1' or g = '1') then
                   next_state <= S0;
               end if;
               door_lock <= '0';

       when S5=>    next_state <= S0;
               door_lock <= '1';

       when others=>     next_state <= S0;

   end case;

end process;

end arch;

-------------------------------------------------------------------------------------------------------------------------------------------------------------

--Simulation on ModelSim

M ModelSim- INTEL FPGA STARIER EDITION 10.5b File Edit View Compile Simulste Add Wave Tools Layout Bookmarks Window Help d M-------------------------------------------------------------------------------------------------------------------------------------------------------------

BLINKING CONTROLLER

STATE DIAGRAM & STATE TABLE is shown below:

LO SISO LI L3 OSTS OSTS L2 SI SOHere LO, L1, L2 and L3 represents four states and S1, S0 are the outputs of the Moore State Machine

We will implement FSM using D Flip Flop and derive expressions for states and outputs using Karnaugh Maps as shown below

QIt=2IQ0+Q1Q0 RO+ QI+= Q1QO P/PO \QO 1 1 S1= QOCONTROLLER CIRCUIT

x1) Q1 Deno x1 Q0 DenO CLOCK x1 S1 S0 X1

Add a comment
Know the answer?
Add Answer to:
Write the following program to be executed on the FPGA board. 1. Write a VHDL model...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need the VHDL code for this pls. Figure 1 Design a soda machine controller that...

    I need the VHDL code for this pls. Figure 1 Design a soda machine controller that can dispense two kinds of soda. If S1 Sel is selected, soda1 2. is dispensed, if S2Sel is selected then soda2 is dispensed. Each soda costs 75 cents and your machine accepts quarters only. The coin sensor has three outputs to detect first coin, second coin and the third coin. Once the soda is dispensed, the controller must be reset to be able to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT