@@ -1,54 +1,54 | |||||
1 | LIBRARY IEEE; |
|
1 | LIBRARY IEEE; | |
2 | USE IEEE.STD_LOGIC_1164.ALL; |
|
2 | USE IEEE.STD_LOGIC_1164.ALL; | |
3 | USE IEEE.std_logic_arith.ALL; |
|
3 | USE IEEE.NUMERIC_STD.ALL; | |
4 | USE IEEE.std_logic_unsigned.ALL; |
|
|||
5 |
|
4 | |||
6 | ENTITY general_counter IS |
|
5 | ENTITY general_counter IS | |
7 |
|
6 | |||
8 | GENERIC ( |
|
7 | GENERIC ( | |
9 | CYCLIC : STD_LOGIC := '1'; |
|
8 | CYCLIC : STD_LOGIC := '1'; | |
10 | NB_BITS_COUNTER : INTEGER := 9 |
|
9 | NB_BITS_COUNTER : INTEGER := 9; | |
|
10 | RST_VALUE : INTEGER := 0 | |||
11 | ); |
|
11 | ); | |
12 |
|
12 | |||
13 | PORT ( |
|
13 | PORT ( | |
14 | clk : IN STD_LOGIC; |
|
14 | clk : IN STD_LOGIC; | |
15 | rstn : IN STD_LOGIC; |
|
15 | rstn : IN STD_LOGIC; | |
16 | -- |
|
16 | -- | |
17 |
|
|
17 | MAX_VALUE : IN STD_LOGIC_VECTOR(NB_BITS_COUNTER-1 DOWNTO 0) := (OTHERS => '1'); | |
18 | MAX_VALUE : IN STD_LOGIC_VECTOR(NB_BITS_COUNTER-1 DOWNTO 0) := (OTHERS => '1'); |
|
|||
19 | -- |
|
18 | -- | |
20 | set : IN STD_LOGIC; |
|
19 | set : IN STD_LOGIC; | |
21 | set_value : IN STD_LOGIC_VECTOR(NB_BITS_COUNTER-1 DOWNTO 0); |
|
20 | set_value : IN STD_LOGIC_VECTOR(NB_BITS_COUNTER-1 DOWNTO 0); | |
22 | add1 : IN STD_LOGIC; |
|
21 | add1 : IN STD_LOGIC; | |
23 | counter : OUT STD_LOGIC_VECTOR(NB_BITS_COUNTER-1 DOWNTO 0) |
|
22 | counter : OUT STD_LOGIC_VECTOR(NB_BITS_COUNTER-1 DOWNTO 0) | |
24 | ); |
|
23 | ); | |
25 |
|
24 | |||
26 | END general_counter; |
|
25 | END general_counter; | |
27 |
|
26 | |||
28 | ARCHITECTURE beh OF general_counter IS |
|
27 | ARCHITECTURE beh OF general_counter IS | |
29 | SIGNAL counter_s : STD_LOGIC_VECTOR(NB_BITS_COUNTER-1 DOWNTO 0); |
|
28 | CONSTANT RST_VALUE_v : STD_LOGIC_VECTOR(NB_BITS_COUNTER-1 DOWNTO 0) := STD_LOGIC_VECTOR(to_unsigned(RST_VALUE, NB_BITS_COUNTER)); | |
|
29 | SIGNAL counter_s : STD_LOGIC_VECTOR(NB_BITS_COUNTER-1 DOWNTO 0); | |||
30 |
|
30 | |||
31 | BEGIN -- beh |
|
31 | BEGIN -- beh | |
32 |
|
32 | |||
33 | PROCESS (clk, rstn) |
|
33 | PROCESS (clk, rstn) | |
34 | BEGIN -- PROCESS |
|
34 | BEGIN -- PROCESS | |
35 | IF rstn = '0' THEN -- asynchronous reset (active low) |
|
35 | IF rstn = '0' THEN -- asynchronous reset (active low) | |
36 | counter_s <= RST_VALUE; |
|
36 | counter_s <= RST_VALUE_v; | |
37 |
ELSIF clk' |
|
37 | ELSIF clk'EVENT AND clk = '1' THEN -- rising clock edge | |
38 | IF set = '1' THEN |
|
38 | IF set = '1' THEN | |
39 | counter_s <= set_value; |
|
39 | counter_s <= set_value; | |
40 | ELSIF add1 = '1' THEN |
|
40 | ELSIF add1 = '1' THEN | |
41 | IF counter_s < MAX_VALUE THEN |
|
41 | IF counter_s < MAX_VALUE THEN | |
42 | counter_s <= counter_s + 1; |
|
42 | counter_s <= STD_LOGIC_VECTOR((UNSIGNED(counter_s) + 1)); | |
43 | ELSE |
|
43 | ELSE | |
44 | IF CYCLIC = '1' THEN |
|
44 | IF CYCLIC = '1' THEN | |
45 | counter_s <= (OTHERS => '0'); |
|
45 | counter_s <= (OTHERS => '0'); | |
46 | END IF; |
|
46 | END IF; | |
47 | END IF; |
|
47 | END IF; | |
48 | END IF; |
|
48 | END IF; | |
49 | END IF; |
|
49 | END IF; | |
50 | END PROCESS; |
|
50 | END PROCESS; | |
51 |
|
51 | |||
52 | counter <= counter_s; |
|
52 | counter <= counter_s; | |
53 |
|
53 | |||
54 | END beh; |
|
54 | END beh; |
@@ -1,395 +1,395 | |||||
1 | ------------------------------------------------------------------------------ |
|
1 | ------------------------------------------------------------------------------ | |
2 | -- This file is a part of the LPP VHDL IP LIBRARY |
|
2 | -- This file is a part of the LPP VHDL IP LIBRARY | |
3 | -- Copyright (C) 2009 - 2010, Laboratory of Plasmas Physic - CNRS |
|
3 | -- Copyright (C) 2009 - 2010, Laboratory of Plasmas Physic - CNRS | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 3 of the License, or |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | ------------------------------------------------------------------------------- |
|
18 | ------------------------------------------------------------------------------- | |
19 | -- Author : Alexis Jeandet |
|
19 | -- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@lpp.polytechnique.fr |
|
20 | -- Mail : alexis.jeandet@lpp.polytechnique.fr | |
21 | ---------------------------------------------------------------------------- |
|
21 | ---------------------------------------------------------------------------- | |
22 | --UPDATE |
|
22 | --UPDATE | |
23 | ------------------------------------------------------------------------------- |
|
23 | ------------------------------------------------------------------------------- | |
24 | -- 14-03-2013 - Jean-christophe Pellion |
|
24 | -- 14-03-2013 - Jean-christophe Pellion | |
25 | -- ADD MUXN (a parametric multiplexor (N stage of MUX2)) |
|
25 | -- ADD MUXN (a parametric multiplexor (N stage of MUX2)) | |
26 | ------------------------------------------------------------------------------- |
|
26 | ------------------------------------------------------------------------------- | |
27 |
|
27 | |||
28 | LIBRARY ieee; |
|
28 | LIBRARY ieee; | |
29 | USE ieee.std_logic_1164.ALL; |
|
29 | USE ieee.std_logic_1164.ALL; | |
30 | USE IEEE.NUMERIC_STD.ALL; |
|
30 | USE IEEE.NUMERIC_STD.ALL; | |
31 |
|
31 | |||
32 |
|
32 | |||
33 |
|
33 | |||
34 | PACKAGE general_purpose IS |
|
34 | PACKAGE general_purpose IS | |
35 |
|
35 | |||
36 |
|
|
36 | COMPONENT general_counter | |
37 | GENERIC ( |
|
37 | GENERIC ( | |
38 | CYCLIC : STD_LOGIC; |
|
38 | CYCLIC : STD_LOGIC; | |
39 |
NB_BITS_COUNTER : INTEGER |
|
39 | NB_BITS_COUNTER : INTEGER; | |
|
40 | RST_VALUE : INTEGER); | |||
40 | PORT ( |
|
41 | PORT ( | |
41 | clk : IN STD_LOGIC; |
|
42 | clk : IN STD_LOGIC; | |
42 | rstn : IN STD_LOGIC; |
|
43 | rstn : IN STD_LOGIC; | |
43 |
|
|
44 | MAX_VALUE : IN STD_LOGIC_VECTOR(NB_BITS_COUNTER-1 DOWNTO 0); | |
44 | MAX_VALUE : IN STD_LOGIC_VECTOR(NB_BITS_COUNTER-1 DOWNTO 0); |
|
|||
45 | set : IN STD_LOGIC; |
|
45 | set : IN STD_LOGIC; | |
46 | set_value : IN STD_LOGIC_VECTOR(NB_BITS_COUNTER-1 DOWNTO 0); |
|
46 | set_value : IN STD_LOGIC_VECTOR(NB_BITS_COUNTER-1 DOWNTO 0); | |
47 | add1 : IN STD_LOGIC; |
|
47 | add1 : IN STD_LOGIC; | |
48 | counter : OUT STD_LOGIC_VECTOR(NB_BITS_COUNTER-1 DOWNTO 0)); |
|
48 | counter : OUT STD_LOGIC_VECTOR(NB_BITS_COUNTER-1 DOWNTO 0)); | |
49 | END COMPONENT; |
|
49 | END COMPONENT; | |
50 |
|
50 | |||
51 | COMPONENT Clk_divider IS |
|
51 | COMPONENT Clk_divider IS | |
52 | GENERIC(OSC_freqHz : INTEGER := 50000000; |
|
52 | GENERIC(OSC_freqHz : INTEGER := 50000000; | |
53 | TargetFreq_Hz : INTEGER := 50000); |
|
53 | TargetFreq_Hz : INTEGER := 50000); | |
54 | PORT (clk : IN STD_LOGIC; |
|
54 | PORT (clk : IN STD_LOGIC; | |
55 | reset : IN STD_LOGIC; |
|
55 | reset : IN STD_LOGIC; | |
56 | clk_divided : OUT STD_LOGIC); |
|
56 | clk_divided : OUT STD_LOGIC); | |
57 | END COMPONENT; |
|
57 | END COMPONENT; | |
58 |
|
58 | |||
59 |
|
59 | |||
60 | COMPONENT Clk_divider2 IS |
|
60 | COMPONENT Clk_divider2 IS | |
61 | generic(N : integer := 16); |
|
61 | generic(N : integer := 16); | |
62 | port( |
|
62 | port( | |
63 | clk_in : in std_logic; |
|
63 | clk_in : in std_logic; | |
64 | clk_out : out std_logic); |
|
64 | clk_out : out std_logic); | |
65 | END COMPONENT; |
|
65 | END COMPONENT; | |
66 |
|
66 | |||
67 | COMPONENT Adder IS |
|
67 | COMPONENT Adder IS | |
68 | GENERIC( |
|
68 | GENERIC( | |
69 | Input_SZ_A : INTEGER := 16; |
|
69 | Input_SZ_A : INTEGER := 16; | |
70 | Input_SZ_B : INTEGER := 16 |
|
70 | Input_SZ_B : INTEGER := 16 | |
71 |
|
71 | |||
72 | ); |
|
72 | ); | |
73 | PORT( |
|
73 | PORT( | |
74 | clk : IN STD_LOGIC; |
|
74 | clk : IN STD_LOGIC; | |
75 | reset : IN STD_LOGIC; |
|
75 | reset : IN STD_LOGIC; | |
76 | clr : IN STD_LOGIC; |
|
76 | clr : IN STD_LOGIC; | |
77 | load : IN STD_LOGIC; |
|
77 | load : IN STD_LOGIC; | |
78 | add : IN STD_LOGIC; |
|
78 | add : IN STD_LOGIC; | |
79 | OP1 : IN STD_LOGIC_VECTOR(Input_SZ_A-1 DOWNTO 0); |
|
79 | OP1 : IN STD_LOGIC_VECTOR(Input_SZ_A-1 DOWNTO 0); | |
80 | OP2 : IN STD_LOGIC_VECTOR(Input_SZ_B-1 DOWNTO 0); |
|
80 | OP2 : IN STD_LOGIC_VECTOR(Input_SZ_B-1 DOWNTO 0); | |
81 | RES : OUT STD_LOGIC_VECTOR(Input_SZ_A-1 DOWNTO 0) |
|
81 | RES : OUT STD_LOGIC_VECTOR(Input_SZ_A-1 DOWNTO 0) | |
82 | ); |
|
82 | ); | |
83 | END COMPONENT; |
|
83 | END COMPONENT; | |
84 |
|
84 | |||
85 | COMPONENT Adder_V0 is |
|
85 | COMPONENT Adder_V0 is | |
86 | generic( |
|
86 | generic( | |
87 | Input_SZ_A : integer := 16; |
|
87 | Input_SZ_A : integer := 16; | |
88 | Input_SZ_B : integer := 16 |
|
88 | Input_SZ_B : integer := 16 | |
89 |
|
89 | |||
90 | ); |
|
90 | ); | |
91 | port( |
|
91 | port( | |
92 | clk : in std_logic; |
|
92 | clk : in std_logic; | |
93 | reset : in std_logic; |
|
93 | reset : in std_logic; | |
94 | clr : in std_logic; |
|
94 | clr : in std_logic; | |
95 | add : in std_logic; |
|
95 | add : in std_logic; | |
96 | OP1 : in std_logic_vector(Input_SZ_A-1 downto 0); |
|
96 | OP1 : in std_logic_vector(Input_SZ_A-1 downto 0); | |
97 | OP2 : in std_logic_vector(Input_SZ_B-1 downto 0); |
|
97 | OP2 : in std_logic_vector(Input_SZ_B-1 downto 0); | |
98 | RES : out std_logic_vector(Input_SZ_A-1 downto 0) |
|
98 | RES : out std_logic_vector(Input_SZ_A-1 downto 0) | |
99 | ); |
|
99 | ); | |
100 | end COMPONENT; |
|
100 | end COMPONENT; | |
101 |
|
101 | |||
102 | COMPONENT ADDRcntr IS |
|
102 | COMPONENT ADDRcntr IS | |
103 | PORT( |
|
103 | PORT( | |
104 | clk : IN STD_LOGIC; |
|
104 | clk : IN STD_LOGIC; | |
105 | reset : IN STD_LOGIC; |
|
105 | reset : IN STD_LOGIC; | |
106 | count : IN STD_LOGIC; |
|
106 | count : IN STD_LOGIC; | |
107 | clr : IN STD_LOGIC; |
|
107 | clr : IN STD_LOGIC; | |
108 | Q : OUT STD_LOGIC_VECTOR(7 DOWNTO 0) |
|
108 | Q : OUT STD_LOGIC_VECTOR(7 DOWNTO 0) | |
109 | ); |
|
109 | ); | |
110 | END COMPONENT; |
|
110 | END COMPONENT; | |
111 |
|
111 | |||
112 | COMPONENT ALU IS |
|
112 | COMPONENT ALU IS | |
113 | GENERIC( |
|
113 | GENERIC( | |
114 | Arith_en : INTEGER := 1; |
|
114 | Arith_en : INTEGER := 1; | |
115 | Logic_en : INTEGER := 1; |
|
115 | Logic_en : INTEGER := 1; | |
116 | Input_SZ_1 : INTEGER := 16; |
|
116 | Input_SZ_1 : INTEGER := 16; | |
117 | Input_SZ_2 : INTEGER := 9; |
|
117 | Input_SZ_2 : INTEGER := 9; | |
118 | COMP_EN : INTEGER := 0 -- 1 => No Comp |
|
118 | COMP_EN : INTEGER := 0 -- 1 => No Comp | |
119 |
|
119 | |||
120 | ); |
|
120 | ); | |
121 | PORT( |
|
121 | PORT( | |
122 | clk : IN STD_LOGIC; |
|
122 | clk : IN STD_LOGIC; | |
123 | reset : IN STD_LOGIC; |
|
123 | reset : IN STD_LOGIC; | |
124 | ctrl : IN STD_LOGIC_VECTOR(2 downto 0); |
|
124 | ctrl : IN STD_LOGIC_VECTOR(2 downto 0); | |
125 | comp : IN STD_LOGIC_VECTOR(1 downto 0); |
|
125 | comp : IN STD_LOGIC_VECTOR(1 downto 0); | |
126 | OP1 : IN STD_LOGIC_VECTOR(Input_SZ_1-1 DOWNTO 0); |
|
126 | OP1 : IN STD_LOGIC_VECTOR(Input_SZ_1-1 DOWNTO 0); | |
127 | OP2 : IN STD_LOGIC_VECTOR(Input_SZ_2-1 DOWNTO 0); |
|
127 | OP2 : IN STD_LOGIC_VECTOR(Input_SZ_2-1 DOWNTO 0); | |
128 | RES : OUT STD_LOGIC_VECTOR(Input_SZ_1+Input_SZ_2-1 DOWNTO 0) |
|
128 | RES : OUT STD_LOGIC_VECTOR(Input_SZ_1+Input_SZ_2-1 DOWNTO 0) | |
129 | ); |
|
129 | ); | |
130 | END COMPONENT; |
|
130 | END COMPONENT; | |
131 |
|
131 | |||
132 | COMPONENT ALU_V0 IS |
|
132 | COMPONENT ALU_V0 IS | |
133 | GENERIC( |
|
133 | GENERIC( | |
134 | Arith_en : INTEGER := 1; |
|
134 | Arith_en : INTEGER := 1; | |
135 | Logic_en : INTEGER := 1; |
|
135 | Logic_en : INTEGER := 1; | |
136 | Input_SZ_1 : INTEGER := 16; |
|
136 | Input_SZ_1 : INTEGER := 16; | |
137 | Input_SZ_2 : INTEGER := 9 |
|
137 | Input_SZ_2 : INTEGER := 9 | |
138 |
|
138 | |||
139 | ); |
|
139 | ); | |
140 | PORT( |
|
140 | PORT( | |
141 | clk : IN STD_LOGIC; |
|
141 | clk : IN STD_LOGIC; | |
142 | reset : IN STD_LOGIC; |
|
142 | reset : IN STD_LOGIC; | |
143 | ctrl : IN STD_LOGIC_VECTOR(3 DOWNTO 0); |
|
143 | ctrl : IN STD_LOGIC_VECTOR(3 DOWNTO 0); | |
144 | OP1 : IN STD_LOGIC_VECTOR(Input_SZ_1-1 DOWNTO 0); |
|
144 | OP1 : IN STD_LOGIC_VECTOR(Input_SZ_1-1 DOWNTO 0); | |
145 | OP2 : IN STD_LOGIC_VECTOR(Input_SZ_2-1 DOWNTO 0); |
|
145 | OP2 : IN STD_LOGIC_VECTOR(Input_SZ_2-1 DOWNTO 0); | |
146 | RES : OUT STD_LOGIC_VECTOR(Input_SZ_1+Input_SZ_2-1 DOWNTO 0) |
|
146 | RES : OUT STD_LOGIC_VECTOR(Input_SZ_1+Input_SZ_2-1 DOWNTO 0) | |
147 | ); |
|
147 | ); | |
148 | END COMPONENT; |
|
148 | END COMPONENT; | |
149 |
|
149 | |||
150 | COMPONENT MAC_V0 is |
|
150 | COMPONENT MAC_V0 is | |
151 | generic( |
|
151 | generic( | |
152 | Input_SZ_A : integer := 8; |
|
152 | Input_SZ_A : integer := 8; | |
153 | Input_SZ_B : integer := 8 |
|
153 | Input_SZ_B : integer := 8 | |
154 |
|
154 | |||
155 | ); |
|
155 | ); | |
156 | port( |
|
156 | port( | |
157 | clk : in std_logic; |
|
157 | clk : in std_logic; | |
158 | reset : in std_logic; |
|
158 | reset : in std_logic; | |
159 | clr_MAC : in std_logic; |
|
159 | clr_MAC : in std_logic; | |
160 | MAC_MUL_ADD : in std_logic_vector(1 downto 0); |
|
160 | MAC_MUL_ADD : in std_logic_vector(1 downto 0); | |
161 | OP1 : in std_logic_vector(Input_SZ_A-1 downto 0); |
|
161 | OP1 : in std_logic_vector(Input_SZ_A-1 downto 0); | |
162 | OP2 : in std_logic_vector(Input_SZ_B-1 downto 0); |
|
162 | OP2 : in std_logic_vector(Input_SZ_B-1 downto 0); | |
163 | RES : out std_logic_vector(Input_SZ_A+Input_SZ_B-1 downto 0) |
|
163 | RES : out std_logic_vector(Input_SZ_A+Input_SZ_B-1 downto 0) | |
164 | ); |
|
164 | ); | |
165 | end COMPONENT; |
|
165 | end COMPONENT; | |
166 |
|
166 | |||
167 | --------------------------------------------------------- |
|
167 | --------------------------------------------------------- | |
168 | -------- // SΓ©lection grace a l'entrΓ©e "ctrl" \\ -------- |
|
168 | -------- // SΓ©lection grace a l'entrΓ©e "ctrl" \\ -------- | |
169 | --------------------------------------------------------- |
|
169 | --------------------------------------------------------- | |
170 | Constant ctrl_IDLE : std_logic_vector(2 downto 0) := "000"; |
|
170 | Constant ctrl_IDLE : std_logic_vector(2 downto 0) := "000"; | |
171 | Constant ctrl_MAC : std_logic_vector(2 downto 0) := "001"; |
|
171 | Constant ctrl_MAC : std_logic_vector(2 downto 0) := "001"; | |
172 | Constant ctrl_MULT : std_logic_vector(2 downto 0) := "010"; |
|
172 | Constant ctrl_MULT : std_logic_vector(2 downto 0) := "010"; | |
173 | Constant ctrl_ADD : std_logic_vector(2 downto 0) := "011"; |
|
173 | Constant ctrl_ADD : std_logic_vector(2 downto 0) := "011"; | |
174 | Constant ctrl_CLRMAC : std_logic_vector(2 downto 0) := "100"; |
|
174 | Constant ctrl_CLRMAC : std_logic_vector(2 downto 0) := "100"; | |
175 |
|
175 | |||
176 |
|
176 | |||
177 | Constant IDLE_V0 : std_logic_vector(3 downto 0) := "0000"; |
|
177 | Constant IDLE_V0 : std_logic_vector(3 downto 0) := "0000"; | |
178 | Constant MAC_op_V0 : std_logic_vector(3 downto 0) := "0001"; |
|
178 | Constant MAC_op_V0 : std_logic_vector(3 downto 0) := "0001"; | |
179 | Constant MULT_V0 : std_logic_vector(3 downto 0) := "0010"; |
|
179 | Constant MULT_V0 : std_logic_vector(3 downto 0) := "0010"; | |
180 | Constant ADD_V0 : std_logic_vector(3 downto 0) := "0011"; |
|
180 | Constant ADD_V0 : std_logic_vector(3 downto 0) := "0011"; | |
181 | Constant CLR_MAC_V0 : std_logic_vector(3 downto 0) := "0100"; |
|
181 | Constant CLR_MAC_V0 : std_logic_vector(3 downto 0) := "0100"; | |
182 | --------------------------------------------------------- |
|
182 | --------------------------------------------------------- | |
183 |
|
183 | |||
184 | COMPONENT MAC IS |
|
184 | COMPONENT MAC IS | |
185 | GENERIC( |
|
185 | GENERIC( | |
186 | Input_SZ_A : INTEGER := 8; |
|
186 | Input_SZ_A : INTEGER := 8; | |
187 | Input_SZ_B : INTEGER := 8; |
|
187 | Input_SZ_B : INTEGER := 8; | |
188 | COMP_EN : INTEGER := 0 -- 1 => No Comp |
|
188 | COMP_EN : INTEGER := 0 -- 1 => No Comp | |
189 | ); |
|
189 | ); | |
190 | PORT( |
|
190 | PORT( | |
191 | clk : IN STD_LOGIC; |
|
191 | clk : IN STD_LOGIC; | |
192 | reset : IN STD_LOGIC; |
|
192 | reset : IN STD_LOGIC; | |
193 | clr_MAC : IN STD_LOGIC; |
|
193 | clr_MAC : IN STD_LOGIC; | |
194 | MAC_MUL_ADD : IN STD_LOGIC_VECTOR(1 DOWNTO 0); |
|
194 | MAC_MUL_ADD : IN STD_LOGIC_VECTOR(1 DOWNTO 0); | |
195 | Comp_2C : IN STD_LOGIC_VECTOR(1 DOWNTO 0); |
|
195 | Comp_2C : IN STD_LOGIC_VECTOR(1 DOWNTO 0); | |
196 | OP1 : IN STD_LOGIC_VECTOR(Input_SZ_A-1 DOWNTO 0); |
|
196 | OP1 : IN STD_LOGIC_VECTOR(Input_SZ_A-1 DOWNTO 0); | |
197 | OP2 : IN STD_LOGIC_VECTOR(Input_SZ_B-1 DOWNTO 0); |
|
197 | OP2 : IN STD_LOGIC_VECTOR(Input_SZ_B-1 DOWNTO 0); | |
198 | RES : OUT STD_LOGIC_VECTOR(Input_SZ_A+Input_SZ_B-1 DOWNTO 0) |
|
198 | RES : OUT STD_LOGIC_VECTOR(Input_SZ_A+Input_SZ_B-1 DOWNTO 0) | |
199 | ); |
|
199 | ); | |
200 | END COMPONENT; |
|
200 | END COMPONENT; | |
201 |
|
201 | |||
202 | COMPONENT TwoComplementer is |
|
202 | COMPONENT TwoComplementer is | |
203 | generic( |
|
203 | generic( | |
204 | Input_SZ : integer := 16); |
|
204 | Input_SZ : integer := 16); | |
205 | port( |
|
205 | port( | |
206 | clk : in std_logic; --! Horloge du composant |
|
206 | clk : in std_logic; --! Horloge du composant | |
207 | reset : in std_logic; --! Reset general du composant |
|
207 | reset : in std_logic; --! Reset general du composant | |
208 | clr : in std_logic; --! Un reset spΓ©cifique au programme |
|
208 | clr : in std_logic; --! Un reset spΓ©cifique au programme | |
209 | TwoComp : in std_logic; --! Autorise l'utilisation du complΓ©ment |
|
209 | TwoComp : in std_logic; --! Autorise l'utilisation du complΓ©ment | |
210 | OP : in std_logic_vector(Input_SZ-1 downto 0); --! OpΓ©rande d'entrΓ©e |
|
210 | OP : in std_logic_vector(Input_SZ-1 downto 0); --! OpΓ©rande d'entrΓ©e | |
211 | RES : out std_logic_vector(Input_SZ-1 downto 0) --! RΓ©sultat, opΓ©rande complΓ©mentΓ© ou non |
|
211 | RES : out std_logic_vector(Input_SZ-1 downto 0) --! RΓ©sultat, opΓ©rande complΓ©mentΓ© ou non | |
212 | ); |
|
212 | ); | |
213 | end COMPONENT; |
|
213 | end COMPONENT; | |
214 |
|
214 | |||
215 | COMPONENT MAC_CONTROLER IS |
|
215 | COMPONENT MAC_CONTROLER IS | |
216 | PORT( |
|
216 | PORT( | |
217 | ctrl : IN STD_LOGIC_VECTOR(1 DOWNTO 0); |
|
217 | ctrl : IN STD_LOGIC_VECTOR(1 DOWNTO 0); | |
218 | MULT : OUT STD_LOGIC; |
|
218 | MULT : OUT STD_LOGIC; | |
219 | ADD : OUT STD_LOGIC; |
|
219 | ADD : OUT STD_LOGIC; | |
220 | -- LOAD_ADDER : out std_logic; |
|
220 | -- LOAD_ADDER : out std_logic; | |
221 | MACMUX_sel : OUT STD_LOGIC; |
|
221 | MACMUX_sel : OUT STD_LOGIC; | |
222 | MACMUX2_sel : OUT STD_LOGIC |
|
222 | MACMUX2_sel : OUT STD_LOGIC | |
223 | ); |
|
223 | ); | |
224 | END COMPONENT; |
|
224 | END COMPONENT; | |
225 |
|
225 | |||
226 | COMPONENT MAC_MUX IS |
|
226 | COMPONENT MAC_MUX IS | |
227 | GENERIC( |
|
227 | GENERIC( | |
228 | Input_SZ_A : INTEGER := 16; |
|
228 | Input_SZ_A : INTEGER := 16; | |
229 | Input_SZ_B : INTEGER := 16 |
|
229 | Input_SZ_B : INTEGER := 16 | |
230 |
|
230 | |||
231 | ); |
|
231 | ); | |
232 | PORT( |
|
232 | PORT( | |
233 | sel : IN STD_LOGIC; |
|
233 | sel : IN STD_LOGIC; | |
234 | INA1 : IN STD_LOGIC_VECTOR(Input_SZ_A-1 DOWNTO 0); |
|
234 | INA1 : IN STD_LOGIC_VECTOR(Input_SZ_A-1 DOWNTO 0); | |
235 | INA2 : IN STD_LOGIC_VECTOR(Input_SZ_A-1 DOWNTO 0); |
|
235 | INA2 : IN STD_LOGIC_VECTOR(Input_SZ_A-1 DOWNTO 0); | |
236 | INB1 : IN STD_LOGIC_VECTOR(Input_SZ_B-1 DOWNTO 0); |
|
236 | INB1 : IN STD_LOGIC_VECTOR(Input_SZ_B-1 DOWNTO 0); | |
237 | INB2 : IN STD_LOGIC_VECTOR(Input_SZ_B-1 DOWNTO 0); |
|
237 | INB2 : IN STD_LOGIC_VECTOR(Input_SZ_B-1 DOWNTO 0); | |
238 | OUTA : OUT STD_LOGIC_VECTOR(Input_SZ_A-1 DOWNTO 0); |
|
238 | OUTA : OUT STD_LOGIC_VECTOR(Input_SZ_A-1 DOWNTO 0); | |
239 | OUTB : OUT STD_LOGIC_VECTOR(Input_SZ_B-1 DOWNTO 0) |
|
239 | OUTB : OUT STD_LOGIC_VECTOR(Input_SZ_B-1 DOWNTO 0) | |
240 | ); |
|
240 | ); | |
241 | END COMPONENT; |
|
241 | END COMPONENT; | |
242 |
|
242 | |||
243 |
|
243 | |||
244 | COMPONENT MAC_MUX2 IS |
|
244 | COMPONENT MAC_MUX2 IS | |
245 | GENERIC(Input_SZ : INTEGER := 16); |
|
245 | GENERIC(Input_SZ : INTEGER := 16); | |
246 | PORT( |
|
246 | PORT( | |
247 | sel : IN STD_LOGIC; |
|
247 | sel : IN STD_LOGIC; | |
248 | RES1 : IN STD_LOGIC_VECTOR(Input_SZ-1 DOWNTO 0); |
|
248 | RES1 : IN STD_LOGIC_VECTOR(Input_SZ-1 DOWNTO 0); | |
249 | RES2 : IN STD_LOGIC_VECTOR(Input_SZ-1 DOWNTO 0); |
|
249 | RES2 : IN STD_LOGIC_VECTOR(Input_SZ-1 DOWNTO 0); | |
250 | RES : OUT STD_LOGIC_VECTOR(Input_SZ-1 DOWNTO 0) |
|
250 | RES : OUT STD_LOGIC_VECTOR(Input_SZ-1 DOWNTO 0) | |
251 | ); |
|
251 | ); | |
252 | END COMPONENT; |
|
252 | END COMPONENT; | |
253 |
|
253 | |||
254 |
|
254 | |||
255 | COMPONENT MAC_REG IS |
|
255 | COMPONENT MAC_REG IS | |
256 | GENERIC(size : INTEGER := 16); |
|
256 | GENERIC(size : INTEGER := 16); | |
257 | PORT( |
|
257 | PORT( | |
258 | reset : IN STD_LOGIC; |
|
258 | reset : IN STD_LOGIC; | |
259 | clk : IN STD_LOGIC; |
|
259 | clk : IN STD_LOGIC; | |
260 | D : IN STD_LOGIC_VECTOR(size-1 DOWNTO 0); |
|
260 | D : IN STD_LOGIC_VECTOR(size-1 DOWNTO 0); | |
261 | Q : OUT STD_LOGIC_VECTOR(size-1 DOWNTO 0) |
|
261 | Q : OUT STD_LOGIC_VECTOR(size-1 DOWNTO 0) | |
262 | ); |
|
262 | ); | |
263 | END COMPONENT; |
|
263 | END COMPONENT; | |
264 |
|
264 | |||
265 |
|
265 | |||
266 | COMPONENT MUX2 IS |
|
266 | COMPONENT MUX2 IS | |
267 | GENERIC(Input_SZ : INTEGER := 16); |
|
267 | GENERIC(Input_SZ : INTEGER := 16); | |
268 | PORT( |
|
268 | PORT( | |
269 | sel : IN STD_LOGIC; |
|
269 | sel : IN STD_LOGIC; | |
270 | IN1 : IN STD_LOGIC_VECTOR(Input_SZ-1 DOWNTO 0); |
|
270 | IN1 : IN STD_LOGIC_VECTOR(Input_SZ-1 DOWNTO 0); | |
271 | IN2 : IN STD_LOGIC_VECTOR(Input_SZ-1 DOWNTO 0); |
|
271 | IN2 : IN STD_LOGIC_VECTOR(Input_SZ-1 DOWNTO 0); | |
272 | RES : OUT STD_LOGIC_VECTOR(Input_SZ-1 DOWNTO 0) |
|
272 | RES : OUT STD_LOGIC_VECTOR(Input_SZ-1 DOWNTO 0) | |
273 | ); |
|
273 | ); | |
274 | END COMPONENT; |
|
274 | END COMPONENT; | |
275 |
|
275 | |||
276 | TYPE MUX_INPUT_TYPE IS ARRAY (NATURAL RANGE <>, NATURAL RANGE <>) OF STD_LOGIC; |
|
276 | TYPE MUX_INPUT_TYPE IS ARRAY (NATURAL RANGE <>, NATURAL RANGE <>) OF STD_LOGIC; | |
277 | TYPE MUX_OUTPUT_TYPE IS ARRAY (NATURAL RANGE <>) OF STD_LOGIC; |
|
277 | TYPE MUX_OUTPUT_TYPE IS ARRAY (NATURAL RANGE <>) OF STD_LOGIC; | |
278 |
|
278 | |||
279 | COMPONENT MUXN |
|
279 | COMPONENT MUXN | |
280 | GENERIC ( |
|
280 | GENERIC ( | |
281 | Input_SZ : INTEGER; |
|
281 | Input_SZ : INTEGER; | |
282 | NbStage : INTEGER); |
|
282 | NbStage : INTEGER); | |
283 | PORT ( |
|
283 | PORT ( | |
284 | sel : IN STD_LOGIC_VECTOR(NbStage-1 DOWNTO 0); |
|
284 | sel : IN STD_LOGIC_VECTOR(NbStage-1 DOWNTO 0); | |
285 | INPUT : IN MUX_INPUT_TYPE(0 TO (2**NbStage)-1,Input_SZ-1 DOWNTO 0); |
|
285 | INPUT : IN MUX_INPUT_TYPE(0 TO (2**NbStage)-1,Input_SZ-1 DOWNTO 0); | |
286 | --INPUT : IN ARRAY (0 TO (2**NbStage)-1) OF STD_LOGIC_VECTOR(Input_SZ-1 DOWNTO 0); |
|
286 | --INPUT : IN ARRAY (0 TO (2**NbStage)-1) OF STD_LOGIC_VECTOR(Input_SZ-1 DOWNTO 0); | |
287 | RES : OUT MUX_OUTPUT_TYPE(Input_SZ-1 DOWNTO 0)); |
|
287 | RES : OUT MUX_OUTPUT_TYPE(Input_SZ-1 DOWNTO 0)); | |
288 | END COMPONENT; |
|
288 | END COMPONENT; | |
289 |
|
289 | |||
290 |
|
290 | |||
291 |
|
291 | |||
292 | COMPONENT Multiplier IS |
|
292 | COMPONENT Multiplier IS | |
293 | GENERIC( |
|
293 | GENERIC( | |
294 | Input_SZ_A : INTEGER := 16; |
|
294 | Input_SZ_A : INTEGER := 16; | |
295 | Input_SZ_B : INTEGER := 16 |
|
295 | Input_SZ_B : INTEGER := 16 | |
296 |
|
296 | |||
297 | ); |
|
297 | ); | |
298 | PORT( |
|
298 | PORT( | |
299 | clk : IN STD_LOGIC; |
|
299 | clk : IN STD_LOGIC; | |
300 | reset : IN STD_LOGIC; |
|
300 | reset : IN STD_LOGIC; | |
301 | mult : IN STD_LOGIC; |
|
301 | mult : IN STD_LOGIC; | |
302 | OP1 : IN STD_LOGIC_VECTOR(Input_SZ_A-1 DOWNTO 0); |
|
302 | OP1 : IN STD_LOGIC_VECTOR(Input_SZ_A-1 DOWNTO 0); | |
303 | OP2 : IN STD_LOGIC_VECTOR(Input_SZ_B-1 DOWNTO 0); |
|
303 | OP2 : IN STD_LOGIC_VECTOR(Input_SZ_B-1 DOWNTO 0); | |
304 | RES : OUT STD_LOGIC_VECTOR(Input_SZ_A+Input_SZ_B-1 DOWNTO 0) |
|
304 | RES : OUT STD_LOGIC_VECTOR(Input_SZ_A+Input_SZ_B-1 DOWNTO 0) | |
305 | ); |
|
305 | ); | |
306 | END COMPONENT; |
|
306 | END COMPONENT; | |
307 |
|
307 | |||
308 | COMPONENT REG IS |
|
308 | COMPONENT REG IS | |
309 | GENERIC(size : INTEGER := 16; initial_VALUE : INTEGER := 0); |
|
309 | GENERIC(size : INTEGER := 16; initial_VALUE : INTEGER := 0); | |
310 | PORT( |
|
310 | PORT( | |
311 | reset : IN STD_LOGIC; |
|
311 | reset : IN STD_LOGIC; | |
312 | clk : IN STD_LOGIC; |
|
312 | clk : IN STD_LOGIC; | |
313 | D : IN STD_LOGIC_VECTOR(size-1 DOWNTO 0); |
|
313 | D : IN STD_LOGIC_VECTOR(size-1 DOWNTO 0); | |
314 | Q : OUT STD_LOGIC_VECTOR(size-1 DOWNTO 0) |
|
314 | Q : OUT STD_LOGIC_VECTOR(size-1 DOWNTO 0) | |
315 | ); |
|
315 | ); | |
316 | END COMPONENT; |
|
316 | END COMPONENT; | |
317 |
|
317 | |||
318 |
|
318 | |||
319 |
|
319 | |||
320 | COMPONENT RShifter IS |
|
320 | COMPONENT RShifter IS | |
321 | GENERIC( |
|
321 | GENERIC( | |
322 | Input_SZ : INTEGER := 16; |
|
322 | Input_SZ : INTEGER := 16; | |
323 | shift_SZ : INTEGER := 4 |
|
323 | shift_SZ : INTEGER := 4 | |
324 | ); |
|
324 | ); | |
325 | PORT( |
|
325 | PORT( | |
326 | clk : IN STD_LOGIC; |
|
326 | clk : IN STD_LOGIC; | |
327 | reset : IN STD_LOGIC; |
|
327 | reset : IN STD_LOGIC; | |
328 | shift : IN STD_LOGIC; |
|
328 | shift : IN STD_LOGIC; | |
329 | OP : IN STD_LOGIC_VECTOR(Input_SZ-1 DOWNTO 0); |
|
329 | OP : IN STD_LOGIC_VECTOR(Input_SZ-1 DOWNTO 0); | |
330 | cnt : IN STD_LOGIC_VECTOR(shift_SZ-1 DOWNTO 0); |
|
330 | cnt : IN STD_LOGIC_VECTOR(shift_SZ-1 DOWNTO 0); | |
331 | RES : OUT STD_LOGIC_VECTOR(Input_SZ-1 DOWNTO 0) |
|
331 | RES : OUT STD_LOGIC_VECTOR(Input_SZ-1 DOWNTO 0) | |
332 | ); |
|
332 | ); | |
333 | END COMPONENT; |
|
333 | END COMPONENT; | |
334 |
|
334 | |||
335 | COMPONENT SYNC_FF |
|
335 | COMPONENT SYNC_FF | |
336 | GENERIC ( |
|
336 | GENERIC ( | |
337 | NB_FF_OF_SYNC : INTEGER); |
|
337 | NB_FF_OF_SYNC : INTEGER); | |
338 | PORT ( |
|
338 | PORT ( | |
339 | clk : IN STD_LOGIC; |
|
339 | clk : IN STD_LOGIC; | |
340 | rstn : IN STD_LOGIC; |
|
340 | rstn : IN STD_LOGIC; | |
341 | A : IN STD_LOGIC; |
|
341 | A : IN STD_LOGIC; | |
342 | A_sync : OUT STD_LOGIC); |
|
342 | A_sync : OUT STD_LOGIC); | |
343 | END COMPONENT; |
|
343 | END COMPONENT; | |
344 |
|
344 | |||
345 | COMPONENT lpp_front_to_level |
|
345 | COMPONENT lpp_front_to_level | |
346 | PORT ( |
|
346 | PORT ( | |
347 | clk : IN STD_LOGIC; |
|
347 | clk : IN STD_LOGIC; | |
348 | rstn : IN STD_LOGIC; |
|
348 | rstn : IN STD_LOGIC; | |
349 | sin : IN STD_LOGIC; |
|
349 | sin : IN STD_LOGIC; | |
350 | sout : OUT STD_LOGIC); |
|
350 | sout : OUT STD_LOGIC); | |
351 | END COMPONENT; |
|
351 | END COMPONENT; | |
352 |
|
352 | |||
353 | COMPONENT lpp_front_detection |
|
353 | COMPONENT lpp_front_detection | |
354 | PORT ( |
|
354 | PORT ( | |
355 | clk : IN STD_LOGIC; |
|
355 | clk : IN STD_LOGIC; | |
356 | rstn : IN STD_LOGIC; |
|
356 | rstn : IN STD_LOGIC; | |
357 | sin : IN STD_LOGIC; |
|
357 | sin : IN STD_LOGIC; | |
358 | sout : OUT STD_LOGIC); |
|
358 | sout : OUT STD_LOGIC); | |
359 | END COMPONENT; |
|
359 | END COMPONENT; | |
360 |
|
360 | |||
361 | COMPONENT lpp_front_positive_detection |
|
361 | COMPONENT lpp_front_positive_detection | |
362 | PORT ( |
|
362 | PORT ( | |
363 | clk : IN STD_LOGIC; |
|
363 | clk : IN STD_LOGIC; | |
364 | rstn : IN STD_LOGIC; |
|
364 | rstn : IN STD_LOGIC; | |
365 | sin : IN STD_LOGIC; |
|
365 | sin : IN STD_LOGIC; | |
366 | sout : OUT STD_LOGIC); |
|
366 | sout : OUT STD_LOGIC); | |
367 | END COMPONENT; |
|
367 | END COMPONENT; | |
368 |
|
368 | |||
369 | COMPONENT SYNC_VALID_BIT |
|
369 | COMPONENT SYNC_VALID_BIT | |
370 | GENERIC ( |
|
370 | GENERIC ( | |
371 | NB_FF_OF_SYNC : INTEGER); |
|
371 | NB_FF_OF_SYNC : INTEGER); | |
372 | PORT ( |
|
372 | PORT ( | |
373 | clk_in : IN STD_LOGIC; |
|
373 | clk_in : IN STD_LOGIC; | |
374 | clk_out : IN STD_LOGIC; |
|
374 | clk_out : IN STD_LOGIC; | |
375 | rstn : IN STD_LOGIC; |
|
375 | rstn : IN STD_LOGIC; | |
376 | sin : IN STD_LOGIC; |
|
376 | sin : IN STD_LOGIC; | |
377 | sout : OUT STD_LOGIC); |
|
377 | sout : OUT STD_LOGIC); | |
378 | END COMPONENT; |
|
378 | END COMPONENT; | |
379 |
|
379 | |||
380 | COMPONENT RR_Arbiter_4 |
|
380 | COMPONENT RR_Arbiter_4 | |
381 | PORT ( |
|
381 | PORT ( | |
382 | clk : IN STD_LOGIC; |
|
382 | clk : IN STD_LOGIC; | |
383 | rstn : IN STD_LOGIC; |
|
383 | rstn : IN STD_LOGIC; | |
384 | in_valid : IN STD_LOGIC_VECTOR(3 DOWNTO 0); |
|
384 | in_valid : IN STD_LOGIC_VECTOR(3 DOWNTO 0); | |
385 | out_grant : OUT STD_LOGIC_VECTOR(3 DOWNTO 0)); |
|
385 | out_grant : OUT STD_LOGIC_VECTOR(3 DOWNTO 0)); | |
386 | END COMPONENT; |
|
386 | END COMPONENT; | |
387 |
|
387 | |||
388 | COMPONENT Clock_Divider is |
|
388 | COMPONENT Clock_Divider is | |
389 | generic(N :integer := 10); |
|
389 | generic(N :integer := 10); | |
390 | port( |
|
390 | port( | |
391 | clk, rst : in std_logic; |
|
391 | clk, rst : in std_logic; | |
392 | sclk : out std_logic); |
|
392 | sclk : out std_logic); | |
393 | end COMPONENT; |
|
393 | end COMPONENT; | |
394 |
|
394 | |||
395 | END; |
|
395 | END; |
@@ -1,108 +1,109 | |||||
1 | LIBRARY IEEE; |
|
1 | LIBRARY IEEE; | |
2 | USE IEEE.STD_LOGIC_1164.ALL; |
|
2 | USE IEEE.STD_LOGIC_1164.ALL; | |
3 | USE IEEE.NUMERIC_STD.ALL; |
|
3 | USE IEEE.NUMERIC_STD.ALL; | |
4 |
|
4 | |||
5 | LIBRARY lpp; |
|
5 | LIBRARY lpp; | |
6 | USE lpp.general_purpose.ALL; |
|
6 | USE lpp.general_purpose.ALL; | |
7 |
|
7 | |||
8 | ENTITY coarse_time_counter IS |
|
8 | ENTITY coarse_time_counter IS | |
9 | GENERIC ( |
|
9 | GENERIC ( | |
10 | NB_SECOND_DESYNC : INTEGER := 60); |
|
10 | NB_SECOND_DESYNC : INTEGER := 60); | |
11 |
|
11 | |||
12 | PORT ( |
|
12 | PORT ( | |
13 | clk : IN STD_LOGIC; |
|
13 | clk : IN STD_LOGIC; | |
14 | rstn : IN STD_LOGIC; |
|
14 | rstn : IN STD_LOGIC; | |
15 |
|
15 | |||
16 | tick : IN STD_LOGIC; |
|
16 | tick : IN STD_LOGIC; | |
17 | set_TCU : IN STD_LOGIC; |
|
17 | set_TCU : IN STD_LOGIC; | |
18 | new_TCU : IN STD_LOGIC; |
|
18 | new_TCU : IN STD_LOGIC; | |
19 | set_TCU_value : IN STD_LOGIC_VECTOR(30 DOWNTO 0); |
|
19 | set_TCU_value : IN STD_LOGIC_VECTOR(30 DOWNTO 0); | |
20 | CT_add1 : IN STD_LOGIC; |
|
20 | CT_add1 : IN STD_LOGIC; | |
21 | fsm_desync : IN STD_LOGIC; |
|
21 | fsm_desync : IN STD_LOGIC; | |
22 | FT_max : IN STD_LOGIC; |
|
22 | FT_max : IN STD_LOGIC; | |
23 |
|
23 | |||
24 | coarse_time : OUT STD_LOGIC_VECTOR(31 DOWNTO 0); |
|
24 | coarse_time : OUT STD_LOGIC_VECTOR(31 DOWNTO 0); | |
25 | coarse_time_new : OUT STD_LOGIC |
|
25 | coarse_time_new : OUT STD_LOGIC | |
26 |
|
26 | |||
27 | ); |
|
27 | ); | |
28 |
|
28 | |||
29 | END coarse_time_counter; |
|
29 | END coarse_time_counter; | |
30 |
|
30 | |||
31 | ARCHITECTURE beh OF coarse_time_counter IS |
|
31 | ARCHITECTURE beh OF coarse_time_counter IS | |
32 |
|
32 | |||
33 | SIGNAL add1_bit31 : STD_LOGIC; |
|
33 | SIGNAL add1_bit31 : STD_LOGIC; | |
34 | SIGNAL nb_second_counter : STD_LOGIC_VECTOR(5 DOWNTO 0); |
|
34 | SIGNAL nb_second_counter : STD_LOGIC_VECTOR(5 DOWNTO 0); | |
35 | SIGNAL coarse_time_new_counter : STD_LOGIC; |
|
35 | SIGNAL coarse_time_new_counter : STD_LOGIC; | |
36 | SIGNAL coarse_time_31 : STD_LOGIC; |
|
36 | SIGNAL coarse_time_31 : STD_LOGIC; | |
37 | SIGNAL coarse_time_31_reg : STD_LOGIC; |
|
37 | SIGNAL coarse_time_31_reg : STD_LOGIC; | |
38 |
|
38 | |||
39 | SIGNAL set_synchronized : STD_LOGIC; |
|
39 | SIGNAL set_synchronized : STD_LOGIC; | |
40 | SIGNAL set_synchronized_value : STD_LOGIC_VECTOR(5 DOWNTO 0); |
|
40 | SIGNAL set_synchronized_value : STD_LOGIC_VECTOR(5 DOWNTO 0); | |
41 |
|
41 | |||
42 | --CONSTANT NB_SECOND_DESYNC : INTEGER := 4; -- TODO : 60 |
|
42 | --CONSTANT NB_SECOND_DESYNC : INTEGER := 4; -- TODO : 60 | |
43 | BEGIN -- beh |
|
43 | BEGIN -- beh | |
44 |
|
44 | |||
45 | ----------------------------------------------------------------------------- |
|
45 | ----------------------------------------------------------------------------- | |
46 | -- COARSE_TIME( 30 DOWNTO 0) |
|
46 | -- COARSE_TIME( 30 DOWNTO 0) | |
47 | ----------------------------------------------------------------------------- |
|
47 | ----------------------------------------------------------------------------- | |
48 | counter_1 : general_counter |
|
48 | counter_1 : general_counter | |
49 | GENERIC MAP ( |
|
49 | GENERIC MAP ( | |
50 | CYCLIC => '1', |
|
50 | CYCLIC => '1', | |
51 |
NB_BITS_COUNTER => 31 |
|
51 | NB_BITS_COUNTER => 31, | |
|
52 | RST_VALUE => 0) | |||
52 | PORT MAP ( |
|
53 | PORT MAP ( | |
53 | clk => clk, |
|
54 | clk => clk, | |
54 | rstn => rstn, |
|
55 | rstn => rstn, | |
55 | RST_VALUE => (OTHERS => '0'), |
|
|||
56 | MAX_VALUE => "111" & X"FFFFFFF" , |
|
56 | MAX_VALUE => "111" & X"FFFFFFF" , | |
57 | set => set_TCU, |
|
57 | set => set_TCU, | |
58 | set_value => set_TCU_value(30 DOWNTO 0), |
|
58 | set_value => set_TCU_value(30 DOWNTO 0), | |
59 | add1 => CT_add1, |
|
59 | add1 => CT_add1, | |
60 | counter => coarse_time(30 DOWNTO 0)); |
|
60 | counter => coarse_time(30 DOWNTO 0)); | |
61 |
|
61 | |||
62 |
|
62 | |||
63 | add1_bit31 <= '1' WHEN fsm_desync = '1' AND FT_max = '1' ELSE '0'; |
|
63 | add1_bit31 <= '1' WHEN fsm_desync = '1' AND FT_max = '1' ELSE '0'; | |
64 |
|
64 | |||
65 | ----------------------------------------------------------------------------- |
|
65 | ----------------------------------------------------------------------------- | |
66 | -- COARSE_TIME(31) |
|
66 | -- COARSE_TIME(31) | |
67 | ----------------------------------------------------------------------------- |
|
67 | ----------------------------------------------------------------------------- | |
68 |
|
68 | |||
69 | --set_synchronized <= (tick AND (NOT coarse_time_31)) OR (coarse_time_31 AND set_TCU); |
|
69 | --set_synchronized <= (tick AND (NOT coarse_time_31)) OR (coarse_time_31 AND set_TCU); | |
70 | --set_synchronized_value <= STD_LOGIC_VECTOR(to_unsigned(NB_SECOND_DESYNC, 6)) WHEN (set_TCU AND set_TCU_value(31)) = '1' ELSE |
|
70 | --set_synchronized_value <= STD_LOGIC_VECTOR(to_unsigned(NB_SECOND_DESYNC, 6)) WHEN (set_TCU AND set_TCU_value(31)) = '1' ELSE | |
71 | -- (OTHERS => '0'); |
|
71 | -- (OTHERS => '0'); | |
72 | set_synchronized <= tick AND ((NOT coarse_time_31) OR (coarse_time_31 AND new_TCU)); |
|
72 | set_synchronized <= tick AND ((NOT coarse_time_31) OR (coarse_time_31 AND new_TCU)); | |
73 | set_synchronized_value <= (OTHERS => '0'); |
|
73 | set_synchronized_value <= (OTHERS => '0'); | |
74 |
|
74 | |||
75 | counter_2 : general_counter |
|
75 | counter_2 : general_counter | |
76 | GENERIC MAP ( |
|
76 | GENERIC MAP ( | |
77 | CYCLIC => '0', |
|
77 | CYCLIC => '0', | |
78 |
NB_BITS_COUNTER => 6 |
|
78 | NB_BITS_COUNTER => 6, | |
|
79 | RST_VALUE => NB_SECOND_DESYNC | |||
|
80 | ) | |||
79 | PORT MAP ( |
|
81 | PORT MAP ( | |
80 | clk => clk, |
|
82 | clk => clk, | |
81 | rstn => rstn, |
|
83 | rstn => rstn, | |
82 | RST_VALUE => STD_LOGIC_VECTOR(to_unsigned(NB_SECOND_DESYNC, 6)), |
|
|||
83 | MAX_VALUE => STD_LOGIC_VECTOR(to_unsigned(NB_SECOND_DESYNC, 6)), |
|
84 | MAX_VALUE => STD_LOGIC_VECTOR(to_unsigned(NB_SECOND_DESYNC, 6)), | |
84 | set => set_synchronized, |
|
85 | set => set_synchronized, | |
85 | set_value => set_synchronized_value, |
|
86 | set_value => set_synchronized_value, | |
86 | add1 => add1_bit31, |
|
87 | add1 => add1_bit31, | |
87 | counter => nb_second_counter); |
|
88 | counter => nb_second_counter); | |
88 |
|
89 | |||
89 | coarse_time_31 <= '1' WHEN nb_second_counter = STD_LOGIC_VECTOR(to_unsigned(NB_SECOND_DESYNC, 6)) ELSE '0'; |
|
90 | coarse_time_31 <= '1' WHEN nb_second_counter = STD_LOGIC_VECTOR(to_unsigned(NB_SECOND_DESYNC, 6)) ELSE '0'; | |
90 | coarse_time(31) <= coarse_time_31; |
|
91 | coarse_time(31) <= coarse_time_31; | |
91 | coarse_time_new <= coarse_time_new_counter OR (coarse_time_31 XOR coarse_time_31_reg); |
|
92 | coarse_time_new <= coarse_time_new_counter OR (coarse_time_31 XOR coarse_time_31_reg); | |
92 |
|
93 | |||
93 | PROCESS (clk, rstn) |
|
94 | PROCESS (clk, rstn) | |
94 | BEGIN -- PROCESS |
|
95 | BEGIN -- PROCESS | |
95 | IF rstn = '0' THEN -- asynchronous reset (active low) |
|
96 | IF rstn = '0' THEN -- asynchronous reset (active low) | |
96 | coarse_time_new_counter <= '0'; |
|
97 | coarse_time_new_counter <= '0'; | |
97 | coarse_time_31_reg <= '0'; |
|
98 | coarse_time_31_reg <= '0'; | |
98 | ELSIF clk'event AND clk = '1' THEN -- rising clock edge |
|
99 | ELSIF clk'event AND clk = '1' THEN -- rising clock edge | |
99 | coarse_time_31_reg <= coarse_time_31; |
|
100 | coarse_time_31_reg <= coarse_time_31; | |
100 | IF set_TCU = '1' OR CT_add1 = '1' THEN |
|
101 | IF set_TCU = '1' OR CT_add1 = '1' THEN | |
101 | coarse_time_new_counter <= '1'; |
|
102 | coarse_time_new_counter <= '1'; | |
102 | ELSE |
|
103 | ELSE | |
103 | coarse_time_new_counter <= '0'; |
|
104 | coarse_time_new_counter <= '0'; | |
104 | END IF; |
|
105 | END IF; | |
105 | END IF; |
|
106 | END IF; | |
106 | END PROCESS; |
|
107 | END PROCESS; | |
107 |
|
108 | |||
108 |
END beh; |
|
109 | END beh; No newline at end of file |
@@ -1,93 +1,94 | |||||
1 | LIBRARY IEEE; |
|
1 | LIBRARY IEEE; | |
2 | USE IEEE.STD_LOGIC_1164.ALL; |
|
2 | USE IEEE.STD_LOGIC_1164.ALL; | |
3 | USE IEEE.NUMERIC_STD.ALL; |
|
3 | USE IEEE.NUMERIC_STD.ALL; | |
4 |
|
4 | |||
5 | LIBRARY lpp; |
|
5 | LIBRARY lpp; | |
6 | USE lpp.general_purpose.ALL; |
|
6 | USE lpp.general_purpose.ALL; | |
7 |
|
7 | |||
8 | ENTITY fine_time_counter IS |
|
8 | ENTITY fine_time_counter IS | |
9 |
|
9 | |||
10 | GENERIC ( |
|
10 | GENERIC ( | |
11 | WAITING_TIME : STD_LOGIC_VECTOR(15 DOWNTO 0) := X"0040"; |
|
11 | WAITING_TIME : STD_LOGIC_VECTOR(15 DOWNTO 0) := X"0040"; | |
12 | FIRST_DIVISION : INTEGER := 374 |
|
12 | FIRST_DIVISION : INTEGER := 374 | |
13 | ); |
|
13 | ); | |
14 |
|
14 | |||
15 | PORT ( |
|
15 | PORT ( | |
16 | clk : IN STD_LOGIC; |
|
16 | clk : IN STD_LOGIC; | |
17 | rstn : IN STD_LOGIC; |
|
17 | rstn : IN STD_LOGIC; | |
18 | -- |
|
18 | -- | |
19 | tick : IN STD_LOGIC; |
|
19 | tick : IN STD_LOGIC; | |
20 | fsm_transition : IN STD_LOGIC; |
|
20 | fsm_transition : IN STD_LOGIC; | |
21 |
|
21 | |||
22 | FT_max : OUT STD_LOGIC; |
|
22 | FT_max : OUT STD_LOGIC; | |
23 | FT_half : OUT STD_LOGIC; |
|
23 | FT_half : OUT STD_LOGIC; | |
24 | FT_wait : OUT STD_LOGIC; |
|
24 | FT_wait : OUT STD_LOGIC; | |
25 | fine_time : OUT STD_LOGIC_VECTOR(15 DOWNTO 0); |
|
25 | fine_time : OUT STD_LOGIC_VECTOR(15 DOWNTO 0); | |
26 | fine_time_new : OUT STD_LOGIC |
|
26 | fine_time_new : OUT STD_LOGIC | |
27 | ); |
|
27 | ); | |
28 |
|
28 | |||
29 | END fine_time_counter; |
|
29 | END fine_time_counter; | |
30 |
|
30 | |||
31 | ARCHITECTURE beh OF fine_time_counter IS |
|
31 | ARCHITECTURE beh OF fine_time_counter IS | |
32 |
|
32 | |||
33 | SIGNAL new_ft_counter : STD_LOGIC_VECTOR(8 DOWNTO 0); |
|
33 | SIGNAL new_ft_counter : STD_LOGIC_VECTOR(8 DOWNTO 0); | |
34 | SIGNAL new_ft : STD_LOGIC; |
|
34 | SIGNAL new_ft : STD_LOGIC; | |
35 | SIGNAL fine_time_counter : STD_LOGIC_VECTOR(15 DOWNTO 0); |
|
35 | SIGNAL fine_time_counter : STD_LOGIC_VECTOR(15 DOWNTO 0); | |
36 |
|
36 | |||
37 | -- CONSTANT FIRST_DIVISION : INTEGER := 20; -- TODO : 374 |
|
37 | -- CONSTANT FIRST_DIVISION : INTEGER := 20; -- TODO : 374 | |
38 |
|
38 | |||
39 | BEGIN -- beh |
|
39 | BEGIN -- beh | |
40 |
|
40 | |||
41 |
|
41 | |||
42 |
|
42 | |||
43 | counter_1 : general_counter |
|
43 | counter_1 : general_counter | |
44 | GENERIC MAP ( |
|
44 | GENERIC MAP ( | |
45 | CYCLIC => '1', |
|
45 | CYCLIC => '1', | |
46 |
NB_BITS_COUNTER => 9 |
|
46 | NB_BITS_COUNTER => 9, | |
|
47 | RST_VALUE => 0 | |||
|
48 | ) | |||
47 | PORT MAP ( |
|
49 | PORT MAP ( | |
48 | clk => clk, |
|
50 | clk => clk, | |
49 | rstn => rstn, |
|
51 | rstn => rstn, | |
50 | RST_VALUE => (OTHERS => '0'), |
|
|||
51 | MAX_VALUE => STD_LOGIC_VECTOR(to_unsigned(FIRST_DIVISION, 9)), |
|
52 | MAX_VALUE => STD_LOGIC_VECTOR(to_unsigned(FIRST_DIVISION, 9)), | |
52 | set => tick, |
|
53 | set => tick, | |
53 | set_value => (OTHERS => '0'), |
|
54 | set_value => (OTHERS => '0'), | |
54 | add1 => '1', |
|
55 | add1 => '1', | |
55 | counter => new_ft_counter); |
|
56 | counter => new_ft_counter); | |
56 |
|
57 | |||
57 | new_ft <= '1' WHEN new_ft_counter = STD_LOGIC_VECTOR(to_unsigned(FIRST_DIVISION, 9)) ELSE '0'; |
|
58 | new_ft <= '1' WHEN new_ft_counter = STD_LOGIC_VECTOR(to_unsigned(FIRST_DIVISION, 9)) ELSE '0'; | |
58 |
|
59 | |||
59 | counter_2 : general_counter |
|
60 | counter_2 : general_counter | |
60 | GENERIC MAP ( |
|
61 | GENERIC MAP ( | |
61 | CYCLIC => '1', |
|
62 | CYCLIC => '1', | |
62 |
NB_BITS_COUNTER => 16 |
|
63 | NB_BITS_COUNTER => 16, | |
|
64 | RST_VALUE => 0 | |||
|
65 | ) | |||
63 | PORT MAP ( |
|
66 | PORT MAP ( | |
64 | clk => clk, |
|
67 | clk => clk, | |
65 | rstn => rstn, |
|
68 | rstn => rstn, | |
66 | RST_VALUE => (OTHERS => '0'), |
|
|||
67 | MAX_VALUE => X"FFFF", |
|
69 | MAX_VALUE => X"FFFF", | |
68 | set => tick, |
|
70 | set => tick, | |
69 | set_value => (OTHERS => '0'), |
|
71 | set_value => (OTHERS => '0'), | |
70 | add1 => new_ft, |
|
72 | add1 => new_ft, | |
71 | counter => fine_time_counter); |
|
73 | counter => fine_time_counter); | |
72 |
|
74 | |||
73 | FT_max <= '1' WHEN new_ft = '1' AND fine_time_counter = X"FFFF" ELSE '0'; |
|
75 | FT_max <= '1' WHEN new_ft = '1' AND fine_time_counter = X"FFFF" ELSE '0'; | |
74 | FT_half <= '1' WHEN fine_time_counter > X"7FFF" ELSE '0'; |
|
76 | FT_half <= '1' WHEN fine_time_counter > X"7FFF" ELSE '0'; | |
75 | FT_wait <= '1' WHEN fine_time_counter > WAITING_TIME ELSE '0'; |
|
77 | FT_wait <= '1' WHEN fine_time_counter > WAITING_TIME ELSE '0'; | |
76 |
|
78 | |||
77 | fine_time <= X"FFFF" WHEN fsm_transition = '1' ELSE fine_time_counter; |
|
79 | fine_time <= X"FFFF" WHEN fsm_transition = '1' ELSE fine_time_counter; | |
78 |
|
80 | |||
79 | PROCESS (clk, rstn) |
|
81 | PROCESS (clk, rstn) | |
80 | BEGIN -- PROCESS |
|
82 | BEGIN -- PROCESS | |
81 | IF rstn = '0' THEN -- asynchronous reset (active low) |
|
83 | IF rstn = '0' THEN -- asynchronous reset (active low) | |
82 | fine_time_new <= '0'; |
|
84 | fine_time_new <= '0'; | |
83 | ELSIF clk'EVENT AND clk = '1' THEN -- rising clock edge |
|
85 | ELSIF clk'EVENT AND clk = '1' THEN -- rising clock edge | |
84 | IF (new_ft = '1' AND fsm_transition = '0') OR tick = '1' THEN |
|
86 | IF (new_ft = '1' AND fsm_transition = '0') OR tick = '1' THEN | |
85 | fine_time_new <= '1'; |
|
87 | fine_time_new <= '1'; | |
86 | ELSE |
|
88 | ELSE | |
87 | fine_time_new <= '0'; |
|
89 | fine_time_new <= '0'; | |
88 | END IF; |
|
90 | END IF; | |
89 | END IF; |
|
91 | END IF; | |
90 | END PROCESS; |
|
92 | END PROCESS; | |
91 |
|
93 | |||
92 | END beh; |
|
94 | END beh; | |
93 |
|
@@ -1,117 +1,117 | |||||
1 | ------------------------------------------------------------------------------ |
|
1 | ------------------------------------------------------------------------------ | |
2 | -- This file is a part of the LPP VHDL IP LIBRARY |
|
2 | -- This file is a part of the LPP VHDL IP LIBRARY | |
3 | -- Copyright (C) 2009 - 2015, Laboratory of Plasmas Physic - CNRS |
|
3 | -- Copyright (C) 2009 - 2015, Laboratory of Plasmas Physic - CNRS | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 3 of the License, or |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | ------------------------------------------------------------------------------ |
|
18 | ------------------------------------------------------------------------------ | |
19 | -- Author : Alexis Jeandet |
|
19 | -- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@member.fsf.org |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
21 | ------------------------------------------------------------------------------ |
|
21 | ------------------------------------------------------------------------------ | |
22 | library IEEE; |
|
22 | library IEEE; | |
23 | use IEEE.STD_LOGIC_1164.ALL; |
|
23 | use IEEE.STD_LOGIC_1164.ALL; | |
24 | use IEEE.NUMERIC_STD.ALL; |
|
24 | use IEEE.NUMERIC_STD.ALL; | |
25 |
|
25 | |||
26 | entity RAM_READER is |
|
26 | entity RAM_READER is | |
27 | Generic( |
|
27 | Generic( | |
28 | datawidth : integer := 18; |
|
28 | datawidth : integer := 18; | |
29 | dacresolution : integer := 12; |
|
29 | dacresolution : integer := 12; | |
30 | abits : integer := 8 |
|
30 | abits : integer := 8 | |
31 | ); |
|
31 | ); | |
32 | Port ( |
|
32 | Port ( | |
33 | clk : in STD_LOGIC; --! clock input |
|
33 | clk : in STD_LOGIC; --! clock input | |
34 | rstn : in STD_LOGIC; --! Active low restet input |
|
34 | rstn : in STD_LOGIC; --! Active low restet input | |
35 | DATA_IN : in STD_LOGIC_VECTOR (datawidth-1 downto 0); --! DATA input vector -> connect to RAM DATA output |
|
35 | DATA_IN : in STD_LOGIC_VECTOR (datawidth-1 downto 0); --! DATA input vector -> connect to RAM DATA output | |
36 | ADDRESS : out STD_LOGIC_VECTOR (abits-1 downto 0); --! ADDRESS output vector -> connect to RAM read ADDRESS input |
|
36 | ADDRESS : out STD_LOGIC_VECTOR (abits-1 downto 0); --! ADDRESS output vector -> connect to RAM read ADDRESS input | |
37 | REN : out STD_LOGIC; --! Active low read enable -> connect to RAM read enable |
|
37 | REN : out STD_LOGIC; --! Active low read enable -> connect to RAM read enable | |
38 | DATA_OUT : out STD_LOGIC_VECTOR (dacresolution-1 downto 0); --! DATA output vector |
|
38 | DATA_OUT : out STD_LOGIC_VECTOR (dacresolution-1 downto 0); --! DATA output vector | |
39 | SMP_CLK : in STD_LOGIC; --! Sampling clock input, each rising edge will provide a DATA to the output and read a new one in RAM |
|
39 | SMP_CLK : in STD_LOGIC; --! Sampling clock input, each rising edge will provide a DATA to the output and read a new one in RAM | |
40 | INTERLEAVED : in STD_LOGIC --! When 1, interleaved mode is actived. |
|
40 | INTERLEAVED : in STD_LOGIC --! When 1, interleaved mode is actived. | |
41 | ); |
|
41 | ); | |
42 | end RAM_READER; |
|
42 | end RAM_READER; | |
43 |
|
43 | |||
44 | architecture Behavioral of RAM_READER is |
|
44 | architecture Behavioral of RAM_READER is | |
45 | CONSTANT interleaved_sz : integer := dacresolution/(datawidth-dacresolution); |
|
45 | CONSTANT interleaved_sz : integer := dacresolution/(datawidth-dacresolution); | |
46 |
|
46 | |||
47 |
signal ADDRESS_R : STD_LOGIC_VECTOR (abits-1 downto 0) |
|
47 | signal ADDRESS_R : STD_LOGIC_VECTOR (abits-1 downto 0);--:=(others=>'0'); | |
48 | signal SAMPLE_R : STD_LOGIC_VECTOR (dacresolution-1 downto 0):=(others=>'0'); |
|
48 | signal SAMPLE_R : STD_LOGIC_VECTOR (dacresolution-1 downto 0):=(others=>'0'); | |
49 | signal INTERLEAVED_SAMPLE_R : STD_LOGIC_VECTOR (dacresolution-1 downto 0):=(others=>'0'); |
|
49 | signal INTERLEAVED_SAMPLE_R : STD_LOGIC_VECTOR (dacresolution-1 downto 0):=(others=>'0'); | |
50 | signal SMP_CLK_R : STD_LOGIC; |
|
50 | signal SMP_CLK_R : STD_LOGIC; | |
51 | signal interleavedCNTR : integer range 0 to interleaved_sz; |
|
51 | signal interleavedCNTR : integer range 0 to interleaved_sz; | |
52 | signal REN_R : STD_LOGIC:='1'; |
|
52 | signal REN_R : STD_LOGIC:='1'; | |
53 | signal interleave : STD_LOGIC:='0'; |
|
53 | signal interleave : STD_LOGIC:='0'; | |
54 | signal loadEvent : STD_LOGIC:='0'; |
|
54 | signal loadEvent : STD_LOGIC:='0'; | |
55 | signal loadEvent_R : STD_LOGIC:='0'; |
|
55 | signal loadEvent_R : STD_LOGIC:='0'; | |
56 | signal loadEvent_R2 : STD_LOGIC:='0'; |
|
56 | signal loadEvent_R2 : STD_LOGIC:='0'; | |
57 | begin |
|
57 | begin | |
58 |
|
58 | |||
59 | REN <= REN_R; |
|
59 | REN <= REN_R; | |
60 | DATA_OUT <= SAMPLE_R; |
|
60 | DATA_OUT <= SAMPLE_R; | |
61 | ADDRESS <= ADDRESS_R; |
|
61 | ADDRESS <= ADDRESS_R; | |
62 | interleave <= '1' when interleavedCNTR=interleaved_sz else '0'; |
|
62 | interleave <= '1' when interleavedCNTR=interleaved_sz else '0'; | |
63 |
|
63 | |||
64 | loadEvent <= SMP_CLK and not SMP_CLK_R ; |
|
64 | loadEvent <= SMP_CLK and not SMP_CLK_R ; | |
65 |
|
65 | |||
66 | process(clk,rstn) |
|
66 | process(clk,rstn) | |
67 | begin |
|
67 | begin | |
68 | if rstn='0' then |
|
68 | if rstn='0' then | |
69 | SMP_CLK_R <= '0'; |
|
69 | SMP_CLK_R <= '0'; | |
70 | loadEvent_R <= '0'; |
|
70 | loadEvent_R <= '0'; | |
71 | loadEvent_R2 <= '0'; |
|
71 | loadEvent_R2 <= '0'; | |
72 | elsif clk'event and clk='1' then |
|
72 | elsif clk'event and clk='1' then | |
73 | SMP_CLK_R <= SMP_CLK; |
|
73 | SMP_CLK_R <= SMP_CLK; | |
74 | loadEvent_R <= loadEvent; |
|
74 | loadEvent_R <= loadEvent; | |
75 | loadEvent_R2 <= loadEvent_R; |
|
75 | loadEvent_R2 <= loadEvent_R; | |
76 | end if; |
|
76 | end if; | |
77 | end process; |
|
77 | end process; | |
78 |
|
78 | |||
79 | process(clk,rstn) |
|
79 | process(clk,rstn) | |
80 | begin |
|
80 | begin | |
81 | if rstn='0' then |
|
81 | if rstn='0' then | |
82 | ADDRESS_R <= (others=>'0'); |
|
82 | ADDRESS_R <= (others=>'0'); | |
83 | SAMPLE_R <= (others=>'0'); |
|
83 | SAMPLE_R <= (others=>'0'); | |
84 | INTERLEAVED_SAMPLE_R <= (others=>'0'); |
|
84 | INTERLEAVED_SAMPLE_R <= (others=>'0'); | |
85 | REN_R <= '1'; |
|
85 | REN_R <= '1'; | |
86 | interleavedCNTR <= 0; |
|
86 | interleavedCNTR <= 0; | |
87 | elsif clk'event and clk='1' then |
|
87 | elsif clk'event and clk='1' then | |
88 | if loadEvent = '1' then |
|
88 | if loadEvent = '1' then | |
89 | if(interleave='0') then |
|
89 | if(interleave='0') then | |
90 | REN_R <= '0'; |
|
90 | REN_R <= '0'; | |
91 | end if; |
|
91 | end if; | |
92 | else |
|
92 | else | |
93 | REN_R <= '1'; |
|
93 | REN_R <= '1'; | |
94 | end if; |
|
94 | end if; | |
95 |
|
95 | |||
96 | if REN_R = '0' then |
|
96 | if REN_R = '0' then | |
97 | ADDRESS_R <= std_logic_vector(UNSIGNED(ADDRESS_R) + 1); --Automatic increment on each read |
|
97 | ADDRESS_R <= std_logic_vector(UNSIGNED(ADDRESS_R) + 1); --Automatic increment on each read | |
98 | end if; |
|
98 | end if; | |
99 |
|
99 | |||
100 | if loadEvent_R2='1' then |
|
100 | if loadEvent_R2='1' then | |
101 | if(interleave='1') then |
|
101 | if(interleave='1') then | |
102 | interleavedCNTR <= 0; |
|
102 | interleavedCNTR <= 0; | |
103 | SAMPLE_R <= INTERLEAVED_SAMPLE_R; |
|
103 | SAMPLE_R <= INTERLEAVED_SAMPLE_R; | |
104 | else |
|
104 | else | |
105 | if interleaved='1' then |
|
105 | if interleaved='1' then | |
106 | interleavedCNTR <= interleavedCNTR + 1; |
|
106 | interleavedCNTR <= interleavedCNTR + 1; | |
107 | else |
|
107 | else | |
108 | interleavedCNTR <= 0; |
|
108 | interleavedCNTR <= 0; | |
109 | end if; |
|
109 | end if; | |
110 | SAMPLE_R <= DATA_IN(dacresolution-1 downto 0); |
|
110 | SAMPLE_R <= DATA_IN(dacresolution-1 downto 0); | |
111 | INTERLEAVED_SAMPLE_R(dacresolution-1 downto 0) <= INTERLEAVED_SAMPLE_R(datawidth-dacresolution-1 downto 0) & DATA_IN(datawidth-1 downto dacresolution); |
|
111 | INTERLEAVED_SAMPLE_R(dacresolution-1 downto 0) <= INTERLEAVED_SAMPLE_R(datawidth-dacresolution-1 downto 0) & DATA_IN(datawidth-1 downto dacresolution); | |
112 | end if; |
|
112 | end if; | |
113 | end if; |
|
113 | end if; | |
114 | end if; |
|
114 | end if; | |
115 | end process; |
|
115 | end process; | |
116 |
|
116 | |||
117 |
end Behavioral; |
|
117 | end Behavioral; No newline at end of file |
@@ -1,107 +1,103 | |||||
1 | ------------------------------------------------------------------------------ |
|
1 | ------------------------------------------------------------------------------ | |
2 | -- This file is a part of the LPP VHDL IP LIBRARY |
|
2 | -- This file is a part of the LPP VHDL IP LIBRARY | |
3 | -- Copyright (C) 2009 - 2015, Laboratory of Plasmas Physic - CNRS |
|
3 | -- Copyright (C) 2009 - 2015, Laboratory of Plasmas Physic - CNRS | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 3 of the License, or |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | ------------------------------------------------------------------------------ |
|
18 | ------------------------------------------------------------------------------ | |
19 | -- Author : Alexis Jeandet |
|
19 | -- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@member.fsf.org |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
21 | ------------------------------------------------------------------------------ |
|
21 | ------------------------------------------------------------------------------ | |
22 |
|
22 | |||
23 |
|
23 | |||
24 | LIBRARY IEEE; |
|
24 | LIBRARY IEEE; | |
25 | USE IEEE.STD_LOGIC_1164.ALL; |
|
25 | USE IEEE.STD_LOGIC_1164.ALL; | |
26 | USE IEEE.NUMERIC_STD.ALL; |
|
26 | USE IEEE.NUMERIC_STD.ALL; | |
27 |
|
27 | |||
28 | ENTITY SPI_DAC_DRIVER IS |
|
28 | ENTITY SPI_DAC_DRIVER IS | |
29 | GENERIC( |
|
29 | GENERIC( | |
30 | datawidth : INTEGER := 16; |
|
30 | datawidth : INTEGER := 16; | |
31 | MSBFIRST : INTEGER := 1 |
|
31 | MSBFIRST : INTEGER := 1 | |
32 | ); |
|
32 | ); | |
33 | PORT ( |
|
33 | PORT ( | |
34 | clk : IN STD_LOGIC; |
|
34 | clk : IN STD_LOGIC; | |
35 | rstn : IN STD_LOGIC; |
|
35 | rstn : IN STD_LOGIC; | |
36 | DATA : IN STD_LOGIC_VECTOR(datawidth-1 DOWNTO 0); |
|
36 | DATA : IN STD_LOGIC_VECTOR(datawidth-1 DOWNTO 0); | |
37 | SMP_CLK : IN STD_LOGIC; |
|
37 | SMP_CLK : IN STD_LOGIC; | |
38 | SYNC : OUT STD_LOGIC; |
|
38 | SYNC : OUT STD_LOGIC; | |
39 | DOUT : OUT STD_LOGIC; |
|
39 | DOUT : OUT STD_LOGIC; | |
40 | SCLK : OUT STD_LOGIC |
|
40 | SCLK : OUT STD_LOGIC | |
41 | ); |
|
41 | ); | |
42 | END ENTITY SPI_DAC_DRIVER; |
|
42 | END ENTITY SPI_DAC_DRIVER; | |
43 |
|
43 | |||
44 | ARCHITECTURE behav OF SPI_DAC_DRIVER IS |
|
44 | ARCHITECTURE behav OF SPI_DAC_DRIVER IS | |
45 | SIGNAL SHIFTREG : STD_LOGIC_VECTOR(datawidth-1 DOWNTO 0) := (OTHERS => '0'); |
|
45 | SIGNAL SHIFTREG : STD_LOGIC_VECTOR(datawidth-1 DOWNTO 0) := (OTHERS => '0'); | |
46 | SIGNAL INPUTREG : STD_LOGIC_VECTOR(datawidth-1 DOWNTO 0) := (OTHERS => '0'); |
|
46 | SIGNAL INPUTREG : STD_LOGIC_VECTOR(datawidth-1 DOWNTO 0) := (OTHERS => '0'); | |
47 | SIGNAL SMP_CLK_R : STD_LOGIC := '0'; |
|
47 | SIGNAL SMP_CLK_R : STD_LOGIC := '0'; | |
48 | SIGNAL shiftcnt : INTEGER := 0; |
|
48 | SIGNAL shiftcnt : INTEGER := 0; | |
49 | SIGNAL shifting : STD_LOGIC := '0'; |
|
49 | SIGNAL shifting : STD_LOGIC := '0'; | |
50 | SIGNAL shifting_R : STD_LOGIC := '0'; |
|
|||
51 | BEGIN |
|
50 | BEGIN | |
52 |
|
51 | |||
53 |
|
52 | |||
54 | MSB : IF MSBFIRST = 1 GENERATE |
|
53 | MSB : IF MSBFIRST = 1 GENERATE | |
55 | INPUTREG <= DATA; |
|
54 | INPUTREG <= DATA; | |
56 | END GENERATE; |
|
55 | END GENERATE; | |
57 |
|
56 | |||
58 | LSB : IF MSBFIRST = 0 GENERATE |
|
57 | LSB : IF MSBFIRST = 0 GENERATE | |
59 | INPUTREG(datawidth-1 DOWNTO 0) <= DATA(0 TO datawidth-1); |
|
58 | INPUTREG(datawidth-1 DOWNTO 0) <= DATA(0 TO datawidth-1); | |
60 | END GENERATE; |
|
59 | END GENERATE; | |
61 |
|
60 | |||
62 | SCLK <= clk; |
|
61 | SCLK <= clk; | |
63 |
|
62 | |||
64 | PROCESS(clk, rstn) |
|
63 | PROCESS(clk, rstn) | |
65 | BEGIN |
|
64 | BEGIN | |
66 | IF rstn = '0' THEN |
|
65 | IF rstn = '0' THEN | |
67 | -- shifting_R <= '0'; |
|
|||
68 | SMP_CLK_R <= '0'; |
|
66 | SMP_CLK_R <= '0'; | |
69 | ELSIF clk'EVENT AND clk = '1' THEN |
|
67 | ELSIF clk'EVENT AND clk = '1' THEN | |
70 | SMP_CLK_R <= SMP_CLK; |
|
68 | SMP_CLK_R <= SMP_CLK; | |
71 | -- shifting_R <= shifting; |
|
|||
72 | END IF; |
|
69 | END IF; | |
73 | END PROCESS; |
|
70 | END PROCESS; | |
74 |
|
71 | |||
75 | PROCESS(clk, rstn) |
|
72 | PROCESS(clk, rstn) | |
76 | BEGIN |
|
73 | BEGIN | |
77 | IF rstn = '0' THEN |
|
74 | IF rstn = '0' THEN | |
78 | shifting <= '0'; |
|
75 | shifting <= '0'; | |
79 | SHIFTREG <= (OTHERS => '0'); |
|
76 | SHIFTREG <= (OTHERS => '0'); | |
80 | SYNC <= '0'; |
|
77 | SYNC <= '0'; | |
81 | shiftcnt <= 0; |
|
78 | shiftcnt <= 0; | |
82 | DOUT <= '0'; |
|
79 | DOUT <= '0'; | |
83 | ELSIF clk'EVENT AND clk = '1' THEN |
|
80 | ELSIF clk'EVENT AND clk = '1' THEN | |
84 | DOUT <= SHIFTREG(datawidth-1); |
|
81 | DOUT <= SHIFTREG(datawidth-1); | |
85 | IF(SMP_CLK = '1' AND SMP_CLK_R = '0') THEN |
|
82 | IF(SMP_CLK = '1' AND SMP_CLK_R = '0') THEN | |
86 | SYNC <= '1'; |
|
83 | SYNC <= '1'; | |
87 | shifting <= '1'; |
|
84 | shifting <= '1'; | |
88 | ELSE |
|
85 | ELSE | |
89 | SYNC <= '0'; |
|
86 | SYNC <= '0'; | |
90 | IF shiftcnt = datawidth-1 THEN |
|
87 | IF shiftcnt = datawidth-1 THEN | |
91 | shifting <= '0'; |
|
88 | shifting <= '0'; | |
92 | END IF; |
|
89 | END IF; | |
93 | END IF; |
|
90 | END IF; | |
94 | IF shifting = '1' THEN |
|
91 | IF shifting = '1' THEN | |
95 | shiftcnt <= shiftcnt + 1; |
|
92 | shiftcnt <= shiftcnt + 1; | |
96 | SHIFTREG <= SHIFTREG (datawidth-2 DOWNTO 0) & '0'; |
|
93 | SHIFTREG <= SHIFTREG (datawidth-2 DOWNTO 0) & '0'; | |
97 |
|
94 | |||
98 | ELSE |
|
95 | ELSE | |
99 | SHIFTREG <= INPUTREG; |
|
96 | SHIFTREG <= INPUTREG; | |
100 | shiftcnt <= 0; |
|
97 | shiftcnt <= 0; | |
101 | END IF; |
|
98 | END IF; | |
102 | END IF; |
|
99 | END IF; | |
103 | END PROCESS; |
|
100 | END PROCESS; | |
104 |
|
101 | |||
105 | END ARCHITECTURE behav; |
|
102 | END ARCHITECTURE behav; | |
106 |
|
103 | |||
107 |
|
@@ -1,99 +1,99 | |||||
1 | ------------------------------------------------------------------------------ |
|
1 | ------------------------------------------------------------------------------ | |
2 | -- This file is a part of the LPP VHDL IP LIBRARY |
|
2 | -- This file is a part of the LPP VHDL IP LIBRARY | |
3 | -- Copyright (C) 2009 - 2015, Laboratory of Plasmas Physic - CNRS |
|
3 | -- Copyright (C) 2009 - 2015, Laboratory of Plasmas Physic - CNRS | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 3 of the License, or |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | ------------------------------------------------------------------------------ |
|
18 | ------------------------------------------------------------------------------ | |
19 | -- Author : Alexis Jeandet |
|
19 | -- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@member.fsf.org |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
21 | ------------------------------------------------------------------------------ |
|
21 | ------------------------------------------------------------------------------ | |
22 | library IEEE; |
|
22 | library IEEE; | |
23 | use IEEE.STD_LOGIC_1164.ALL; |
|
23 | use IEEE.STD_LOGIC_1164.ALL; | |
24 | use IEEE.NUMERIC_STD.ALL; |
|
24 | use IEEE.NUMERIC_STD.ALL; | |
25 |
|
25 | |||
26 | entity dynamic_freq_div is |
|
26 | entity dynamic_freq_div is | |
27 | generic( |
|
27 | generic( | |
28 | PRESZ : integer range 1 to 32:=4; |
|
28 | PRESZ : integer range 1 to 32:=4; | |
29 | PREMAX : integer := 16#FFFFFF#; |
|
29 | PREMAX : integer := 16#FFFFFF#; | |
30 | CPTSZ : integer range 1 to 32:=16 |
|
30 | CPTSZ : integer range 1 to 32:=16 | |
31 | ); |
|
31 | ); | |
32 | Port ( |
|
32 | Port ( | |
33 | clk : in STD_LOGIC; |
|
33 | clk : in STD_LOGIC; | |
34 | rstn : in STD_LOGIC; |
|
34 | rstn : in STD_LOGIC; | |
35 | pre : in STD_LOGIC_VECTOR(PRESZ-1 downto 0); |
|
35 | pre : in STD_LOGIC_VECTOR(PRESZ-1 downto 0); | |
36 | N : in STD_LOGIC_VECTOR(CPTSZ-1 downto 0); |
|
36 | N : in STD_LOGIC_VECTOR(CPTSZ-1 downto 0); | |
37 | Reload : in std_logic; |
|
37 | Reload : in std_logic; | |
38 | clk_out : out STD_LOGIC |
|
38 | clk_out : out STD_LOGIC | |
39 | ); |
|
39 | ); | |
40 | end dynamic_freq_div; |
|
40 | end dynamic_freq_div; | |
41 |
|
41 | |||
42 | architecture Behavioral of dynamic_freq_div is |
|
42 | architecture Behavioral of dynamic_freq_div is | |
43 | constant prescaller_reg_sz : integer := 2**PRESZ; |
|
43 | constant prescaller_reg_sz : integer := 2**PRESZ; | |
44 | constant PREMAX_max : STD_LOGIC_VECTOR(PRESZ-1 downto 0):=(others => '1'); |
|
44 | constant PREMAX_max : STD_LOGIC_VECTOR(PRESZ-1 downto 0):=(others => '1'); | |
45 | signal cpt_reg : std_logic_vector(CPTSZ-1 downto 0):=(others => '0'); |
|
45 | signal cpt_reg : std_logic_vector(CPTSZ-1 downto 0):=(others => '0'); | |
46 |
signal prescaller_reg : std_logic_vector(prescaller_reg_sz-1 downto 0) |
|
46 | signal prescaller_reg : std_logic_vector(prescaller_reg_sz-1 downto 0);--:=(others => '0'); | |
47 | signal internal_clk : std_logic:='0'; |
|
47 | signal internal_clk : std_logic:='0'; | |
48 | signal internal_clk_reg : std_logic:='0'; |
|
48 | signal internal_clk_reg : std_logic:='0'; | |
49 | signal clk_out_reg : std_logic:='0'; |
|
49 | signal clk_out_reg : std_logic:='0'; | |
50 |
|
50 | |||
51 | begin |
|
51 | begin | |
52 |
|
52 | |||
53 | max0: if (UNSIGNED(PREMAX_max) < PREMAX) generate |
|
53 | max0: if (UNSIGNED(PREMAX_max) < PREMAX) generate | |
54 |
|
54 | |||
55 | internal_clk <= prescaller_reg(to_integer(unsigned(pre))) when (to_integer(unsigned(pre))<=UNSIGNED(PREMAX_max)) else |
|
55 | internal_clk <= prescaller_reg(to_integer(unsigned(pre))) when (to_integer(unsigned(pre))<=UNSIGNED(PREMAX_max)) else | |
56 | prescaller_reg(to_integer(UNSIGNED(PREMAX_max))); |
|
56 | prescaller_reg(to_integer(UNSIGNED(PREMAX_max))); | |
57 | end generate; |
|
57 | end generate; | |
58 | max1: if UNSIGNED(PREMAX_max) > PREMAX generate |
|
58 | max1: if UNSIGNED(PREMAX_max) > PREMAX generate | |
59 | internal_clk <= prescaller_reg(to_integer(unsigned(pre))) when (to_integer(unsigned(pre))<=PREMAX) else |
|
59 | internal_clk <= prescaller_reg(to_integer(unsigned(pre))) when (to_integer(unsigned(pre))<=PREMAX) else | |
60 | prescaller_reg(PREMAX); |
|
60 | prescaller_reg(PREMAX); | |
61 | end generate; |
|
61 | end generate; | |
62 |
|
62 | |||
63 |
|
63 | |||
64 |
|
64 | |||
65 | prescaller: process(rstn, clk) |
|
65 | prescaller: process(rstn, clk) | |
66 | begin |
|
66 | begin | |
67 | if rstn='0' then |
|
67 | if rstn='0' then | |
68 | prescaller_reg <= (others => '0'); |
|
68 | prescaller_reg <= (others => '0'); | |
69 | elsif clk'event and clk = '1' then |
|
69 | elsif clk'event and clk = '1' then | |
70 | prescaller_reg <= std_logic_vector(UNSIGNED(prescaller_reg) + 1); |
|
70 | prescaller_reg <= std_logic_vector(UNSIGNED(prescaller_reg) + 1); | |
71 | end if; |
|
71 | end if; | |
72 | end process; |
|
72 | end process; | |
73 |
|
73 | |||
74 |
|
74 | |||
75 | clk_out <= clk_out_reg; |
|
75 | clk_out <= clk_out_reg; | |
76 |
|
76 | |||
77 | counter: process(rstn, clk) |
|
77 | counter: process(rstn, clk) | |
78 | begin |
|
78 | begin | |
79 | if rstn='0' then |
|
79 | if rstn='0' then | |
80 | cpt_reg <= (others => '0'); |
|
80 | cpt_reg <= (others => '0'); | |
81 | internal_clk_reg <= '0'; |
|
81 | internal_clk_reg <= '0'; | |
82 | clk_out_reg <= '0'; |
|
82 | clk_out_reg <= '0'; | |
83 | elsif clk'event and clk = '1' then |
|
83 | elsif clk'event and clk = '1' then | |
84 | internal_clk_reg <= internal_clk; |
|
84 | internal_clk_reg <= internal_clk; | |
85 | if Reload = '1' then |
|
85 | if Reload = '1' then | |
86 | clk_out_reg <= '0'; |
|
86 | clk_out_reg <= '0'; | |
87 | cpt_reg <= (others => '0'); |
|
87 | cpt_reg <= (others => '0'); | |
88 | elsif (internal_clk = '1' and internal_clk_reg = '0') then |
|
88 | elsif (internal_clk = '1' and internal_clk_reg = '0') then | |
89 | if cpt_reg = N then |
|
89 | if cpt_reg = N then | |
90 | clk_out_reg <= not clk_out_reg; |
|
90 | clk_out_reg <= not clk_out_reg; | |
91 | cpt_reg <= (others => '0'); |
|
91 | cpt_reg <= (others => '0'); | |
92 | else |
|
92 | else | |
93 | cpt_reg <= std_logic_vector(UNSIGNED(cpt_reg) + 1); |
|
93 | cpt_reg <= std_logic_vector(UNSIGNED(cpt_reg) + 1); | |
94 | end if; |
|
94 | end if; | |
95 | end if; |
|
95 | end if; | |
96 | end if; |
|
96 | end if; | |
97 | end process; |
|
97 | end process; | |
98 |
|
98 | |||
99 |
end Behavioral; |
|
99 | end Behavioral; No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now