##// END OF EJS Templates
temp
pellion -
r159:941888d85bda JC
parent child
Show More
@@ -0,0 +1,41
1
2 --=================================================================================
3 --THIS FILE IS GENERATED BY A SCRIPT, DON'T TRY TO EDIT
4 --
5 --TAKE A LOOK AT VHD_LIB/APB_DEVICES FOLDER TO ADD A DEVICE ID OR VENDOR ID
6 --=================================================================================
7
8
9 library ieee;
10 use ieee.std_logic_1164.all;
11 library grlib;
12 use grlib.amba.all;
13 use std.textio.all;
14
15
16 package apb_devices_list is
17
18
19 constant VENDOR_LPP : amba_vendor_type := 16#19#;
20
21 constant ROCKET_TM : amba_device_type := 16#1#;
22 constant otherCore : amba_device_type := 16#2#;
23 constant LPP_SIMPLE_DIODE : amba_device_type := 16#3#;
24 constant LPP_MULTI_DIODE : amba_device_type := 16#4#;
25 constant LPP_LCD_CTRLR : amba_device_type := 16#5#;
26 constant LPP_UART : amba_device_type := 16#6#;
27 constant LPP_CNA : amba_device_type := 16#7#;
28 constant LPP_APB_ADC : amba_device_type := 16#8#;
29 constant LPP_CHENILLARD : amba_device_type := 16#9#;
30 constant LPP_IIR_CEL_FILTER : amba_device_type := 16#10#;
31 constant LPP_FIFO_PID : amba_device_type := 16#11#;
32 constant LPP_FFT : amba_device_type := 16#12#;
33 constant LPP_MATRIX : amba_device_type := 16#13#;
34 constant LPP_BALISE : amba_device_type := 16#14#;
35 constant LPP_USB : amba_device_type := 16#15#;
36 constant LPP_DELAY : amba_device_type := 16#16#;
37 constant LPP_DMA_TYPE : amba_device_type := 16#17#;
38 constant LPP_BOOTLOADER_TYPE : amba_device_type := 16#18#;
39
40
41 end;
@@ -0,0 +1,71
1 LIBRARY ieee;
2 USE ieee.std_logic_1164.ALL;
3
4 LIBRARY grlib;
5
6 LIBRARY lpp;
7 USE lpp.lpp_ad_conv.ALL;
8 USE lpp.iir_filter.ALL;
9 USE lpp.FILTERcfg.ALL;
10 USE lpp.lpp_memory.ALL;
11 LIBRARY techmap;
12 USE techmap.gencomp.ALL;
13
14 PACKAGE lpp_top_lfr_pkg IS
15
16 COMPONENT lpp_top_acq
17 GENERIC (
18 tech : integer);
19 PORT (
20 cnv_run : IN STD_LOGIC;
21 cnv : OUT STD_LOGIC;
22 sck : OUT STD_LOGIC;
23 sdo : IN STD_LOGIC_VECTOR(7 DOWNTO 0);
24 cnv_clk : IN STD_LOGIC;
25 cnv_rstn : IN STD_LOGIC;
26 clk : IN STD_LOGIC;
27 rstn : IN STD_LOGIC;
28 sample_f0_0_wen : OUT STD_LOGIC_VECTOR(4 DOWNTO 0);
29 sample_f0_1_wen : OUT STD_LOGIC_VECTOR(4 DOWNTO 0);
30 sample_f0_wdata : OUT STD_LOGIC_VECTOR((5*16)-1 DOWNTO 0);
31 sample_f1_wen : OUT STD_LOGIC_VECTOR(4 DOWNTO 0);
32 sample_f1_wdata : OUT STD_LOGIC_VECTOR((5*16)-1 DOWNTO 0);
33 sample_f2_wen : OUT STD_LOGIC_VECTOR(4 DOWNTO 0);
34 sample_f2_wdata : OUT STD_LOGIC_VECTOR((5*16)-1 DOWNTO 0);
35 sample_f3_wen : OUT STD_LOGIC_VECTOR(4 DOWNTO 0);
36 sample_f3_wdata : OUT STD_LOGIC_VECTOR((5*16)-1 DOWNTO 0));
37 END COMPONENT;
38
39 COMPONENT lpp_top_apbreg
40 GENERIC (
41 pindex : INTEGER;
42 paddr : INTEGER;
43 pmask : INTEGER;
44 pirq : INTEGER);
45 PORT (
46 HCLK : IN STD_ULOGIC;
47 HRESETn : IN STD_ULOGIC;
48 apbi : IN apb_slv_in_type;
49 apbo : OUT apb_slv_out_type;
50 ready_matrix_f0_0 : IN STD_LOGIC;
51 ready_matrix_f0_1 : IN STD_LOGIC;
52 ready_matrix_f1 : IN STD_LOGIC;
53 ready_matrix_f2 : IN STD_LOGIC;
54 error_anticipating_empty_fifo : IN STD_LOGIC;
55 error_bad_component_error : IN STD_LOGIC;
56 debug_reg : IN STD_LOGIC_VECTOR(31 DOWNTO 0);
57 status_ready_matrix_f0_0 : OUT STD_LOGIC;
58 status_ready_matrix_f0_1 : OUT STD_LOGIC;
59 status_ready_matrix_f1 : OUT STD_LOGIC;
60 status_ready_matrix_f2 : OUT STD_LOGIC;
61 status_error_anticipating_empty_fifo : OUT STD_LOGIC;
62 status_error_bad_component_error : OUT STD_LOGIC;
63 config_active_interruption_onNewMatrix : OUT STD_LOGIC;
64 config_active_interruption_onError : OUT STD_LOGIC;
65 addr_matrix_f0_0 : OUT STD_LOGIC_VECTOR(31 DOWNTO 0);
66 addr_matrix_f0_1 : OUT STD_LOGIC_VECTOR(31 DOWNTO 0);
67 addr_matrix_f1 : OUT STD_LOGIC_VECTOR(31 DOWNTO 0);
68 addr_matrix_f2 : OUT STD_LOGIC_VECTOR(31 DOWNTO 0));
69 END COMPONENT;
70
71 END lpp_top_lfr_pkg; No newline at end of file
@@ -1,212 +1,213
1 ------------------------------------------------------------------------------
2 -- This file is a part of the LPP VHDL IP LIBRARY
3 -- Copyright (C) 2009 - 2010, Laboratory of Plasmas Physic - CNRS
4 --
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
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
9 --
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14 --
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
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------
19 -- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 -------------------------------------------------------------------------------
22 library ieee;
23 use ieee.std_logic_1164.all;
24 use ieee.numeric_std.all;
25 library grlib;
26 use grlib.amba.all;
27 use grlib.stdlib.all;
28 use grlib.devices.all;
29 library lpp;
30 use lpp.iir_filter.all;
31 use lpp.general_purpose.all;
32 use lpp.lpp_amba.all;
33 use lpp.apb_devices_list.all;
34
35 entity APB_IIR_CEL is
36 generic (
37 tech : integer := 0;
38 pindex : integer := 0;
39 paddr : integer := 0;
40 pmask : integer := 16#fff#;
41 pirq : integer := 0;
42 abits : integer := 8;
43 Sample_SZ : integer := 16;
44 ChanelsCount : integer := 1;
45 Coef_SZ : integer := 9;
46 CoefCntPerCel: integer := 6;
47 Cels_count : integer := 5;
48 virgPos : integer := 3;
49 Mem_use : integer := use_RAM
50 );
51 port (
52 rst : in std_logic;
53 clk : in std_logic;
54 apbi : in apb_slv_in_type;
55 apbo : out apb_slv_out_type;
56 sample_clk : in std_logic;
57 sample_clk_out : out std_logic;
58 sample_in : in samplT(ChanelsCount-1 downto 0,Sample_SZ-1 downto 0);
59 sample_out : out samplT(ChanelsCount-1 downto 0,Sample_SZ-1 downto 0);
60 CoefsInitVal : in std_logic_vector((Cels_count*CoefCntPerCel*Coef_SZ)-1 downto 0) := (others => '1')
61 );
62 end;
63
64
65 architecture AR_APB_IIR_CEL of APB_IIR_CEL is
66
67 constant REVISION : integer := 1;
68
69 constant pconfig : apb_config_type := (
70 0 => ahb_device_reg (VENDOR_LPP, LPP_IIR_CEL_FILTER, 0, REVISION, 0),
71 1 => apb_iobar(paddr, pmask));
72
73
74
75 type FILTERreg is record
76 regin : in_IIR_CEL_reg;
77 regout : out_IIR_CEL_reg;
78 end record;
79
80 signal Rdata : std_logic_vector(31 downto 0);
81 signal r : FILTERreg;
82 signal filter_reset : std_logic:='0';
83 signal smp_cnt : integer :=0;
84 signal sample_clk_out_R : std_logic;
85 signal RawCoefs : std_logic_vector(((Coef_SZ*CoefCntPerCel*Cels_count)-1) downto 0);
86
87 type CoefCelT is array(0 to (CoefCntPerCel/2)-1) of std_logic_vector(Coef_SZ-1 downto 0);
88 type CoefTblT is array(0 to Cels_count-1) of CoefCelT;
89
90 type CoefsRegT is record
91 numCoefs : CoefTblT;
92 denCoefs : CoefTblT;
93 end record;
94
95 signal CoefsReg : CoefsRegT;
96 signal CoefsReg_d : CoefsRegT;
97
98
99 begin
100
101 filter_reset <= rst and r.regin.config(0);
102 sample_clk_out <= sample_clk_out_R;
103 --
104 filter : IIR_CEL_FILTER
105 generic map(tech,Sample_SZ,ChanelsCount,Coef_SZ,CoefCntPerCel,Cels_count,Mem_use)
106 port map(
107 reset => filter_reset,
108 clk => clk,
109 sample_clk => sample_clk,
110 regs_in => r.regin,
111 regs_out => r.regout,
112 sample_in => sample_in,
113 sample_out => sample_out,
114 coefs => RawCoefs
115 );
116
117 process(rst,sample_clk)
118 begin
119 if rst = '0' then
120 smp_cnt <= 0;
121 sample_clk_out_R <= '0';
122 elsif sample_clk'event and sample_clk = '1' then
123 if smp_cnt = 1 then
124 smp_cnt <= 0;
125 sample_clk_out_R <= not sample_clk_out_R;
126 else
127 smp_cnt <= smp_cnt +1;
128 end if;
129 end if;
130 end process;
131
132
133 coefsConnectL0: for z in 0 to Cels_count-1 generate
134 coefsConnectL1: for y in 0 to (CoefCntPerCel/2)-1 generate
135 RawCoefs(((((z*CoefCntPerCel+y)+1)*Coef_SZ)-1) downto (((z*CoefCntPerCel+y))*Coef_SZ) ) <= CoefsReg_d.numCoefs(z)(y)(Coef_SZ-1 downto 0);
136 RawCoefs(((((z*CoefCntPerCel+y+(CoefCntPerCel/2))+1)*Coef_SZ)-1) downto ((z*CoefCntPerCel+y+(CoefCntPerCel/2))*Coef_SZ)) <= CoefsReg_d.denCoefs(z)(y)(Coef_SZ-1 downto 0);
137 end generate;
138 end generate;
139
140
141 process(rst,clk)
142 begin
143 if rst = '0' then
144 r.regin.virgPos <= std_logic_vector(to_unsigned(virgPos,5));
145 coefsRstL0: for z in 0 to Cels_count-1 loop
146 coefsRstL1: for y in 0 to (CoefCntPerCel/2)-1 loop
147 CoefsReg.numCoefs(z)(y) <= CoefsInitVal(((((z*CoefCntPerCel+y)+1)*Coef_SZ)-1) downto (((z*CoefCntPerCel+y))*Coef_SZ) );
148 CoefsReg.denCoefs(z)(y) <= CoefsInitVal(((((z*CoefCntPerCel+y+(CoefCntPerCel/2))+1)*Coef_SZ)-1) downto ((z*CoefCntPerCel+y+(CoefCntPerCel/2))*Coef_SZ));
149 end loop;
150 end loop;
151 elsif clk'event and clk = '1' then
152 CoefsReg_d <= CoefsReg;
153
154 --APB Write OP
155 if (apbi.psel(pindex) and apbi.penable and apbi.pwrite) = '1' then
156 if apbi.paddr(7 downto 2) = "000000" then
157 r.regin.config(0) <= apbi.pwdata(0);
158 elsif apbi.paddr(7 downto 2) = "000001" then
159 r.regin.virgPos <= apbi.pwdata(4 downto 0);
160 else
161 for i in 0 to Cels_count-1 loop
162 for j in 0 to (CoefCntPerCel/2) - 1 loop
163 if apbi.paddr(9 downto 2) = std_logic_vector(TO_UNSIGNED((2+ (i*(CoefCntPerCel/2))+j),8)) then
164 CoefsReg.numCoefs(i)(j) <= apbi.pwdata(Coef_SZ-1 downto 0);
165 CoefsReg.denCoefs(i)(j) <= apbi.pwdata((Coef_SZ+15) downto 16);
166 end if;
167 end loop;
168 end loop;
169 end if;
170 end if;
171
172 --APB READ OP
173 if (apbi.psel(pindex) and (not apbi.pwrite)) = '1' then
174 if apbi.paddr(7 downto 2) = "000000" then
175 Rdata(7 downto 0) <= std_logic_vector(TO_UNSIGNED(ChanelsCount,8));
176 Rdata(15 downto 8) <= std_logic_vector(TO_UNSIGNED(Sample_SZ,8));
177 Rdata(23 downto 16) <= std_logic_vector(TO_UNSIGNED(CoefCntPerCel,8));
178 Rdata(31 downto 24) <= std_logic_vector(TO_UNSIGNED(Cels_count,8));
179 elsif apbi.paddr(7 downto 2) = "000001" then
180 Rdata(4 downto 0) <= r.regin.virgPos;
181 Rdata(15 downto 8) <= std_logic_vector(TO_UNSIGNED(Coef_SZ,8));
182 Rdata(7 downto 5) <= (others => '0');
183 Rdata(31 downto 16) <= (others => '0');
184 else
185 for i in 0 to Cels_count-1 loop
186 for j in 0 to (CoefCntPerCel/2) - 1 loop
187 if apbi.paddr(9 downto 2) = std_logic_vector(TO_UNSIGNED((2+ (i*(CoefCntPerCel/2))+j),8)) then
188 Rdata(Coef_SZ-1 downto 0) <= CoefsReg_d.numCoefs(i)(j);
189 Rdata((Coef_SZ+15) downto 16) <= CoefsReg_d.denCoefs(i)(j);
190 end if;
191 end loop;
192 end loop;
193 end if;
194 end if;
195 end if;
196 apbo.pconfig <= pconfig;
197 end process;
198
199 apbo.prdata <= Rdata when apbi.penable = '1' ;
200
201 -- pragma translate_off
202 bootmsg : report_version
203 generic map ("apb IIR filter" & tost(pindex) &
204 ": IIR filter rev " & tost(REVISION) & ", fifo " & tost(fifosize) &
205 ", irq " & tost(pirq));
206 -- pragma translate_on
207
208
209
210
211 end ar_APB_IIR_CEL;
212
1 ------------------------------------------------------------------------------
2 -- This file is a part of the LPP VHDL IP LIBRARY
3 -- Copyright (C) 2009 - 2010, Laboratory of Plasmas Physic - CNRS
4 --
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
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
9 --
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14 --
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
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------
19 -- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 -------------------------------------------------------------------------------
22 library ieee;
23 use ieee.std_logic_1164.all;
24 use ieee.numeric_std.all;
25 library grlib;
26 use grlib.amba.all;
27 use grlib.stdlib.all;
28 use grlib.devices.all;
29 library lpp;
30 use lpp.iir_filter.all;
31 use lpp.general_purpose.all;
32 use lpp.lpp_amba.all;
33 use lpp.apb_devices_list.all;
34
35 entity APB_IIR_CEL is
36 generic (
37 tech : integer := 0;
38 pindex : integer := 0;
39 paddr : integer := 0;
40 pmask : integer := 16#fff#;
41 pirq : integer := 0;
42 abits : integer := 8;
43 Sample_SZ : integer := 16;
44 ChanelsCount : integer := 1;
45 Coef_SZ : integer := 9;
46 CoefCntPerCel: integer := 6;
47 Cels_count : integer := 5;
48 virgPos : integer := 3;
49 Mem_use : integer := use_RAM
50 );
51 port (
52 rst : in std_logic;
53 clk : in std_logic;
54 apbi : in apb_slv_in_type;
55 apbo : out apb_slv_out_type;
56 sample_clk : in std_logic;
57 sample_clk_out : out std_logic;
58 sample_in : in samplT(ChanelsCount-1 downto 0,Sample_SZ-1 downto 0);
59 sample_out : out samplT(ChanelsCount-1 downto 0,Sample_SZ-1 downto 0);
60 CoefsInitVal : in std_logic_vector((Cels_count*CoefCntPerCel*Coef_SZ)-1 downto 0) := (others => '1')
61 );
62 end;
63
64
65 architecture AR_APB_IIR_CEL of APB_IIR_CEL is
66
67 constant REVISION : integer := 1;
68
69 constant pconfig : apb_config_type := (
70 0 => ahb_device_reg (VENDOR_LPP, LPP_IIR_CEL_FILTER, 0, REVISION, 0),
71 1 => apb_iobar(paddr, pmask));
72
73
74
75 type FILTERreg is record
76 regin : in_IIR_CEL_reg;
77 regout : out_IIR_CEL_reg;
78 end record;
79
80 signal Rdata : std_logic_vector(31 downto 0);
81 signal r : FILTERreg;
82 signal filter_reset : std_logic:='0';
83 signal smp_cnt : integer :=0;
84 signal sample_clk_out_R : std_logic;
85 signal RawCoefs : std_logic_vector(((Coef_SZ*CoefCntPerCel*Cels_count)-1) downto 0);
86
87 type CoefCelT is array(0 to (CoefCntPerCel/2)-1) of std_logic_vector(Coef_SZ-1 downto 0);
88 type CoefTblT is array(0 to Cels_count-1) of CoefCelT;
89
90 type CoefsRegT is record
91 numCoefs : CoefTblT;
92 denCoefs : CoefTblT;
93 end record;
94
95 signal CoefsReg : CoefsRegT;
96 signal CoefsReg_d : CoefsRegT;
97
98
99 begin
100
101 filter_reset <= rst and r.regin.config(0);
102 sample_clk_out <= sample_clk_out_R;
103 --
104 filter : IIR_CEL_FILTER
105 generic map(tech,Sample_SZ,ChanelsCount,Coef_SZ,CoefCntPerCel,Cels_count,Mem_use)
106 port map(
107 reset => filter_reset,
108 clk => clk,
109 sample_clk => sample_clk,
110 regs_in => r.regin,
111 regs_out => r.regout,
112 sample_in => sample_in,
113 sample_out => sample_out,
114 coefs => RawCoefs
115 );
116
117 process(rst,sample_clk)
118 begin
119 if rst = '0' then
120 smp_cnt <= 0;
121 sample_clk_out_R <= '0';
122 elsif sample_clk'event and sample_clk = '1' then
123 if smp_cnt = 1 then
124 smp_cnt <= 0;
125 sample_clk_out_R <= not sample_clk_out_R;
126 else
127 smp_cnt <= smp_cnt +1;
128 end if;
129 end if;
130 end process;
131
132
133 coefsConnectL0: for z in 0 to Cels_count-1 generate
134 coefsConnectL1: for y in 0 to (CoefCntPerCel/2)-1 generate
135 RawCoefs(((((z*CoefCntPerCel+y)+1)*Coef_SZ)-1) downto (((z*CoefCntPerCel+y))*Coef_SZ) ) <= CoefsReg_d.numCoefs(z)(y)(Coef_SZ-1 downto 0);
136 RawCoefs(((((z*CoefCntPerCel+y+(CoefCntPerCel/2))+1)*Coef_SZ)-1) downto ((z*CoefCntPerCel+y+(CoefCntPerCel/2))*Coef_SZ)) <= CoefsReg_d.denCoefs(z)(y)(Coef_SZ-1 downto 0);
137 end generate;
138 end generate;
139
140
141 process(rst,clk)
142 begin
143 if rst = '0' then
144 r.regin.virgPos <= std_logic_vector(to_unsigned(virgPos,5));
145 coefsRstL0: for z in 0 to Cels_count-1 loop
146 coefsRstL1: for y in 0 to (CoefCntPerCel/2)-1 loop
147 CoefsReg.numCoefs(z)(y) <= CoefsInitVal(((((z*CoefCntPerCel+y)+1)*Coef_SZ)-1) downto (((z*CoefCntPerCel+y))*Coef_SZ) );
148 CoefsReg.denCoefs(z)(y) <= CoefsInitVal(((((z*CoefCntPerCel+y+(CoefCntPerCel/2))+1)*Coef_SZ)-1) downto ((z*CoefCntPerCel+y+(CoefCntPerCel/2))*Coef_SZ));
149 end loop;
150 end loop;
151 elsif clk'event and clk = '1' then
152 CoefsReg_d <= CoefsReg;
153
154 --APB Write OP
155 if (apbi.psel(pindex) and apbi.penable and apbi.pwrite) = '1' then
156 if apbi.paddr(7 downto 2) = "000000" then
157 r.regin.config(0) <= apbi.pwdata(0);
158 elsif apbi.paddr(7 downto 2) = "000001" then
159 r.regin.virgPos <= apbi.pwdata(4 downto 0);
160 else
161 for i in 0 to Cels_count-1 loop
162 for j in 0 to (CoefCntPerCel/2) - 1 loop
163 if apbi.paddr(9 downto 2) = std_logic_vector(TO_UNSIGNED((2+ (i*(CoefCntPerCel/2))+j),8)) then
164 CoefsReg.numCoefs(i)(j) <= apbi.pwdata(Coef_SZ-1 downto 0);
165 CoefsReg.denCoefs(i)(j) <= apbi.pwdata((Coef_SZ+15) downto 16);
166 end if;
167 end loop;
168 end loop;
169 end if;
170 end if;
171
172 --APB READ OP
173 if (apbi.psel(pindex) and (not apbi.pwrite)) = '1' then
174 if apbi.paddr(7 downto 2) = "000000" then
175 Rdata(7 downto 0) <= std_logic_vector(TO_UNSIGNED(ChanelsCount,8));
176 Rdata(15 downto 8) <= std_logic_vector(TO_UNSIGNED(Sample_SZ,8));
177 Rdata(23 downto 16) <= std_logic_vector(TO_UNSIGNED(CoefCntPerCel,8));
178 Rdata(31 downto 24) <= std_logic_vector(TO_UNSIGNED(Cels_count,8));
179 elsif apbi.paddr(7 downto 2) = "000001" then
180 Rdata(4 downto 0) <= r.regin.virgPos;
181 Rdata(15 downto 8) <= std_logic_vector(TO_UNSIGNED(Coef_SZ,8));
182 Rdata(7 downto 5) <= (others => '0');
183 Rdata(31 downto 16) <= (others => '0');
184 else
185 for i in 0 to Cels_count-1 loop
186 for j in 0 to (CoefCntPerCel/2) - 1 loop
187 if apbi.paddr(9 downto 2) = std_logic_vector(TO_UNSIGNED((2+ (i*(CoefCntPerCel/2))+j),8)) then
188 Rdata(Coef_SZ-1 downto 0) <= CoefsReg_d.numCoefs(i)(j);
189 Rdata((Coef_SZ+15) downto 16) <= CoefsReg_d.denCoefs(i)(j);
190 end if;
191 end loop;
192 end loop;
193 end if;
194 end if;
195 end if;
196 apbo.pconfig <= pconfig;
197 end process;
198
199 apbo.prdata <= Rdata when apbi.penable = '1' ;
200
201 -- pragma translate_off
202 bootmsg : report_version
203 generic map ("apb IIR filter" & tost(pindex) &
204 ": IIR filter rev " & tost(REVISION)&
205 --", fifo " & tost(fifosize) &
206 ", irq " & tost(pirq));
207 -- pragma translate_on
208
209
210
211
212 end ar_APB_IIR_CEL;
213
@@ -63,7 +63,7 begin
63 63 --==============================================================
64 64 --=========================A L U================================
65 65 --==============================================================
66 ALU1 : entity ALU
66 ALU1 : ALU
67 67 generic map(
68 68 Arith_en => 1,
69 69 Logic_en => 0,
@@ -18,97 +18,180
18 18 -------------------------------------------------------------------------------
19 19 -- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 ----------------------------------------------------------------------------
22 library IEEE;
23 use IEEE.STD_LOGIC_1164.ALL;
24 library lpp;
25 use lpp.lpp_ad_conv.all;
26 use lpp.general_purpose.Clk_divider;
27
28 --! \brief AD7688 driver, generates all needed signal to drive this ADC.
29 --!
30 --! \author Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr
21 -------------------------------------------------------------------------------
22 -- MODIFIED by Jean-christophe PELLION
23 -- jean-christophe.pellion@lpp.polytechnique.fr
24 -------------------------------------------------------------------------------
25 LIBRARY IEEE;
26 USE IEEE.STD_LOGIC_1164.ALL;
27 LIBRARY lpp;
28 USE lpp.lpp_ad_conv.ALL;
29 USE lpp.general_purpose.SYNC_FF;
31 30
32 entity AD7688_drvr is
33 generic(
34 ChanelCount :integer; --! Number of ADC you whant to drive
35 clkkHz :integer --! System clock frequency in kHz usefull to generate some pulses with good width.
36 );
37 Port(
38 clk : in STD_LOGIC; --! System clock
39 rstn : in STD_LOGIC; --! System reset
40 enable : in std_logic; --! Negative enable
41 smplClk : in STD_LOGIC; --! Sampling clock
42 DataReady : out std_logic; --! New sample available
43 smpout : out Samples_out(ChanelCount-1 downto 0); --! Samples
44 AD_in : in AD7688_in(ChanelCount-1 downto 0); --! Input signals for ADC see lpp.lpp_ad_conv
45 AD_out : out AD7688_out --! Output signals for ADC see lpp.lpp_ad_conv
46 );
47 end AD7688_drvr;
48
49 architecture ar_AD7688_drvr of AD7688_drvr is
50
51 constant convTrigger : integer:= clkkHz*16/10000; --tconv = 1.6µs
52
53 signal i : integer range 0 to convTrigger :=0;
54 signal clk_int : std_logic;
55 signal clk_int_inv : std_logic;
56 signal smplClk_reg : std_logic;
57 signal cnv_int : std_logic;
58 signal reset : std_logic;
31 ENTITY AD7688_drvr IS
32 GENERIC(
33 ChanelCount : INTEGER;
34 ncycle_cnv_high : INTEGER := 79;
35 ncycle_cnv : INTEGER := 500);
36 PORT (
37 -- CONV --
38 cnv_clk : IN STD_LOGIC;
39 cnv_rstn : IN STD_LOGIC;
40 cnv_run : IN STD_LOGIC;
41 cnv : OUT STD_LOGIC;
59 42
60 begin
61
62 clkdiv: if clkkHz>=66000 generate
63 clkdivider: entity work.Clk_divider
64 generic map(clkkHz*1000,60000000)
65 Port map( clk ,reset,clk_int);
66 end generate;
43 -- DATA --
44 clk : IN STD_LOGIC;
45 rstn : IN STD_LOGIC;
46 sck : OUT STD_LOGIC;
47 sdo : IN STD_LOGIC_VECTOR(ChanelCount-1 DOWNTO 0);
67 48
68 clknodiv: if clkkHz<66000 generate
69 nodiv: clk_int <= clk;
70 end generate;
71
72 clk_int_inv <= not clk_int;
73
74 AD_out.CNV <= cnv_int;
75 AD_out.SCK <= clk_int;
76 reset <= rstn and enable;
49 sample : OUT Samples(ChanelCount-1 DOWNTO 0);
50 sample_val : OUT STD_LOGIC
51 );
52 END AD7688_drvr;
77 53
78 sckgen: process(clk,reset)
79 begin
80 if reset = '0' then
81 i <= 0;
82 cnv_int <= '0';
83 smplClk_reg <= '0';
84 elsif clk'event and clk = '1' then
85 if smplClk = '1' and smplClk_reg = '0' then
86 if i = convTrigger then
87 smplClk_reg <= '1';
88 i <= 0;
89 cnv_int <= '0';
90 else
91 i <= i+1;
92 cnv_int <= '1';
93 end if;
94 elsif smplClk = '0' and smplClk_reg = '1' then
95 smplClk_reg <= '0';
96 end if;
97 end if;
98 end process;
54 ARCHITECTURE ar_AD7688_drvr OF AD7688_drvr IS
55
56 COMPONENT SYNC_FF
57 GENERIC (
58 NB_FF_OF_SYNC : INTEGER);
59 PORT (
60 clk : IN STD_LOGIC;
61 rstn : IN STD_LOGIC;
62 A : IN STD_LOGIC;
63 A_sync : OUT STD_LOGIC);
64 END COMPONENT;
99 65
100 66
67 SIGNAL cnv_cycle_counter : INTEGER;
68 SIGNAL cnv_s : STD_LOGIC;
69 SIGNAL cnv_sync : STD_LOGIC;
70 SIGNAL cnv_sync_r : STD_LOGIC;
71 SIGNAL cnv_done : STD_LOGIC;
72 SIGNAL sample_bit_counter : INTEGER;
73 SIGNAL shift_reg : Samples(ChanelCount-1 DOWNTO 0);
101 74
102 spidrvr: entity work.AD7688_spi_if
103 generic map(ChanelCount)
104 Port map(clk_int_inv,reset,cnv_int,DataReady,AD_in,smpout);
75 SIGNAL cnv_run_sync : STD_LOGIC;
76
77 BEGIN
78 -----------------------------------------------------------------------------
79 -- CONV
80 -----------------------------------------------------------------------------
81 PROCESS (cnv_clk, cnv_rstn)
82 BEGIN -- PROCESS
83 IF cnv_rstn = '0' THEN -- asynchronous reset (active low)
84 cnv_cycle_counter <= 0;
85 cnv_s <= '0';
86 ELSIF cnv_clk'EVENT AND cnv_clk = '1' THEN -- rising clock edge
87 IF cnv_run = '1' THEN
88 IF cnv_cycle_counter < ncycle_cnv THEN
89 cnv_cycle_counter <= cnv_cycle_counter +1;
90 IF cnv_cycle_counter < ncycle_cnv_high THEN
91 cnv_s <= '1';
92 ELSE
93 cnv_s <= '0';
94 END IF;
95 ELSE
96 cnv_s <= '1';
97 cnv_cycle_counter <= 0;
98 END IF;
99 ELSE
100 cnv_s <= '0';
101 cnv_cycle_counter <= 0;
102 END IF;
103 END IF;
104 END PROCESS;
105 105
106 cnv <= cnv_s;
107
108 -----------------------------------------------------------------------------
106 109
107 110
108 end ar_AD7688_drvr;
111 -----------------------------------------------------------------------------
112 -- SYNC CNV
113 -----------------------------------------------------------------------------
114
115 SYNC_FF_cnv : SYNC_FF
116 GENERIC MAP (
117 NB_FF_OF_SYNC => 2)
118 PORT MAP (
119 clk => clk,
120 rstn => rstn,
121 A => cnv_s,
122 A_sync => cnv_sync);
109 123
124 PROCESS (clk, rstn)
125 BEGIN
126 IF rstn = '0' THEN
127 cnv_sync_r <= '0';
128 cnv_done <= '0';
129 ELSIF clk'EVENT AND clk = '1' THEN
130 cnv_sync_r <= cnv_sync;
131 cnv_done <= (NOT cnv_sync) AND cnv_sync_r;
132 END IF;
133 END PROCESS;
134
135 -----------------------------------------------------------------------------
136
137 SYNC_FF_run : SYNC_FF
138 GENERIC MAP (
139 NB_FF_OF_SYNC => 2)
140 PORT MAP (
141 clk => clk,
142 rstn => rstn,
143 A => cnv_run,
144 A_sync => cnv_run_sync);
110 145
111 146
112
147
148 -----------------------------------------------------------------------------
149 -- DATA
150 -----------------------------------------------------------------------------
151 PROCESS (clk, rstn)
152 BEGIN -- PROCESS
153 IF rstn = '0' THEN
154 FOR l IN 0 TO ChanelCount-1 LOOP
155 shift_reg(l) <= (OTHERS => '0');
156 END LOOP;
157 sample_bit_counter <= 0;
158 sample_val <= '0';
159 SCK <= '1';
160 ELSIF clk'EVENT AND clk = '1' THEN
161
162 IF cnv_run_sync = '0' THEN
163 sample_bit_counter <= 0;
164 ELSIF cnv_done = '1' THEN
165 sample_bit_counter <= 1;
166 ELSIF sample_bit_counter > 0 AND sample_bit_counter < 32 THEN
167 sample_bit_counter <= sample_bit_counter + 1;
168 END IF;
113 169
170 IF (sample_bit_counter MOD 2) = 1 THEN
171 FOR l IN 0 TO ChanelCount-1 LOOP
172 --shift_reg(l)(15) <= sdo(l);
173 --shift_reg(l)(14 DOWNTO 0) <= shift_reg(l)(15 DOWNTO 1);
174 shift_reg(l)(0) <= sdo(l);
175 shift_reg(l)(15 DOWNTO 1) <= shift_reg(l)(14 DOWNTO 0);
176 END LOOP;
177 SCK <= '0';
178 ELSE
179 SCK <= '1';
180 END IF;
114 181
182 IF sample_bit_counter = 31 THEN
183 sample_val <= '1';
184 FOR l IN 0 TO ChanelCount-1 LOOP
185 --sample(l)(15) <= sdo(l);
186 --sample(l)(14 DOWNTO 0) <= shift_reg(l)(15 DOWNTO 1);
187 sample(l)(0) <= sdo(l);
188 sample(l)(15 DOWNTO 1) <= shift_reg(l)(14 DOWNTO 0);
189 END LOOP;
190 ELSE
191 sample_val <= '0';
192 END IF;
193 END IF;
194 END PROCESS;
195
196 END ar_AD7688_drvr;
197
@@ -50,7 +50,7 PACKAGE lpp_ad_conv IS
50 50
51 51 TYPE Samples IS ARRAY(NATURAL RANGE <>) OF STD_LOGIC_VECTOR(15 DOWNTO 0);
52 52
53 COMPONENT ADS7886_drvr
53 COMPONENT AD7688_drvr
54 54 GENERIC (
55 55 ChanelCount : INTEGER;
56 56 ncycle_cnv_high : INTEGER := 79;
@@ -162,26 +162,26 Type ADS127X_config is
162 162 MODE : ADS127X_MODE_Type;
163 163 end record;
164 164
165 COMPONENT ADS1274_DRIVER is
166 generic(modeCfg : ADS127X_MODE_Type := ADS127X_MODE_low_power; formatCfg : ADS127X_FORMAT_Type := ADS127X_FSYNC_FORMAT);
167 port(
168 Clk : in std_logic;
169 reset : in std_logic;
170 SpiClk : out std_logic;
171 DIN : in std_logic_vector(3 downto 0);
172 Ready : in std_logic;
173 Format : out std_logic_vector(2 downto 0);
174 Mode : out std_logic_vector(1 downto 0);
175 ClkDiv : out std_logic;
176 PWDOWN : out std_logic_vector(3 downto 0);
177 SmplClk : in std_logic;
178 OUT0 : out std_logic_vector(23 downto 0);
179 OUT1 : out std_logic_vector(23 downto 0);
180 OUT2 : out std_logic_vector(23 downto 0);
181 OUT3 : out std_logic_vector(23 downto 0);
182 FSynch : out std_logic;
183 test : out std_logic
184 );
165 COMPONENT ADS1274_DRIVER is
166 generic(modeCfg : ADS127X_MODE_Type := ADS127X_MODE_low_power; formatCfg : ADS127X_FORMAT_Type := ADS127X_FSYNC_FORMAT);
167 port(
168 Clk : in std_logic;
169 reset : in std_logic;
170 SpiClk : out std_logic;
171 DIN : in std_logic_vector(3 downto 0);
172 Ready : in std_logic;
173 Format : out std_logic_vector(2 downto 0);
174 Mode : out std_logic_vector(1 downto 0);
175 ClkDiv : out std_logic;
176 PWDOWN : out std_logic_vector(3 downto 0);
177 SmplClk : in std_logic;
178 OUT0 : out std_logic_vector(23 downto 0);
179 OUT1 : out std_logic_vector(23 downto 0);
180 OUT2 : out std_logic_vector(23 downto 0);
181 OUT3 : out std_logic_vector(23 downto 0);
182 FSynch : out std_logic;
183 test : out std_logic
184 );
185 185 end COMPONENT;
186 186
187 187
@@ -1,7 +1,6
1 1 fifo_latency_correction.vhd
2 2 lpp_dma.vhd
3 3 lpp_dma_apbreg.vhd
4 lpp_dma_fsm.vhd
5 4 lpp_dma_ip.vhd
6 5 lpp_dma_pkg.vhd
7 6 lpp_dma_send_16word.vhd
General Comments 0
You need to be logged in to leave comments. Login now