1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.all;
entity lab is
Port ( clk, rst, rx : in STD_LOGIC; -- rst är tryckknappen i mitten under displayen
seg: out UNSIGNED(7 downto 0);
an : out UNSIGNED (3 downto 0));
end lab;
architecture Behavioral of lab is
component leddriver
Port ( clk,rst : in STD_LOGIC;
seg : out UNSIGNED(7 downto 0);
an : out UNSIGNED (3 downto 0);
value : in UNSIGNED (15 downto 0));
end component;
signal sreg : UNSIGNED(9 downto 0) := B"0_00000000_0"; -- 10 bit skiftregister
signal tal : UNSIGNED(15 downto 0) := X"0000";
signal rx1,rx2 : std_logic; -- vippor på insignalen
signal sp : std_logic; -- skiftpuls
signal lp : std_logic; -- laddpuls
signal pos : UNSIGNED(1 downto 0) := "00";
begin
-- *****************************
-- * synkroniseringsvippor *
-- *****************************
-- 1 process
--
-- Förändringarna på insignalen ska komma i takt med vår klocka.
process(clk) begin
if rising_edge(clk) then
if rst='1' then
rx1 <= '0';
rx2 <= '0';
else
rx1 <= rx;
rx2 <= rx1;
end if;
end if;
end process;
-- *****************************
-- * styrenhet *
-- *****************************
-- 1 eller 2 processer
--
-- Denna producerar två styrsignaler, båda enpulsade:
-- – Skiftpulsen sp, som kommer mitt i (ungefär) varje bit.
-- – Laddpulsen lp, som kommer efter den sista skiftpulsen.
process(clk) begin
if rising_edge(clk) then
if rst='1' then
sp <= '0';
lp <= '0';
elsif _ then
else
end if;
end if;
end process;
process(clk) begin
if rising_edge(clk) then
if rst='1' then
elsif _ then
else
end if;
end if;
end process;
-- *****************************
-- * 10 bit skiftregister *
-- *****************************
-- 1 process
--
-- De 10 bitarna i varje siffra skiftas in i skiftregistret.
process(clk) begin
if rising_edge(clk) then
if rst='1' then
elsif _ then
else
end if;
end if;
end process;
-- *****************************
-- * 2 bit räknare *
-- *****************************
-- 1 process
process(clk) begin
if rising_edge(clk) then
if rst='1' then
elsif _ then
else
end if;
end if;
end process;
-- *****************************
-- * 16 bit register *
-- *****************************
-- 1 process
--
-- ... för 4 siffror. Laddas av laddpulsen, samtidigt räknas räknaren upp.
process(clk) begin
if rising_edge(clk) then
if rst='1' then
elsif _ then
else
end if;
end if;
end process;
-- *****************************
-- * Multiplexad display *
-- *****************************
-- Inkoppling av komponenten leddriver
led: leddriver port map (clk, rst, seg, an, tal);
end Behavioral;
|