DLP29006-Engtelecom (Diário) - Prof. Marcos Moecke
Registro on-line das aulas
Unidade 1 - Introdução a disciplina
- 3 ENCONTROS
Unidade 1 - Introdução a disciplina | ||
---|---|---|
|
|}
-->
- FUNCTION e PROCEDURE (são chamados de subprogramas), e podem ser construídos em um PACKAGE, ENTITY, ARCHITECTURE, ou PROCESS.
A instrução ASSERT é útil para verificar as entradas de um subprograma. Seu propósito não é criar circuito, mas assegurar que certos requisitos são atendidos durante a síntese e/ou simulação. Pode ser condicional ou incondicional (condição_booleana = FALSE). A sintaxe da instrução é:
[rótulo:] assert condição_booleana
[report mensagem]
[severity nivel_severidade];
A mensagem pode ser criada usando STRINGs que podem ser concatenadas.
O nível de severidade pode ser NOTE (para passar informação para o compilador/simulator), WARNING (para informar que algo não usual ocorreu), ERROR (para informar que alguma condição não usual "sério" ocorreu), ou FAILURE (para informar que uma condição não aceitável ocorreu). Normalmente o compilador para quando ocorre um ERROR ou FAILURE. ERROR é o valor "default" [1].
- A FUNCTION: declaração, uso, mapeamento posicional x nominal, PURE x IMPURE.
function nome_funçao (lista_parametros_entrada) return tipo_saida is
declarações
begin
afirmações sequenciais
end function;
- A PROCEDURE: declaração e uso
procedure nome_procedimento (lista_parâmetros_entrada, lista_parâmetros_saída) is
declarações
begin
afirmações sequenciais
end procedure;
- Exemplos de uso ASSERT, FUNCTION e PROCEDURE
- Exemplo: Cálculo do log2 de um número inteiro. Pode ser usado para determinar o número de bits necessário para um número natural.
function log2c (n : integer) return integer is
variable m , p : integer;
begin
m := 0;
p : = 1;
while p < n loop
m : = m + 1;
p := p * 2;
end loop;
return m;
end log2c;
- Exemplo: Declaração de FUNCTION em ARCHITECTURE Ex.9.1
- Aplicação no projeto do timer0_9
- Exemplo: Declaração em FUNCTION PACKAGE Ex. 9.2
-- FILE: comparator.vhd
-- Fonte: PEDRONI, Volnei A. Circuit Design and Simulation with VHDL; 2 ed. Massachusetts-EUA:MIT, 2010.
library ieee;
use ieee.numeric_std.all;
use work.my_package.all;
entity organizer is
generic (size : natural := 3);
port
(
x : in UNSIGNED(2 to 5);
y : out UNSIGNED(size - 1 downto 0)
);
end entity;
architecture organizer of organizer is
begin
y <= order_and_fill(x, size);
end architecture;
-- FILE: my_pkg.vhd
-- Fonte: PEDRONI, Volnei A. Circuit Design and Simulation with VHDL; 2 ed. Massachusetts-EUA:MIT, 2010. 608 p. ISBN 9780262014335
library ieee;
use ieee.numeric_std.all;
package my_package is
function order_and_fill (input : UNSIGNED; bits : natural) return UNSIGNED;
end package;
package body my_package is
function order_and_fill (input : UNSIGNED; bits : natural) return UNSIGNED is
variable a : UNSIGNED(input'LENGTH - 1 downto 0);
variable result : UNSIGNED(bits - 1 downto 0);
begin
assert (input'LENGTH <= bits)
report "Improper input size!"
severity FAILURE;
if (input'LEFT > input'RIGHT) then
a := input;
else
for i in a'range loop
a(i) := input(input'LEFT + i);
end loop;
end if;
if (a'LENGTH < bits) then
result(bits - 1 downto a'LENGTH) := (others => '0');
result(a'LENGTH - 1 downto 0) := a;
else
result := a;
end if;
return result;
end function;
end package body;
- Exemplo: min_max Ex.9.4
Figura 6.1 - Fluxograma da PROCEDURE min_max
-- FILE: comparator.vhd
-- Fonte: PEDRONI, Volnei A. Circuit Design and Simulation with VHDL; 2 ed. Massachusetts-EUA:MIT, 2010.
use work.my_package.all;
entity comparator is
port
(
a, b, c : in integer range 0 to 255;
min, max : out integer range 0 to 255
);
end entity;
architecture comparator of comparator is
begin
min_max(a, b, c, min, max);
end architecture;
-- FILE: my_pkg.vhd
-- Fonte: PEDRONI, Volnei A. Circuit Design and Simulation with VHDL; 2 ed. Massachusetts-EUA:MIT, 2010.
package my_package is
procedure min_max (
signal a, b, c : in integer;
signal min, max : out integer
);
end package;
package body my_package is
procedure min_max (
signal a, b, c : in integer range 0 to 255;
signal min, max : out integer range 0 to 255) is
begin
if (a >= b) then
if (a >= c) then
max <= a;
if (b >= c) then
min <= c;
else
min <= b;
end if;
else
max <= c;
min <= b;
end if;
else
if (b >= c) then
max <= b;
if (a >= c) then
min <= c;
else min <= a;
end if;
else
max <= c;
min <= a;
end if;
end if;
end procedure;
end package body;
- Exercícios: 9.1 a 9.4, 9.6 a 9.9
- Ver pag. 213 a 239 de [1])
- Aula 43 e 44 (12 mar) (presencial - Sábado 8h00 as 11h30)
- AE12 - Laboratório de programação de FPGA - Relógio Digital de 24 horas
|}
-->
- Aula 45 (15 mar)
- Projeto de FSM temporizadas (nas quais as transições são ativadas também pelo tempo).
Figura 7.9 - Tipos de FSM (Condicional, Temporizada e Hibrida)
- Modelo de FSM temporizada
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
----------------------------------------------------------
ENTITY < entity_name > IS
PORT (
clk, rst : IN STD_LOGIC;
input : IN < data_type > ;
output : OUT < data_type >);
END entity;
----------------------------------------------------------
ARCHITECTURE < architecture_name > OF < entity_name > IS
TYPE state IS (A, B, C, ...);
SIGNAL pr_state, nx_state : state;
signal timer: integer range 0 to MAX;
-- ATTRIBUTE ENUM_ENCODING : STRING; --optional attribute
-- ATTRIBUTE ENUM_ENCODING OF state : TYPE IS "sequential";
BEGIN
------Logica Sequencial da FSM:------------
PROCESS (clk, rst)
variable count: integer range o to MAX;
BEGIN
IF (rst = '1') THEN
pr_state <= A;
count := 0;
ELSIF (clk'EVENT AND clk = '1') THEN
count := count + 1;
if (count >= timer) then
pr_state <= nx_state;
count := 0;
end if;
END IF;
END PROCESS;
------Logica Combinacional da FSM:------------
PROCESS (pr_state, input)
BEGIN
------Valores default das saidas------------
output <= < value >;
------Valores default do timer------------
timer <= <value>;
CASE pr_state IS
WHEN A =>
output <= < value > ; -- apenas se diferente do valor default
IF (input =< value >) THEN
timer <= <value>; -- apenas se diferente do valor default
nx_state <= B;
...
ELSE
timer <= <value>; -- apenas se diferente do valor default
nx_state <= A;
END IF;
WHEN B =>
output <= < value > ; -- apenas se diferente do valor default
IF (input =< value >) THEN
timer <= <value>; -- apenas se diferente do valor default
nx_state <= C;
...
ELSE
timer <= <value>; -- apenas se diferente do valor default
nx_state <= B;
END IF;
WHEN ...
END CASE;
END PROCESS;
------Seção de Saída (opcional):-------
PROCESS (clk, rst)
BEGIN
IF (rst = '1') THEN
new_output <= < value > ;
ELSIF (clk'EVENT AND clk = '1') THEN --or clk='0'
new_output <= output;
END IF;
END PROCESS;
END architecture;
- Ver pag. 298 a 301 de [1]
- Exemplo de FSM temporizada - semáforo temporizado
- Usando o template acima descreva em VHDL a FSM de um controlador de semáforo Regular indicado pela FSM da figura abaixo:
Figura 7.10 - Diagrama de estados do controlador de semáforo
Figura 7.11 - Simulação do controlador de semáforo no Modelsim
Exercício - Semaforo |
---|
Figura 7.12 - Diagrama de estados do controlador de semáforo Figura 7.13 - Diagrama de estados do Quartus do controlador de semáforo |
-->
- 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.
ATIVIDADE EXTRA-CLASSE (AE)
A soma das atividades Extra-classe será correspondente a 25% do conceito final na disciplina. A entrega das mesmas será feita pelo Moodle da disciplinas, e cada dia de atraso irá descontar 0,2 na nota da atividade. Muitas dessas atividades também possuem BÔNUS que são adicionados aos conceitos das avaliações A1 e A2. Para os BÔNUS só serão considerados projetos entregues no prazo.
AE1 - Palavras-cruzadas INTRODUÇÃO
AE1 - Palavras-cruzadas INTRODUÇÃO |
---|
|
AE2 - Conhecendo os dispositivos lógicos programáveis
AE2 - Conhecendo os dispositivos lógicos programáveis |
---|
|
AE3 - SNCT 2021 | 5G e Conectividade com IoT
AE3 - SNCT 2021 |
---|
5G e Conectividade com IoT |
Após assistir a palestra e debate do dia de hoje, seguem algumas perguntas que devem ser respondidas em um PDF.
|
AE4 - Programação do kit Mercurio IV
AE4 - Programação do kit Mercurio IV |
---|
entity counter is
generic (WIDTH : in natural := 4);
port (
RST : in std_logic;
CLK : in std_logic;
LOAD : in std_logic;
DATA : in std_logic_vector(WIDTH-1 downto 0);
R0 : out std_logic
Q : out std_logic_vector(WIDTH-1 downto 0));
end entity;
architecture ifsc_v1 of counter is
signal Q_aux : std_logic(WIDTH-1 downto 0);
begin
process(RST,CLK) is
begin
if RST = '1' then
Q_aux <= (others => '0');
elsif rising_edge(CLK) then
if LOAD= '1' then
Q_aux <= DATA;
else
Q_aux <= std_logic_vector(unsigned(Q_aux) + 1);
end if;
end if;
end process;
-- Adaptacao feita devido a matriz de leds acender com ZERO
Q <= not Q_aux;
-- Para acender um led eh necessario colocar ZERO na linha correspondente da matriz.
R0 <= '0';
end architecture;
CLK: PIN_Y17 ou PIN_V21 DATA[3]: PIN_H18 DATA[2]: PIN_H20 DATA[1]: PIN_K21 DATA[0]: PIN_J21 LOAD: PIN_Y22 Q[3]: PIN_J6 Q[2]: PIN_K8 Q[1]: PIN_J8 Q[0]: PIN_L8 RST: PIN_W21 R0: PIN_F10
-- insira na declaração das portas da entity a linha
LCD_BACKLIGHT: out std_logic;
-- insira na architecture a linha
LCD_BACKLIGHT <= '0';
LCD_BACKLIGHT: PIN_V10
entity COUNTER_db is
...
CLK50MHz : in std_logic;
...
end entity
architecture ifsc_v2 of COUNTER_db is
...
signal CLK_db: std_logic := '0';
...
begin
-- debouncer de 10ms
process (CLK50MHz, CLK, RST, CLK_db) is
constant max_cnt: natural := 500000; -- 500000 10ms para clk 20ns
variable cnt_db : integer range 0 to max_cnt-1;
begin
if (RST = '1') then
cnt_db := 0;
CLK_db <= '0';
elsif ((CLK = '0') and (CLK_db = '0')) or
((CLK = '1') and (CLK_db = '1')) then
cnt_db := 0;
elsif (rising_edge(CLK50MHz)) then
if (cnt_db = max_cnt - 1) then
CLK_db <= not CLK_db;
else
cnt_db := cnt_db + 1;
end if;
end if;
end process;
...
-- Troque no process(RST,CLK) a entrada '''CLK''' do circuito anterior pela entrada '''CLK_db'''
CLK50MHz: PIN_T1
create_clock -name CLK50MHz -period 50MHz [get_ports -no_case {clk*}]
|
AE5 - Desafio das vagas de garagem
AE5 - Desafio das vagas de garagem |
---|
|
AE6 - Conversor de binário para BCD
AE7 - Estudo dos atributos de objetos e de síntese
AE8 - Estudo dos Arrays
AE8 - Estudo dos Arrays |
---|
entity array_1Dx1D_integer is
port (
row : in integer range 1 to 3;
slice : out integer range 0 to 15
);
end entity;
architecture teste of array_1Dx1D_integer is
type a1Dx1D_integer is array (1 to 3) of integer range 0 to 15;
constant table : a1Dx1D_integer := (15, 5, 7);
begin
slice <= table(row);
end architecture;
entity array_1Dx1D_bit is
port (
row : in integer range 1 to 3;
column : in integer range 0 to 4; --3 bits
slice1 : out bit;
slice2 : out bit_vector(1 to 2);
slice3 : out bit_vector(1 to 4);
slice4 : out bit_vector(1 to 3)
);
end entity;
architecture teste of array_1Dx1D_bit is
type a1Dx1D_bit is array (1 to 3) of bit_vector(1 to 4);
constant table : a1Dx1D_bit :=
(('1', '1', '1', '1'), --15
('0', '1', '0', '1'), -- 5
('0', '1', '1', '1')); -- 7
begin
--slice1 <= table(row)(column);
--slice2 <= table(row)(1 to 2);
--slice3 <= table(row)(1 to 4);
--slice4 <= table(1 TO 3)(column);
--slice4 <= table(1)(column) & table(2)(column) & table(3)(column);
--gen : for i in 1 to 3 generate
-- slice4(i) <= table(i)(column);
--end generate;
end architecture;
entity array_2D_bits is
port (
row : in integer range 0 to 3;
column : in integer range 0 to 4; --3 bits
slice1 : out bit;
slice2 : out BIT_VECTOR(1 to 2);
slice3 : out BIT_VECTOR(1 to 4);
slice4 : out BIT_VECTOR(1 to 3)
);
end entity;
architecture teste of array_2D_bits is
type a2D_bits is array (1 to 3, 1 to 4) of bit;
constant table : a2D_bits := (('0', '0', '0', '1'),
('1', '0', '0', '1'), ('1', '1', '0', '1')
);
begin
--slice1 <= table(row, column);
--slice2 <= table(row, 1 TO 2);
--slice3 <= table(row, 1 TO 4);
--slice4 <= table(1 TO 3, column);
--slice4 <= table(1, column) & table(2, column) & tabl
--gen : for i in 1 to 3 generate
-- slice4(i) <= table(i, column);
--end generate;
end architecture;
--Acessando uma linha de uma matriz
gen1 : for j in 1 to 4 generate
slice3(j) <= table(row, j);
end generate;
-- Acessando uma coluna de uma matriz
gen2 : for i in 1 to 3 generate
slice4(i) <= table(i, column);
end generate;
|
AE9 - Calculadora básica implementada no kit DE2-115
AE9 - Calculadora básica implementada no kit DE2-115 |
---|
|
AE10 - Simulação funcional com o ModelSim
AE10 - Simulação funcional com o ModelSim |
---|
/opt/altera/13.0sp1/modelsim_ae/bin/vsim
cd /home/nome_usuario/nome_pasta/.../AE10
pwd
ls
------------------------------------------------------
-- FILE : n_flip_flop.vhd
-- AUTOR: Marcos Moecke
-- DATA : 22 de dezembro de 2021
------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY n_flip_flop IS
GENERIC (N : NATURAL := 4);
PORT
(
clk : IN std_logic;
rst : IN std_logic;
d : IN std_logic_vector(N - 1 DOWNTO 0);
q : OUT std_logic_vector(N - 1 DOWNTO 0)
);
END;
ARCHITECTURE ifsc_v1 OF n_flip_flop IS
BEGIN
PROCESS (clk, rst)
BEGIN
IF (rst = '1') THEN
q <= (OTHERS => '0');
ELSIF (clk'EVENT AND clk = '1') THEN
q <= d;
END IF;
END PROCESS;
END;
vlib work vcom -work work n_flip_flop.vhd
vsim work.n_flip_flop
wave create -pattern none -portmode in -language vhdl -range N 1 /n_flip_flop/d wave create -pattern none -portmode in -language vhdl /n_flip_flop/clk wave create -pattern none -portmode in -language vhdl /n_flip_flop/rst wave create -pattern none -portmode out -language vhdl -range 1 N /n_flip_flop/q Será aberta uma janela [Wave] na qual irão ser mostrados as 3 portas de entrada da Entity e a porta de saída. Clique sobre o sinal da porta de saída q e [Delete], pois esse sinal não será editado. Aproveite para arrastar com o mouse os sinais na janela Wave para ficarem na seguinte ordem: rst, clk, d.
Clique_direito sobre o sinal rst e selecione [Edit > Create/Modify Waveform] e escolha [Patterns = Constant], [Start Time = 0] [End Time = 3000] [Time Unit = ps] e clique em [Next], [Value = 0] e clique em [Finish]. Ou wave modify -driver freeze -pattern constant -value 0 -starttime 0ps -endtime 3000ps Edit:/n_flip_flop/rst Clique_direito sobre o sinal rst e selecione [Edit > Create/Modify Waveform] e escolha [Patterns = Constant], [Start Time = 20] [End Time = 30] [Time Unit = ps] e clique em [Next], [Value = 1] e clique em [Finish]. Ou wave modify -driver freeze -pattern constant -value 1 -starttime 20ps -endtime 30ps Edit:/n_flip_flop/rst
Clique_direito sobre o sinal clk e selecione [Edit > Create/Modify Waveform] e escolha [Patterns = Clock], [Start Time = 0] [End Time = 3000] [Time Unit = ps] e clique em [Next], [Initial Value = 1], [Clock Period = 100ps], [Duty Cycle = 50] e clique em [Finish]. Ou wave modify -driver freeze -pattern clock -initialvalue 1 -period 100ps -dutycycle 50 -starttime 0ps -endtime 3000ps Edit:/n_flip_flop/clk
Clique_direito sobre o sinal d e selecione [Edit > Create/Modify Waveform] e escolha [Patterns = Counter], [Start Time = 0] [End Time = 1000] [Time Unit = ps] e clique em [Next], [Start Value = 0000], [End Value = 1111], [Time Period = 120ps], [Counter Type = Range], [Count Direction = Up], [Step Count = 1], [Repeat = Forever] e clique em [Finish]. Ou wave modify -driver freeze -pattern counter -startvalue 0000 -endvalue 1111 -type Range -direction Up -period 120ps -step 1 -repeat forever -range 4 1 -starttime 0ps -endtime 3000ps Edit:/n_flip_flop/d
Clique sobre o sinal q na janela Objects e solte-o na janela Wave. Ao final desses passos a janela Wave deverá estar conforme mostrado abaixo: Figura AE10a - Edição do Waveform de 4 FF 1000ns no Modelsim
run -all
Selecione com o shift_clique_esquerdo do mouse os sinas d e q (barramentos de 4 bits) e em seguida clique_direito e selecione [radix > unsigned]. A janela Wave deverá estar conforme mostrado abaixo: Figura AE10b - Simulação funcional de 4 FF 1000ns no Modelsim
Use os comandos da janela de transcript para criar um arquivo tb_nFF.do que permite repetir de forma automática o teste realizado. ################################
# FILE : tb_FF_create1.do
# AUTOR: Marcos Moecke
# DATA : 14 de agosto de 2019
################################
#criacao da library work
vlib work
#compilacao da entity nome.vhd (nao necessita ser compilado no quartus II)
vcom -work work n_flip_flop.vhd
#simulacao na entity nome.vhd
vsim work.n_flip_flop
#inclusao de um divisor
add wave -noupdate -divider Entradas
#edicao do sinal rst
wave create -pattern none -portmode in -language vhdl /n_flip_flop/rst
wave modify -driver freeze -pattern constant -value 0 -starttime 0ps -endtime 3000ps Edit:/n_flip_flop/rst
wave modify -driver freeze -pattern constant -value 1 -starttime 20ps -endtime 30ps Edit:/n_flip_flop/rst
#edicao do sinal clock
wave create -pattern none -portmode in -language vhdl /n_flip_flop/clk
wave modify -driver freeze -pattern clock -initialvalue 1 -period 100ps -dutycycle 50 -starttime 0ps -endtime 3000ps Edit:/n_flip_flop/clk
#edicao do sinal d
wave create -pattern none -portmode in -language vhdl -range N 1 /n_flip_flop/d
wave modify -driver freeze -pattern counter -startvalue 0000 -endvalue 1111 -type Range -direction Up -period 120ps -step 1 -repeat forever -range 4 1 -starttime 0ps -endtime 3000ps Edit:/n_flip_flop/d
#inclusao do sinal de saida q (como UNSIGNED)
add wave -position end -radix hexadecimal sim:/n_flip_flop/d
#inclusao de um divisor
add wave -noupdate -divider Saidas
#inclusao do sinal de saida q (como BINARY)
add wave -position end sim:/n_flip_flop/q
#inclusao do sinal de saida q (como UNSIGNED)
add wave -position end -radix hexadecimal sim:/n_flip_flop/q
#Definir o zoom a ser mostrado na tela
WaveRestoreZoom {500 ps} {3000 ps}
#execucao da simulacao inteira
run -all
Figura AE10c - Simulação funcional no Modelsim Se desejar reiniciar a simulação use o comando restart E em seguida execute a simulação pelo tempo que desejar run 1200 ps Uma segunda opção de criação do testbench é salvando o formato e criação do WAVE em um arquivo wave.do e executar esse script dentro do testbench. ###############################################
## FILE : wave.do
## AUTOR: Marcos Moecke
## DATA : 22 de dezembro de 2021
###############################################
onerror {resume}
quietly WaveActivateNextPane {} 0
add wave -noupdate -divider Entradas
wave clipboard store
wave create -pattern none -portmode in -language vhdl /n_flip_flop/rst
wave create -pattern none -portmode in -language vhdl /n_flip_flop/clk
wave create -pattern none -portmode in -language vhdl -range N 1 /n_flip_flop/d
wave modify -driver freeze -pattern constant -value 0 -starttime 0ps -endtime 3000ps Edit:/n_flip_flop/rst
wave modify -driver freeze -pattern constant -value 1 -starttime 20ps -endtime 30ps Edit:/n_flip_flop/rst
wave modify -driver freeze -pattern clock -initialvalue 1 -period 100ps -dutycycle 50 -starttime 0ps -endtime 3000ps Edit:/n_flip_flop/clk
wave modify -driver freeze -pattern counter -startvalue 0000 -endvalue 1111 -type Range -direction Up -period 120ps -step 1 -repeat forever -range 3 0 -starttime 0ps -endtime 3000ps Edit:/n_flip_flop/d
add wave -noupdate -radix unsigned /n_flip_flop/d
add wave -noupdate -divider Saidas
add wave -noupdate /n_flip_flop/q
add wave -noupdate -radix unsigned /n_flip_flop/q
TreeUpdate [SetDefaultTree]
WaveRestoreCursors {{Cursor 1} {1000 ps} 0}
quietly wave cursor active 1
configure wave -namecolwidth 150
configure wave -valuecolwidth 100
configure wave -justifyvalue left
configure wave -signalnamewidth 1
configure wave -snapdistance 10
configure wave -datasetprefix 0
configure wave -rowmargin 4
configure wave -childrowmargin 2
configure wave -gridoffset 0
configure wave -gridperiod 1
configure wave -griddelta 40
configure wave -timeline 0
configure wave -timelineunits ps
update
WaveRestoreZoom {0 ps} {3000 ps}
view wave
WaveCollapseAll -1
wave clipboard restore
###############################################
## FILE : tb_nFF_create2.do
## AUTOR: Marcos Moecke
## DATA : 22 de dezembro de 2021
###############################################
vlib work
vcom -reportprogress 300 -work work /home/moecke/DLP29006/ANO2021_2/AE10/n_flip_flop.vhd
vsim work.n_flip_flop
do wave.do
run -all
Figura AE10d - Simulação funcional no Modelsim
|
AE11 - Laboratório de programação de FPGA - Timer 00 a 99
AE11 - Laboratório de programação de FPGA - Timer 00 a 99 |
---|
entity bin2ssd is
port (
bin_in : in std_logic_vector(3 downto 0);
ssd_out : out std_logic_vector(0 to 6)
);
end entity;
entity contador_bcd_00_99 is
generic (max_dezena : natural := 5; max_unidade : natural := 9);
port (
clk, rst : in std_logic;
bcd_dezena, bcd_unidade : out std_logic_vector(3 downto 0)
);
end entity;
entity contador_ssd_00_99 is
generic (max_dezena : natural := 5; max_unidade : natural := 9);
port (
clk, rst : in std_logic;
bcd_unidade : buffer std_logic_vector(3 downto 0);
bcd_dezena : buffer std_logic_vector(3 downto 0);
ssd_unidade : out std_logic_vector(0 to 6);
ssd_dezena : out std_logic_vector(0 to 6)
);
end entity;
Figura AE11a - Simulação do contador ssd 00 a 99 no Modelsim
|
AE12 - Laboratório de programação de FPGA - Relógio Digital de 24 horas
AE12 - Laboratório de programação de FPGA - Relógio Digital de 24 horas | ||
---|---|---|
entity relogio24h IS
-- O valor do fclk2 corresponde a metade do periodo do clock de entrada em Hz
generic (fclk2 : natural := 50); -- ao simular o circuito utilize um valor baixo para acelerar a simulaçao
-- generic (fclk2 : natural := 50000000); -- ao implementar no hardware use o valor do clock em Hz
port
(
clk50MHz: in STD_LOGIC;
rst: in STD_LOGIC;
ligar: in STD_LOGIC;
ssd_DS, ssd_DM, ssd_DH : out STD_LOGIC_VECTOR(6 downto 0);
ssd_US, ssd_UM, ssd_UH : out STD_LOGIC_VECTOR(6 downto 0)
);
end entity;
O projeto deve ser dividido em pelo menos os seguintes componentes (ver exemplo do RTL abaixo) Figura AE12.a - RTL do Relógio Digital de 24 horas
component div_clk is
generic (fclk2 : natural := 50); -- frequecia para simulacao
port (
clk,rst : in std_logic;
clk_out : out std_logic
);
end component;
component count00_99 is
generic (D : natural := 9; U : natural := 9);
port (
clk,rst : in std_logic;
enable_in : in std_logic;
enable_out : out std_logic;
bcd_U : out std_logic_vector(3 downto 0);
bcd_D : out std_logic_vector(3 downto 0)
);
end component;
Esse contador precisa ser modificado para permitir que o clock seja síncrono em todos os flip-flops. Para isso é necessário usar um sinal de enable_in para habilitar a contagem durante um período de clock. Também será necessário gerar o sinal de enable_out para habilitar a contagem do próximo contador.
component bin2ssd is
generic (ac_ccn : natural := 0);
port (
bin_in : in std_logic_vector(3 downto 0);
ssd_out : out std_logic_vector(6 downto 0)
);
end component;
Figura AE12.b - Simulação funcional do Relógio Digital de 24 horas Figura AE12.b - Simulação funcional do Relógio Digital de 24 horas - detalhe enable 1sec
Anote a pinagem que você utilizou:
Nesta atividade devem ser entregues os seguintes arquivos.
|
AE13 - Laboratório de programação de FPGA - Relógio Digital de 24 horas com ajuste
AE13 - Laboratório de programação de FPGA - Relógio Digital de 24 horas com ajuste | ||
---|---|---|
Essa FSM deve ler uma chave sw_ajustar e dois push botton pb_HH, e pb_MM, os quais devem ser usados para controlar a FSM conforme indicado no diagrama de estados abaixo: Figura AE13.a - Diagrama de estados da FSM para ajuste do relógio
Nessa nova versão do relógio algumas modificações foram realizadas conforme está destacado no RLT a seguir: Figura AE13.b - RTL do Relógio Digital de 24 horas com ajuste
entity div_clk_ajustar is
generic (fclk : natural := 50);
port
(
clk, rst : in std_logic;
clk_100ms : out std_logic;
clk_out : out std_logic
);
end entity;
entity count00_99_ajustar is
generic
(
D : natural := 9;
U : natural := 9;
MODO_PROG : natural := 1
);
port
(
clk, rst : in std_logic;
one_clk : in std_logic;
ena2 : in std_logic;
prog_in : in integer range 0 to MODO_PROG;
zera_in : in std_logic;
enable_in : in std_logic;
enable_out : out std_logic;
bcd_U : out std_logic_vector(3 downto 0);
bcd_D : out std_logic_vector(3 downto 0)
);
end entity;
Figura AE13.c - Simulação funcional do Relógio Digital de 24 horas
Figura AE13.d - Simulação funcional do Relógio Digital de 24 horas - detalhe enable 1sec
Anote a pinagem que você utilizou:
Nesta atividade devem ser entregues os seguintes arquivos.
|
-->