Mudanças entre as edições de "DI2022802 2021 1 AULA16"
Ir para navegação
Ir para pesquisar
Linha 115: | Linha 115: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | ==Parte 2 - Simulador== | ||
+ | |||
+ | # O que é o ModelSIM? | ||
+ | # Para que serve o ModelSIM? | ||
+ | # O que é o ''Jumpstart'' que aparece na primeira vez que se executa o ModelSIM? | ||
+ | # O que é um ''testbench''? | ||
+ | # O que eu devo fazer para rodar um simulação? Onde devo clicar? | ||
+ | # O que é ''Wave''? Esse termo é utiliza pra quê? | ||
+ | # O que é "passo da simulação"? | ||
+ | # O que é "tempo de simulação"? | ||
+ | # Tente simular o seguinte código VHDL abaixo. É importante estabelecer um passo de simulação na ordem 100 ps. Perceba também que, quando ele atinge a contagem de 15 ele para de contar. Tente resolver esse problema alterando o range e/ou mudando a forma com que as informações são enviadas para o saída. | ||
+ | <syntaxhighlight lang=vhdl> | ||
+ | library ieee; | ||
+ | use ieee.std_logic_1164.all; | ||
+ | use ieee.std_logic_arith.all; | ||
+ | |||
+ | entity CONTADOR is | ||
+ | port( | ||
+ | CLK: in std_logic; | ||
+ | RESET: in std_logic; | ||
+ | ENABLE: in std_logic; | ||
+ | Q: out std_logic_vector (3 downto 0) | ||
+ | ); | ||
+ | end CONTADOR; | ||
+ | |||
+ | architecture CONTADOR_arq of CONTADOR is | ||
+ | begin | ||
+ | process(CLK,RESET) | ||
+ | variable X: integer range 0 to 15; | ||
+ | begin | ||
+ | if (RESET = '1') then | ||
+ | X := 0; | ||
+ | |||
+ | elsif (CLK'event and CLK='1') then | ||
+ | if (ENABLE = '1') then | ||
+ | X := X + 1; | ||
+ | end if; | ||
+ | end if; | ||
+ | |||
+ | Q <= conv_std_logic_vector(X, 4); | ||
+ | |||
+ | end process; | ||
+ | end CONTADOR_arq; | ||
+ | </syntaxhighlight> | ||
+ | # Tente simular o seguinte código: | ||
+ | <syntaxhighlight lang=vhdl> | ||
+ | library ieee; | ||
+ | use ieee.std_logic_1164.all; | ||
+ | |||
+ | ENTITY mux4x1 is | ||
+ | port(i0, i1, i2, i3: in bit; | ||
+ | a0, a1: in bit; | ||
+ | y: out bit); | ||
+ | END mux4x1; | ||
+ | |||
+ | ARCHITECTURE teste of mux4x1 is | ||
+ | BEGIN | ||
+ | y <= i0 when a1='0' and a0='0' else | ||
+ | i1 when a1='0' and a0='1' else | ||
+ | i2 when a1='1' and a0='0' else | ||
+ | i3; | ||
+ | END teste; | ||
+ | </syntaxhighlight> | ||
Edição das 13h11min de 6 de setembro de 2021
Lista de Exercícios para AT2
Parte 1 - VHDL
- O que significa CPLD, FPGA e VHDL?
- Quais as principais vantagens no uso do VHDL?
- Quais as etapas de um ciclo de projeto de sistemas em VHDL?
- Qual a diferença entre uma Entidade (entity) e uma Arquitetura (architecture)?
- O que são os Ports?
- Que tipo de pinos (ports) existem e onde são aplicados?
- O que é uma Descrição comportamental?
- O que é uma Descrição por fluxo de dados?
- O que é uma Descrição estrutural?
- Quais são as regras para a formação dos Identificadores?
- O que é uma constante?
- Qual a diferença de Sinais e de Variáveis?
- Quais os tipos de dados disponíveis em VHDL?
- Projetar e simular:
- Biestável tipo JK com clock e borda de subida, com descrição comportamental.
- Idem, com Preset e Clear assíncronos
- Realizar o projeto de um contador síncrono, com uma sequência pré-definida em VHDL e simular.
- Comentar os exemplos:
- Exemplo 1
library ieee;
use ieee.std_logic_1164.all;
entity FF_D is
port
(
D : in std_logic;
clk : in std_logic;
Q : out std_logic
);
end FF_D;
architecture Ex1 of FF_D is
begin
-- Update the register output on the clock's rising edge
process (clk)
begin
if (rising_edge(clk)) then
Q <= D;
end if;
end process;
end Ex1;
- Exemplo 2
library ieee;
use ieee.std_logic_1164.all;
ENTITY ff_jk is
port(j,k,clk: in bit;
q: out bit);
END ff_jk;
ARCHITECTURE teste of ff_jk is
BEGIN
process(clk)
variable temp : bit :='0';
begin
if( falling_edge(clk) ) then
if (j='1' and k='0') then
temp:='1';
elsif (j='0' and k='1') then
temp:='0';
elsif (j='1' and k='1') then
temp:= not temp;
else
temp:=temp;
end if;
q<=temp;
end if;
end process;
END teste;
- Exemplo 3
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
entity CONTADOR is
port(
CLK: in std_logic;
RESET: in std_logic;
ENABLE: in std_logic;
Q: out std_logic_vector (3 downto 0)
);
end CONTADOR;
architecture CONTADOR_arq of CONTADOR is
begin
process(CLK,RESET)
variable X: integer range 0 to 15;
begin
if (RESET = '1') then
X := 0;
elsif (CLK'event and CLK='1') then
if (ENABLE = '1') then
X := X + 1;
end if;
end if;
Q <= conv_std_logic_vector(X, 4);
end process;
end CONTADOR_arq;
Parte 2 - Simulador
- O que é o ModelSIM?
- Para que serve o ModelSIM?
- O que é o Jumpstart que aparece na primeira vez que se executa o ModelSIM?
- O que é um testbench?
- O que eu devo fazer para rodar um simulação? Onde devo clicar?
- O que é Wave? Esse termo é utiliza pra quê?
- O que é "passo da simulação"?
- O que é "tempo de simulação"?
- Tente simular o seguinte código VHDL abaixo. É importante estabelecer um passo de simulação na ordem 100 ps. Perceba também que, quando ele atinge a contagem de 15 ele para de contar. Tente resolver esse problema alterando o range e/ou mudando a forma com que as informações são enviadas para o saída.
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
entity CONTADOR is
port(
CLK: in std_logic;
RESET: in std_logic;
ENABLE: in std_logic;
Q: out std_logic_vector (3 downto 0)
);
end CONTADOR;
architecture CONTADOR_arq of CONTADOR is
begin
process(CLK,RESET)
variable X: integer range 0 to 15;
begin
if (RESET = '1') then
X := 0;
elsif (CLK'event and CLK='1') then
if (ENABLE = '1') then
X := X + 1;
end if;
end if;
Q <= conv_std_logic_vector(X, 4);
end process;
end CONTADOR_arq;
- Tente simular o seguinte código:
library ieee;
use ieee.std_logic_1164.all;
ENTITY mux4x1 is
port(i0, i1, i2, i3: in bit;
a0, a1: in bit;
y: out bit);
END mux4x1;
ARCHITECTURE teste of mux4x1 is
BEGIN
y <= i0 when a1='0' and a0='0' else
i1 when a1='0' and a0='1' else
i2 when a1='1' and a0='0' else
i3;
END teste;