A
aleksa
My VHD files now begin with
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
and I have some questions...
Example1:
I'm copying CURRENT to ADDR, but limiting to 999:
-- 2^10 = 1024
signal CURRENT, ADDR : unsigned(9 downto 0);
if CURRENT < 1000 then
ADDR <= CURRENT;
else
ADDR <= to_unsigned(999, ADDR'length);
end if;
At first I had "ADDR <= 999" but had to change it.
Is "to_unsigned" the correct way?
Next, if I have to use "to_unsigned", is it safe to use
"if CURRENT < 1000" or should I use
"if CURRENT < to_unsigned(1000, CURRENT'length)" ?
Example2:
I have a data bus defined like this:
signal DOUT : std_logic_vector(17 downto 0);
and DOUT is aliased into 3 unsigned indexes:
alias INDEX1 : unsigned(3 downto 0) is DOUT ( 3 downto 0);
alias INDEX2 : unsigned(8 downto 0) is DOUT (12 downto 4);
alias INDEX3 : unsigned(4 downto 0) is DOUT (17 downto 13);
I get the error that the types are incompatible.
Should I not use alias here, but create another signal?
signal INDEX1 : unsigned(3 downto 0);
INDEX1 <= DOUT(3 downto 0);
INDEX1 <= to_unsigned(DOUT(3 downto 0));
none of the above works.. how do I write it?
Example3:
signal DOUT : std_logic;
signal COUNTER : unsigned(15 downto 0);
signal INDEX : unsigned( 3 downto 0);
DOUT <= COUNTER(to_integer(INDEX));
Is that the correct way of extracting one bit?
I'll probably ask more questions after I grasp these
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
and I have some questions...
Example1:
I'm copying CURRENT to ADDR, but limiting to 999:
-- 2^10 = 1024
signal CURRENT, ADDR : unsigned(9 downto 0);
if CURRENT < 1000 then
ADDR <= CURRENT;
else
ADDR <= to_unsigned(999, ADDR'length);
end if;
At first I had "ADDR <= 999" but had to change it.
Is "to_unsigned" the correct way?
Next, if I have to use "to_unsigned", is it safe to use
"if CURRENT < 1000" or should I use
"if CURRENT < to_unsigned(1000, CURRENT'length)" ?
Example2:
I have a data bus defined like this:
signal DOUT : std_logic_vector(17 downto 0);
and DOUT is aliased into 3 unsigned indexes:
alias INDEX1 : unsigned(3 downto 0) is DOUT ( 3 downto 0);
alias INDEX2 : unsigned(8 downto 0) is DOUT (12 downto 4);
alias INDEX3 : unsigned(4 downto 0) is DOUT (17 downto 13);
I get the error that the types are incompatible.
Should I not use alias here, but create another signal?
signal INDEX1 : unsigned(3 downto 0);
INDEX1 <= DOUT(3 downto 0);
INDEX1 <= to_unsigned(DOUT(3 downto 0));
none of the above works.. how do I write it?
Example3:
signal DOUT : std_logic;
signal COUNTER : unsigned(15 downto 0);
signal INDEX : unsigned( 3 downto 0);
DOUT <= COUNTER(to_integer(INDEX));
Is that the correct way of extracting one bit?
I'll probably ask more questions after I grasp these