Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This VHDL code measures the distance with HCSR 0 4 . I want to add some values to the amount in specified distances and shows
This VHDL code measures the distance with HCSR I want to add some values to the amount in specified distances and shows it on seven segment display. The code that I sent always increases whether sensor dedect in specified distances or not but want to increase when sensor detect between and between
can you fix it according to this arrangements.
library IEEE;
use IEEE.STDLOGICALL;
use IEEE.stdlogicunsigned.all;
use ieee.NUMERICSTDall;
entity decimal is
Port
sw : in stdlogicvector downto ;
reset : in stdlogic;
clk : in stdlogic;
an : out stdlogicvector downto ;
led : out stdlogicvector downto
;
end decimal;
architecture Behavioral of decimal is
signal LEDBCD : integer;
signal refreshcounter : stdlogicvector downto ;
signal LEDactivatingcounter : stdlogicvector downto ;
signal w w w w : integer :;
signal number : integer :;
signal amount : integer :;
signal prevnumber : integer :; To store previous number for comparison
begin
process clk reset
begin
if reset then
refreshcounter others ;
number ;
amount ;
prevnumber ;
elsif risingedgeclk then
refreshcounter refreshcounter ;
number TOINTEGERunsignedsw;
Conditional increment logic
if number and number and not prevnumber and prevnumber then
amount amount ;
elsif number and number and not prevnumber and prevnumber then
amount amount ;
end if;
prevnumber number; Update previous number
end if;
end process;
w amount ;
wamount mod ;
wamount mod ;
wamount mod ;
processclk
begin
if risingedgeclk then
case refreshcounter downto is
when
an ;
LEDBCD w;
when
an ;
LEDBCD w;
when
an ;
LEDBCD w;
when
an ;
LEDBCD w;
when others
null; Do nothing
end case;
end if;
end process;
Sevensegment display decoder
processLEDBCD
begin
case LEDBCD is
when led ;
when led ;
when led ;
when led ;
when led ;
when led ;
when led ;
when led ;
when led ;
when led ;
when others led ; Default or error case
end case;
end process;
end Behavioral;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started