how to create a if else statement when the statement i as below...
if a>b.c
{P='0110';
D='0000'
eleseif c>b>a
P='0110';
D='1111"
eleseif b>c>a
P='0110';
D='0000'
else a=b=c
P='0000'
D='0000'
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity comparator is
port( a, b, c : in std_logic_vector( 6 downto 0); --
p, D : out std_logic_vector( 3 downto 0));
end comparator;
architecture processing of comparator is
begin
process (a, b, c)
begin
if (a=> b)
then p<='1';
else
p<='0';
end if;
end process;
end architecture processing;
i try to do but dunno what is the problem as i am still new to VHDL codings... please do help me as i need to do this assignment
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity comparator is
port( a, b, c : in std_logic_vector( 6 downto 0); --
p, D : out std_logic_vector( 3 downto 0));
end comparator;
architecture processing of comparator is
begin
process (a, b, c)
begin
if ([B]a <= b[/B]) then
p<=[B]"0001"[/B];
else
p<=[B]"0000"[/B];
end if;
end process;
end architecture processing;
Bigger than or equal is written >=
P is a 4 bit vector, you can't assign a bit value to it.
When you are working with vector and you want to write only one or more bits you can use:
for p in your example
p : out std_logic_vector( 3 downto 0);
p(3)<='1'; -- assign only bit 3 with value 1
p(0)<='0'; -- assign only bit 0 with value 0
p(3 down to 2)<= "01"; -- assign bits 3 and 2 with value 01 (partial assignment)
p(2 down to 0)<= "001"; -- assign bits 2,1 and 0 with value 001
Alex
---------- Post added at 17:26 ---------- Previous post was at 17:24 ----------
You can break it in 2 parts
if ((a>b) and (b>c)) then
set value here
set value here
else
do something
do something more
end if;