Des De scr criipc pció ión n y pr prác ácti tic ca con el ISE ISE Design Suite
EDIG
Content • ����������: ���� ������� • E�������
EDIG
VHDL: Testbenches
EDIG
Flujo de Trabajo con FPGAs
E�������� ��� ������
����������
��������
s ream” Depuración y optimización
EDIG
Flujo de trabajo con FPGAs E�������������
D��������� �D���������� ��� ������� �� �� �������� �� ����������� �������� (�HD�)
� �� �
������������
� ��
•
� �������������� ��� ������ � ��������� �����������
C����������� �������� ������������ �� ��� �� �������������� �� �� �������� �� �� ��������������
C��������� � ������ �A��������� �� ��� ��������� � ��������������� � ��������� ��������� ������ �� �� F�GA
������������ �C������������ �� ��� ��������� ��������� � �� ������� ������ ���������������
EDIG
���� •
C����������� �������� ����� �� ��� �� �������������� �� �� �������� �� �� ��������������
Simulación • ����������� ��������� ��� �� �������� ��� ����� �������� ������ ��� ���������������� – E������: �� ������ �� ��� ������� ������ �� �������� ���� ����� ��� ������������� �� �������
• E� �� �������� ���� ��� ��������� �� ��� �������� , ���� �������� • ���� ��������� �� �������������� ������� ��� ������� ����� ������� �������� � ��� ��� ��� ������� ��� ��������� • E� ���������� ��� ������� ���� ������� �� ����� ��������� (����� �� �������) EDIG
Testbench • �� ��������� �� ��� �������/������������ �HD� ��� ��� ���������� ���������������: – �� ������� ���� �����, �� ����� ������� �� ������� � ������ – E����� ��� ����������� ����������� � �� ������ ��� �� �� � ��� ����� �� ��������� ��� �� ��� ����� ������������� • ����������� �� ������ �� ������ ��� �� �� � ��������� ���� D�� (������ ����� ���� ) � ��� (���� ����� ���� )
– ��� ��������� �� ������� ��������� ������� ��������� ��� �� ������ � ��� ������� ��� �� �������� � ��� �������� ��� D�� – ��� ������� ��� D�� �� �������� � ������� ��� ��������� EDIG
Uso de “after ” • ��� ������ �������� �� ������� ��������� ��������� �� �� ������ �� ������� ������������ �� ������� ��� ������ – � <= �1�, �0� ����� 2��, �1� ����� 4��;
• ������� ��� ����������� �� ������ ����� ��� ����� �� ������� ��� �����. • E� ��������� ��� �������� �� ����������� � �������� �� ������ �� ��� �������, ��� ����������� ��� ������ �� ���� �� ��� ������� �� ������� �� ��� �������� ��� ������� ��������. • �����������, ������� ��� ��������� ��� �� �������������� �� �� ��������. EDIG
Ejemplo Puerta and ������� IEEE; ��� IEEE.��D���GIC�1164.A��; ������ ��������� �� ���� ( �������� : �� ��D���GIC;
�������� � �� ��D���GIC; ������ : ��� ��D���GIC); ��� ���������;
������������������������������������������������
������������ B��������� �� ��������� �� �����
������ �� (�������� ��� ��������); ��� B���������;
���������������������������������������������������
EDIG
Ejemplo Puerta and Test bench �IB�A�� ����;
•Un test bench es un archivo vhdl que nos permite generar señales para probar una entity
��E ����.����������1164.A��;
•El mismo test bench es una entidad pero sin entradas/salidas (Parte 1)
������������ �������� �� ������������ ��
������ ������������ �� ��� ������������;
��������� ��������� ����( �������� : �� ���������;
�������� : �� ���������;
Declaramos el módulo que queremos probar como un componente para conexión estructural (Parte 2)
); ��� ���������;
��E�������
Declaraciones
������ ��������� : ����������������(1 ������ 0) := "00";
Declaramos señales internas para entradas y salidas, in_vector y salidaS (Parte 3)
EDIG
������ � ��� ���������
��������� ������ ������� : ��������� ;
Ejemplo Puerta and Test bench �����
Conectamos estructuralmente la entidad que queremos probar/simular a las señales internas que hemos definido (Parte 4)
���: ��������� ���� ��� ( �������� => ���������(1), �������� => ���������(0), ������ => ������� ); ��������� <= "00", "01" ����� 2��, "10" ����� 4��, "11" ����� 6 ��;
Damos valores a nuestras señales internas a nuestro gusto y variando con el tiempo (Parte 5) ����
EDIG
Ejemplo : Puerta XOR • ����� � ����� ��� ������ ��� � ������ �� ��� �����������:
A B
A
B
S = A·B + A·B EDIG
VHDL : Ejemplo Puerta XOR library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity AAND2 is Port ( A : in STD_LOGIC; B : in STD_LOGIC; S : out STD_LOGIC); end AAND2; architecture Behavioral of AAND2 is begin S<=A and B; end Behavioral; -----------------------------library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity NNOT1 is Port ( A : in STD_LOGIC; S : out STD_LOGIC); end NNOT1; architecture Behavioral of NNOT1 is begin S<=not A; end Behavioral;
EDIG
--------------------------------library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity OOR2 is Port ( A : in STD_LOGIC; B : in STD_LOGIC; S : out STD_LOGIC); end OOR2; architecture Behavioral of OOR2 is begin S <= A or B; end Behavioral;
A
S
A B
S
A B
S
VHDL : Ejemplo Puerta XOR ------------------------------library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity XXOR2 Port ( A B S end XXOR2;
signal SN1,SN2,SN3,SN4 : STD_LOGIC; begin U1 : NNOT1 port map (A,SN1); U2 : NNOT1 port map (B,SN2); U3 : AAND2 port map (SN1,B,SN3); U4 : AAND2 port map (A,SN2,SN4); U5 : OOR2 port map (SN3,SN4,S); end Behavioral;
is : in STD_LOGIC; : in STD_LOGIC; : out STD_LOGIC);
architecture Behavioral of XXOR2 is ----------------------------com onent AAND2 Port ( A : in STD_LOGIC; B : in STD_LOGIC; S : out STD_LOGIC); end component; component OOR2 Port ( A : in STD_LOGIC; B : in STD_LOGIC; S : out STD_LOGIC); end component; component NNOT1 Port ( A : in STD_LOGIC; S : out STD_LOGIC); end component;
EDIG
A
SN1 SN3
S B
SN4 SN2
Test bench para XOR Archivo de test bench �������� ������� �� �������������� ��� ������ ���2 ��������: entity XOR2 is Port ( A : in STD_LOGIC; B : in STD_LOGIC; S : out STD_LOGIC); end XOR2;
Declaramos el módulo que queremos probar como un componente
Declaramos señales para entradas y salidas
EDIG
LIBRARY ieee; USE ieee.std_logic_1164.ALL; ENTITY test_xor2 IS END test_xor2; e av or
es _xor
COMPONENT XXOR2 PORT( A : IN std_logic; B : IN std_logic; S : OUT std_logic ); END COMPONENT; signal C,D : std_logic; signal S : std_logic;
VHDL : Ejemplo Puerta XOR BEGIN
Instanciamos la unidad. Es decir, asignamos las entradas y salidas a las señales declaradas anteriormente Damos diferentes valores a las entradas con un intervalo de tiempo entre ellas. De esta forma se pue en as gnar, por e emp o, to os los valores de la tabla de verdad.
uut: XXOR2 PORT MAP ( A => C, B => D, S => S );
C<='0','0' after 2 ns, '1' after 4 ns, '1' after 6 ns; D<='0','1' after 2 ns, '0' after 4 ns, '1' after 6 ns; END;
Resultado de la simulación
VHDL : Ejemplo � ���� ����� ��� �������� �� ���������� ��� ����� �� ������ �������� ��������� �� �������������� ��� ������ A�D2 ��������: entity AND2 is Port ( A : in STD_LOGIC; B : in STD_LOGIC; S : out STD_LOGIC); end AND2;
Archivo de test bench LIBRARY ieee; USE ieee.std_logic_1164.ALL; ENTITY test_and2 IS END test_and2; ARCHITECTURE behavior OF test_and2 IS
Declaramos el módulo que queremos probar como un componente Declaramos las entradas como un único vector.
COMPONENT AND2 PORT( A : IN std_logic; B : IN std_logic; S : OUT std_logic ); END COMPONENT; signal in_vector : std_logic_vector(1 downto 0) := "00"; signal S : std_logic;
VHDL : Ejemplo Puerta XOR BEGIN
Instanciamos la unidad. Es decir, asignamos las entradas y salidas a las señales declaradas anteriormente Damos diferentes valores a las . esta forma se pueden asignar, por ejemplo, todos los valores de la tabla de verdad.
uut: AND2 PORT A => B => S => ); in_vector <=
END;
MAP ( in_vector(1), in_vector(0), S
"00", "01" after 2ns, "10" after 4ns, "11" after 6ns;
Ejemplo minterms • I��������� �� ������� library IEEE; use IEEE.STD_LOGIC_1164.ALL;
y
=
∑a, b, c (0,3)
architecture Behavioral of truth_table is signal temp : std_logic_vector (2 downto 0);
entity truth_table is _ b : in STD_LOGIC; c : in STD_LOGIC; y : out STD_LOGIC); end truth_table;
temp <= a & b & c; with temp select y <= '1' when "000", '1' when "011", '0' when others; end Behavioral;
EDIG
Ejemplo funcion lógica • I��������� �� ������� �(�,�,�)=�� + ��� + �� library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity funcion_f is Port ( a : in STD_LOGIC; b : in STD_LOGIC; c : in STD_LOGIC; y : out STD_LOGIC); end funcion_f; architecture Behavioral of funcion_f is begin y <= (a and b) or (b and (not c)) or (a and c); end Behavioral;
EDIG
Otro ejemplo estructural •
I��������� �� ������� �(�,�,�) �������� ��� �� ��������� �������� a b c
Signal 1 �
a b
g(a,b,c)
�
library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity funcion_g is Port ( a : in STD_LOGIC; b : in STD_LOGIC; c : in STD_LOGIC; y : out STD_LOGIC); end funcion_g;
architecture structural of funcion_g is COMPONENT funcion_f PORT( a : IN std_logic; b : IN std_logic; c : IN std_logic; y : OUT std_logic ); END COMPONENT; signal signal1: std_logic;
EDIG
begin u1: funcion_f PORT MAP ( a => a, b => b c => c, y => signal1 ); u2: funcion_f PORT MAP ( a => signal1, b => a, c => b, y => y );
end structural;