1 |
2 |
amulcock |
-----------------------------------------------------------------------
|
2 |
|
|
---- ----
|
3 |
|
|
---- ----
|
4 |
|
|
---- This file is part of the big_counter project ----
|
5 |
|
|
---- http://www.opencores.org/cores/big_counter ----
|
6 |
|
|
---- ----
|
7 |
|
|
---- Description ----
|
8 |
|
|
---- Implementation of a large counter made of SRL's ----
|
9 |
|
|
---- ----
|
10 |
|
|
---- ----
|
11 |
|
|
---- To Do: ----
|
12 |
|
|
---- NA ----
|
13 |
|
|
---- ----
|
14 |
|
|
---- Author(s): ----
|
15 |
|
|
---- Andrew Mulcock, amulcock@opencores.org ----
|
16 |
|
|
---- ----
|
17 |
|
|
-----------------------------------------------------------------------
|
18 |
|
|
---- ----
|
19 |
|
|
---- Copyright (C) 2007 Authors and OPENCORES.ORG ----
|
20 |
|
|
---- ----
|
21 |
|
|
---- This source file may be used and distributed without ----
|
22 |
|
|
---- restriction provided that this copyright statement is not ----
|
23 |
|
|
---- removed from the file and that any derivative work contains ----
|
24 |
|
|
---- the original copyright notice and the associated disclaimer. ----
|
25 |
|
|
---- ----
|
26 |
|
|
---- This source file is free software; you can redistribute it ----
|
27 |
|
|
---- and/or modify it under the terms of the GNU Lesser General ----
|
28 |
|
|
---- Public License as published by the Free Software Foundation; ----
|
29 |
|
|
---- either version 2.1 of the License, or (at your option) any ----
|
30 |
|
|
---- later version. ----
|
31 |
|
|
---- ----
|
32 |
|
|
---- This source is distributed in the hope that it will be ----
|
33 |
|
|
---- useful, but WITHOUT ANY WARRANTY; without even the implied ----
|
34 |
|
|
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ----
|
35 |
|
|
---- PURPOSE. See the GNU Lesser General Public License for more ----
|
36 |
|
|
---- details. ----
|
37 |
|
|
---- ----
|
38 |
|
|
---- You should have received a copy of the GNU Lesser General ----
|
39 |
|
|
---- Public License along with this source; if not, download it ----
|
40 |
|
|
---- from http://www.opencores.org/lgpl.shtml ----
|
41 |
|
|
---- ----
|
42 |
|
|
-----------------------------------------------------------------------
|
43 |
|
|
-- ----
|
44 |
|
|
-- CVS Revision History ----
|
45 |
|
|
-- ----
|
46 |
|
|
-- $Log: not supported by cvs2svn $ ----
|
47 |
|
|
-- ----
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
|
51 |
|
|
library ieee;
|
52 |
|
|
use ieee.std_logic_1164.all;
|
53 |
|
|
|
54 |
|
|
entity am_srl_counter_rtl is
|
55 |
|
|
generic (
|
56 |
|
|
no_of_stages : integer := 200
|
57 |
|
|
);
|
58 |
|
|
port( clk : in std_logic;
|
59 |
|
|
en_in : in std_logic;
|
60 |
|
|
rco : out std_logic_vector ( no_of_stages - 1 downto 0)
|
61 |
|
|
);
|
62 |
|
|
end am_srl_counter_rtl;
|
63 |
|
|
|
64 |
|
|
architecture Behavioral of am_srl_counter_rtl is
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
type shift_counter_type is array ( no_of_stages - 1 downto 0 ) of STD_LOGIC_VECTOR ( 15 downto 0 ) ;
|
68 |
|
|
|
69 |
|
|
signal shift_srl : shift_counter_type := ( others => X"0001" );
|
70 |
|
|
signal clk_en : std_logic_vector ( no_of_stages - 1 downto 0) := ( others => '0');
|
71 |
|
|
signal rco_int : std_logic_vector ( no_of_stages - 1 downto 0) := ( others => '0');
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
begin
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
gen_srls : for n in 0 to no_of_stages - 1 generate
|
78 |
|
|
|
79 |
|
|
tap_a: if n = 0 generate
|
80 |
|
|
clk_en(n) <= en_in;
|
81 |
|
|
srl_proc_a :process (clk)
|
82 |
|
|
begin
|
83 |
|
|
if rising_edge( clk ) then
|
84 |
|
|
if clk_en(n) = '1' then
|
85 |
|
|
shift_srl(n) <= shift_srl(n)(shift_srl(n)'left-1 downto 0) & shift_srl(n)(shift_srl(n)'left);
|
86 |
|
|
end if;
|
87 |
|
|
end if;
|
88 |
|
|
end process srl_proc_a;
|
89 |
|
|
rco_int(n) <= shift_srl(n)(shift_srl(n)'left);
|
90 |
|
|
end generate tap_a;
|
91 |
|
|
|
92 |
|
|
|
93 |
|
|
tap_b: if n = 1 generate
|
94 |
|
|
clk_en(n) <= rco_int(n-1) and en_in;
|
95 |
|
|
srl_proc_b :process (clk)
|
96 |
|
|
begin
|
97 |
|
|
if rising_edge( clk) then
|
98 |
|
|
if clk_en(n) = '1' then
|
99 |
|
|
shift_srl(n) <= shift_srl(n)(shift_srl(n)'left-1 downto 0) & shift_srl(n)(shift_srl(n)'left);
|
100 |
|
|
end if;
|
101 |
|
|
end if;
|
102 |
|
|
end process srl_proc_b;
|
103 |
|
|
rco_int(n) <= en_in and shift_srl(n)(shift_srl(n)'left);
|
104 |
|
|
end generate tap_b;
|
105 |
|
|
|
106 |
|
|
tap_cp: if n > 1 generate
|
107 |
|
|
clk_en(n) <= rco_int(n-1) and rco_int(0);
|
108 |
|
|
srl_proc_c :process (clk)
|
109 |
|
|
begin
|
110 |
|
|
if rising_edge( clk) then
|
111 |
|
|
if clk_en(n) = '1' then
|
112 |
|
|
shift_srl(n) <= shift_srl(n)(shift_srl(n)'left-1 downto 0) & shift_srl(n)(shift_srl(n)'left);
|
113 |
|
|
end if;
|
114 |
|
|
end if;
|
115 |
|
|
end process srl_proc_c;
|
116 |
|
|
rco_int(n) <= rco_int(n-1) and shift_srl(n)(shift_srl(n)'left);
|
117 |
|
|
end generate tap_cp;
|
118 |
|
|
|
119 |
|
|
rco <= rco_int;
|
120 |
|
|
|
121 |
|
|
|
122 |
|
|
end generate gen_srls;
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
end Behavioral;
|