Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

fortune: not found


devel / comp.arch.fpga / Vending Machine

SubjectAuthor
* Vending MachineEsma
`- Re: Vending Machinegnuarm.del...@gmail.com

1
Vending Machine

<99fa8df9-aa05-4ecc-bcb9-47474e289025n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=426&group=comp.arch.fpga#426

  copy link   Newsgroups: comp.arch.fpga
X-Received: by 2002:a05:622a:1045:b0:3f6:a725:25ad with SMTP id f5-20020a05622a104500b003f6a72525admr2178223qte.5.1686852917333;
Thu, 15 Jun 2023 11:15:17 -0700 (PDT)
X-Received: by 2002:a25:6988:0:b0:bc5:8d31:fdd5 with SMTP id
e130-20020a256988000000b00bc58d31fdd5mr785917ybc.7.1686852916872; Thu, 15 Jun
2023 11:15:16 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch.fpga
Date: Thu, 15 Jun 2023 11:15:16 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=94.121.80.220; posting-account=UUAt0goAAAB9A981zXPS3x3XOni1SkYn
NNTP-Posting-Host: 94.121.80.220
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <99fa8df9-aa05-4ecc-bcb9-47474e289025n@googlegroups.com>
Subject: Vending Machine
From: esmakara...@gmail.com (Esma)
Injection-Date: Thu, 15 Jun 2023 18:15:17 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 6390
 by: Esma - Thu, 15 Jun 2023 18:15 UTC

my project designing a vending machine that sells a candy for 40 cent. it accept olny 5 cent(N) and 10 cent (D). and the candy i wrote this code for this but i couldn't write a testbench to see waveform Can you help me please
library ieee;
use ieee.std_logic_1164.all;

entity vending_machine is
port (
CLK, RESET: in std_logic;
N, D: in std_logic;
output: out std_logic;
change: out std_logic_vector(5 downto 0)
);
end vending_machine;

architecture process_3 of vending_machine is
type state_type is (s0, s1, s2, s3, s4, s5, s6, s7, s8, s9);
signal state, next_state: state_type;

begin
process (CLK, RESET)
begin
if (RESET = '1') then
state <= s0;
elsif (rising_edge(CLK)) then
state <= next_state;
end if;
end process;

process (state, N, D)
begin
case state is
when s0 =>
if N = '0' and D = '0' then
next_state <= s0;
output <= '0';
change <= "000000";
elsif N = '0' and D = '1' then
next_state <= s1;
output <= '0';
change <= "000000";
elsif N = '1' and D = '0' then
next_state <= s2;
output <= '0';
change <= "000000";
end if;

when s1 =>
if N = '0' and D = '0' then
next_state <= s0;
output <= '0';
change <= "000101";
elsif N = '0' and D = '1' then
next_state <= s2;
output <= '0';
change <= "000000";
elsif N = '1' and D = '0' then
next_state <= s3;
output <= '0';
change <= "000000";
end if;

when s2 =>
if N = '0' and D = '0' then
next_state <= s0;
output <= '0';
change <= "001010";
elsif N = '0' and D = '1' then
next_state <= s3;
output <= '0';
change <= "000000";
elsif N = '1' and D = '0' then
next_state <= s4;
output <= '0';
change <= "000000";
end if;

when s3 =>
if N = '0' and D = '0' then
next_state <= s0;
output <= '0';
change <= "001111";
elsif N = '0' and D = '1' then
next_state <= s4;
output <= '0';
change <= "000000";
elsif N = '1' and D = '0' then
next_state <= s5;
output <= '0';
change <= "000000";
end if;

when s4 =>
if N = '0' and D = '0' then
next_state <= s0;
output <= '0';
change <= "010100";
elsif N = '0' and D = '1' then
next_state <= s5;
output <= '0';
change <= "000000";
elsif N = '1' and D = '0' then
next_state <= s6;
output <= '0';
change <= "000000";
end if;

when s5 =>
if N = '0' and D = '0' then
next_state <= s0;
output <= '0';
change <= "011001";
elsif N = '0' and D = '1' then
next_state <= s6;
output <= '0';
change <= "000000";
elsif N = '1' and D = '0' then
next_state <= s7;
output <= '0';
change <= "000000";
end if;

when s6 =>
if N = '0' and D = '0' then
next_state <= s0;
output <= '0';
change <= "011110";
elsif N = '0' and D = '1' then
next_state <= s7;
output <= '0';
change <= "000000";
elsif N = '1' and D = '0' then
if RESET = '1' then
next_state <= s0;
output <= '1';
change <= "000000";
else
next_state <= s8;
output <= '1';
change <= "000000";
end if;
end if;

when s7 =>
if N = '0' and D = '0' then
next_state <= s0;
output <= '0';
change <= "100011";
elsif N = '0' and D = '1' then
if RESET = '1' then
next_state <= s0;
output <= '1';
change <= "000101";
else
next_state <= s9;
output <= '1';
change <= "000101";
end if;
elsif N = '1' and D = '0' then
if RESET = '1' then
next_state <= s0;
output <= '1';
change <= "000000";
else
next_state <= s9;
output <= '1';
change <= "000000";
end if;
end if;
when s8 =>
if N = '0' and D = '0' then
if RESET = '1' then
next_state <= s0;
output <= '1';
change <= "000000";
else
next_state <= s8;
output <= '1';
change <= "000000";
end if;
end if;

when s9 =>
if RESET = '1' then
next_state <= s0;
output <= '1';
change <= "000101";
else
next_state <= s9;
output <= '0';
change <= "000000";
end if;

when others =>
next_state <= s0;
output <= '0';
change <= "000000";
end case;
end process;

end architecture process_3;

Re: Vending Machine

<7fc11391-5334-48d0-89a0-6f7cc6b3ec5bn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=427&group=comp.arch.fpga#427

  copy link   Newsgroups: comp.arch.fpga
X-Received: by 2002:a05:6214:a49:b0:62f:fa6f:209b with SMTP id ee9-20020a0562140a4900b0062ffa6f209bmr162308qvb.3.1686892004053;
Thu, 15 Jun 2023 22:06:44 -0700 (PDT)
X-Received: by 2002:a05:6902:140f:b0:bb1:569c:f381 with SMTP id
z15-20020a056902140f00b00bb1569cf381mr387656ybu.1.1686892003646; Thu, 15 Jun
2023 22:06:43 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch.fpga
Date: Thu, 15 Jun 2023 22:06:43 -0700 (PDT)
In-Reply-To: <99fa8df9-aa05-4ecc-bcb9-47474e289025n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=63.114.57.174; posting-account=I-_H_woAAAA9zzro6crtEpUAyIvzd19b
NNTP-Posting-Host: 63.114.57.174
References: <99fa8df9-aa05-4ecc-bcb9-47474e289025n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7fc11391-5334-48d0-89a0-6f7cc6b3ec5bn@googlegroups.com>
Subject: Re: Vending Machine
From: gnuarm.d...@gmail.com (gnuarm.del...@gmail.com)
Injection-Date: Fri, 16 Jun 2023 05:06:44 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 7429
 by: gnuarm.del...@gmail. - Fri, 16 Jun 2023 05:06 UTC

On Thursday, June 15, 2023 at 2:15:19 PM UTC-4, Esma wrote:
> my project designing a vending machine that sells a candy for 40 cent. it accept olny 5 cent(N) and 10 cent (D). and the candy i wrote this code for this but i couldn't write a testbench to see waveform Can you help me please
> library ieee;
> use ieee.std_logic_1164.all;
>
> entity vending_machine is
> port (
> CLK, RESET: in std_logic;
> N, D: in std_logic;
> output: out std_logic;
> change: out std_logic_vector(5 downto 0)
> );
> end vending_machine;
>
> architecture process_3 of vending_machine is
> type state_type is (s0, s1, s2, s3, s4, s5, s6, s7, s8, s9);
> signal state, next_state: state_type;
>
> begin
> process (CLK, RESET)
> begin
> if (RESET = '1') then
> state <= s0;
> elsif (rising_edge(CLK)) then
> state <= next_state;
> end if;
> end process;
>
> process (state, N, D)
> begin
> case state is
> when s0 =>
> if N = '0' and D = '0' then
> next_state <= s0;
> output <= '0';
> change <= "000000";
> elsif N = '0' and D = '1' then
> next_state <= s1;
> output <= '0';
> change <= "000000";
> elsif N = '1' and D = '0' then
> next_state <= s2;
> output <= '0';
> change <= "000000";
> end if;
>
> when s1 =>
> if N = '0' and D = '0' then
> next_state <= s0;
> output <= '0';
> change <= "000101";
> elsif N = '0' and D = '1' then
> next_state <= s2;
> output <= '0';
> change <= "000000";
> elsif N = '1' and D = '0' then
> next_state <= s3;
> output <= '0';
> change <= "000000";
> end if;
>
> when s2 =>
> if N = '0' and D = '0' then
> next_state <= s0;
> output <= '0';
> change <= "001010";
> elsif N = '0' and D = '1' then
> next_state <= s3;
> output <= '0';
> change <= "000000";
> elsif N = '1' and D = '0' then
> next_state <= s4;
> output <= '0';
> change <= "000000";
> end if;
>
> when s3 =>
> if N = '0' and D = '0' then
> next_state <= s0;
> output <= '0';
> change <= "001111";
> elsif N = '0' and D = '1' then
> next_state <= s4;
> output <= '0';
> change <= "000000";
> elsif N = '1' and D = '0' then
> next_state <= s5;
> output <= '0';
> change <= "000000";
> end if;
>
> when s4 =>
> if N = '0' and D = '0' then
> next_state <= s0;
> output <= '0';
> change <= "010100";
> elsif N = '0' and D = '1' then
> next_state <= s5;
> output <= '0';
> change <= "000000";
> elsif N = '1' and D = '0' then
> next_state <= s6;
> output <= '0';
> change <= "000000";
> end if;
>
> when s5 =>
> if N = '0' and D = '0' then
> next_state <= s0;
> output <= '0';
> change <= "011001";
> elsif N = '0' and D = '1' then
> next_state <= s6;
> output <= '0';
> change <= "000000";
> elsif N = '1' and D = '0' then
> next_state <= s7;
> output <= '0';
> change <= "000000";
> end if;
>
> when s6 =>
> if N = '0' and D = '0' then
> next_state <= s0;
> output <= '0';
> change <= "011110";
> elsif N = '0' and D = '1' then
> next_state <= s7;
> output <= '0';
> change <= "000000";
> elsif N = '1' and D = '0' then
> if RESET = '1' then
> next_state <= s0;
> output <= '1';
> change <= "000000";
> else
> next_state <= s8;
> output <= '1';
> change <= "000000";
> end if;
> end if;
>
> when s7 =>
> if N = '0' and D = '0' then
> next_state <= s0;
> output <= '0';
> change <= "100011";
> elsif N = '0' and D = '1' then
> if RESET = '1' then
> next_state <= s0;
> output <= '1';
> change <= "000101";
> else
> next_state <= s9;
> output <= '1';
> change <= "000101";
> end if;
> elsif N = '1' and D = '0' then
> if RESET = '1' then
> next_state <= s0;
> output <= '1';
> change <= "000000";
> else
> next_state <= s9;
> output <= '1';
> change <= "000000";
> end if;
> end if;
> when s8 =>
> if N = '0' and D = '0' then
> if RESET = '1' then
> next_state <= s0;
> output <= '1';
> change <= "000000";
> else
> next_state <= s8;
> output <= '1';
> change <= "000000";
> end if;
> end if;
>
> when s9 =>
> if RESET = '1' then
> next_state <= s0;
> output <= '1';
> change <= "000101";
> else
> next_state <= s9;
> output <= '0';
> change <= "000000";
> end if;
>
> when others =>
> next_state <= s0;
> output <= '0';
> change <= "000000";
> end case;
> end process;
>
> end architecture process_3;

The bit that is important in the test bench is this:

entity vending_machine is
port (
CLK, RESET: in std_logic;
N, D: in std_logic;
output: out std_logic;
change: out std_logic_vector(5 downto 0)
);
end vending_machine;

You need to treat your design as a component in the test bench. Write code to drive the clock, the N and the D inputs as you choose. You can examine the outputs manually in the simulator, or, if you wish to analyze the design carefully, you can write code to verify the outputs automatically. The statement to assist with this is:

assert(exp);

Where exp is an expression that should evaluate to TRUE. If not, the assert statement will print to the simulation output. You can combine assert with report to give a specific text output indicating exactly what is wrong, including the value of the thing being tested.

--

Rick C.

- Get 1,000 miles of free Supercharging
- Tesla referral code - https://ts.la/richard11209


devel / comp.arch.fpga / Vending Machine

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor