OpenCores
URL https://opencores.org/ocsvn/pcie_ds_dma/pcie_ds_dma/trunk

Subversion Repositories pcie_ds_dma

[/] [pcie_ds_dma/] [trunk/] [core/] [adm/] [cl_sp605/] [rtl/] [ctrl_blink.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dsmv
-------------------------------------------------------------------------------
2
--
3
-- Title       : ctrl_blink
4
-- Design      : ambpex5_v11_lx50t_ddr2
5
-- Author      : Dmitry Smekhov
6
-- Company     : NNS
7
--
8
-------------------------------------------------------------------------------
9
--
10
-- Description : Управление светодиодом состояния шины PCI-Express
11
--                                RESET=0 - светодиод горит
12
--                                pcie_link_up=1 - не прошла инициализация PCI-Express - 
13
--                                                               - светодиод часто непрерывно мигает
14
--                                pcie_link_up=0 - число миганий соответствует ширине
15
--                                                                 шины PCI-Express
16
--                                                                 
17
--
18
-------------------------------------------------------------------------------
19
 
20
 
21
library ieee;
22
use ieee.std_logic_1164.all;
23
 
24
package  ctrl_blink_pkg is
25
 
26
component ctrl_blink is
27
        generic(
28
                is_simulation   : in integer:=0
29
        );
30
        port(
31
                clk                             : in std_logic; -- тактовая частота 250 
32
                reset                   : in std_logic; -- 0 - сброс
33
                clk30k                  : in std_logic; -- тактовая частота 30 кГц
34
 
35
                pcie_link_up    : in std_logic; -- 0 - завершена инициализация PCI-Express
36
                pcie_lstatus    : in std_logic_vector( 15 downto 0 );    -- регистра LSTATUS
37
 
38
                led_h1                  : out std_logic -- светодиод
39
        );
40
end component;
41
 
42
end package;
43
 
44
 
45
library ieee;
46
use ieee.std_logic_1164.all;
47
use ieee.std_logic_arith.all;
48
use ieee.std_logic_unsigned.all;
49
 
50
library unisim;
51
use unisim.vcomponents.all;
52
 
53
entity ctrl_blink is
54
        generic(
55
                is_simulation   : in integer:=0
56
        );
57
        port(
58
                clk                             : in std_logic; -- тактовая частота 250 
59
                reset                   : in std_logic; -- 0 - сброс
60
                clk30k                  : in std_logic; -- тактовая частота 30 кГц
61
 
62
                pcie_link_up    : in std_logic; -- 0 - завершена инициализация PCI-Express
63
                pcie_lstatus    : in std_logic_vector( 15 downto 0 );    -- регистра LSTATUS
64
 
65
                led_h1                  : out std_logic -- светодиод
66
        );
67
end ctrl_blink;
68
 
69
 
70
architecture ctrl_blink of ctrl_blink is
71
 
72
 
73
signal  clk_blink                       : std_logic;
74
signal  clk_z1, clk_z2          : std_logic;
75
signal  mask                            : std_logic;
76
signal  cnt                                     : std_logic_vector( 3 downto 0 );
77
signal  cnt30k                          : std_logic_vector( 13 downto 0 ):=(others=>'0');
78
signal  ncnt30k                         : std_logic_vector( 13 downto 0 );
79
 
80
signal stp                                      : std_logic;
81
 
82
begin
83
gen_sim: if( is_simulation=1 ) generate
84
 
85
        clk_blink <= cnt30k(4) when stp='1' else cnt30k(3);
86
 
87
end generate;
88
 
89
gen_syn: if( is_simulation=0 ) generate
90
 
91
 
92
        clk_blink <= cnt30k(13) when stp='1' else cnt30k(12);
93
 
94
end generate;
95
 
96
 
97
 
98
clk_z1 <= clk_blink after 1 ns when rising_edge( clk );
99
clk_z2 <= clk_z1 after 1 ns when rising_edge( clk );
100
 
101
cnt30k(0) <= ncnt30k(0) when rising_edge( clk30k );
102
 
103
gen_30k: for i in 1 to 13 generate
104
        fd30k:  fd port map( q=>cnt30k(i), c=>cnt30k(i-1), d=>ncnt30k(i) );
105
end generate;
106
 
107
ncnt30k <= not cnt30k;
108
 
109
 
110
pr_state: process( clk ) begin
111
 
112
        if( rising_edge( clk ) ) then
113
                if( clk_z1='1' and clk_z2='0' ) then
114
 
115
                        case( stp ) is
116
                                when '0' =>
117
                                                if( pcie_link_up='0' ) then
118
                                                        stp <= '1' after 1 ns;
119
                                                end if;
120
                                                mask <= '0' after 1 ns;
121
                                                cnt <= "0000" after 1 ns;
122
 
123
                                when '1' =>
124
                                                if( pcie_link_up='1' ) then
125
                                                        stp <= '0' after 1 ns;
126
                                                end if;
127
                                                if( cnt(3 downto 0 )="0000" ) then
128
                                                        mask <= '0' after 1 ns;
129
                                                elsif( pcie_lstatus(6 downto 4)=cnt( 2 downto 0 ) ) then
130
                                                        mask <= '1' after 1 ns;
131
                                                end if;
132
 
133
                                                cnt <= cnt + 1 after 1 ns;
134
 
135
                                when others => null;
136
                        end case;
137
 
138
 
139
 
140
                end if;
141
 
142
                if( reset='0' ) then
143
                        mask <= '0' after 1 ns;
144
                        stp <= '0' after 1 ns;
145
                end if;
146
        end if;
147
end process;
148
 
149
led_h1 <= reset and ( clk_blink or mask );
150
 
151
end ctrl_blink;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.