1 / 11

Instanciação em VHDL

Instanciação em VHDL. Definição. Meio pelo qual componentes definidos em VHDL podem ser incorporados em outros projetos, além daquele em que foram criados. Exemplo. a. &. c. entity nand2 is port (a, b: in bit; c : out bit); end nand2; architecture behave of nand2 is begin

leanna
Download Presentation

Instanciação em VHDL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Instanciação em VHDL

  2. Definição • Meio pelo qual componentes definidos em VHDL podem ser incorporados em outros projetos, além daquele em que foram criados.

  3. Exemplo a & c entity nand2 is port (a, b: in bit; c : out bit); end nand2; architecture behave of nand2 is begin c <= not(a and b) after 1 ns; end behave; b

  4. entity mynand is port (a, b: in bit; c : out bit); end mynand; architecture version1 of mynand is begin c <= not(a and b) after 1 ns; end version1; -- nand2 e mynand são duas entidades diferentes -- que realizam a mesma função. A cláusula -- “after” não é sintetizável

  5. U1 set a & q c b ENTITY rsff IS PORT ( set, reset : IN BIT; q, qb : INOUT BIT); END rsff; ARCHITECTURE netlist OF rsff IS COMPONENT nand2 PORT ( a, b : IN BIT; c : OUT BIT); END COMPONENT; BEGIN U1: nand2 PORT MAP (set, qb, q); U2: nand2 PORT MAP (reset, q, qb); END netlist; ARCHITECTURE behave OF rsff IS BEGIN q <= NOT( qb AND set ) AFTER 2 ns; qb <= NOT( q AND reset ) AFTER 2 ns; END behave; U2 b qb & c reset a

  6. ARCHITECTURE sequential OF rsff IS BEGIN PROCESS (set, reset ) BEGIN IF set = '1' AND reset = '0' THEN q <= '0' AFTER 2 ns; qb <= '1' AFTER 4 ns; ELSIF set = '0' AND reset = '1' THEN q <= '1' AFTER 4 ns; qb <='0' AFTER 2 ns; ELSIF set = '0' AND reset = '0' THEN q <= '1' AFTER 2 ns; qb <= '1' AFTER 2 ns; END IF; END PROCESS; END sequential;

  7. CONFIGURATION rsffcon1 OF rsff IS FOR netlist FOR U1,U2 : mynand USE ENTITY WORK.mynand(version1); END FOR; END FOR; END rsffcon1; -- rsffcon1 tem uma configuração mais extensa pois -- possui uma estrutura mais hierarquizada. Alternati- -- vamente poderíamos ter: FOR U1: nand2 USE ENTITY WORK.nand2(behave); FOR U2: mynand USE ENTITY WORK.mynand(version1); ------------------------------------------------------- CONFIGURATION rsffcon2 OF rsff IS FOR behave END FOR; END rsffcon2; -- A configuração rsffcon2 tem apenas um nível hie- -- rárquico, tendo portanto uma definição mais simples

  8. Packages / Functions Packages representam a possibilidade de “agrupamento” de funções, geralmente com finalidades semelhantes. O exemplo a seguir agrupa funções matemáticas de conversão de tipos comuns em VHDL.

  9. LIBRARY IEEE; USE IEEE.std_logic_1164.ALL; PACKAGE math IS TYPE st16 IS ARRAY(0 TO 15) OF std_logic; FUNCTION add(a, b: IN st16) RETURN st16; FUNCTION sub(a, b: IN st16) RETURN st16; END math; PACKAGE BODY math IS FUNCTION vect_to_int(S : st16) RETURN INTEGER IS VARIABLE result : INTEGER := 0; BEGIN FOR i IN 0 TO 7 LOOP result := result * 2; IF S(i) = '1' THEN result := result + 1; END IF; END LOOP; RETURN result; END vect_to_int;

  10. FUNCTION int_to_st16(s : INTEGER) RETURN st16 IS VARIABLE result : st16; VARIABLE digit : INTEGER := 2**15; VARIABLE local : INTEGER; BEGIN local := s; FOR i IN 15 DOWNTO 0 LOOP IF local/digit >= 1 THEN result(i) := '1'; local := local - digit; ELSE result(i) := '0'; END IF; digit := digit/2; END LOOP; RETURN result; END int_to_st16;

  11. FUNCTION add(a, b: IN st16) RETURN st16 IS VARIABLE result : INTEGER; BEGIN result := vect_to_int(a) + vect_to_int(b); RETURN int_to_st16(result); END add; FUNCTION sub(a, b: IN st16) RETURN st16 IS VARIABLE result : INTEGER; BEGIN result := vect_to_int(a) - vect_to_int(b); RETURN int_to_st16(result); END sub; END math; -------------------------------------------------------------------- --Para usar-se as funções definidas no “package” acima, é necessária a ---inclusão da seguinte diretiva: USE WORK.math.ALL;

More Related