blob: c9925ee760d0860e6c0893895f309f8af7181350 (
plain)
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
|
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
library work;
use work.top_pack.all;
entity top is port (
clk : in std_logic;
D : out std_logic_vector(1 to 5));
end top;
architecture beh of top is
signal this_c : top_reg_t;
signal this_r : top_reg_t;
-- signal rst : std_logic := '0';
begin
led : process(this_r, clk)
variable this : top_reg_t;
variable en : std_logic;
begin
this := this_r;
en := '0';
if this.prescale < 5000000 then en := '1'; end if;
this.y := to_slv(this.count, this.blip, en);
if this.prescale > 5999999 then
this.prescale := 0;
this.blip := '1';
if this.count = 3 then
this.count := 0;
else
this.count := this.count + 1;
end if;
else
if this.prescale = 1000000 then this.blip := '0'; end if;
this.prescale := this.prescale + 1;
end if;
this_c <= this;
end process;
led_r0 : process(clk)
begin
if clk = '1' and clk'event then
this_r <= this_c;
end if;
end process;
D <= this_r.y;
end beh;
|