Array aggregates type columns is range 1 to 4; type row is array (columns) of std_logic; variable r1 : row := ('1', '0', '1', '1'); variable r2 : row :=

Slides:



Advertisements
Apresentações semelhantes
Aritmética Computacional
Advertisements

Circuitos Lógicos e Organização de Computadores Capítulo 8 –Circuitos Seqüenciais Síncronos Ricardo Pannain
Capítulo 2 - Introdução aos Circuitos Lógicos
Circuitos Lógicos e Organização de Computadores Capítulo 6 – Blocos com Circuitos Combinacionais Ricardo Pannain
Aula 2 – Sumário Transferências entre registos
Copyright (c) 2003 by Valery Sklyarov and Iouliia Skliarova: DETUA, IEETA, Aveiro University, Portugal.
VHDL VHSIC Hardware Description Language Very High Speed Integrated Circuits VHDL-87 VHDL-93.
VHDL VHSIC Hardware Description Language Very High Speed Integrated Circuits VHDL-87 VHDL-93.
abs access after alias all and architecture array assert attribute begin block body buffer bus case component configuration constant disconnect downto.
Árvores Equilibradas Sumário Splay Vermelho-Preto AA e BB
The new way! The old way... TC – DEI, 2005/2006.
©Silberschatz, Korth and Sudarshan (modificado)1Database System Concepts result := {R}; done := false; calcular F+; while (not done) do if (há um esquema.
VHDL - VHSIC Hardware Description Language
VHDL - VHSIC Hardware Description Language
Fernando Gehm Moraes Ney Laert Vilar Calazans
César Augusto Missio Marcon Ney Laert Vilar Calazans
VHDL Linguagem de Descrição e Síntese de Circuitos Digitais
VHDL Linguagem de Descrição e Síntese de Circuitos Digitais Sistemas Digitais.
VHDL AULA - 2.
Associação de resistores
VHDL Very High Speed Integrated Circuit Hardware Description Language Prof. Eduardo Todt 2008.
FAFIMAN – Prof. Flávio Uber FAFIMAN – Departamento de Informática Curso: Ciência da Computação Professor: Flávio Rogério Uber Arquitetura e Organização.
VHDL - uma visão geral 5 tipos de unidades
MC613 Laboratório de Circuitos Lógicos
VHDL - Tipos de dados compostos e operações
VHDL Introdução Paulo C. Centoducatte fevereiro de 2005
VHDL - Tipos de dados e operações
Introdução a circuitos lógicos
Verificação MO801/MC912.
Dicas de Circuitos MO801/MC912.
VHDL - Introdução MO801/MC912.
VHDL (outros tópicos) MO801/MC912.
MC542 Organização de Computadores Teoria e Prática
MC542 Organização de Computadores Teoria e Prática
MO Prof. Paulo Cesar Centoducatte MC542 Organização de Computadores Teoria e Prática.
Semana de Engenharia Introdução a Linguagem de Descrição de HW VHDL a ao Projeto Baseado em Lógica de Programação ALTERA Prof. Daniel Barros Júnior
FLI – ModelSim Pedro Velho.
A.4. Trabalhando com elementos de biblioteca STL – Standard Template Libraby Disponibiliza um conjunto de classes templates, provendo algoritmos eficientes.
Uma chave é normalmente aberta e a outra normalmente fechada
Library IEEE; use ieee.std_logic_1164.all; use IEEE.std_logic_arith.all;
Tipos de dados Existentes BIT - {0, 1} BIT_VECTOR - {vetor de BIT}
VERILOG HDL (HARDWARE DESCRIPTION LANGUAGE)
Máquina de Estados Uma máquina de estados finitos ou autômato finito é uma modelagem de um comportamento composto por estados, transições e ações Um estado.
Construção sequencial CASE WHEN
7 Abstração Genérica Unidades genéricas e instanciação.
1. Conceitos de Álgebra Booleana 2. Portas Lógicas e Inversores
2ª Aula Teórica Prof. Cesar Costa
Hierarquia de Memória Organização da cache
Fundamentos de Eletrônica Digital
Conversão entre base decimal e binária
Máquina de Estados Finito
ORGANIZAÇÃO E ARQUITETURA DE COMPUTADORES I prof. Dr. César Augusto M. Marcon prof. Dr. Edson Ifarraguirre Moreno Verificação por Simulação Circuitos Descritos.
Circuitos Seqüenciais Descrição VHDL
Instanciação em VHDL.
Circuitos Seqüenciais Contadores
Test-bench para Somador
ORGANIZAÇÃO E ARQUITETURA DE COMPUTADORES I prof. Dr. César Augusto M. Marcon prof. Dr. Edson Ifarraguirre Moreno Projeto de Somador com e sem Sinal Descrição.
ORGANIZAÇÃO E ARQUITETURA DE COMPUTADORES I prof. Dr. César Augusto M. Marcon prof. Dr. Edson Ifarraguirre Moreno Exercícios Circuitos Descritos em VHDL.
Diagramas de Blocos e Descrição VHDL
ORGANIZAÇÃO E ARQUITETURA DE COMPUTADORES I prof. Dr. César Augusto M. Marcon prof. Dr. Edson Ifarraguirre Moreno Memórias.
Tópicos em Arquitetura de Computadores João Angelo Martini Universidade Estadual de Maringá Departamento de Informática Mestrado em Ciência.
Subtrator e Somador BCD
Descrição de Circuitos Combinacionais em VHDL
Projetos Grandes MO801/MC912. Roteiro Componentes Configurações Instanciação múltipla Instanciação condicional Atenção: Os exemplos são cumulativos.
ORGANIZAÇÃO E ARQUITETURA DE COMPUTADORES I prof. Dr. César Augusto M. Marcon prof. Dr. Edson Ifarraguirre Moreno Exercícios Circuitos Descritos em VHDL.
Introdução a VHDL Monitoria de Digitais.
Verilog HDL. Introduzida em 1985 pela Gateway Design System Corporation Após 1990, passou a ser de domínio público, e em 1995 passou a ser padrão IEEE.
Unidade 1 – Portas Lógicas Básicas – NOR, NAND, XOR e XNOR.
PORTAS LóGICAS Samuel S. S. Sistemas para internet
Comandos sequenciais entity mux4_1 is
Transcrição da apresentação:

Array aggregates type columns is range 1 to 4; type row is array (columns) of std_logic; variable r1 : row := ('1', '0', '1', '1'); variable r2 : row := (1 => '1', 2 => '0', others => '1'); variable r3 : row := (1 => '1', 2 => '0', 3 to 4 => '1'); variable r4 : row := (2 => '0', others => '1'); variable r5 : row := (1 | 3 | 4 => '1', 2 => '0'); variable r6 : row := ('0', 2 | 3 => '1', 4 => '0'); -- erro associação posicional associação nomeada 1011 r1 – r5

Array aggregates variable m3 : matrix2 := ( ('0', '0', '0', '0'), ('1', '1', '1', '1')); variable m4 : matrix1 := ((others => '0'), (others => '1')); variable m5 : matrix1 := (others => (others => '1')); variable m6 : matrix1 := (1 => (1|2 => '1', 3|4 => '0'), 2=> (1 => '0', others => '1')); m3, m m m6 type rows is range 1 to 2; type columns is range 1 to 4; type row is array (columns) of std_logic; type matrix1 is array (rows) of row; type matrix2 is array (rows, columns) of std_logic;

type mapping is array (character range 'a' to 'b', 1 to 3) of std_logic; variable mapa : mapping := ('a' => (others => '0'), 'b' => (1 => '1', 2 => '0', 3 => '1')); a b 1 2 3

entity bcd_code is Port ( bin : in std_logic_vector(3 downto 0); bcd : out std_logic_vector(4 downto 0)); end bcd_code; architecture Behavioral of bcd_code is type codes is array (0 to 15) of std_logic_vector(4 downto 0); constant code : codes := ( "00000", "00001", "00010", "00011", "00100", "00101", "00110", "00111", "01000", "01001", "10000", "10001", "10010", "10011", "10100", "10101 ); begin bcd <= code(conv_integer(bin)); end Behavioral;

type type_name is array (range) of type_of_elements; type RAM is array (9 downto 0) of std_logic_vector(7 downto 0); signal my_RAM : RAM; architecture Behavioral of VHDL_test is type RAM is array (9 downto 0) of std_logic_vector(7 downto 0); signal my_RAM : RAM; begin process(clk,reset) variable tmp : integer range 0 to 9; begin if reset = '1' then tmp := 0; elsif rising_edge(clk) then my_RAM(tmp) <= data_in + conv_std_logic_vector(tmp,8); if (tmp < 9) then tmp := tmp + 1; else tmp := 0; end if; end if; end process; my_RAM(0) = my_RAM(1) = my_RAM(2) = my_RAM(3) = my_RAM(4) = my_RAM(5) = my_RAM(6) = my_RAM(7) = my_RAM(8) = my_RAM(9) = data_in =

Agregados na atribuição signal reg : std_logic_vector(3 downto 0); signal ms, b2, b1, ls : std_logic; ms <= reg(3); b2 <= reg(2); b1 <= reg(1); ls <= reg(0); (ms, b2, b1, ls) <= reg; =

Atributos de arrays type'left(N);-- índice esquerdo da dimensão N do tipo (array) type type'right(N);-- índice direito da dimensão N do tipo (array) type typelow(N);-- índice menor da dimensão N do tipo (array) type typehigh(N);-- índice maior da dimensão N do tipo (array) type typerange(N);-- gama de índices da dimensão N do tipo (array) type typereverse_range(N);-- gama de índices invertida da dimensão N -//- typelength(N);-- número de índices da dimensão N do tipo (array) type typeascending(N);-- true se gama de índices da dimensão N do tipo (array) type é uma gama ascendente type matrix2 is array (rows, columns) of std_logic; type matriz is array (1 to 3, 3 downto 0) of std_logic; type mapping is array (character range 'a' to 'b', 1 to 3) of std_logic; variable m2 : matrix2; variable mapa : mapping; mapa'left(1) = 'a' mapping'right(1) = 'b' mappinghigh(2) = 3 mapa'length = 2 mapa'ascending(2) = true for i in mapa'reverse_range(1) loop --'b' downto 'a' end loop; matriz'ascending(2) = false m2'low(2) = 1 O número N pode ser omitido quando se refere à primeira dimensão.

Arrays não restringidos Os arrays não restringidos não especificam os limites para os seus índices, indicando apenas o tipo dos índices e o tipo de elementos a guardar. Quando se declara um objecto deste tipo é necessário indicar a gama de índices possíveis. type inteiro is array (natural range <> ) of integer; variable v1 : inteiro (3 to 8); variable v2 : inteiro (10 downto 0); 1. Indicação explícita subtype small_int is inteiro (0 to 64); variable v3 : small_int; 2. Sub-tipos constant c1 : inteiro := (1 => 1, 2 => 2, 3 => 3); constant c2 : inteiro := (1, 2, 3); 3. Inicialização de constantes com agregados

Arrays não restringidos predefinidos type string is array (positive range <>) of character; constant linha1 : string := "Os nomes sao"; constant linha2 : string (1 to 12) := "Os nomes sao"; constant linha3 : string (30 downto 28) := "Ola"; type bit_vector is array (natural range <>) of bit; type std_logic_vector is array (natural range <>) of std_logic; É possível utilizar strings e bit strings para inicializar arrays cujos elementos são do tipo enumerativo que inclui caracteres. signal s4 : std_logic_vector(3 downto 0); s4 <= "010-"; s4 <= x"f"; s4(s4'high - 1 downto s2'low) <= o"5"; std_logic_1164

Portas não restringidas entity porta_or is Port ( input : in std_logic_vector; result : out std_logic); end porta_or; architecture beh of porta_or is begin process (input) is variable temp : std_logic; begin temp := '0'; for i in input'range loop temp := temp or input(i); if (temp = '1') then exit; end if; end loop; result <= temp; end process; end beh; entity calc is Port ( vector1 : in std_logic_vector(1 downto 0); vector2 : in std_logic_vector(7 downto 0); vector3 : in std_logic_vector(0 to 15); r1 : out std_logic; r2 : out std_logic; r3 : out std_logic); end calc; architecture Behavioral of calc is begin v1: entity work.porta_or(beh) port map (input => vector1, result => r1); v2: entity work.porta_or(beh) port map (input => vector2, result => r2); v3: entity work.porta_or(beh) port map (input => vector3, result => r3); end Behavioral;

Operações sobre arrays Operações lógicas not, and, or, nand, nor, xor, xnor podem ser aplicadas a um ou a dois arrays unidimensionais desde que estas operações sejam definidas para os elementos dos arrays. Operações de deslocamento sll, srl, sla, sra, rol, ror podem ser aplicadas a um array unidimensional (operando esquerdo) de bits ou valores booleanos. Operações comparativas podem ser aplicadas a dois arrays unidimensionais cujos elementos são de qualquer tipo discreto. entity arr_op is Port ( x : in std_logic_vector(7 downto 0); y : in std_logic_vector(7 downto 0); gr : out std_logic); end arr_op; architecture Beh of arr_op is begin process (x, y) is begin if (x > y) then gr <= '1'; else gr <= '0'; end if; end process; end Beh; O operador de concatenação & pode ser aplicado a dois arrays unidimensionais e a valores escalares. cmd <= "0011" & digit_dec; cmd <= " " & 1';

Array slices Servem para especificar um subconjunto de elementos num array. A direcção de índices num slice deve ser idêntica à direcção de índices no array. signal x : std_logic_vector(7 downto 0); signal y : std_logic_vector(7 downto 0); signal s1 : std_logic_vector(3 downto 0); signal s2 : std_logic_vector(0 to 3); s1 <= x (7 downto 4); s1 <= y (0 to 3); -- erro s2 <= x (7 downto 4); s2 <= y (3 downto 0); y (0 downto 3); -- null slice

Conversão entre tipos Um valor do tipo array pode ser convertido num outro valor de outro tipo array desde que ambos os tipos tenham: - o mesmo tipo de elementos; - o mesmo número de dimensões; - os tipos de índices que podem ser convertidos. type arr1 is array (b downto a, 1 to 2) of std_logic; type arr2 is array (a to b, 3 to 4) of std_logic; variable v1 : arr1; variable v2 : arr2; v2 := (v1); -- erro v2 := arr2(v1);

Quando atribuímos um valor de um subtipo a um objecto de um outro subtipo do mesmo tipo, a conversão ocorre automaticamente. subtype BE is std_logic_vector(0 to 3); subtype LE is std_logic_vector(3 downto 0); subtype M is std_logic_vector(20 to 23); variable b : BE; variable l : LE; variable m : M; b := x"b"; l := b; m := b; b l m

Records - composição de elementos de vários tipos. entity rec is Port ( clk : in std_logic; d : in std_logic_vector(7 downto 0)); end rec; architecture Behavioral of rec is type sp is record start_bit : std_logic; data_bits : std_logic_vector (7 downto 0); parity_bit : std_ulogic; stop_bit : std_logic; end record sp; signal s1, s2 : sp; begin s1.data_bits <= d; s2 <= s1; end Behavioral;

Agregados em records constant c1 : sp := (start_bit => '1', data_bits => x"f5", parity_bit => '0', stop_bit => '1'); constant c2 : sp := ('1', x"f5", '0', '1'); constant c3 : sp := (data_bits => x"f5", parity_bit => '0', stop_bit => '1', start_bit => '1'); type sp is record start_bit : std_logic; data_bits : std_logic_vector (7 downto 0); parity_bit : std_ulogic; stop_bit : std_logic; end record sp; associações posicionais e nomeadas

code of entity architecture Behavioral of VHDL_test is -- declaração de bit3,…,bit0 e my_bus begin bit3 <= '0'; bit2 <= '1'; bit1 <= '1'; bit0 <= '1'; my_bus bit3, 2=>bit2, 1=>bit1, 3=>bit0); data_out <= my_bus; end Behavioral; Isto é uma associação nomeada Example in VHDL_AF.zip

code of entity architecture Behavioral of VHDL_test is signal my_bus : std_logic_vector(3 downto 0); begin my_bus '1', others => '0'); data_out <= my_bus; -- valor 3 end Behavioral; Os elementos podem ser agrupados. Palavra chave others indica os restantes elementos Example in VHDL_AF.zip

code of entity architecture Behavioral of VHDL_test is type my_packet is record first_bit: std_logic; second_bit : std_logic; data: std_logic_vector (1 downto 0); end record; signal record_data: my_packet; begin record_data <= ('0', '1', "01"); data_out <= record_data.first_bit & record_data.second_bit & record_data.data;-- valor 5 end Behavioral; Example in VHDL_AF.zip

code of entity architecture Behavioral of VHDL_test is type my_array is array(3 downto 0) of std_logic; type my_packet is array(0 to 5) of my_array; signal my_data: my_packet := (others => "0110"); begin data_out <= my_data(2)(3) & my_data(2)(2) & my_data(2)(1) & my_data(2)(0); -- valor 6 end Behavioral; 3210 std_logic my_array my_packet my_data Example in VHDL_AF.zip

architecture Behavioral of VHDL_test is type my_array is array(3 downto 0) of std_logic; type my_packet is array(0 to 5) of my_array; signal my_data: my_packet := (others => "0110"); process(reset,clk) variable my_ind : integer range 0 to 5; begin if reset = '1' then my_data "1000", 3=>"1001", others => "0100"); my_ind := 0; elsif rising_edge(clk) then data_out <= my_data(my_ind)(3) & my_data(my_ind)(2) & my_data(my_ind)(1) & my_data(my_ind)(0); index_out <= conv_std_logic_vector(my_ind,4); if my_ind = 5 then my_ind := 0; else my_ind := my_ind + 1; end if; end process; end Behavioral; inicialização saída de dados para índice my_ind output to display index on LCD a sequência dos índices 0,1,2,3,4,5 Example in VHDL_AF.zip

type type_name is array (range) of type_of_elements; type RAM is array (9 downto 0) of std_logic_vector(7 downto 0); signal my_RAM : RAM; architecture Behavioral of VHDL_test is type RAM is array (9 downto 0) of std_logic_vector(7 downto 0); signal my_RAM : RAM; begin process(clk,reset) variable tmp : integer range 0 to 9; begin if reset = '1' then tmp := 0; elsif rising_edge(clk) then my_RAM(tmp) <= data_in + conv_std_logic_vector(tmp,8); if (tmp < 9) then tmp := tmp + 1; else tmp := 0; end if; end if; end process; my_RAM(0) = my_RAM(1) = my_RAM(2) = my_RAM(3) = my_RAM(4) = my_RAM(5) = my_RAM(6) = my_RAM(7) = my_RAM(8) = my_RAM(9) = data_in =

objectonome_de_atributo; process(clk,reset) begin if falling_edge(clk) then for i in my_RAM'reverse_range loop -- o resultado é (ASCII – 9) data_out <= my_RAM(i); end loop; end if; end process; process(clk,reset) begin if falling_edge(clk) then for i in my_RAM'range loop -- o resultado é (ASCII – 0) data_out <= my_RAM(i); end loop; end if; end process;

objectattribute_name; process(clk,reset) variable tmp : integer range 0 to 9; begin if reset = '1' then tmp := 0; elsif falling_edge(clk) then data_out <= my_RAM(tmp); index_out <= "000" & my_RAM(tmp)(my_RAM(tmp)'right); index_out <= "000" & my_RAM(tmp)(my_RAM(tmp)'left); index_out <= x"30" + conv_std_logic_vector((my_RAM'length)-1,8); --my_RAM'high - my_RAM'low + 1- o resultado é 9 index_out <= x"30" + conv_std_logic_vector(my_RAM(0)'length,8); if (tmp < 9) then tmp := tmp + 1; else tmp := 0; end if; end if; end process; index_out <= "000" & my_RAM(tmp)(my_RAM(tmp)'right); bit direito bit esquerdo o resultado é (ASCII – 8) length

type nome_de tipo is especificação_de_tipo; Tipos escalares predefinidos são: integer, real, bit, Boolean, character subtype word8 is std_logic_vector (8 downto 1); type serial_pac is array (0 to 8) of word8; constant line_RS : serial_pac := ( x"1B", --delete display x"44", --delete display x"4C", --delete display x"1B", --draw line (ESC) x"47", --draw line (code of this operation) x"30",-- x1 left point x"15",-- y1 upper point x"E6",-- x2 right point x"72");-- y2 bottom point type positive_integers is range 0 to integer'high; type FSM_states is (start, increment, save, decrement,repeat); signal state : FSM_states; signal p_i : positive_integers;

type serial_package is record start_bit : std_logic; data_bits : std_logic_vector (7 downto 0); parity_bit : std_ulogic; stop_bit : std_logic; number : integer range 0 to 127; end record; signal my_sp : serial_package; my_sp.number <= 10; my_sp.start_bit <= '1'; my_sp.data_bits '1'); Atribuição de bits individuais

use IEEE.NUMERIC_STD.ALL;-- para to_unsigned index_out <= conv_std_logic_vector(index,4); for_op1 <= conv_integer(data_in(7 downto 5)); index_out <= std_logic_vector(to_unsigned(character'pos('6'),4)); index_out <= std_logic_vector(to_unsigned(character'pos(line2(1)), 8)); target_type(expressão)function(expressão) Só as expressões relacionadas podem ser convertidas type my_array is array (0 to 5) of std_logic; signal mem1 : my_array; signal mem2 : std_logic_vector (0 to 5); --mem1 <= mem2; erro mem1 <= my_array(mem2);-- OK mem2 <= std_logic_vector(mem1);-- OK exemplos:

Para conversão de tipos não relacionados pode-se usar funções definidas pelo utilizador, por exemplo: architecture Behavioral of VHDL_test is function Bollean_to_std_logic(input : Boolean) return std_logic is begin if input then return '1'; else return '0'; end if; end Bollean_to_std_logic; begin index_out <= "000" & Bollean_to_std_logic(true);

subtype tiny is integer range 0 to 63; subtype part_of_std is std_logic range '1' to '-'; subtype nome_de_subtipo is tipo_base range intervalo_de_valores; 1)'1'- logical 1 2)'0'- logical 0 3)'H' – weak 1 4)'L' – weak 0 5)'X' – unknown 6)'U' – uninitialized 7)'Z' – high impedance 8)'-' – don't care 9)'W' – weak unknown std_logic values subtype word8 is std_logic_vector (8 downto 1); type serial_pac is array (0 to 8) of word8; constant line_RS : serial_pac := ( x"1B", --delete display x"44", --delete display x"4C", --delete display x"1B", --draw line (ESC) x"47", --draw line (code of this operation) x"30",-- x1 left point x"15",-- y1 upper point x"E6",-- x2 right point x"72");-- y2 bottom point