the use
of VHDL generic
and component instantiation -> generic decoders
with n-bit input and
m-bit output defined at instantiation phase (structural
model)
the use
of generic functions and data flow architecture -> generic decoders
with n-bit input and
m-bit output defined with the generic function call (data_flow
model)
library IEEE;
use
IEEE.std_logic_1164.all;
entity dec_gen is
port (e: in std_logic; a: in unsigned (size_in-1 downto 0);
|
architecture
process_dec_gen of
dec_gen is
begin process(a) begin
else
x(i) <='1'; else x(i) <='0'; end if; end process_dec_gen; |
and its
instantiations in a structural architecture of a higher level entity:
library IEEE;
use
IEEE.std_logic_1164.all;
entity str_dec_gen is
in_b: in unsigned (7 downto 0); out_a: out unsigned(31 downto 0); out_b: out unsigned(255 downto 0)); |
architecture
structural of
str_dec_gen is
component dec_gen is
port (e: in std_logic; a: in unsigned (size_in-1 downto 0);
begin decoder_5to32:dec_gen -- decoder_5to32 instantiation
port map(e_a, in_a, out_a);
port map(e_b, in_b, out_b); |
a package
with a decoder function:
library IEEE;
use
IEEE.std_logic_1164.all;
package dec_gen_pack
is
package body dec_gen_pack is function gen_dec(e:std_logic;
a:unsigned; size_in,size_out:integer) return
unsigned is
begin
else
tmp(i) :='1'; else tmp(i) :='0'; end if; return tmp; end dec_gen_pack; |
and an entity
with data_flow architecture and function calls
library IEEE;
use IEEE.std_logic_1164.all; use IEEE.numeric_std.all; use work.dec_gen_pack.all; entity fun_dec_gen is
in_b: in unsigned (7 downto 0); out_a: out unsigned(31 downto 0); out_b: out unsigned(255 downto 0)); |
architecture
data_flow_dec of
fun_dec_gen is
begin process(e_a,in_a,e_b,in_b)
-- two function calls (instead of two instantiations)
out_b <= gen_dec(e_b,in_b,8,256); |