VHDL Introdução Paulo C. Centoducatte fevereiro de 2005

Slides:



Advertisements
Apresentações semelhantes
Chapter Five The Processor: Datapath and Control (Parte B: multiciclo)
Advertisements

Circuitos Lógicos e Organização de Computadores Capítulo 6 – Blocos com Circuitos Combinacionais Ricardo Pannain
Projecto de Hardware com FPGAs
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.
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 :=
The new way! The old way... TC – DEI, 2005/2006.
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 Sistemas Digitais.
VHDL AULA - 2.
Manipulação de Arquivos de Dados
Java: Comandos Básicos
VHDL Very High Speed Integrated Circuit Hardware Description Language Prof. Eduardo Todt 2008.
VHDL - uma visão geral 5 tipos de unidades
MC613 Laboratório de Circuitos Lógicos
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.
MC Prof. Paulo Cesar Centoducatte MC542 Organização de Computadores Teoria e Prática.
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.
MC542 Organização de Computadores Teoria e Prática
FLI – ModelSim Pedro Velho.
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}
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
SQL Procedural Junho/2006.
SQL procedural – parte 2.
2ª Aula Teórica Prof. Cesar Costa
Modelagem de Sistemas com VHDL
Stored Procedure, Function and Trigger
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.
EPUSP – PTC Guido Stolfi
Validação de VHDL: técnicas e ferramentas
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
Projeto de Circuito Combinacional Unidade Lógica e Aritmética (ULA)
ORGANIZAÇÃO E ARQUITETURA DE COMPUTADORES I prof. Dr. César Augusto M. Marcon prof. Dr. Edson Ifarraguirre Moreno Memórias.
Ney Laert Vilar Calazans
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.
Introdução ao VHDL João M. P. Cardoso.
1. 2 Objetivos 1.Análise dos resultados da primeira avaliação. Notas importantes para futuro. 2.Comunicação de placas baseadas em FPGAs com computador.
VHDL (Very High Speed Integrated Circuit HDL (VHSIC HDL)) GRECO CIn-UFPE.
Projeto de Circuitos Integrados Semidedicados Prof. Marcio Cunha Aula 04 – Linguagem de Descrição de Hardware: VHDL.
Introdução à Programação da FPGA
Projeto de Circuitos Integrados Semidedicados
Máquina de Estados Finitos com Dados (FSMD)
Lógica Sequencial e Máquina de Estados Finitos
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.
Projeto de Circuitos Integrados Semidedicados
Comandos sequenciais entity mux4_1 is
Transcrição da apresentação:

VHDL Introdução Paulo C. Centoducatte fevereiro de 2005 1 VHDL Introdução Paulo C. Centoducatte ducatte@ic.unicamp.br fevereiro de 2005

VHDL - Comandos seqüenciais 2 Chamada de procedimentos (também concorrente) Assertion (também concorrente) Assinalamento de sinal (também concorrente) Assinalamento de variáveis WAIT IF, CASE NEXT EXIT, RETURN, LOOP NULL

VHDL - Atribuição Condicional 3 Cláusula IF Cláusula WHEN Cláusula CASE

VHDL - Cláusula IF IF (condição 1) THEN Cláusula acertiva 1; 4 IF (condição 1) THEN Cláusula acertiva 1; ELSEIF (condição 2) THEN Cláusula acertiva 2; ELSE Cláusula acertiva 3; END IF;

VHDL - Cláusula IF Process (acao, cor) IF cor = verde THEN 5 Process (acao, cor) IF cor = verde THEN acao <= va_em_frente; ELSEIF cor = amarelo THEN acao <= atencao; ELSE acao <= pare; END IF;

VHDL - Cláusula IF latchD: process (dado,enable) begin 6 latchD: process (dado,enable) begin IF enable = ‘1’ THEN Q <= dado; notQ <= not dado END IF; end process latchD;

VHDL - Cláusula IF Architecture rtl of sps is 7 Architecture rtl of sps is signal prec : std_ulogic; signal Xsp : std_logic_vector(7 downto 0) := “00000000”; begin process(clk) if (clk´event and clk´last_value = ‘0’ and clk = ‘1’) then if en_sr = ‘0’ then ultimo_bit <= Xsp(7); Xsp(7 downto 1) <= Xsp(6 downto 0); Xsp(0) <= IO; elseif em_load = ‘1’ then Xsp <= bus_data; end if; end if; end process; end rtl; -- Conversor paralelo/serie -- shift right -- carga paralela

VHDL - Escrever o processo de um contador de 4 bits 8 Architecture rtl of contador is signal cont : unsigned(3 downto 0) := “0000”; begin process(reset,clk) if reset = ‘1’ then cont <= “0000”; elseif (clk´event and clk = ‘1’) then if enable = ‘1’ then if incr = ‘1’ then cont <= cont + “0001”; else cont <= cont - “0001”; end if; end if; end process; end rtl;

VHDL - Cláusula When (concorrente) 9 Atribuição WHEN condição sinal <= atribuição WHEN valor_expressão Exemplo: acao <= prosseguir WHEN sinal_verde;

VHDL - Seletor out <= in1 WHEN sel else in0; if sel = ‘1’ then 10 out <= in1 WHEN sel else in0; if sel = ‘1’ then out <= in1; else out <= in0; out <= in0 WHEN sel0 else in1 WHEN sel1 else in2 WHEN sel2 else in3 WHEN sel3 else inx;

VHDL- Cláusula With (concorrente) 11 WITH expressão SELECT signal <= atribuição WHEN valor_expressão Exemplo: WITH cor SELECT acao <= prosseguir WHEN “verde”, parar WHEN “vermelho”, alerta WHEN OTHERS;

VHDL- Cláusula With with regsel select 12 with regsel select z <= A after Tprop when “00’, B after Tprop when “01”, C after Tprop when “10”, D after Tprop when “11”, “X” after Tprop when others;

VHDL- Cláusula With signal Y : std_logic_vector(0 to3); 13 signal Y : std_logic_vector(0 to3); signal opcode : std_logic_vector(0 to 1); with opcode select Y <= “0001” when “00”, “0010” when “01”, “0100” when “10”, “1000” when “11”;

VHDL- Exercícios 14 Escrever o modelo vhdl de um multiplexador 2x1 com 8 bits de dados usando WHEN usando IF usando somente comando de atribuição simples Signal temp : std_logic_vector(7 downto 0); Begin temp <= (s,s,s, others => s); -- s é o sinal de seleção y <= (temp and IN1) or (not temp and IN0);

VHDL- Cláusula Case CASE sinal IS 15 CASE sinal IS WHEN “condição 1” => dado <= dado1; WHEN “condição 2” => dado <= dado2; WHEN others => dado <= dado3; END CASE;

VHDL- Cláusula Case signal p : integer range 0 to 3; 16 signal p : integer range 0 to 3; signal y : std_logic_vector(0 to 1); CASE p IS WHEN 0 => y <= “10”; WHEN 1 => y <= A; WHEN 2 => y <= B WHEN 3 => y <= “01”; END CASE;

VHDL - Comando NULL 17 Utilizado no caso de não ser necessário nenhuma ação em uma alternativa que precisa ser coberta Exemplo: case opcode is when add => Acc := Acc + operando; when sub => Acc := Acc - operando; when nop => NULL; end case;

VHDL - Exercício 18 Utilizado o comando case escreva um conversor do código binário para o código Gray

VHDL - Loop loop comando_1 comando_2; end loop; Exemplo: begin 19 loop comando_1 comando_2; end loop; Exemplo: begin count <= count_value; wait until clk = '1'; count_value := (count_value + 1) mod 16;

VHDL - Next e Exit begin count <= count_value; loop 20 begin count <= count_value; loop wait until clk = '1' or reset = '1'; exit when reset = '1'; count_value := (count_value + 1) mod 16; end loop; count_value := 0; -- at this point, reset = '1’ wait until reset = '0'; loop comando_1 next when condição; comando_2; end loop;

VHDL - While loops result <= sum; entity cos is 21 entity cos is port ( theta : in real; result : out real ); end entity cos; ….. sum := 1.0; term := 1.0; n := 0; while abs(term) > abs (sum / 1.0E6) loop n := n + 2; term := (-term) * theta**2 / real(((n-1) * n)); sum := sum + term; end loop; result <= sum; …

VHDL – For Loops entity cos is 22 entity cos is port ( theta : in real; result : out real ); end entity cos; ….. sum := 1.0; term := 1.0; for n in 1 to 9 loop term := (-term) * theta**2 / real(((2*n-1) * 2*n)); sum := sum + term; end loop; result <= sum;

VHDL – For Loops variable a, b : integer; begin a := 10; 23 variable a, b : integer; begin a := 10; for a in 0 to 7 loop b := a; end loop; -- a = 10, and b = 7 wait;

VHDL - Assertion [Label:] assert exp_booleana 24 [Label:] assert exp_booleana [report expressão [severity expressão]; Type severity_level is (note, warning, error, failure) assert valor <= max_valor; -- “Assertion violation” assert valor <= max_valor -- Severity = erro report “valor maior que o permitido"; assert valor <= max_valor report “valor maior que o permitido“ severity note;

VHDL - Assertion entity SR_flipflop is 25 entity SR_flipflop is port ( S, R : in bit; Q : out bit ); end entity SR_flipflop; architecture checking of SR_flipflop is begin set_reset : process (S, R) is assert S = '1' nand R = '1'; if S = '1' then Q <= '1'; end if; if R = '1' then Q <= '0'; end process set_reset; end architecture checking;

VHDL – Atributos de tipos escalar 26 Atributos comuns a todos os tipos escalares: T’left primeiro (mais a esquerda) valor em T T’right último (mais a direita) valor em T T’low menor valor em T T’high maior valor em T T’ascending TRUE se T o range de T é crescente T’image(x) string representando o valor de x T’value(s) o valor em T que é representado por s

VHDL - Atributos de tipos escalar 27 VHDL - Atributos de tipos escalar type resistance is range 0 to 1E9 units ohm; kohm = 1000 ohm; Mohm = 1000 kohm; end units resistance; type set_index_range is range 21 downto 11; type logic_level is (unknown, low, undriven, high); set_index_range'left = 21; set_index_range'right = 11; set_index_range'low = 11; set_index_range'high = 21; set_index_range'ascending = false; set_index_range'image(14) = "14"; set_index_range'value("20") = 20; resistance'left = 0 ohm; resistance'right = 1E9 ohm; resistance'low = 0 ohm; resistance'high = 1E9 ohm; resistance'ascending = true; resistance'image(2 kohm) = "2000 ohm"; resistance'value("5 Mohm") = 5_000_000 ohm;

VHDL - Atributos de tipos escalar 28 VHDL - Atributos de tipos escalar Atributos relativos aos tipos escalares discreto e físico: T’pos(x) número da posição de x em T T’val(n) valor em T na posição n T’succ(x) valor em T na posição maior que x T’pred(x) valor em T na posição menor que x T’leftof(x) valor em T na posição a esquerda de x T’rightof(x) valor em T na posição a direita de x

VHDL - Atributos de tipos escalar 29 VHDL - Atributos de tipos escalar type resistance is range 0 to 1E9 units ohm; kohm = 1000 ohm; Mohm = 1000 kohm; end units resistance; type set_index_range is range 21 downto 11; type logic_level is (unknown, low, undriven, high); logic_level'left = unknown; logic_level'right = high; logic_level'low = unknown; logic_level'high = high; logic_level'ascending = true; logic_level'image(undriven) = "undriven"; logic_level'value("Low") = low; logic_level'pos(unknown) = 0; logic_level'val(3) = high; logic_level'succ(unknown) = low; logic_level'pred(undriven) = low;

VHDL - Atributos de tipos array 30 VHDL - Atributos de tipos array Atributos A’left(N) A’right(N) A’low(N) A’high(N) A’range(N) A’reverse_range(N) A’length(N) A’ascending(N) Exemplo type A is array ( 1 to 4 , 31 downto 0) of boolean; A’left(1) = 1 A’right(2) = 0 A’low(1) = 1 A’high(2) = 31 A’range(1) is 1 to 4 A’reverse_range(2) is 0 to 31 A’length(2) = 32 A’ascending(1) = true A’ascending(2) = false

VHDL – Atributos de Sinais 31 S´delayed(T) - mesmo valor que S porém atrasado de T S´stable(T) - booleano: true se não houve evento em S S´quit(T) - booleano: true se não houve transação em S S´transaction - bit: alterna entre ´0´ e ´1´ a cada transação em S S´event - booleano: true se houve um evento em S S´active - booleano: true se houve uma transação em S S´last_event - intervalo de tempo desde o último evento em S S´last_active - intervalo de tempo desde a última transação em S S´last_value - valor de S antes do último evento

VHDL – Uso de Atributos Detecção de borda de relógio 32 Detecção de borda de relógio clk’EVENT and clk = ‘1’ Determinação de largura de pulso Sinal’LAST_EVENT >= 5 ns Teste de Hold e Setup clk’LAST_VALUE = ‘0’ AND clk = ‘1’ AND dado’STABLE(min_setup_time)

VHDL - Componente Declaração Instanciação Instanciação condicional 33 Declaração Instanciação Instanciação condicional Modelamento Estrutural

VHDL - Componente OBS.: Similar a ENTIDADE Declaração de um componente 34 Declaração de um componente component identifier [is] [generic (generic_interface_list);] [port (port_interface_list);] end component [identifier]; OBS.: Similar a ENTIDADE

VHDL - Componente Exemplo component flip-flop is 35 Exemplo component flip-flop is generic (Tprop, Tsetup, Thold : delay); port (clk: in bit; clr : in bit; d : in bit; q : out bit); end component flip_flop;

VHDL - Componente Instanciação 36 Instanciação Declaração de componente define o tipo do módulo Instaciação de componenente define seu uso em um projeto instatiation_label: [component ] componente_name [generic map (generic_association_list) ] [port map (port_association_list) ];

VHDL – Componente (exemplo) 37 Exemplo: entity reg4 is port ( clk, clr : in bit; d : in bit_vector(0 to 3); q : out bit_vector(0 to 3) ); end entity reg4; --------------------------------------------------------------------------- architecture struct of reg4 is component flipflop is generic ( Tprop, Tsetup, Thold : delay_length ); port ( clk : in bit; clr : in bit; d : in bit; q : out bit ); end component flipflop;

VHDL – Componente (exemplo) 38 begin bit0 : component flipflop generic map ( Tprop => 2 ns, Tsetup => 2 ns, Thold => 1 ns ) port map ( clk => clk, clr => clr, d => d(0), q => q(0) ); bit1 : component flipflop port map ( clk => clk, clr => clr, d => d(1), q => q(1) ); bit2 : component flipflop port map ( clk => clk, clr => clr, d => d(2), q => q(2) ); bit3 : component flipflop port map ( clk => clk, clr => clr, d => d(3), q => q(3) ); end architecture struct;

VHDL - Configuração configuration identifier of entity_name is 39 configuration identifier of entity_name is for architeture_name { for component_specification binding_indication; end for;} end for; end [ configuration] [ identifier];

VHDL - Componente Configuração 40 Configuração FOR nome_da_instancia|others|all: nome_componente -- component_specification USE ENTITY especificação_da_entidade; -- binding_indication END FOR; FOR inst51: xor_gate USE ENTITY lib_projeto.xor(arq_rtl); FOR bit0,bit1: flipflop use entity work.edge_triggered_Dff(basic); end for; FOR others: flipflop use entity work.edge_triggered_Dff(rtl);

VHDL – Exemplo Architecture rtl of top is Component and2 41 Architecture rtl of top is Component and2 port(a, b: in std_logic; c: out std_logic); End component; Component latchD port(d, clk : in std_ulogic; q, notq : out std_logic); For all : and2 use entity work.and2(rtl); For all : latchD use entity work.latchD(rtl); signal Q, NOTQ : std_ulogic := ‘1’; Begin inst_latchD: latchD port map(d1,clk, Q,NOTQ); inst_and2_a: and2 port map(d1,Q,S1); inst_and2_b: and2 port map(d2,NOTQ,S3); End rtl; OBS.: d1, d2 e clk são sinais de entrada e S1, S2 e S3 são sinais de saída