Question

In: Electrical Engineering

LIBRARY ieee; USE ieee.std_logic_1164.ALL; ENTITY Vendingvhdl IS PORT( Clk                            : IN  &

LIBRARY ieee;

USE ieee.std_logic_1164.ALL;

ENTITY Vendingvhdl IS

PORT(

Clk                            : IN        STD_LOGIC;

Change                    : OUT    STD_LOGIC_VECTOR(1 downto 0);

Inputs                      : IN        STD_LOGIC_VECTOR(1 downto 0);

output                     : OUT    STD_LOGIC);

END Vendingvhdl;

ARCHITECTURE vending of Vendingvhdl IS

                              TYPE STATE_TYPE IS (empty, fivecent, tencent, ready);

                              SIGNAL current_state, next_state   : STATE_TYPE;

BEGIN

Combinational LOGIC

COMBINE: PROCESS (inputs)

BEGIN

                              CASE current_state IS

                                             When empty =>

                                                            IF inputs = “00” THEN

                                                                                          next_state <= empty;

                                                                                          output <= ‘0’;

                                                                                          change <= “00”;

                                                            ELSEIF inputs = “01” THEN

next_state <= fivecent;

                                                                                          output <= ‘0’;

                                                                                          change <= “00”;

ELSEIF inputs = “10” THEN

next_state <= tencent;

                                                                                          output <= ‘0’;

                                                                                          change <= “00”;

ELSEIF inputs = “11” THEN

next_state <= ready;

                                                                                          output <= ‘1’;

                                                                                          change <= “10”;

                                                            ENDIF;

                                             WHEN fivecent =>

                                                            IF inputs = “00” THEN

next_state <= fivecent;

                                                                                          output <= ‘0’;

                                                                                          change <= “00”;

ELSEIF inputs = “01” THEN

next_state <= tencent;

                                                                                          output <= ‘0’;

                                                                                          change <= “00”;

ELSEIF inputs = “10” THEN

next_state <= ready;

                                                                                          output <= ‘0’;

                                                                                          change <= “00”;

ELSEIF inputs = “11” THEN

next_state <= ready;

                                                                                          output <= ‘1’;

                                                                                          change <= “01”;

                                                                                          change <= “10”;

                                                            ENDIF;

                                             WHEN tencent =>

                                                            IF inputs = “00” THEN

next_state <= tencent;

                                                                                          output <= ‘0’;

                                                                                          change <= “00”;

ELSEIF inputs = “01” THEN

next_state <= ready;

                                                                                          output <= ‘1’;

                                                                                          change <= “00”;

ELSEIF inputs = “10” THEN

next_state <= ready;

                                                                                          output <= ‘1’;

                                                                                          change <= “00”;

ELSEIF inputs = “11” THEN

next_state <= ready;

                                                                                          output <= ‘1’;

                                                                                          change <= “01”;

                                                                                          change <= “10”;

Please complete the following VHDL code...I am implementing a simple vending machine FSM

Solutions

Expert Solution

-- Here it is understood from code snipet that cost of good is 15 cent. Hence two more states added to return 10 or 20 ---cents based on inputs

LIBRARY ieee;

USE ieee.std_logic_1164.ALL;

ENTITY Vendingvhdl IS

PORT(

Clk : IN STD_LOGIC;

Change : OUT STD_LOGIC_VECTOR(1 downto 0);

Inputs : IN STD_LOGIC_VECTOR(1 downto 0);

output : OUT STD_LOGIC);

END Vendingvhdl;

ARCHITECTURE vending of Vendingvhdl IS

TYPE STATE_TYPE IS (empty, fivecent, tencent, return15, return20,ready);

SIGNAL current_state, next_state : STATE_TYPE;

BEGIN

process(clk)

begin

if rising_edge (Clk) then

current_state <= next_state;

end if;

end process;

COMBINE: PROCESS (current_state, inputs)

BEGIN

CASE current_state IS

When empty =>

IF inputs = "00" then

next_state <= empty;

output <= '0';

change <= "00";

ELSIF inputs = "01" THEN

next_state <= fivecent;

output <= '0';

change <= "00";

ELSIF inputs = "10" THEN

next_state <= tencent;

output <= '0';

change <= "00";

ELSIF inputs = "11" THEN

next_state <= ready;

output <= '1';

change <= "10";

END IF;

When fivecent =>

IF inputs = "00" then

next_state <= fivecent;

output <= '0';

change <= "00";

ELSIF inputs = "01" THEN

next_state <= tencent;

output <= '0';

change <= "00";

ELSIF inputs = "10" THEN

next_state <= ready;

output <= '1';

change <= "00";

ELSIF inputs = "11" THEN

next_state <= return15;

output <= '1';

change <= "01";

END IF;

When return15 =>

next_state <= ready;

change <= "10";

When tencent =>

IF inputs = "00" then

next_state <= tencent;

output <= '0';

change <= "00";

ELSIF inputs = "01" THEN

next_state <= ready;

output <= '1';

change <= "00";

ELSIF inputs = "10" THEN

next_state <= ready;

output <= '1';

change <= "01";

ELSIF inputs = "11" THEN

next_state <= return20;

output <= '1';

change <= "10";

END IF;

When return20 => next_state <= ready;

change <= "10";

When ready => next_state <= empty;

end case;

end process;

end vending;


Related Solutions

CAN SOMEONE RUN THIS WITH VHDL AND SEND ME THE OUTPUT? LIBRARY ieee; USE ieee.std_logic_1164.ALL; ENTITY...
CAN SOMEONE RUN THIS WITH VHDL AND SEND ME THE OUTPUT? LIBRARY ieee; USE ieee.std_logic_1164.ALL; ENTITY LFSR8 IS PORT (Clk, Rst: IN std_logic; output: OUT std_logic_vector (7 DOWNTO 0)); END LFSR8; ARCHITECTURE LFSR8_beh OF LFSR8 IS SIGNAL Currstate, Nextstate: std_logic_vector (7 DOWNTO 0); SIGNAL feedback: std_logic; BEGIN StateReg: PROCESS (Clk,Rst) BEGIN IF (Rst = '1') THEN Currstate <= (0 => '1', OTHERS =>'0'); ELSIF (Clk = '1' AND Clk'EVENT) THEN Currstate <= Nextstate; END IF; END PROCESS; feedback <= Currstate(4)...
Simulate this code in ISE Simulator (ISim) and screenshot the simulation library IEEE; use IEEE.STD_LOGIC_1164.ALL; use...
Simulate this code in ISE Simulator (ISim) and screenshot the simulation library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity multiplexer is Port (     din:in STD_LOGIC_VECTOR (7 downto 0);    sel:in STD_LOGIC_VECTOR (2 downto 0);    dout : out STD_LOGIC); end multiplexer; architecture Behavioral of multiplexer is begin     process (din,sel)     begin       case sel is            when "000"=> dout <= din(7);            when "001"=> dout <= din(6);            when "010"=> dout <= din(5);            when "011"=>...
Can someone run this in vhdl and send me the output? acreenshot library IEEE; use IEEE.STD_LOGIC_1164.ALL;...
Can someone run this in vhdl and send me the output? acreenshot library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity VHDL_MOORE_FSM_Sequence_Detector is port ( clock: in std_logic; --- clock signal reset: in std_logic; -- reset input sequence_in: in std_logic; -- binary sequence input detector_out: out std_logic -- output of the VHDL sequence detector ); end VHDL_MOORE_FSM_Sequence_Detector; architecture Behavioral of VHDL_MOORE_FSM_Sequence_Detector is type MOORE_FSM is (Zero, One, OneZero, OneZeroZero, OneZeroZeroOne); signal current_state, next_state: MOORE_FSM; begin -- Sequential memory of the VHDL MOORE FSM Sequence...
Queens Library, an independent not-for-profit entity received $30,000 in dividends and $24,000 in interest on its...
Queens Library, an independent not-for-profit entity received $30,000 in dividends and $24,000 in interest on its investment portfolio.  In addition, the entity also accrued $6,000 in interest on the portfolio.  The decrease in fair value of the portfolio during the year was $8,000. How much should the entity report as investment at the end of the year $8,000 $52,000 $54,000 $60,000
Convert 1.8125 to IEEE-754 representation. Show all your work.
Convert 1.8125 to IEEE-754 representation. Show all your work.
Convert 1.8125 to IEEE-754 representation. Show all your work.
Convert 1.8125 to IEEE-754 representation. Show all your work.
Question #4 DO NOT USE ANY NON-STANDARD LIBRARY. o All the required libraries have already been...
Question #4 DO NOT USE ANY NON-STANDARD LIBRARY. o All the required libraries have already been included. O DO NOT INCLUDE ANY OTHER LIBRARY INTO THE CODE. o DO NOT ALTER THE NAMES OF THE C FILES PROVIDED. o DO NOT ALTER THE NAMES AND PROTOTYPES OF THE FUNCTIONS. DO NOT ALTER THE CODE, ONLY ADD WHATS NEEDED TO MAKE IT WORK. This is the code: #include <stdio.h> /* * This function counts and returns the number of adjacent Up...
can i use port mapping inside a process in vhdl coding
can i use port mapping inside a process in vhdl coding
Compare the ACM, Software Developers, and IEEE codes of ethics. 1. What concerns do they all...
Compare the ACM, Software Developers, and IEEE codes of ethics. 1. What concerns do they all share? 2. Why do you think they share these concerns? 3. In what ways are the three codes not alike? 4. Why do you think they differ in these ways?
Compare the ACM, Software Developers, and IEEE codes of ethics. 1. What concerns do they all...
Compare the ACM, Software Developers, and IEEE codes of ethics. 1. What concerns do they all share? 2. Why do you think they share these concerns? 3. In what ways are the three codes not alike? 4. Why do you think they differ in these ways?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT