Mudanças entre as edições de "SST20707-2015-1 - Avaliação 1 - Equipe 1"
Ir para navegação
Ir para pesquisar
m |
|||
Linha 23: | Linha 23: | ||
|- | |- | ||
|} | |} | ||
+ | *Código: | ||
+ | ;:<syntaxhighlight lang=vhdl> | ||
+ | library ieee; | ||
+ | use ieee.std_logic_1164.all; | ||
+ | |||
+ | entity questao1 is | ||
+ | |||
+ | port( | ||
+ | |||
+ | --Entradas: sensores 1 e 2 | ||
+ | --Saidas: semafaros 1 e 2 | ||
+ | |||
+ | sensores : in std_logic_vector(1 downto 0); | ||
+ | semafaroA, semafaroB : out std_logic); | ||
+ | |||
+ | |||
+ | end entity; | ||
+ | |||
+ | architecture funcio of questao1 is | ||
+ | |||
+ | |||
+ | begin | ||
+ | |||
+ | |||
+ | with sensores select | ||
+ | |||
+ | semafaroA <= '1' when "10", | ||
+ | '1' when "11", | ||
+ | '0' when others; | ||
+ | |||
+ | with sensores select | ||
+ | semafaroB <= '1' when "01", | ||
+ | '0' when others; | ||
+ | |||
+ | end architecture; | ||
+ | |||
+ | |||
+ | </syntaxhighlight> | ||
*Forma de onda: | *Forma de onda: | ||
[[Arquivo: sstq1.png]] | [[Arquivo: sstq1.png]] | ||
Linha 62: | Linha 100: | ||
|- | |- | ||
|} | |} | ||
+ | *Código: | ||
+ | ;:<syntaxhighlight lang=vhdl> | ||
+ | library ieee; | ||
+ | use ieee.std_logic_1164.all; | ||
+ | |||
+ | entity questao2 is | ||
+ | |||
+ | port( | ||
+ | |||
+ | --Entradas: amplificador | ||
+ | --Saidas: disco, fita e radio | ||
+ | |||
+ | amplificador: in std_logic_vector(2 downto 0); | ||
+ | disco, fita, radio: out std_logic); | ||
+ | |||
+ | |||
+ | end entity; | ||
+ | |||
+ | architecture funcio of questao2 is | ||
+ | |||
+ | |||
+ | begin | ||
+ | |||
+ | |||
+ | with amplificador select | ||
+ | |||
+ | radio <= '1' when "001", | ||
+ | '0' when others; | ||
+ | |||
+ | with amplificador select | ||
+ | |||
+ | fita <= '1' when "010", | ||
+ | '1' when "011", | ||
+ | '0' when others; | ||
+ | |||
+ | with amplificador select | ||
+ | |||
+ | disco <= '1' when "100", | ||
+ | '1' when "101", | ||
+ | '1' when "110", | ||
+ | '1' when "111", | ||
+ | '0' when others; | ||
+ | |||
+ | end architecture; | ||
+ | </syntaxhighlight> | ||
*Forma de onda: | *Forma de onda: | ||
[[Arquivo: sstq2.png|700px]] | [[Arquivo: sstq2.png|700px]] | ||
Linha 116: | Linha 199: | ||
|- | |- | ||
|} | |} | ||
+ | *Código: | ||
+ | ;:<syntaxhighlight lang=vhdl> | ||
+ | library IEEE; | ||
+ | use IEEE.std_logic_1164.all; | ||
+ | |||
+ | entity questao3 is | ||
+ | |||
+ | port (presidente, vice, engenharia, chefe_secao : in std_logic; | ||
+ | ch_pres, ch_vice, ch_enge, ch_secao : out std_logic | ||
+ | |||
+ | ); | ||
+ | |||
+ | end questao3; | ||
+ | |||
+ | architecture arquitetura of questao3 is | ||
+ | |||
+ | constant ligado : std_logic := '1'; | ||
+ | constant desligado : std_logic := '0'; | ||
+ | signal sel : std_logic_vector(3 downto 0); | ||
+ | |||
+ | begin | ||
+ | |||
+ | sel <= presidente & vice & engenharia & chefe_secao; | ||
+ | |||
+ | ch_pres <= ligado when ( sel(3)='1' ) else | ||
+ | desligado; | ||
+ | |||
+ | ch_vice <= ligado when ( ( sel(3)='0' ) and ( sel(2)='1' ) ) else | ||
+ | desligado; | ||
+ | |||
+ | ch_enge <= ligado when ( ( sel(3)='0' ) and ( sel(2)='0' ) and ( sel(1)='1' ) ) else | ||
+ | desligado; | ||
+ | |||
+ | ch_secao <= ligado when ( ( sel(3)='0' ) and ( sel(2)='0' ) and ( sel(1)='0' ) and ( sel(0)='1' )) else | ||
+ | desligado; | ||
+ | end architecture; | ||
+ | </syntaxhighlight> | ||
*Forma de onda: | *Forma de onda: | ||
[[Arquivo: sstq3.png|800px]] | [[Arquivo: sstq3.png|800px]] | ||
Linha 129: | Linha 249: | ||
* | * | ||
* | * | ||
+ | *Código: | ||
+ | ;:<syntaxhighlight lang=vhdl> | ||
+ | library IEEE; | ||
+ | use IEEE.std_logic_1164.all; | ||
+ | |||
+ | entity questao5 is | ||
+ | |||
+ | port ( on_off, sensor_min, sensor_max : in std_logic; | ||
+ | valvula_entrada, valvula_saida : out std_logic | ||
+ | |||
+ | ); | ||
+ | |||
+ | end questao5; | ||
+ | |||
+ | architecture arquitetura of questao5 is | ||
+ | |||
+ | constant ligado : std_logic := '1'; | ||
+ | constant desligado : std_logic := '0'; | ||
+ | signal aux_val1 : std_logic := '0'; | ||
+ | signal aux_val2 : std_logic := '0'; | ||
+ | begin | ||
+ | |||
+ | aux_val1 <= ligado when ( on_off='1' and ((sensor_min='1') or (sensor_max='0' and aux_val2='0')) ) else | ||
+ | desligado; | ||
+ | |||
+ | valvula_entrada <= aux_val1; | ||
+ | |||
+ | aux_val2 <= ligado when ( on_off='0' or ((sensor_max='1') or (sensor_min='0' and aux_val1='0')) ) else | ||
+ | desligado; | ||
+ | |||
+ | valvula_saida <= aux_val2; | ||
+ | |||
+ | end architecture; | ||
+ | </syntaxhighlight> | ||
*Forma de onda: | *Forma de onda: | ||
[[Arquivo: sstq5.png|800px]] | [[Arquivo: sstq5.png|800px]] | ||
+ | *[Implementação tanque com fluido] | ||
==Questão 6: Cruzamento de três ruas== | ==Questão 6: Cruzamento de três ruas== | ||
Linha 166: | Linha 321: | ||
|- | |- | ||
|} | |} | ||
+ | *Código: | ||
+ | ;:<syntaxhighlight lang=vhdl> | ||
+ | library ieee; | ||
+ | use ieee.std_logic_1164.all; | ||
+ | |||
+ | entity questao6 is | ||
+ | |||
+ | port( | ||
+ | |||
+ | |||
+ | ruaA, ruaB, ruaC: in std_logic; | ||
+ | semafaro1, semafaro2, semafaro3: out std_logic); | ||
+ | |||
+ | |||
+ | end entity; | ||
+ | |||
+ | architecture funcio of questao6 is | ||
+ | |||
+ | |||
+ | signal ruas : std_logic_vector(2 downto 0); | ||
+ | |||
+ | begin | ||
+ | |||
+ | |||
+ | ruas <= (ruaA & ruaB & ruaC); | ||
+ | |||
+ | with (ruas) select | ||
+ | |||
+ | semafaro1 <= '1' when "000", | ||
+ | '1' when "100", | ||
+ | '1' when "110", | ||
+ | '1' when "111", | ||
+ | '0' when others; | ||
+ | |||
+ | with (ruas) select | ||
+ | |||
+ | semafaro2 <= '1' when "010", | ||
+ | '1' when "011", | ||
+ | '0' when others; | ||
+ | |||
+ | with (ruas) select | ||
+ | |||
+ | semafaro3 <= '1' when "001", | ||
+ | '1' when "101", | ||
+ | '1' when "110", | ||
+ | '0' when others; | ||
+ | |||
+ | end architecture; | ||
+ | </syntaxhighlight> | ||
*Forma de onda: | *Forma de onda: | ||
[[Arquivo: sstq6.png|800px]] | [[Arquivo: sstq6.png|800px]] | ||
Linha 171: | Linha 375: | ||
==Questão 7: Tanque de dois níveis, com sensor de temperatura== | ==Questão 7: Tanque de dois níveis, com sensor de temperatura== | ||
* | * | ||
+ | *Código: | ||
+ | ;:<syntaxhighlight lang=vhdl> | ||
+ | |||
+ | </syntaxhighlight> | ||
*Forma de onda: | *Forma de onda: | ||
[[Arquivo: sstq7.png]] | [[Arquivo: sstq7.png]] | ||
Linha 182: | Linha 390: | ||
#<math>soma = a \oplus b \oplus cin </math> | #<math>soma = a \oplus b \oplus cin </math> | ||
#<math>cout = a \cdot b + a \cdot cin + b \cdot cin </math> | #<math>cout = a \cdot b + a \cdot cin + b \cdot cin </math> | ||
+ | *Código: | ||
+ | ;:<syntaxhighlight lang=vhdl> | ||
+ | library ieee; | ||
+ | use ieee.std_logic_1164.all; | ||
+ | |||
+ | entity somador8bits is | ||
+ | |||
+ | port( | ||
+ | |||
+ | a,b : in std_logic_vector(7 downto 0); | ||
+ | cin : in std_logic; | ||
+ | cout : out std_logic; | ||
+ | soma : out std_logic_vector(7 downto 0) | ||
+ | |||
+ | |||
+ | ); | ||
+ | end entity; | ||
+ | |||
+ | architecture funcio of somador8bits is | ||
+ | |||
+ | begin | ||
+ | |||
+ | process(a,b,cin) | ||
+ | variable b_carry : std_logic_vector(8 downto 0); | ||
+ | |||
+ | begin | ||
+ | b_carry(0) := cin; | ||
+ | for i in 0 to 7 loop | ||
+ | soma(i) <= a(i) xor b(i) xor b_carry(i); | ||
+ | b_carry (i + 1) := (a(i) and b(i)) or (a(i) and b_carry(i)) or (b(i) and b_carry(i)); | ||
+ | |||
+ | end loop; | ||
+ | |||
+ | cout <= b_carry(7); | ||
+ | |||
+ | end process; | ||
+ | end architecture; | ||
+ | |||
+ | </syntaxhighlight> | ||
*Forma de onda: | *Forma de onda: | ||
[[Arquivo: sstq8.png|1100px]] | [[Arquivo: sstq8.png|1100px]] |
Edição das 22h01min de 8 de abril de 2015
Questão 1: Cruzamento de duas ruas
- IN: sensores std_logic_vector(1 downto 0);
- OUT: semaforoA, semaforoB std_logic;
- Para resolver o problema foi utilizado atribuição de seleção através dos sensores.
- Quando houver carro na rua B (identificado pelo sensor[0]) o semaforoB acende(verde); Quando houver carro na rua A (identificado pelo sensor[1]) o semaforoA acende(verde); Quando houver carros em ambas as ruas, o semaforoA liga(verde), pois tem prioridade sobre o semaforoB.
- Tabela verdade:
Entradas] | Saídas | ||
---|---|---|---|
Sensor[1] | Sensor[0] | SemaforoA | SemaforoB |
0 | 0 | 0 | 0 |
0 | 1 | 0 | 1 |
1 | 0 | 1 | 0 |
1 | 1 | 1 | 0 |
- Código:
library ieee; use ieee.std_logic_1164.all; entity questao1 is port( --Entradas: sensores 1 e 2 --Saidas: semafaros 1 e 2 sensores : in std_logic_vector(1 downto 0); semafaroA, semafaroB : out std_logic); end entity; architecture funcio of questao1 is begin with sensores select semafaroA <= '1' when "10", '1' when "11", '0' when others; with sensores select semafaroB <= '1' when "01", '0' when others; end architecture;
- Forma de onda:
Questão 2: Um amplificador e três aparelhos
- IN: disco, fita, radio std_logic;
- OUT: amp_disco, amp_fita, amp_radio std_logic;
- Para resolver o problema foi utilizado atribuição de seleção através dos equipamentos (disco, fita e rádio).
- Quando apenas o rádio está ligado, o amp_radio é comutado; Quando apenas a fita está ligada, ou a fita e o rádio estão ligados, o amp_fita é comutado; Quando o disco está ligado, o amp_disco é comutado, independente das outras opções de fita ou rádio.
- Tabela verdade:
Entradas] | Saídas | ||||
---|---|---|---|---|---|
Disco | Fita | Radio | amp_D | amo_F | amp_R |
0 | 0 | 0 | o | 0 | 0 |
0 | 0 | 1 | 0 | 0 | 1 |
0 | 1 | 0 | 0 | 1 | 0 |
0 | 1 | 1 | 0 | 1 | 0 |
1 | 0 | 0 | 1 | 0 | 0 |
1 | 0 | 1 | 1 | 0 | 0 |
1 | 1 | 0 | 1 | 0 | 0 |
1 | 1 | 1 | 1 | 0 | 0 |
- Código:
library ieee; use ieee.std_logic_1164.all; entity questao2 is port( --Entradas: amplificador --Saidas: disco, fita e radio amplificador: in std_logic_vector(2 downto 0); disco, fita, radio: out std_logic); end entity; architecture funcio of questao2 is begin with amplificador select radio <= '1' when "001", '0' when others; with amplificador select fita <= '1' when "010", '1' when "011", '0' when others; with amplificador select disco <= '1' when "100", '1' when "101", '1' when "110", '1' when "111", '0' when others; end architecture;
- Forma de onda:
Questão 3: Intercomunicadores
- IN: presidente, vice, engenharia, seção std_logic;
- OUT: ch_presidente, ch_vice, ch_engenharia, ch_seção std_logic;
- Quando a seção está ligada, a comutação resulta em ch_secao; Quando a engenharia está ligada, ou engenharia e seção estão ligadas, a comutação resulta em ch_eng; Quando vice está ligada, ou engenharia e/ou seção estão ligadas, ch_vice é comutada; Quando presidente está ligada, a comutação é ch_pres, independente das demais entradas.
- Tabela verdade:
Entradas | Saídas | ||||||
---|---|---|---|---|---|---|---|
Pres | Vice | Eng | Seção | ch_P | ch_V | ch_E | ch_S |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 |
0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 |
0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 |
0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 |
0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 |
0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 |
0 | 1 | 1 | 1 | 0 | 1 | 0 | 0 |
1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
1 | 0 | 0 | 1 | 1 | 0 | 0 | 0 |
1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 |
1 | 0 | 1 | 1 | 1 | 0 | 0 | 0 |
1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 |
1 | 1 | 0 | 1 | 1 | 0 | 0 | 0 |
1 | 1 | 1 | 0 | 1 | 0 | 0 | 0 |
1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 |
- Código:
library IEEE; use IEEE.std_logic_1164.all; entity questao3 is port (presidente, vice, engenharia, chefe_secao : in std_logic; ch_pres, ch_vice, ch_enge, ch_secao : out std_logic ); end questao3; architecture arquitetura of questao3 is constant ligado : std_logic := '1'; constant desligado : std_logic := '0'; signal sel : std_logic_vector(3 downto 0); begin sel <= presidente & vice & engenharia & chefe_secao; ch_pres <= ligado when ( sel(3)='1' ) else desligado; ch_vice <= ligado when ( ( sel(3)='0' ) and ( sel(2)='1' ) ) else desligado; ch_enge <= ligado when ( ( sel(3)='0' ) and ( sel(2)='0' ) and ( sel(1)='1' ) ) else desligado; ch_secao <= ligado when ( ( sel(3)='0' ) and ( sel(2)='0' ) and ( sel(1)='0' ) and ( sel(0)='1' )) else desligado; end architecture;
- Forma de onda:
Questão 4: Display de 7 segmentos
- Forma de onda:
Questão 5: Tanque com fluido
- Código:
library IEEE; use IEEE.std_logic_1164.all; entity questao5 is port ( on_off, sensor_min, sensor_max : in std_logic; valvula_entrada, valvula_saida : out std_logic ); end questao5; architecture arquitetura of questao5 is constant ligado : std_logic := '1'; constant desligado : std_logic := '0'; signal aux_val1 : std_logic := '0'; signal aux_val2 : std_logic := '0'; begin aux_val1 <= ligado when ( on_off='1' and ((sensor_min='1') or (sensor_max='0' and aux_val2='0')) ) else desligado; valvula_entrada <= aux_val1; aux_val2 <= ligado when ( on_off='0' or ((sensor_max='1') or (sensor_min='0' and aux_val1='0')) ) else desligado; valvula_saida <= aux_val2; end architecture;
- Forma de onda:
- [Implementação tanque com fluido]
Questão 6: Cruzamento de três ruas
- IN: ruaA, ruaB, ruaC std_logic;
- OUT: semaforo1, semaforo2, semaforo3 std_logic;
- Para resolver o problema foi utilizado atribuição de seleção através da variável "ruas", que é uma concatenação das entradas(ruaA, ruaB e ruaC).
- Tabela verdade:
Entradas] | Saídas | ||||
---|---|---|---|---|---|
ruaA | ruaB | ruaC | semaforo1 | semaforo2 | semaforo3 |
0 | 0 | 0 | 1 | 0 | 0 |
0 | 0 | 1 | 0 | 0 | 1 |
0 | 1 | 0 | 0 | 1 | 0 |
0 | 1 | 1 | 0 | 1 | 0 |
1 | 0 | 0 | 1 | 0 | 0 |
1 | 0 | 1 | 0 | 0 | 1 |
1 | 1 | 0 | 1 | 0 | 0 |
1 | 1 | 1 | 1 | 0 | 0 |
- Código:
library ieee; use ieee.std_logic_1164.all; entity questao6 is port( ruaA, ruaB, ruaC: in std_logic; semafaro1, semafaro2, semafaro3: out std_logic); end entity; architecture funcio of questao6 is signal ruas : std_logic_vector(2 downto 0); begin ruas <= (ruaA & ruaB & ruaC); with (ruas) select semafaro1 <= '1' when "000", '1' when "100", '1' when "110", '1' when "111", '0' when others; with (ruas) select semafaro2 <= '1' when "010", '1' when "011", '0' when others; with (ruas) select semafaro3 <= '1' when "001", '1' when "101", '1' when "110", '0' when others; end architecture;
- Forma de onda:
Questão 7: Tanque de dois níveis, com sensor de temperatura
- Código:
- Forma de onda:
Questão 8: Circuito aritmético
- IN: a,b std_logic_vector(7 downto 0); cin : in std_logic;
- OUT: cout std_logic; soma std_logic_vector(7 downto 0);
- Para realizar o processo de soma binária, é necessário um bit de carry in (cin/vem-um) e um bit de carry out(cout/vai-um);
- Para solucionar esse problema, foi utilizado um process com sensibilidade das entradas (a,b e cin), onde nele, foi realizado um for loop que fosse de i=0 até i=7, em cada loop ele realizava as seguintes operações:
- Código:
library ieee; use ieee.std_logic_1164.all; entity somador8bits is port( a,b : in std_logic_vector(7 downto 0); cin : in std_logic; cout : out std_logic; soma : out std_logic_vector(7 downto 0) ); end entity; architecture funcio of somador8bits is begin process(a,b,cin) variable b_carry : std_logic_vector(8 downto 0); begin b_carry(0) := cin; for i in 0 to 7 loop soma(i) <= a(i) xor b(i) xor b_carry(i); b_carry (i + 1) := (a(i) and b(i)) or (a(i) and b_carry(i)) or (b(i) and b_carry(i)); end loop; cout <= b_carry(7); end process; end architecture;
- Forma de onda: