Mudanças entre as edições de "DLP29006-Engtelecom(2020-1) - Prof. Marcos Moecke"
Linha 435: | Linha 435: | ||
::ver [[Media:Quartus_II_Simulation.pdf | Tutorial do QSIM - Introduction to Simulation of VHDL Designs]] da ALTERA. | ::ver [[Media:Quartus_II_Simulation.pdf | Tutorial do QSIM - Introduction to Simulation of VHDL Designs]] da ALTERA. | ||
::Ver pag. 3 a 24 de <ref name="PEDRONI2010b"> PEDRONI, Volnei A. '''Circuit Design and Simulation with VHDL'''; 2ª ed. Massachusetts-EUA:MIT, 2010. 608 p. ISBN 9780262014335 </ref> | ::Ver pag. 3 a 24 de <ref name="PEDRONI2010b"> PEDRONI, Volnei A. '''Circuit Design and Simulation with VHDL'''; 2ª ed. Massachusetts-EUA:MIT, 2010. 608 p. ISBN 9780262014335 </ref> | ||
+ | --> | ||
+ | {{collapse bottom}} | ||
+ | |||
+ | ===Unidade 3 - Tipos de Dados e Operadores em VHDL=== | ||
+ | * 7 AULAS | ||
+ | |||
+ | {{collapse top | Unidade 3 - Tipos de Dados e Operadores em VHDL}} | ||
+ | |||
+ | ;Aula 8 (3 mar): | ||
+ | *Comentários no código (duplo traço --) | ||
+ | -- Isso eh uma linha de comentario | ||
+ | y <= a * b ; --o sinal y recebe o resultado da multiplicacao a x b | ||
+ | *Representação de números e caracteres em VHDL. | ||
+ | :*Caracteres | ||
+ | caracter: 'A' 'x' '#' (com aspas simples) | ||
+ | string de caracteres: "IFSC" "teste" "teste123" | ||
+ | |||
+ | :*Números em geral | ||
+ | bit único: '0' '1' 'Z' (com aspas simples) | ||
+ | vetor de bits: "0110" "101001Z" (com aspas duplas) | ||
+ | vetor de 1 bit: "0" "1" (com aspas duplas) | ||
+ | inteiros: 5 1101 1102 (sem aspas) | ||
+ | |||
+ | :*Números binários: | ||
+ | 0 -> '0' | ||
+ | 7 -> "0111" ou b"0111" ou B"0111" | ||
+ | 1023 -> "001111111111" ou b"1111111111" ou B"1111111111" | ||
+ | |||
+ | :*Números octais: | ||
+ | 44 -> 5*8^1 + 4*8^0 -> O"54" ou o"54" | ||
+ | 1023 -> 1*8^3 + 7*8^2 + 7*8^1 + 7*8^0 -> o"1777" 8#1777# | ||
+ | |||
+ | :*Números Hexadecimais: | ||
+ | 1023 -> 3*16^2 + 15*16^1 + 15*16^0 = X"3FF" ou x"3FF" 16#3FF# | ||
+ | |||
+ | :*Números decimais: | ||
+ | 1023 -> 1023 ou 1_023 | ||
+ | 1000 -> 1000 ou 1_000 ou 1E3 | ||
+ | |||
+ | :*Números em outras bases (de 2 a 16) | ||
+ | 5#320# (3*5^2 + 2*5^1 + 0*5^0) -> 85 | ||
+ | 3#201#E4 (2*3^2+0*3^1+1*3^0)*3^4 -> 1539 | ||
+ | |||
+ | *Tipos de Dados em VHDL. | ||
+ | :*Objetos de VHDL: '''CONSTANT''', '''SIGNAL''', '''VARIABLE''', '''FILE'''. | ||
+ | |||
+ | <syntaxhighlight lang=vhdl> | ||
+ | constant <constant_name> : <type> := <constant_value>; | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | A '''constant''' pode ser declarado na parte declarativa da ENTITY, ARCHITECTURE, PACKAGE, PACKAGE_BODY, BLOCK, GENERATE, PROCESS, FUNCTION e PROCEDURE. | ||
+ | |||
+ | <syntaxhighlight lang=vhdl> | ||
+ | -- Signal sem valor default | ||
+ | -- Para atribuir um valor a um signal use "<=" como operador. | ||
+ | |||
+ | signal <name> : <type>; | ||
+ | |||
+ | -- Signal com valor default | ||
+ | signal <name> : <type> := <default_value>; | ||
+ | |||
+ | -- Declarações comuns de signals | ||
+ | |||
+ | signal <name> : std_logic; | ||
+ | signal <name> : std_logic_vector(<msb_index> downto <lsb_index>); | ||
+ | signal <name> : integer; | ||
+ | signal <name> : integer range <low> to <high>; | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | O '''signal''' pode ser declarado na parte declarativa da ENTITY, ARCHITECTURE, PACKAGE, BLOCK, GENERATE. Os sinais não podem ser declarados no código sequencial (PROCESS, FUNCTION e PROCEDURE), mas podem ser usados. | ||
+ | |||
+ | <syntaxhighlight lang=vhdl> | ||
+ | -- Variables devem ser declarada em process ou subprogramas. | ||
+ | -- Para atribuir um valor a um variable use "<=" como operador. | ||
+ | |||
+ | -- Variable sem valor default. | ||
+ | variable <name> : <type>; | ||
+ | |||
+ | -- Variable com valor default. | ||
+ | variable <name> : <type> := <default_value>; | ||
+ | |||
+ | -- Declarações comuns de variables | ||
+ | variable <name> : std_logic; | ||
+ | variable <name> : std_logic_vector(<msb_index> downto <lsb_index>); | ||
+ | variable <name> : integer; | ||
+ | variable <name> : integer range <low> to <high>; | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | O '''variable''' (variável) só pode ser declarada e usada dentro do escopo no código sequencial (PROCESS, FUNCTION e PROCEDURE). | ||
+ | |||
+ | :*Palavra chave '''OTHERS''' para formação de agregados | ||
+ | Exemplos de declaração de CONSTANT, SIGNAL, VARIABLE, inicializando o valor usando o agregados | ||
+ | |||
+ | <syntaxhighlight lang=vhdl> | ||
+ | CONSTANT a: BIT_VECTOR(5 DOWNTO 0) := (OTHERS => '0'); -- "000000" | ||
+ | |||
+ | CONSTANT b: BIT_VECTOR(7 DOWNTO 0) := (7 => '0', OTHERS => '1'); -- "01111111" | ||
+ | CONSTANT c: BIT_VECTOR(7 DOWNTO 0) := (7 => '0', 6 DOWNTO 0 => '1'); -- "01111111" | ||
+ | CONSTANT d: BIT_VECTOR(7 DOWNTO 0) := "01111111"; | ||
+ | |||
+ | SIGNAL e: STD_LOGIC_VECTOR(7 DOWNTO 0); -- Not initialized | ||
+ | SIGNAL f: STD_LOGIC_VECTOR(1 TO 8) := (2|3|8 => '1', 4 => 'Z', OTHERS => '0' ); -- "011Z0001" | ||
+ | |||
+ | VARIABLE g: BIT_VECTOR(1 TO 16); -- Not initialized | ||
+ | VARIABLE h: BIT_VECTOR(1 TO 16) := (1 TO 8 => '1', OTHERS => '0'); -- "1111111100000000" | ||
+ | |||
+ | </syntaxhighlight> | ||
+ | |||
+ | :: Ver pag. 31 a 35 de <ref name="PEDRONI2010b"/> | ||
+ | |||
+ | :* Bibliotecas padrão IEEE ('''[[Std logic 1164.vhd]]''', '''[[Numeric std.vhd]]'''). | ||
+ | ::* '''ATENÇÃO!!! Não use as bibliotecas que não são padrão (''std_logic_arith, std_logic_unsigned, std_logic_signed''''') | ||
+ | ::* Ler e guardar a página sobre [[Aritmética com vetores em VDHL]] | ||
+ | |||
+ | * Classificação dos tipos de dados. | ||
+ | |||
+ | A biblioteca [[standard.vhd]] define os tipos BIT, BIT_VECTOR, BOOLEAN, INTEGER, NATURAL, POSITIVE, CHARACTER, STRING. | ||
+ | |||
+ | <syntaxhighlight lang=vhdl> | ||
+ | package standard is | ||
+ | type boolean is (false,true); | ||
+ | type bit is ('0', '1'); | ||
+ | type severity_level is (note, warning, error, failure); | ||
+ | type integer is range -2147483647 to 2147483647; | ||
+ | type real is range -1.0E308 to 1.0E308; | ||
+ | type time is range -2147483648 to 2147483647 | ||
+ | units | ||
+ | fs; | ||
+ | ps = 1000 fs; | ||
+ | ns = 1000 ps; | ||
+ | us = 1000 ns; | ||
+ | ms = 1000 us; | ||
+ | sec = 1000 ms; | ||
+ | min = 60 sec; | ||
+ | hr = 60 min; | ||
+ | end units; | ||
+ | subtype natural is integer range 0 to integer'high; | ||
+ | subtype positive is integer range 1 to integer'high; | ||
+ | type string is array (positive range <>) of character; | ||
+ | type bit_vector is array (natural range <>) of bit; | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | A biblioteca [[Std logic 1164.vhd]] define os tipos STD_(U)LOGIG, STD_(U)LOGIG_VECTOR. | ||
+ | |||
+ | <syntaxhighlight lang=vhdl> | ||
+ | PACKAGE std_logic_1164 IS | ||
+ | TYPE std_ulogic IS ( 'U', -- Uninitialized | ||
+ | 'X', -- Forcing Unknown | ||
+ | '0', -- Forcing 0 | ||
+ | '1', -- Forcing 1 | ||
+ | 'Z', -- High Impedance | ||
+ | 'W', -- Weak Unknown | ||
+ | 'L', -- Weak 0 | ||
+ | 'H', -- Weak 1 | ||
+ | '-' -- Don't care | ||
+ | ); | ||
+ | TYPE std_ulogic_vector IS ARRAY ( NATURAL RANGE <> ) OF std_ulogic; | ||
+ | SUBTYPE std_logic IS resolved std_ulogic; | ||
+ | TYPE std_logic_vector IS ARRAY ( NATURAL RANGE <>) OF std_logic; | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | A biblioteca [[Std logic 1164.vhd]] ainda define algumas funções importantes como a '''rising_edge''' que determina se um sinal está na borda de subida (usado em sinais de clock). | ||
+ | |||
+ | <syntaxhighlight lang=vhdl> | ||
+ | ------------------------------------------------------------------- | ||
+ | -- conversion functions | ||
+ | ------------------------------------------------------------------- | ||
+ | FUNCTION To_bit ( s : std_ulogic; xmap : BIT := '0') RETURN BIT; | ||
+ | FUNCTION To_bitvector ( s : std_logic_vector ; xmap : BIT := '0') RETURN BIT_VECTOR; | ||
+ | FUNCTION To_StdULogic ( b : BIT ) RETURN std_ulogic; | ||
+ | FUNCTION To_StdLogicVector ( b : BIT_VECTOR ) RETURN std_logic_vector; | ||
+ | |||
+ | ------------------------------------------------------------------- | ||
+ | -- edge detection | ||
+ | ------------------------------------------------------------------- | ||
+ | FUNCTION rising_edge (SIGNAL s : std_ulogic) RETURN BOOLEAN; | ||
+ | FUNCTION falling_edge (SIGNAL s : std_ulogic) RETURN BOOLEAN; | ||
+ | |||
+ | ------------------------------------------------------------------- | ||
+ | -- edge detection | ||
+ | ------------------------------------------------------------------- | ||
+ | FUNCTION rising_edge (SIGNAL s : std_ulogic) RETURN BOOLEAN IS | ||
+ | -- altera built_in builtin_rising_edge | ||
+ | BEGIN | ||
+ | RETURN (s'EVENT AND (To_X01(s) = '1') AND | ||
+ | (To_X01(s'LAST_VALUE) = '0')); | ||
+ | END; | ||
+ | |||
+ | </syntaxhighlight> | ||
+ | |||
+ | A biblioteca [[Numeric std.vhd]] define os tipos UNSIGNED e SIGNED. | ||
+ | |||
+ | <syntaxhighlight lang=vhdl> | ||
+ | package NUMERIC_STD is | ||
+ | type UNSIGNED is array (NATURAL range <>) of STD_LOGIC; | ||
+ | type SIGNED is array (NATURAL range <>) of STD_LOGIC; | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | A biblioteca [[Numeric std.vhd]] ainda define os operadores (abs, "+", "-", "*", "\", rem, mod, sll, slr, ror, rol), comparações ("=", '/=', ">", ">=", "<", "<=") e operadores lógicos (not, and, nand, or, nor, xor, xnor) para os tipos SIGNED e UNSIGNED. Além disso também define algumas funções muito utilizadas como: | ||
+ | |||
+ | <syntaxhighlight lang=vhdl> | ||
+ | --============================================================================ | ||
+ | -- RESIZE Functions | ||
+ | --============================================================================ | ||
+ | function RESIZE (ARG: SIGNED; NEW_SIZE: NATURAL) return SIGNED; | ||
+ | function RESIZE (ARG: UNSIGNED; NEW_SIZE: NATURAL) return UNSIGNED; | ||
+ | |||
+ | --============================================================================ | ||
+ | -- Conversion Functions | ||
+ | --============================================================================ | ||
+ | function TO_INTEGER (ARG: UNSIGNED) return NATURAL; | ||
+ | function TO_INTEGER (ARG: SIGNED) return INTEGER; | ||
+ | function TO_UNSIGNED (ARG, SIZE: NATURAL) return UNSIGNED; | ||
+ | function TO_SIGNED (ARG: INTEGER; SIZE: NATURAL) return SIGNED; | ||
+ | |||
+ | </syntaxhighlight> | ||
+ | <!-- | ||
+ | |||
+ | ;Aula 8 (21 ago): | ||
+ | :* Resumo dos Tipos predefinidos. | ||
+ | {| class="wikitable sortable" border="1" cellpadding="3" cellspacing="0" style="text-align:left; font-size:100%" bgcolor="#efefef" | ||
+ | ! scope="col" width=15% align="left"| Tipo de Dado | ||
+ | ! scope="col" width=10% align="left"| Package | ||
+ | ! scope="col" width=7% align="left"| Library | ||
+ | ! scope="col" width=50% align="left"| Valores | ||
+ | ! scope="col" width=15% align="left"| Observações | ||
+ | |- | ||
+ | | BOOLEAN || standard || std || TRUE e FALSE || sintetizável | ||
+ | |- | ||
+ | | BIT || standard || std || valores '0', '1' || sintetizável | ||
+ | |- | ||
+ | | INTEGER || standard || std || números inteiros de 32 bits [de -2^31 até + (2^31 - 1)] || sintetizável | ||
+ | |- | ||
+ | | NATURAL || standard || std || números inteiros não negativos [de 0 até + (2^31 - 1)] || sintetizável | ||
+ | |- | ||
+ | | POSITIVE || standard || std || números inteiros positivos [de 1 até + (2^31 - 1)] || sintetizável | ||
+ | |- | ||
+ | | BOOLEAN_VECTOR || standard (2008) || std || vetor de BOOLEAN || sintetizável | ||
+ | |- | ||
+ | | BIT_VECTOR || standard || std || vetor de BIT || sintetizável | ||
+ | |- | ||
+ | | INTEGER_VECTOR || standard || std || vetor de INTEGER || sintetizável | ||
+ | |- | ||
+ | | REAL || standard || std || números reais [de -1.0E-38 até + 1.0E-38] || simulação | ||
+ | |- | ||
+ | | CHARACTER || standard || std || caracteres ASCII || | ||
+ | |- | ||
+ | | STRING || standard || std || vetor de CHARACTER || | ||
+ | |- | ||
+ | | STD_LOGIC || std_logic_1164 || ieee || valores 'U', 'X', '0', '1', 'Z', 'W', 'L', 'H', '-' || sintetizável | ||
+ | |- | ||
+ | | STD_LOGIC_VECTOR || std_logic_1164 || ieee || vetor de STD_LOGIC || sintetizável | ||
+ | |- | ||
+ | | SIGNED || numeric_std || ieee || STD_LOGIC_VECTOR que aceitam operações aritméticas com sinal|| sintetizável | ||
+ | |- | ||
+ | | UNSIGNED || numeric_std || ieee || STD_LOGIC_VECTOR que aceitam operações aritméticas || sintetizável | ||
+ | |- | ||
+ | | SIGNED || numeric_bit || ieee || BIT_VECTOR que aceitam operações aritméticas com sinal || sintetizável | ||
+ | |- | ||
+ | | UNSIGNED || numeric_bit || ieee || BIT_VECTOR que aceitam operações aritméticas || sintetizável | ||
+ | |- | ||
+ | | SIGNED || std_logic_arith || ieee || STD_LOGIC_VECTOR que aceitam operações aritméticas com sinal || sintetizável (não é padrão) | ||
+ | |- | ||
+ | | UNSIGNED || std_logic_arith || ieee || STD_LOGIC_VECTOR que aceitam operações aritméticas || sintetizável (não é padrão) | ||
+ | |- | ||
+ | | UFIXED || fixed_pkg + (2008) || ieee || números de ponto fixo sem sinal|| sintetizável | ||
+ | |- | ||
+ | | SFIXED || fixed_pkg + (2008) || ieee || números de ponto fixo com sinal|| sintetizável | ||
+ | |- | ||
+ | | FLOAT || float_pkg + (2008) || ieee || Números de ponto flutuante || sintetizável | ||
+ | |} | ||
+ | |||
+ | :* Tipos de dados predefinidos: FIXED e FLOAT (apenas conhecer) | ||
+ | |||
+ | :* Exemplo 3.1 Buffer Tri-state | ||
+ | {{collapse top | Buffer tri_state}} | ||
+ | <syntaxhighlight lang=vhdl> | ||
+ | library ieee; | ||
+ | use ieee.std_logic_1164.all; | ||
+ | |||
+ | entity tri_state is | ||
+ | generic (N: NATURAL := 1); | ||
+ | port | ||
+ | ( | ||
+ | input : in std_logic_vector(N-1 downto 0); | ||
+ | ena : in std_logic; | ||
+ | output : out std_logic_vector(N-1 downto 0); | ||
+ | ); | ||
+ | end entity; | ||
+ | |||
+ | architecture tri_state of tri_state is | ||
+ | begin | ||
+ | output <= input when ena = '1' else "Z"; | ||
+ | end architecture; | ||
+ | </syntaxhighlight> | ||
+ | {{collapse bottom}} | ||
+ | ::* Corrija os erros do código e verifique o modelo RTL obtido. | ||
+ | ::* Em seguida modifique as portas '''input''' e '''output''' para o tipo '''std_logic'''. | ||
+ | ::* Analise se seria possível modificar as portas para o tipo '''bit'''. | ||
+ | :: '''Importante''': O terceiro estado 'Z' só pode ser usado em saídas, e a sua realização nos FPGAs só ocorre nos nós de I/O. | ||
+ | |||
+ | :* Exemplo 3.2 Circuito com Saida "don't care" | ||
+ | |||
+ | {{collapse top | Saída don't care}} | ||
+ | <syntaxhighlight lang=vhdl> | ||
+ | library ieee; | ||
+ | use ieee.std_logic_1164.all; | ||
+ | |||
+ | entity Ex3_2 is | ||
+ | port | ||
+ | ( | ||
+ | x : in STD_LOGIC_VECTOR(1 downto 0); | ||
+ | y : out STD_LOGIC_VECTOR(1 downto 0) | ||
+ | ); | ||
+ | end entity; | ||
+ | |||
+ | architecture un3 of Ex3_2 is | ||
+ | begin | ||
+ | y <= "00" when x = "00" else | ||
+ | "01" when x = "10" else | ||
+ | "10" when x = "01" else | ||
+ | "--"; | ||
+ | end architecture; | ||
+ | </syntaxhighlight> | ||
+ | {{collapse bottom}} | ||
+ | |||
+ | :* Tipos de dados: SIGNED e UNSIGNED | ||
+ | |||
+ | :* Exemplo 3.3 Multiplicador de 4x4 bits (UN)SIGNED e INTEGER | ||
+ | |||
+ | {{collapse top | Código Multiplicador}} | ||
+ | <syntaxhighlight lang=vhdl> | ||
+ | --LIBRARY ieee; | ||
+ | --USE ieee.numeric_std.all; | ||
+ | |||
+ | ENTITY multiplicador4x4 IS | ||
+ | |||
+ | -- multiplicador usando INTEGER (positivos) | ||
+ | -- PORT (a, b: IN INTEGER RANGE 0 TO 15; -- min(a) = 0; max(a) = 15 -> 4 bits | ||
+ | -- y: OUT INTEGER RANGE 0 TO 225); -- min(a*b) = 0, max(a*b) = 225 -> 8 bits | ||
+ | |||
+ | -- multiplicador usando INTEGER (positivos e negativos) | ||
+ | -- PORT (a, b: IN INTEGER RANGE -8 TO 7; -- min(a) = -8; max(a) = 7 -> 4 bits | ||
+ | -- y: OUT INTEGER RANGE -56 TO 64); -- min(a*b) = -56, max(a*b) = 64 -> 8 bits | ||
+ | |||
+ | -- multiplicador usando UNSIGNED | ||
+ | -- PORT (a, b: IN UNSIGNED(3 DOWNTO 0); -- min(a) = 0; max(a) = 15 <- 4 bits | ||
+ | -- y: OUT UNSIGNED(7 DOWNTO 0)); -- min(a*b) = 0, max(a*b) = 225 -> 8 bits | ||
+ | |||
+ | -- multiplicador usando SIGNED | ||
+ | -- PORT (a, b: IN SIGNED(3 DOWNTO 0); -- min(a) = -8; max(a) = 7 <- 4 bits | ||
+ | -- y: OUT SIGNED(7 DOWNTO 0)); -- min(a*b) = -56, max(a*b) = 64 -> 8 bits | ||
+ | |||
+ | |||
+ | -- multiplicador usando STD_LOGIC_VECTOR | ||
+ | -- PORT (a, b: IN STD_LOGIC_VECTOR(3 DOWNTO 0); -- min(a) = 0; max(a) = 15 <- 4 bits | ||
+ | -- y: OUT STD_LOGIC_VECTOR(7 DOWNTO 0)); -- min(a*b) = 0, max(a*b) = 225 -> 8 bits | ||
+ | |||
+ | -- multiplicador usando STD_LOGIC_VECTOR | ||
+ | -- PORT (a, b: STD_LOGIC_VECTOR(3 DOWNTO 0); -- min(a) = -8; max(a) = 7 <- 4 bits | ||
+ | -- y: OUT STD_LOGIC_VECTOR(7 DOWNTO 0)); -- min(a*b) = -56, max(a*b) = 64 -> 8 bits | ||
+ | |||
+ | |||
+ | END ENTITY; | ||
+ | |||
+ | ARCHITECTURE v1 OF multiplicador4x4 IS | ||
+ | BEGIN | ||
+ | y <= a * b; | ||
+ | END ARCHITECTURE; | ||
+ | </syntaxhighlight> | ||
+ | *Observar o número de elementos lógicos, bits usados para representar as entradas e saídas. | ||
+ | *Observar o código RTL obtido. | ||
+ | *Realizar a simulação com entradas UNSIGNED e INTEGER na faixa de valores de 0 até 15, e analisar se o valor da saída está correto. | ||
+ | *Realizar a simulação com entradas SIGNED e INTEGER na faixa de valores de -8 até 7, e analisar se o valor da saída está correto. | ||
+ | *Realizar a simulação com entradas STD_LOGIC_VECTOR na faixa de valores de 0 até 15, e analisar se o valor da saída está correto. Neste caso será necessário realizar uma conversão de STD_LOGIC_VECTOR para UNSIGNED antes de efetuar a operação de "*", e após a operação é necessário fazer a operação inversa UNSIGNED para STD_LOGIC_VECTOR | ||
+ | *Realizar a simulação com entradas STD_LOGIC_VECTOR na faixa de valores de -8 até 7, e analisar se o valor da saída está correto. Neste caso será necessário realizar uma conversão de STD_LOGIC_VECTOR para SIGNED antes de efetuar a operação de "*", e após a operação é necessário fazer a operação inversa SIGNED para STD_LOGIC_VECTOR | ||
+ | |||
+ | {{collapse bottom}} | ||
+ | |||
+ | :: Ver pag. 39 a 54 de <ref name="PEDRONI2010b"/> | ||
+ | |||
+ | ;Aula 9 (26 ago): | ||
+ | |||
+ | :* Tipos definidos pelo usuário: | ||
+ | ::* Escalares (Inteiros e Enumerados) | ||
+ | ::* Tipos de Array 1D x 1D, 2D , 1D x 1D x 1D, 3D. Ver : [[Array em VHDL]] | ||
+ | |||
+ | :::Exemplos Ex 3.5, Ex 3.6 e Ex 3.7 | ||
+ | :* RECORD e SUBTYPE | ||
+ | |||
+ | ;Aula 13 (30 ago): | ||
+ | :* Uso de ARRAYs em portas | ||
+ | ::* Declaração do TYPE em PACKAGE | ||
+ | ::* Exemplo 3.8: Multiplexador com porta 1D x 1D.:: | ||
+ | Ver pag. 60 a 73 de <ref name="PEDRONI2010b"/> | ||
+ | *Qualificação de tipos, conversão de tipos (automática, casting e funções de conversão). | ||
+ | :* Resumo das funções de conversão de tipos (Tabela 3.10) e ver [[Aritmética com vetores em VDHL]] | ||
+ | |||
+ | <!-- | ||
+ | :* Exercício: Multiplicador/Divisor/Somador/Subtrator com sinal e sem sinal (entradas do tipo STD_LOGIC VECTOR) | ||
+ | <syntaxhighlight lang=vhdl> | ||
+ | LIBRARY ieee; | ||
+ | USE ieee.std_logic_1164.all; | ||
+ | USE ieee.numeric_std.all; | ||
+ | |||
+ | ENTITY operadores IS | ||
+ | PORT ( | ||
+ | a, b: IN STD_LOGIC_VECTOR(3 DOWNTO 0); | ||
+ | mult: OUT STD_LOGIC_VECTOR(? DOWNTO 0); | ||
+ | div: OUT STD_LOGIC_VECTOR(? DOWNTO 0); | ||
+ | sum: OUT STD_LOGIC_VECTOR(? DOWNTO 0); | ||
+ | sub: OUT STD_LOGIC_VECTOR(? DOWNTO 0); | ||
+ | ); | ||
+ | END ENTITY; | ||
+ | |||
+ | ARCHITECTURE type_conv_arch OF operadores IS | ||
+ | BEGIN | ||
+ | -- Inserir o código e definir o tamanho das saidas. | ||
+ | END ARCHITECTURE; | ||
+ | </syntaxhighlight> | ||
+ | --> | ||
+ | * '''Desafio''' - Fazer um circuito que detecte se existe alguma vaga vazia em um lote de 5 vagas. Cada entrada x(n) está alta '1' se a vaga está vazia. A saída y estará alta '1' sempre que houver uma ou mais vagas vazias. | ||
+ | :'''Importante''': O ''don't care'' não funciona como se espera para uma entrada, por isso, use ''don't care'' apenas para saídas. | ||
+ | x = "1----" -- não funciona em VHDL | ||
+ | *Se quiser mesmo usar ''don't care'' em entradas use a função '''std_match''' do pacote '''numeric_std''' | ||
+ | std_match(x, "1----") -- funciona em VHDL | ||
+ | *Faça a simulação do circuito para ver se está funcionando, | ||
+ | [[Arquivo:vagas5.png | 800px]] | ||
+ | :: Ver função resize | ||
+ | :: Ver pag. 73 a 78 de <ref name="PEDRONI2010b"/> | ||
+ | <!-- | ||
+ | ;Aula 14 e 15 (02 e 04 set): | ||
+ | |||
+ | *Operadores em VHDL. | ||
+ | :* Operadores predefinidos: Atribuição, Lógicos, Aritméticos, Comparação, Deslocamento, Concatenação, "Matching". | ||
+ | :* Exemplo conversor de binário para BCD de dois dígitos decimais (00 a 99). Para ilustrar são utilizadas os operadores DIVISOR e REMAINDER. Note a quantidade de elementos lógicos utilizados. É possível reduzir essa quantidade, aproveitando resultados intermediários e evitando a realização de uma nova divisão pelo uso do operador REM. Faça uma segunda implementação que reduza significativamente o número de elementos lógicos. | ||
+ | |||
+ | <syntaxhighlight lang=vhdl> | ||
+ | library ieee; | ||
+ | use ieee.std_logic_1164.all; | ||
+ | use ieee.numeric_std.all; | ||
+ | |||
+ | entity bin2bcd is | ||
+ | port | ||
+ | ( | ||
+ | |||
+ | C : in std_logic_vector (6 downto 0); | ||
+ | sd, su : out std_logic_vector (3 downto 0) | ||
+ | ); | ||
+ | end entity; | ||
+ | |||
+ | architecture ifsc_v1 of bin2bcd is | ||
+ | signal C_uns : unsigned (6 downto 0); | ||
+ | signal sd_uns, su_uns : unsigned (6 downto 0); | ||
+ | begin | ||
+ | sd <= std_logic_vector(resize(sd_uns, 4)); | ||
+ | su <= std_logic_vector(resize(su_uns, 4)); | ||
+ | sd_uns <= C_uns/10; | ||
+ | su_uns <= C_uns rem 10; | ||
+ | c_uns <= unsigned(c); | ||
+ | end architecture; | ||
+ | |||
+ | architecture ifsc_v2 of bin2bcd is | ||
+ | |||
+ | begin | ||
+ | -- Implemente o circuito usando a definição de REM que é: x REM y = x - (x/y)*y | ||
+ | end architecture; | ||
+ | |||
+ | configuration bin2bcd_cfg of bin2bcd is | ||
+ | --A instrução '''configuration''' associa a '''entity''' bin2bcd a '''architecture'''. | ||
+ | for ifsc_v1 end for; | ||
+ | --Para associar a '''entity''' bin2bcd a '''architecture''' ifsc_v2 comente a linha acima e descomente a linha abaixo. | ||
+ | -- for ifsc_v2 end for; | ||
+ | end configuration; | ||
+ | </syntaxhighlight> | ||
+ | <center> | ||
+ | [[Arquivo:bin2bcdDU_RTL.png| 600px]] | ||
+ | |||
+ | Figura - RTL do conversor de Binário para BCD com 2 digitos | ||
+ | |||
+ | [[Arquivo:bin2bcdDU_modelsim.png| 1000px]] | ||
+ | |||
+ | Figura - Simulação do conversor de Binário para BCD com 2 digitos | ||
+ | </center> | ||
+ | :* Sobrecarga de operadores | ||
+ | |||
+ | :: Ver pag. 91 a 108 de <ref name="PEDRONI2010b"/> | ||
+ | |||
+ | *Realizar e entregar pelo Moodle a '''[https://moodle.sj.ifsc.edu.br/mod/assign/view.php?id=5825 atividade AE1 - Conversor de binário para BCD]''' que está marcado(a) para segunda, 23 setembro, 07:00. Essa atividade todos deverão realizar, mas existem dois BONUS para quem fizer o circuito com menor número de elementos lógicos e menor atraso de propagação. | ||
+ | |||
+ | |||
+ | :Ver: [[Medição de tempos de propagação em circuitos combinacionais]] | ||
+ | |||
+ | |||
+ | ;Aula 16 (9 set): | ||
+ | Atributos em VHDL. | ||
+ | * Atributos predefinidos: | ||
+ | ::*tipo escalar e enumerados; tipo array; de sinal; | ||
+ | * Atributos de síntese: | ||
+ | Em VHDL existem diversos atributos de sintese que controlam a forma como o processo de "Analysis & Synthesis" é realizado pelo Quartus II. Uma listagem completa pode ser encontrada em: | ||
+ | *[https://www.intel.com/content/www/us/en/programmable/quartushelp/current/index.htm#hdl/vhdl/vhdl_file_dir.htm VHDL Synthesis Attributes and Directives] - Quartus Prime Pro Edition Help version 18.1 | ||
+ | |||
+ | :* '''ATTRIBUTE enum_encoding''' [https://www.intel.com/content/www/us/en/programmable/quartushelp/current/index.htm#hdl/vhdl/vhdl_file_dir_enum_encoding.htm] | ||
+ | <syntaxhighlight lang=vhdl> | ||
+ | type fruit is (apple, orange, pear, mango); | ||
+ | attribute enum_encoding : string; | ||
+ | attribute enum_encoding of fruit : type is "11 01 10 00"; | ||
+ | </syntaxhighlight> | ||
+ | :* '''ATTRIBUTE chip_pin''' [https://www.intel.com/content/www/us/en/programmable/quartushelp/current/index.htm#hdl/vhdl/vhdl_file_dir_chip.htm] | ||
+ | <syntaxhighlight lang=vhdl> | ||
+ | entity foo is | ||
+ | port (sel : in std_logic; | ||
+ | data : in std_logic_vector(3 downto 0); | ||
+ | o : out std_logic); | ||
+ | end foo; | ||
+ | architecture rtl of foo is | ||
+ | |||
+ | attribute chip_pin : string; | ||
+ | attribute chip_pin of sel : signal is "C4"; | ||
+ | attribute chip_pin of data : signal is "D1, D2, D3, D4"; | ||
+ | begin | ||
+ | -- Specify additional code | ||
+ | end architecture; | ||
+ | </syntaxhighlight> | ||
+ | <i> | ||
+ | O uso desse atributo sobrepõe a atribuição dos pinos através da IDE do Quartus II, e por isso não é recomendável. | ||
+ | |||
+ | O atributo de síntese chip_pin pode ser usado apenas em portas da entidade "top-level" do projeto. . | ||
+ | </i> | ||
+ | |||
+ | :* '''ATTRIBUTE keep''' [https://www.intel.com/content/www/us/en/programmable/quartushelp/current/index.htm#hdl/vhdl/vhdl_file_dir_keep.htm] | ||
+ | O atributo de síntese KEEP, sinaliza ao processo de "Analysis & Synthesis" para manter intacto um determinado signal ou componente. | ||
+ | <syntaxhighlight lang=vhdl> | ||
+ | signal a,b,c : std_logic; | ||
+ | attribute keep: boolean; | ||
+ | attribute keep of a,b,c: signal is true; | ||
+ | </syntaxhighlight> | ||
+ | :::* Exemplo 4.4: Delay line (Síntese e Simulação temporal sem o com o atributo keep) | ||
+ | :::* Exemplo 5.8 Gerador de Pulsos estreitos | ||
+ | ::* '''ATTRIBUTE preserve''' [https://www.intel.com/content/www/us/en/programmable/quartushelp/current/index.htm#hdl/vhdl/vhdl_file_dir_preserve.htm], [https://www.intel.com/content/www/us/en/programmable/quartushelp/current/index.htm#logicops/logicops/def_preserve_fanout_free_node.htm]. | ||
+ | |||
+ | <syntaxhighlight lang=vhdl> | ||
+ | signal a,b,c : std_logic; | ||
+ | attribute preserve: boolean; | ||
+ | attribute preserve of a,b,c: signal is true; | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | :* '''ATTRIBUTE noprune'''[https://www.intel.com/content/www/us/en/programmable/quartushelp/current/index.htm#hdl/vhdl/vhdl_file_dir_noprune.htm]. | ||
+ | <syntaxhighlight lang=vhdl> | ||
+ | signal reg1: std_logic; | ||
+ | attribute noprune: boolean; | ||
+ | attribute noprune of reg1: signal is true; | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | :::* Exemplo 4.5: Registros redundantes (Síntese sem e com os atributos keep, preserve e noprune) | ||
+ | <syntaxhighlight lang=vhdl> | ||
+ | ENTITY redundant_registers IS | ||
+ | PORT ( | ||
+ | clk, x: IN BIT; | ||
+ | y: OUT BIT); | ||
+ | END ENTITY; | ||
+ | |||
+ | ARCHITECTURE arch OF redundant_registers IS | ||
+ | SIGNAL a, b, c: BIT; | ||
+ | -- NORMAL -- 1 LE | ||
+ | --ATTRIBUTE preserve: BOOLEAN; | ||
+ | --ATTRIBUTE preserve OF a, b, c: SIGNAL IS TRUE; -- 2 LE | ||
+ | --ATTRIBUTE noprune: BOOLEAN; | ||
+ | --ATTRIBUTE noprune OF a, b, c: SIGNAL IS TRUE; --3 LE | ||
+ | --ATTRIBUTE keep: BOOLEAN; | ||
+ | --ATTRIBUTE keep of a,b,c: SIGNAL IS TRUE; | ||
+ | BEGIN | ||
+ | PROCESS (clk) | ||
+ | BEGIN | ||
+ | IF (clk'EVENT AND clk='1') THEN | ||
+ | a <= x; | ||
+ | b <= x; | ||
+ | c <= x; | ||
+ | END IF; | ||
+ | END PROCESS; | ||
+ | y <= a AND b; | ||
+ | END ARCHITECTURE; | ||
+ | </syntaxhighlight> | ||
+ | Após a compilação do código acima, observe o número de elementos lógicos obtidos, observe o '''Technology Map''' dos circuitos gerados e verifique a localização dos FFs no '''Chip Planner'''. | ||
+ | <center> [[Arquivo:Ex4_5_NoAttribute.png | Sem Attribute| 400 px]] <br> '''Fig 12. Technology Map do Circuito sem Attribute'''</center> | ||
+ | <center> [[Arquivo:Ex4_5_PreserveAttribute.png| Preserve (or Keep) Attribute |400 px]] <br> '''Fig 13. Technology Map do Circuito com Attribute Preserve (or Keep) '''</center> | ||
+ | <center> [[Arquivo:Ex4_5_NopruneAttribute.png| Noprune Attribute| 400 px]] <br> '''Fig 14. Technology Map do Circuito com Attribute Noprune '''</center>:: Ver pag. 91 a 111 de <ref name="PEDRONI2010b"/> | ||
+ | |||
+ | :* Atributos definidos pelo usuário; | ||
+ | <syntaxhighlight lang=vhdl> | ||
+ | attribute attribute_name: attribute_type; | ||
+ | attribute attribute_name of entity_tag [signature]: entity_class is value; | ||
+ | </syntaxhighlight> | ||
+ | Exemplo: | ||
+ | |||
+ | |||
+ | ;Aula 17 (11 set): | ||
+ | |||
+ | Uso da instrução ALIAS. | ||
+ | ::*Exemplo de uso de alias no pacote numeric_std.vhd | ||
+ | <syntaxhighlight lang=vhdl> | ||
+ | function ADD_UNSIGNED (L, R: UNSIGNED; C: STD_LOGIC) return UNSIGNED is | ||
+ | constant L_LEFT: INTEGER := L'LENGTH-1; | ||
+ | alias XL: UNSIGNED(L_LEFT downto 0) is L; | ||
+ | alias XR: UNSIGNED(L_LEFT downto 0) is R; | ||
+ | variable RESULT: UNSIGNED(L_LEFT downto 0); | ||
+ | variable CBIT: STD_LOGIC := C; | ||
+ | begin | ||
+ | for I in 0 to L_LEFT loop | ||
+ | RESULT(I) := CBIT xor XL(I) xor XR(I); | ||
+ | CBIT := (CBIT and XL(I)) or (CBIT and XR(I)) or (XL(I) and XR(I)); | ||
+ | end loop; | ||
+ | return RESULT; | ||
+ | end ADD_UNSIGNED; | ||
+ | </syntaxhighlight> | ||
+ | :: '''NOTA''': No exemplo acima, a CONSTANT L_LEFT recebe o tamanho do parâmetro (L), que pode ser qualquer. Esse tamanho é utilizado para criar dois ALIAS para os parâmetros L e R, utilizando uma indexação (L_LEFT DOWNTO 0). Com isso é possível dentro do FOR-LOOP criar os circuitos que realizam as operações lógicas que realizam a operação de soma. | ||
--> | --> | ||
{{collapse bottom}} | {{collapse bottom}} |
Edição das 15h55min de 3 de março de 2020
MURAL DE AVISOS E OPORTUNIDADES DA ÁREA DE TELECOMUNICAÇÕES
Registro on-line das aulas
Unidade 1 - Introdução a disciplina
- 3 AULAS
Unidade 2 - Introdução ao VHDL e ambienta EDA - QUARTUS
- 3 AULAS
Unidade 2 - Introdução ao VHDL e ambienta EDA - QUARTUS |
---|
library library_name;
use library_name.package)name.all;
entity entity_name is
[generic (
cons_name1: const_type const_value;
cons_name2: const_type const_value;
...
cons_nameN: const_type const_value);]
[port (
signal_name1: mode signal_type;
signal_name2: mode signal_type;
...
signal_nameN: mode signal_type);]
[declarative_part]
[begin
statement_part]
end [entity] [entity_name];
architecture arch_name of entity_name is
[declarative_part]
begin
statement_part
end [architecture] [arch_name];
library std;
use std.standard.all;
entity nand_gate is
port (a, b: in bit; x: out bit);
end entity;
architecture nome_arch of nand_gate is
begin
x <= a nand b;
end architecture;
-- Declaração das bibliotecas e pacotes
LIBRARY ieee;
USE ieee.std_logic_1164.all;
-- Especificação de todas as entradas e saídas do circuito
ENTITY flip_flop IS
PORT (d, clk, rst: IN STD_LOGIC;
q: OUT STD_LOGIC);
END;
-- Descrição de como o circuito deve funcionar
ARCHITECTURE flip_flop OF flip_flop IS
BEGIN
PROCESS (clk, rst)
BEGIN
IF (rst='1') THEN
q <= '0';
ELSIF (clk'EVENT AND clk='1') THEN
q <= d;
END IF;
END PROCESS;
END;
ls /opt/altera/13.0sp1/quartus/libraries/vhdl/std
ls /opt/altera/13.0sp1/quartus/libraries/vhdl/ieee
ls /opt/altera/13.0sp1/quartus/libraries/vhdl/mentor/arithmetic (Mentor Graphics) ls /opt/altera/13.0sp1/quartus/libraries/vhdl/synopsys/ieee (Synopsys)
ls /opt/altera/16.0/quartus/libraries/vhdl/ieee/2008
|
Unidade 3 - Tipos de Dados e Operadores em VHDL
- 7 AULAS
Unidade 3 - Tipos de Dados e Operadores em VHDL |
---|
-- Isso eh uma linha de comentario y <= a * b ; --o sinal y recebe o resultado da multiplicacao a x b
caracter: 'A' 'x' '#' (com aspas simples) string de caracteres: "IFSC" "teste" "teste123"
bit único: '0' '1' 'Z' (com aspas simples) vetor de bits: "0110" "101001Z" (com aspas duplas) vetor de 1 bit: "0" "1" (com aspas duplas) inteiros: 5 1101 1102 (sem aspas)
0 -> '0' 7 -> "0111" ou b"0111" ou B"0111" 1023 -> "001111111111" ou b"1111111111" ou B"1111111111"
44 -> 5*8^1 + 4*8^0 -> O"54" ou o"54" 1023 -> 1*8^3 + 7*8^2 + 7*8^1 + 7*8^0 -> o"1777" 8#1777#
1023 -> 3*16^2 + 15*16^1 + 15*16^0 = X"3FF" ou x"3FF" 16#3FF#
1023 -> 1023 ou 1_023 1000 -> 1000 ou 1_000 ou 1E3
5#320# (3*5^2 + 2*5^1 + 0*5^0) -> 85 3#201#E4 (2*3^2+0*3^1+1*3^0)*3^4 -> 1539
constant <constant_name> : <type> := <constant_value>;
A constant pode ser declarado na parte declarativa da ENTITY, ARCHITECTURE, PACKAGE, PACKAGE_BODY, BLOCK, GENERATE, PROCESS, FUNCTION e PROCEDURE. -- Signal sem valor default
-- Para atribuir um valor a um signal use "<=" como operador.
signal <name> : <type>;
-- Signal com valor default
signal <name> : <type> := <default_value>;
-- Declarações comuns de signals
signal <name> : std_logic;
signal <name> : std_logic_vector(<msb_index> downto <lsb_index>);
signal <name> : integer;
signal <name> : integer range <low> to <high>;
O signal pode ser declarado na parte declarativa da ENTITY, ARCHITECTURE, PACKAGE, BLOCK, GENERATE. Os sinais não podem ser declarados no código sequencial (PROCESS, FUNCTION e PROCEDURE), mas podem ser usados. -- Variables devem ser declarada em process ou subprogramas.
-- Para atribuir um valor a um variable use "<=" como operador.
-- Variable sem valor default.
variable <name> : <type>;
-- Variable com valor default.
variable <name> : <type> := <default_value>;
-- Declarações comuns de variables
variable <name> : std_logic;
variable <name> : std_logic_vector(<msb_index> downto <lsb_index>);
variable <name> : integer;
variable <name> : integer range <low> to <high>;
O variable (variável) só pode ser declarada e usada dentro do escopo no código sequencial (PROCESS, FUNCTION e PROCEDURE).
Exemplos de declaração de CONSTANT, SIGNAL, VARIABLE, inicializando o valor usando o agregados CONSTANT a: BIT_VECTOR(5 DOWNTO 0) := (OTHERS => '0'); -- "000000"
CONSTANT b: BIT_VECTOR(7 DOWNTO 0) := (7 => '0', OTHERS => '1'); -- "01111111"
CONSTANT c: BIT_VECTOR(7 DOWNTO 0) := (7 => '0', 6 DOWNTO 0 => '1'); -- "01111111"
CONSTANT d: BIT_VECTOR(7 DOWNTO 0) := "01111111";
SIGNAL e: STD_LOGIC_VECTOR(7 DOWNTO 0); -- Not initialized
SIGNAL f: STD_LOGIC_VECTOR(1 TO 8) := (2|3|8 => '1', 4 => 'Z', OTHERS => '0' ); -- "011Z0001"
VARIABLE g: BIT_VECTOR(1 TO 16); -- Not initialized
VARIABLE h: BIT_VECTOR(1 TO 16) := (1 TO 8 => '1', OTHERS => '0'); -- "1111111100000000"
A biblioteca standard.vhd define os tipos BIT, BIT_VECTOR, BOOLEAN, INTEGER, NATURAL, POSITIVE, CHARACTER, STRING. package standard is
type boolean is (false,true);
type bit is ('0', '1');
type severity_level is (note, warning, error, failure);
type integer is range -2147483647 to 2147483647;
type real is range -1.0E308 to 1.0E308;
type time is range -2147483648 to 2147483647
units
fs;
ps = 1000 fs;
ns = 1000 ps;
us = 1000 ns;
ms = 1000 us;
sec = 1000 ms;
min = 60 sec;
hr = 60 min;
end units;
subtype natural is integer range 0 to integer'high;
subtype positive is integer range 1 to integer'high;
type string is array (positive range <>) of character;
type bit_vector is array (natural range <>) of bit;
A biblioteca Std logic 1164.vhd define os tipos STD_(U)LOGIG, STD_(U)LOGIG_VECTOR. PACKAGE std_logic_1164 IS
TYPE std_ulogic IS ( 'U', -- Uninitialized
'X', -- Forcing Unknown
'0', -- Forcing 0
'1', -- Forcing 1
'Z', -- High Impedance
'W', -- Weak Unknown
'L', -- Weak 0
'H', -- Weak 1
'-' -- Don't care
);
TYPE std_ulogic_vector IS ARRAY ( NATURAL RANGE <> ) OF std_ulogic;
SUBTYPE std_logic IS resolved std_ulogic;
TYPE std_logic_vector IS ARRAY ( NATURAL RANGE <>) OF std_logic;
A biblioteca Std logic 1164.vhd ainda define algumas funções importantes como a rising_edge que determina se um sinal está na borda de subida (usado em sinais de clock). -------------------------------------------------------------------
-- conversion functions
-------------------------------------------------------------------
FUNCTION To_bit ( s : std_ulogic; xmap : BIT := '0') RETURN BIT;
FUNCTION To_bitvector ( s : std_logic_vector ; xmap : BIT := '0') RETURN BIT_VECTOR;
FUNCTION To_StdULogic ( b : BIT ) RETURN std_ulogic;
FUNCTION To_StdLogicVector ( b : BIT_VECTOR ) RETURN std_logic_vector;
-------------------------------------------------------------------
-- edge detection
-------------------------------------------------------------------
FUNCTION rising_edge (SIGNAL s : std_ulogic) RETURN BOOLEAN;
FUNCTION falling_edge (SIGNAL s : std_ulogic) RETURN BOOLEAN;
-------------------------------------------------------------------
-- edge detection
-------------------------------------------------------------------
FUNCTION rising_edge (SIGNAL s : std_ulogic) RETURN BOOLEAN IS
-- altera built_in builtin_rising_edge
BEGIN
RETURN (s'EVENT AND (To_X01(s) = '1') AND
(To_X01(s'LAST_VALUE) = '0'));
END;
A biblioteca Numeric std.vhd define os tipos UNSIGNED e SIGNED. package NUMERIC_STD is
type UNSIGNED is array (NATURAL range <>) of STD_LOGIC;
type SIGNED is array (NATURAL range <>) of STD_LOGIC;
A biblioteca Numeric std.vhd ainda define os operadores (abs, "+", "-", "*", "\", rem, mod, sll, slr, ror, rol), comparações ("=", '/=', ">", ">=", "<", "<=") e operadores lógicos (not, and, nand, or, nor, xor, xnor) para os tipos SIGNED e UNSIGNED. Além disso também define algumas funções muito utilizadas como: --============================================================================
-- RESIZE Functions
--============================================================================
function RESIZE (ARG: SIGNED; NEW_SIZE: NATURAL) return SIGNED;
function RESIZE (ARG: UNSIGNED; NEW_SIZE: NATURAL) return UNSIGNED;
--============================================================================
-- Conversion Functions
--============================================================================
function TO_INTEGER (ARG: UNSIGNED) return NATURAL;
function TO_INTEGER (ARG: SIGNED) return INTEGER;
function TO_UNSIGNED (ARG, SIZE: NATURAL) return UNSIGNED;
function TO_SIGNED (ARG: INTEGER; SIZE: NATURAL) return SIGNED;
x = "1----" -- não funciona em VHDL
std_match(x, "1----") -- funciona em VHDL
|
Avaliações
Atividade Relâmpago (AR)
As atividades relâmpago são atividades avaliativas opcionais que darão BôNUS adicionais ao aluno na próxima avaliação. Elas normalmente consistem de soluções simples para algum problema ou sistema. Elas são enunciadas na aula, e o prazo e a entrega serão definidos no Moodle. Não são aceitas entregas tardias, e apenas 2 alunos podem receber o bonus. A pontuação das atividades é informada a cada atividade.
Avaliação A1
- Conteúdo avaliado serão as unidades 2 a 4 (cap 1 - 5)
- Data da avaliação (xx/xx/2020) - Local: LabSiDi.
Avaliação A2
- Conteúdo avaliado serão as unidades 5 a 8 (Cap 6 a 10)
- Data da avaliação (xx/xx/2020) - Local: LabSiDi.
Recuperação R12
- Esta avaliação somente será realizada se necessária, e deverá ser feita na última semana letiva do semestre
- Conteúdo avaliado será as unidades 2 a 8
- Data da avaliação (XX/XX/2020) - Local: LabSiDi.
- As avaliações A1 e A2 são com consulta apenas as folhas de consulta entregues:
- VHDL Quick Reference - SynthWorks
- VHDL Types and Operators Quick Reference - SynthWorks
- ModelSim Quick Reference - SynthWorks
- Tabelas das figuras 3.6, 3.10 e 4.1 do livro do Pedroni.
- Arquivo:Numeric std conversions.png
- Dica use também como fonte de consulta os templates do Quartus.
- Ao final das avaliações o aluno deverá enviar a avaliação para a plataforma Moodle com os arquivos solicitados.
Estudos livres sem entrega de documentação (EL)
- Os estudos livres são fortemente recomendados aos alunos como forma de melhor compreender o assunto estudado em cada unidade. Nas listas de exemplos e exercícios, os essenciais estão destacados em negrito. Não há prazos nem entregas desses estudos no Moodle, mas pede-se que os alunos realizem esses estudos e tirem suas dúvidas nas aulas destinadas a resolução de exercícios, ou nos minutos iniciais das aulas.
Referências Bibliográficas: