Skip to content

Commit 29fea5e

Browse files
committed
AULA 9
Added Aula 9 / Class 9, derived from Class 8, mini-calculator, operation selection, shift register left/right (multiplication)
1 parent bb887bf commit 29fea5e

File tree

143 files changed

+11593
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+11593
-0
lines changed

AULA9/C1.vhd

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
library IEEE;
2+
use IEEE.Std_Logic_1164.all;
3+
use IEEE.std_logic_unsigned.all;
4+
5+
entity C1 is
6+
port (A: in std_logic_vector(7 downto 0);
7+
B: in std_logic_vector(7 downto 0);
8+
F: out std_logic_vector(7 downto 0)
9+
);
10+
end C1;
11+
12+
architecture circuito of C1 is
13+
begin
14+
F <= A + B;
15+
end circuito;

AULA9/C2.vhd

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
library IEEE;
2+
use IEEE.Std_Logic_1164.all;
3+
4+
entity C2 is
5+
port (A: in std_logic_vector(7 downto 0);
6+
B: in std_logic_vector(7 downto 0);
7+
F: out std_logic_vector(7 downto 0)
8+
);
9+
end C2;
10+
11+
architecture circuito of C2 is
12+
begin
13+
F <= A or B;
14+
end circuito;

AULA9/C3.vhd

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
library IEEE;
2+
use IEEE.Std_Logic_1164.all;
3+
4+
entity desloc_1_bit_esq is
5+
port( CLK: in std_logic;
6+
ENABLE : in std_logic;
7+
RST: in std_logic;
8+
sr_in: in std_logic_vector(7 downto 0);
9+
sr_out: out std_logic_vector(7 downto 0)
10+
);
11+
end entity;
12+
13+
architecture rtl of desloc_1_bit_esq is
14+
signal sr: std_logic_vector (7 downto 0); -- Registrador de N bits
15+
16+
begin
17+
process (CLK, RST)
18+
begin
19+
if (RST = '0') then -- Reset assíncrono do registrador
20+
sr <= (others => '0');
21+
elsif (rising_edge(CLK)) then -- Sinal de clock do registrador (subida)
22+
if (ENABLE = '1') then -- Sinal de enable do registrador
23+
sr(7 downto 1) <= sr_in(6 downto 0);-- Desloca 1 bit para a esquerda. Bit mais significativo é perdido.
24+
sr(0) <= '0';
25+
end if;
26+
end if;
27+
end process;
28+
sr_out <= sr;
29+
end rtl;
30+

AULA9/C3.vhd.bak

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
library IEEE;
2+
use IEEE.Std_Logic_1164.all;
3+
4+
entity C3 is
5+
port (A: in std_logic_vector(7 downto 0);
6+
B: in std_logic_vector(7 downto 0);
7+
F: out std_logic_vector(7 downto 0)
8+
);
9+
end C3;
10+
11+
architecture circuito of C3 is
12+
begin
13+
F <= A xor B;
14+
end circuito;

AULA9/C4.vhd

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
library IEEE;
2+
use IEEE.Std_Logic_1164.all;
3+
4+
entity desloc_1_bit_dir is
5+
generic(N: natural := 64);
6+
port( CLK: in std_logic;
7+
ENABLE : in std_logic;
8+
RST: in std_logic;
9+
sr_in: in std_logic_vector(7 downto 0);
10+
sr_out: out std_logic_vector(7 downto 0)
11+
);
12+
end entity;
13+
14+
architecture rtl of desloc_1_bit_dir is
15+
signal sr: std_logic_vector (7 downto 0); -- Registrador de N bits
16+
17+
begin
18+
process (CLK, RST)
19+
begin
20+
if (RST = '0') then -- Reset assíncrono do registrador
21+
sr <= (others => '0');
22+
elsif (rising_edge(CLK)) then -- Sinal de clock do registrador (subida)
23+
if (ENABLE = '1') then -- Sinal de enable do registrador
24+
sr(6 downto 0) <= sr_in(7 downto 1);-- Desloca 1 bit para a direita. Bit menos significativo é perdido.
25+
sr(7) <= '1';
26+
end if;
27+
end if;
28+
end process;
29+
sr_out <= sr;
30+
end rtl;

AULA9/C4.vhd.bak

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
library IEEE;
2+
use IEEE.Std_Logic_1164.all;
3+
4+
entity C4 is
5+
port (A: in std_logic_vector(7 downto 0);
6+
B: in std_logic_vector(7 downto 0);
7+
F: out std_logic_vector(7 downto 0)
8+
);
9+
end C4;
10+
11+
architecture circuito of C4 is
12+
begin
13+
F <= not(A);
14+
end circuito;

AULA9/FSMctrl.vhd

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
library IEEE;
2+
use ieee.std_logic_1164.all;
3+
4+
-- ENTITY
5+
6+
entity FSMctrl is
7+
port(
8+
CLK, RST, ENTER: in std_logic;
9+
Operacao: in std_logic_vector(1 downto 0);
10+
Selecao: out std_logic_vector(1 downto 0);
11+
Enable_1, Enable_2: out std_logic
12+
);
13+
end FSMctrl;
14+
15+
16+
--ARCHITECTURE
17+
18+
architecture FSM_beh of FSMctrl is
19+
type states is(S0,S1,S2,S3,S4,S5,S6,S7);
20+
signal EA, PE: states;
21+
signal clock: std_logic;
22+
signal reset: std_logic;
23+
24+
begin
25+
26+
clock <= CLK;
27+
28+
P1: process(clock, reset)
29+
begin
30+
if reset = '0' then
31+
EA <= S0;
32+
elsif clock'event and clock = '1' then
33+
EA <= PE;
34+
end if;
35+
end process;
36+
37+
P2: process(EA, ENTER, Operacao)
38+
begin
39+
case EA is
40+
41+
when S0 =>
42+
if Enter = '1' then
43+
PE <= S0;
44+
else
45+
PE <= S1;
46+
end if;
47+
Enable_1 <= '0';
48+
Enable_2 <= '0';
49+
50+
when S1 =>
51+
if Enter = '0' then
52+
PE <= S1;
53+
else
54+
PE <= S2;
55+
end if;
56+
Enable_1 <= '1';
57+
Enable_2 <= '0';
58+
59+
when S2 =>
60+
Enable_1 <= '0';
61+
Enable_2 <= '0';
62+
if Operacao = "00" then
63+
PE <= S3;
64+
elsif Operacao = "01" then
65+
PE <= S4;
66+
elsif Operacao = "10" then
67+
PE <= S5;
68+
elsif Operacao = "11" then
69+
PE <= S6;
70+
end if;
71+
72+
when S3 =>
73+
Selecao <= "00";
74+
if Enter = '1' then
75+
PE <= S3;
76+
else
77+
PE <= S7;
78+
end if;
79+
80+
when S4 =>
81+
Selecao <= "01";
82+
if Enter = '1' then
83+
PE <= S4;
84+
else
85+
PE <= S7;
86+
end if;
87+
88+
when S5 =>
89+
Enable_1 <= '1';
90+
Enable_2 <= '1';
91+
Selecao <= "10";
92+
PE <= S0;
93+
94+
when S6 =>
95+
Enable_1 <= '1';
96+
Enable_2 <= '1';
97+
Selecao <= "11";
98+
PE <= S0;
99+
100+
when S7 =>
101+
Enable_1 <= '0';
102+
Enable_2 <= '1';
103+
PE <= S0;
104+
105+
end case;
106+
end process;
107+
end FSM_beh;
108+
109+
110+
111+

AULA9/FSMctrl.vhd.bak

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
library IEEE;
2+
use ieee.std_logic_1164.all;
3+
4+
-- ENTITY
5+
6+
entity FSMctrl is
7+
port(
8+
CLK, RST, ENTER: in std_logic;
9+
Operacao: in std_logic_vector(1 downto 0);
10+
Selecao: out std_logic_vector(1 downto 0);
11+
Enable_1, Enable_2: out std_logic
12+
);
13+
end FSMctrl;
14+
15+
16+
--ARCHITECTURE
17+
18+
architecture FSM_beh of FSMctrl is
19+
type states is(S0,S1,S2,S3,S4,S5,S6,S7);
20+
signal EA, PE: states;
21+
signal clock: std_logic;
22+
signal reset: std_logic;
23+
24+
begin
25+
26+
clock <= CLK;
27+
28+
P1: process(clock, reset)
29+
begin
30+
if reset = '0' then
31+
EA <= S0;
32+
elsif clock'event and clock = '1' then
33+
EA <= PE;
34+
end if;
35+
end process;
36+
37+
P2: process(EA, ENTER, Operacao)
38+
begin
39+
case EA is
40+
41+
when S0 =>
42+
if Enter = '1' then
43+
PE <= S0;
44+
else
45+
PE <= S1;
46+
end if;
47+
Enable_1 <= '0';
48+
Enable_2 <= '0';
49+
50+
when S1 =>
51+
if Enter = '0' then
52+
PE <= S1;
53+
else
54+
PE <= S2;
55+
end if;
56+
Enable_1 <= '1';
57+
Enable_2 <= '0';
58+
59+
when S2 =>
60+
Enable_1 <= '0';
61+
Enable_2 <= '0';
62+
if Operacao = "00" then
63+
PE <= S3;
64+
elsif Operacao = "01" then
65+
PE <= S4;
66+
elsif Operacao = "10" then
67+
PE <= S5;
68+
elsif Operacao = "11" then
69+
PE <= S6;
70+
end if;
71+
72+
when S3 =>
73+
Selecao <= "00";
74+
if Enter = '1' then
75+
PE <= S3;
76+
else
77+
PE <= S7;
78+
end if;
79+
80+
when S4 =>
81+
Selecao <= "01";
82+
if Enter = '1' then
83+
PE <= S4;
84+
else
85+
PE <= S7;
86+
end if;
87+
88+
when S5 =>
89+
Selecao <= "10";
90+
if Enter = '1' then
91+
PE <= S5;
92+
else
93+
PE <= S7;
94+
end if;
95+
96+
when S6 =>
97+
Enable_1 <= '0';
98+
Enable_2 <= '1';
99+
Selecao <= "11";
100+
PE <= S0;
101+
102+
when S7 =>
103+
Enable_1 <= '0';
104+
Enable_2 <= '1';
105+
PE <= S0;
106+
107+
end case;
108+
end process;
109+
end FSM_beh;
110+
111+
112+
113+

0 commit comments

Comments
 (0)