VHDL 4 RTL Models
VHDL 4 RTL Models
--sync clear
--sync load
shift Q left
Lesser-used packages:
ieee.numeric_bit
same as above except SIGNED/UNSIGNED are arrays of type bit
ieee.std_logic_arith (from Synopsis)
Non-standard predecessor of numeric_std/numeric_bit
NUMERIC_STD package contents
Arithmetic functions: + - * / rem mod
Combinations of operand types for which operators are defined:
SIGNED + SIGNED return SIGNED
SIGNED + INTEGER return SIGNED
INTEGER + SIGNED return SIGNED
SIGNED + STD_LOGIC return SIGNED
PLUS: above combinations with UNSIGNED and NATURAL
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.NUMERIC_STD.all;
entity Adder4 is
port ( in1, in2 : in UNSIGNED(3 downto 0) ;
mySum : out UNSIGNED(3 downto 0) ) ;
end Adder4;
unsigned + natural
entity Adder_1 is
port ( A, B : in UNSIGNED(3 downto 0) ;
C : out UNSIGNED(4 downto 0) ) ; -- C(4) = carry bit
end Adder_1;
z <= a + b + c + d;
a
-- 3 adders stacked 3 deep +
b +
c + z
d
z <= (a + b) + (c + d);
-- 3 adders stacked 2 deep a
+
b
c + z
+
d
Copyright ©2008, Thomson Engineering, a division of Thomson Learning Ltd. 2-31
FFs generated from variables:
3-bit shift register example
-- External input/output din/dout
process (clk)
variable a,b: bit;
begin
if (clk’event and clk = ‘1’) then
dout <= b; dout b a din
b := a;
a := din;
end if;
end process;
-- Note: a,b used before being assigned new values
3-bit shift register example
Unexpected resulting structure
process (clk)
variable a,b: bit;
begin
if (clk’event and clk = ‘1’) then
a := din; -- update a value to din
b := a; -- update b with new a value (din)
dout <= b; -- update dout with new b value (din)
end if;
end process;