@@ -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 | ------------------------------------------------------------------------------ |
|
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 | 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 | library grlib; |
|
25 | library grlib; | |
26 | use grlib.amba.all; |
|
26 | use grlib.amba.all; | |
27 | use grlib.stdlib.all; |
|
27 | use grlib.stdlib.all; | |
28 | use grlib.devices.all; |
|
28 | use grlib.devices.all; | |
29 | library lpp; |
|
29 | library lpp; | |
30 | use lpp.iir_filter.all; |
|
30 | use lpp.iir_filter.all; | |
31 | use lpp.general_purpose.all; |
|
31 | use lpp.general_purpose.all; | |
32 | use lpp.lpp_amba.all; |
|
32 | use lpp.lpp_amba.all; | |
33 | use lpp.apb_devices_list.all; |
|
33 | use lpp.apb_devices_list.all; | |
34 |
|
34 | |||
35 | entity APB_IIR_CEL is |
|
35 | entity APB_IIR_CEL is | |
36 | generic ( |
|
36 | generic ( | |
37 | tech : integer := 0; |
|
37 | tech : integer := 0; | |
38 | pindex : integer := 0; |
|
38 | pindex : integer := 0; | |
39 | paddr : integer := 0; |
|
39 | paddr : integer := 0; | |
40 | pmask : integer := 16#fff#; |
|
40 | pmask : integer := 16#fff#; | |
41 | pirq : integer := 0; |
|
41 | pirq : integer := 0; | |
42 | abits : integer := 8; |
|
42 | abits : integer := 8; | |
43 | Sample_SZ : integer := 16; |
|
43 | Sample_SZ : integer := 16; | |
44 | ChanelsCount : integer := 1; |
|
44 | ChanelsCount : integer := 1; | |
45 | Coef_SZ : integer := 9; |
|
45 | Coef_SZ : integer := 9; | |
46 | CoefCntPerCel: integer := 6; |
|
46 | CoefCntPerCel: integer := 6; | |
47 | Cels_count : integer := 5; |
|
47 | Cels_count : integer := 5; | |
48 | virgPos : integer := 3; |
|
48 | virgPos : integer := 3; | |
49 | Mem_use : integer := use_RAM |
|
49 | Mem_use : integer := use_RAM | |
50 | ); |
|
50 | ); | |
51 | port ( |
|
51 | port ( | |
52 | rst : in std_logic; |
|
52 | rst : in std_logic; | |
53 | clk : in std_logic; |
|
53 | clk : in std_logic; | |
54 | apbi : in apb_slv_in_type; |
|
54 | apbi : in apb_slv_in_type; | |
55 | apbo : out apb_slv_out_type; |
|
55 | apbo : out apb_slv_out_type; | |
56 | sample_clk : in std_logic; |
|
56 | sample_clk : in std_logic; | |
57 | sample_clk_out : out std_logic; |
|
57 | sample_clk_out : out std_logic; | |
58 | sample_in : in samplT(ChanelsCount-1 downto 0,Sample_SZ-1 downto 0); |
|
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); |
|
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') |
|
60 | CoefsInitVal : in std_logic_vector((Cels_count*CoefCntPerCel*Coef_SZ)-1 downto 0) := (others => '1') | |
61 | ); |
|
61 | ); | |
62 | end; |
|
62 | end; | |
63 |
|
63 | |||
64 |
|
64 | |||
65 | architecture AR_APB_IIR_CEL of APB_IIR_CEL is |
|
65 | architecture AR_APB_IIR_CEL of APB_IIR_CEL is | |
66 |
|
66 | |||
67 | constant REVISION : integer := 1; |
|
67 | constant REVISION : integer := 1; | |
68 |
|
68 | |||
69 | constant pconfig : apb_config_type := ( |
|
69 | constant pconfig : apb_config_type := ( | |
70 | 0 => ahb_device_reg (VENDOR_LPP, LPP_IIR_CEL_FILTER, 0, REVISION, 0), |
|
70 | 0 => ahb_device_reg (VENDOR_LPP, LPP_IIR_CEL_FILTER, 0, REVISION, 0), | |
71 | 1 => apb_iobar(paddr, pmask)); |
|
71 | 1 => apb_iobar(paddr, pmask)); | |
72 |
|
72 | |||
73 |
|
73 | |||
74 |
|
74 | |||
75 | type FILTERreg is record |
|
75 | type FILTERreg is record | |
76 | regin : in_IIR_CEL_reg; |
|
76 | regin : in_IIR_CEL_reg; | |
77 | regout : out_IIR_CEL_reg; |
|
77 | regout : out_IIR_CEL_reg; | |
78 | end record; |
|
78 | end record; | |
79 |
|
79 | |||
80 | signal Rdata : std_logic_vector(31 downto 0); |
|
80 | signal Rdata : std_logic_vector(31 downto 0); | |
81 | signal r : FILTERreg; |
|
81 | signal r : FILTERreg; | |
82 | signal filter_reset : std_logic:='0'; |
|
82 | signal filter_reset : std_logic:='0'; | |
83 | signal smp_cnt : integer :=0; |
|
83 | signal smp_cnt : integer :=0; | |
84 | signal sample_clk_out_R : std_logic; |
|
84 | signal sample_clk_out_R : std_logic; | |
85 | signal RawCoefs : std_logic_vector(((Coef_SZ*CoefCntPerCel*Cels_count)-1) downto 0); |
|
85 | signal RawCoefs : std_logic_vector(((Coef_SZ*CoefCntPerCel*Cels_count)-1) downto 0); | |
86 |
|
86 | |||
87 | type CoefCelT is array(0 to (CoefCntPerCel/2)-1) of std_logic_vector(Coef_SZ-1 downto 0); |
|
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; |
|
88 | type CoefTblT is array(0 to Cels_count-1) of CoefCelT; | |
89 |
|
89 | |||
90 | type CoefsRegT is record |
|
90 | type CoefsRegT is record | |
91 | numCoefs : CoefTblT; |
|
91 | numCoefs : CoefTblT; | |
92 | denCoefs : CoefTblT; |
|
92 | denCoefs : CoefTblT; | |
93 | end record; |
|
93 | end record; | |
94 |
|
94 | |||
95 | signal CoefsReg : CoefsRegT; |
|
95 | signal CoefsReg : CoefsRegT; | |
96 | signal CoefsReg_d : CoefsRegT; |
|
96 | signal CoefsReg_d : CoefsRegT; | |
97 |
|
97 | |||
98 |
|
98 | |||
99 | begin |
|
99 | begin | |
100 |
|
100 | |||
101 | filter_reset <= rst and r.regin.config(0); |
|
101 | filter_reset <= rst and r.regin.config(0); | |
102 | sample_clk_out <= sample_clk_out_R; |
|
102 | sample_clk_out <= sample_clk_out_R; | |
103 | -- |
|
103 | -- | |
104 | filter : IIR_CEL_FILTER |
|
104 | filter : IIR_CEL_FILTER | |
105 | generic map(tech,Sample_SZ,ChanelsCount,Coef_SZ,CoefCntPerCel,Cels_count,Mem_use) |
|
105 | generic map(tech,Sample_SZ,ChanelsCount,Coef_SZ,CoefCntPerCel,Cels_count,Mem_use) | |
106 | port map( |
|
106 | port map( | |
107 | reset => filter_reset, |
|
107 | reset => filter_reset, | |
108 | clk => clk, |
|
108 | clk => clk, | |
109 | sample_clk => sample_clk, |
|
109 | sample_clk => sample_clk, | |
110 | regs_in => r.regin, |
|
110 | regs_in => r.regin, | |
111 | regs_out => r.regout, |
|
111 | regs_out => r.regout, | |
112 | sample_in => sample_in, |
|
112 | sample_in => sample_in, | |
113 | sample_out => sample_out, |
|
113 | sample_out => sample_out, | |
114 | coefs => RawCoefs |
|
114 | coefs => RawCoefs | |
115 | ); |
|
115 | ); | |
116 |
|
116 | |||
117 | process(rst,sample_clk) |
|
117 | process(rst,sample_clk) | |
118 | begin |
|
118 | begin | |
119 | if rst = '0' then |
|
119 | if rst = '0' then | |
120 | smp_cnt <= 0; |
|
120 | smp_cnt <= 0; | |
121 | sample_clk_out_R <= '0'; |
|
121 | sample_clk_out_R <= '0'; | |
122 | elsif sample_clk'event and sample_clk = '1' then |
|
122 | elsif sample_clk'event and sample_clk = '1' then | |
123 | if smp_cnt = 1 then |
|
123 | if smp_cnt = 1 then | |
124 | smp_cnt <= 0; |
|
124 | smp_cnt <= 0; | |
125 | sample_clk_out_R <= not sample_clk_out_R; |
|
125 | sample_clk_out_R <= not sample_clk_out_R; | |
126 | else |
|
126 | else | |
127 | smp_cnt <= smp_cnt +1; |
|
127 | smp_cnt <= smp_cnt +1; | |
128 | end if; |
|
128 | end if; | |
129 | end if; |
|
129 | end if; | |
130 | end process; |
|
130 | end process; | |
131 |
|
131 | |||
132 |
|
132 | |||
133 | coefsConnectL0: for z in 0 to Cels_count-1 generate |
|
133 | coefsConnectL0: for z in 0 to Cels_count-1 generate | |
134 | coefsConnectL1: for y in 0 to (CoefCntPerCel/2)-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); |
|
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); |
|
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; |
|
137 | end generate; | |
138 | end generate; |
|
138 | end generate; | |
139 |
|
139 | |||
140 |
|
140 | |||
141 | process(rst,clk) |
|
141 | process(rst,clk) | |
142 | begin |
|
142 | begin | |
143 | if rst = '0' then |
|
143 | if rst = '0' then | |
144 | r.regin.virgPos <= std_logic_vector(to_unsigned(virgPos,5)); |
|
144 | r.regin.virgPos <= std_logic_vector(to_unsigned(virgPos,5)); | |
145 | coefsRstL0: for z in 0 to Cels_count-1 loop |
|
145 | coefsRstL0: for z in 0 to Cels_count-1 loop | |
146 | coefsRstL1: for y in 0 to (CoefCntPerCel/2)-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) ); |
|
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)); |
|
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; |
|
149 | end loop; | |
150 | end loop; |
|
150 | end loop; | |
151 | elsif clk'event and clk = '1' then |
|
151 | elsif clk'event and clk = '1' then | |
152 | CoefsReg_d <= CoefsReg; |
|
152 | CoefsReg_d <= CoefsReg; | |
153 |
|
153 | |||
154 | --APB Write OP |
|
154 | --APB Write OP | |
155 | if (apbi.psel(pindex) and apbi.penable and apbi.pwrite) = '1' then |
|
155 | if (apbi.psel(pindex) and apbi.penable and apbi.pwrite) = '1' then | |
156 | if apbi.paddr(7 downto 2) = "000000" then |
|
156 | if apbi.paddr(7 downto 2) = "000000" then | |
157 | r.regin.config(0) <= apbi.pwdata(0); |
|
157 | r.regin.config(0) <= apbi.pwdata(0); | |
158 | elsif apbi.paddr(7 downto 2) = "000001" then |
|
158 | elsif apbi.paddr(7 downto 2) = "000001" then | |
159 | r.regin.virgPos <= apbi.pwdata(4 downto 0); |
|
159 | r.regin.virgPos <= apbi.pwdata(4 downto 0); | |
160 | else |
|
160 | else | |
161 | for i in 0 to Cels_count-1 loop |
|
161 | for i in 0 to Cels_count-1 loop | |
162 | for j in 0 to (CoefCntPerCel/2) - 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 |
|
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); |
|
164 | CoefsReg.numCoefs(i)(j) <= apbi.pwdata(Coef_SZ-1 downto 0); | |
165 | CoefsReg.denCoefs(i)(j) <= apbi.pwdata((Coef_SZ+15) downto 16); |
|
165 | CoefsReg.denCoefs(i)(j) <= apbi.pwdata((Coef_SZ+15) downto 16); | |
166 | end if; |
|
166 | end if; | |
167 | end loop; |
|
167 | end loop; | |
168 | end loop; |
|
168 | end loop; | |
169 | end if; |
|
169 | end if; | |
170 | end if; |
|
170 | end if; | |
171 |
|
171 | |||
172 | --APB READ OP |
|
172 | --APB READ OP | |
173 | if (apbi.psel(pindex) and (not apbi.pwrite)) = '1' then |
|
173 | if (apbi.psel(pindex) and (not apbi.pwrite)) = '1' then | |
174 | if apbi.paddr(7 downto 2) = "000000" then |
|
174 | if apbi.paddr(7 downto 2) = "000000" then | |
175 | Rdata(7 downto 0) <= std_logic_vector(TO_UNSIGNED(ChanelsCount,8)); |
|
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)); |
|
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)); |
|
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)); |
|
178 | Rdata(31 downto 24) <= std_logic_vector(TO_UNSIGNED(Cels_count,8)); | |
179 | elsif apbi.paddr(7 downto 2) = "000001" then |
|
179 | elsif apbi.paddr(7 downto 2) = "000001" then | |
180 | Rdata(4 downto 0) <= r.regin.virgPos; |
|
180 | Rdata(4 downto 0) <= r.regin.virgPos; | |
181 | Rdata(15 downto 8) <= std_logic_vector(TO_UNSIGNED(Coef_SZ,8)); |
|
181 | Rdata(15 downto 8) <= std_logic_vector(TO_UNSIGNED(Coef_SZ,8)); | |
182 | Rdata(7 downto 5) <= (others => '0'); |
|
182 | Rdata(7 downto 5) <= (others => '0'); | |
183 | Rdata(31 downto 16) <= (others => '0'); |
|
183 | Rdata(31 downto 16) <= (others => '0'); | |
184 | else |
|
184 | else | |
185 | for i in 0 to Cels_count-1 loop |
|
185 | for i in 0 to Cels_count-1 loop | |
186 | for j in 0 to (CoefCntPerCel/2) - 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 |
|
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); |
|
188 | Rdata(Coef_SZ-1 downto 0) <= CoefsReg_d.numCoefs(i)(j); | |
189 | Rdata((Coef_SZ+15) downto 16) <= CoefsReg_d.denCoefs(i)(j); |
|
189 | Rdata((Coef_SZ+15) downto 16) <= CoefsReg_d.denCoefs(i)(j); | |
190 | end if; |
|
190 | end if; | |
191 | end loop; |
|
191 | end loop; | |
192 | end loop; |
|
192 | end loop; | |
193 | end if; |
|
193 | end if; | |
194 | end if; |
|
194 | end if; | |
195 | end if; |
|
195 | end if; | |
196 | apbo.pconfig <= pconfig; |
|
196 | apbo.pconfig <= pconfig; | |
197 | end process; |
|
197 | end process; | |
198 |
|
198 | |||
199 | apbo.prdata <= Rdata when apbi.penable = '1' ; |
|
199 | apbo.prdata <= Rdata when apbi.penable = '1' ; | |
200 |
|
200 | |||
201 | -- pragma translate_off |
|
201 | -- pragma translate_off | |
202 | bootmsg : report_version |
|
202 | bootmsg : report_version | |
203 | generic map ("apb IIR filter" & tost(pindex) & |
|
203 | generic map ("apb IIR filter" & tost(pindex) & | |
204 |
": IIR filter rev " & tost(REVISION) |
|
204 | ": IIR filter rev " & tost(REVISION)& | |
205 |
|
|
205 | --", fifo " & tost(fifosize) & | |
206 | -- pragma translate_on |
|
206 | ", irq " & tost(pirq)); | |
207 |
|
207 | -- pragma translate_on | ||
208 |
|
208 | |||
209 |
|
209 | |||
210 |
|
210 | |||
211 | end ar_APB_IIR_CEL; |
|
211 | ||
212 |
|
212 | end ar_APB_IIR_CEL; | ||
|
213 |
@@ -63,7 +63,7 begin | |||||
63 | --============================================================== |
|
63 | --============================================================== | |
64 | --=========================A L U================================ |
|
64 | --=========================A L U================================ | |
65 | --============================================================== |
|
65 | --============================================================== | |
66 |
ALU1 : |
|
66 | ALU1 : ALU | |
67 | generic map( |
|
67 | generic map( | |
68 | Arith_en => 1, |
|
68 | Arith_en => 1, | |
69 | Logic_en => 0, |
|
69 | Logic_en => 0, |
@@ -18,97 +18,180 | |||||
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 | library IEEE; |
|
22 | -- MODIFIED by Jean-christophe PELLION | |
23 | use IEEE.STD_LOGIC_1164.ALL; |
|
23 | -- jean-christophe.pellion@lpp.polytechnique.fr | |
24 | library lpp; |
|
24 | ------------------------------------------------------------------------------- | |
25 | use lpp.lpp_ad_conv.all; |
|
25 | LIBRARY IEEE; | |
26 | use lpp.general_purpose.Clk_divider; |
|
26 | USE IEEE.STD_LOGIC_1164.ALL; | |
27 |
|
27 | LIBRARY lpp; | ||
28 | --! \brief AD7688 driver, generates all needed signal to drive this ADC. |
|
28 | USE lpp.lpp_ad_conv.ALL; | |
29 | --! |
|
29 | USE lpp.general_purpose.SYNC_FF; | |
30 | --! \author Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr |
|
|||
31 |
|
30 | |||
32 |
|
|
31 | ENTITY AD7688_drvr IS | |
33 | generic( |
|
32 | GENERIC( | |
34 | ChanelCount :integer; --! Number of ADC you whant to drive |
|
33 | ChanelCount : INTEGER; | |
35 | clkkHz :integer --! System clock frequency in kHz usefull to generate some pulses with good width. |
|
34 | ncycle_cnv_high : INTEGER := 79; | |
36 | ); |
|
35 | ncycle_cnv : INTEGER := 500); | |
37 | Port( |
|
36 | PORT ( | |
38 | clk : in STD_LOGIC; --! System clock |
|
37 | -- CONV -- | |
39 | rstn : in STD_LOGIC; --! System reset |
|
38 | cnv_clk : IN STD_LOGIC; | |
40 | enable : in std_logic; --! Negative enable |
|
39 | cnv_rstn : IN STD_LOGIC; | |
41 | smplClk : in STD_LOGIC; --! Sampling clock |
|
40 | cnv_run : IN STD_LOGIC; | |
42 | DataReady : out std_logic; --! New sample available |
|
41 | cnv : OUT STD_LOGIC; | |
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; |
|
|||
59 |
|
42 | |||
60 | begin |
|
43 | -- DATA -- | |
61 |
|
44 | clk : IN STD_LOGIC; | ||
62 | clkdiv: if clkkHz>=66000 generate |
|
45 | rstn : IN STD_LOGIC; | |
63 | clkdivider: entity work.Clk_divider |
|
46 | sck : OUT STD_LOGIC; | |
64 | generic map(clkkHz*1000,60000000) |
|
47 | sdo : IN STD_LOGIC_VECTOR(ChanelCount-1 DOWNTO 0); | |
65 | Port map( clk ,reset,clk_int); |
|
|||
66 | end generate; |
|
|||
67 |
|
48 | |||
68 | clknodiv: if clkkHz<66000 generate |
|
49 | sample : OUT Samples(ChanelCount-1 DOWNTO 0); | |
69 | nodiv: clk_int <= clk; |
|
50 | sample_val : OUT STD_LOGIC | |
70 | end generate; |
|
51 | ); | |
71 |
|
52 | END AD7688_drvr; | ||
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; |
|
|||
77 |
|
53 | |||
78 | sckgen: process(clk,reset) |
|
54 | ARCHITECTURE ar_AD7688_drvr OF AD7688_drvr IS | |
79 | begin |
|
55 | ||
80 | if reset = '0' then |
|
56 | COMPONENT SYNC_FF | |
81 | i <= 0; |
|
57 | GENERIC ( | |
82 | cnv_int <= '0'; |
|
58 | NB_FF_OF_SYNC : INTEGER); | |
83 | smplClk_reg <= '0'; |
|
59 | PORT ( | |
84 | elsif clk'event and clk = '1' then |
|
60 | clk : IN STD_LOGIC; | |
85 | if smplClk = '1' and smplClk_reg = '0' then |
|
61 | rstn : IN STD_LOGIC; | |
86 | if i = convTrigger then |
|
62 | A : IN STD_LOGIC; | |
87 | smplClk_reg <= '1'; |
|
63 | A_sync : OUT STD_LOGIC); | |
88 | i <= 0; |
|
64 | END COMPONENT; | |
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; |
|
|||
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 |
|
75 | SIGNAL cnv_run_sync : STD_LOGIC; | |
103 | generic map(ChanelCount) |
|
76 | ||
104 | Port map(clk_int_inv,reset,cnv_int,DataReady,AD_in,smpout); |
|
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 | TYPE Samples IS ARRAY(NATURAL RANGE <>) OF STD_LOGIC_VECTOR(15 DOWNTO 0); |
|
51 | TYPE Samples IS ARRAY(NATURAL RANGE <>) OF STD_LOGIC_VECTOR(15 DOWNTO 0); | |
52 |
|
52 | |||
53 |
COMPONENT AD |
|
53 | COMPONENT AD7688_drvr | |
54 | GENERIC ( |
|
54 | GENERIC ( | |
55 | ChanelCount : INTEGER; |
|
55 | ChanelCount : INTEGER; | |
56 | ncycle_cnv_high : INTEGER := 79; |
|
56 | ncycle_cnv_high : INTEGER := 79; | |
@@ -162,26 +162,26 Type ADS127X_config is | |||||
162 | MODE : ADS127X_MODE_Type; |
|
162 | MODE : ADS127X_MODE_Type; | |
163 | end record; |
|
163 | end record; | |
164 |
|
164 | |||
165 | COMPONENT ADS1274_DRIVER is |
|
165 | COMPONENT ADS1274_DRIVER is | |
166 | generic(modeCfg : ADS127X_MODE_Type := ADS127X_MODE_low_power; formatCfg : ADS127X_FORMAT_Type := ADS127X_FSYNC_FORMAT); |
|
166 | generic(modeCfg : ADS127X_MODE_Type := ADS127X_MODE_low_power; formatCfg : ADS127X_FORMAT_Type := ADS127X_FSYNC_FORMAT); | |
167 | port( |
|
167 | port( | |
168 | Clk : in std_logic; |
|
168 | Clk : in std_logic; | |
169 | reset : in std_logic; |
|
169 | reset : in std_logic; | |
170 | SpiClk : out std_logic; |
|
170 | SpiClk : out std_logic; | |
171 | DIN : in std_logic_vector(3 downto 0); |
|
171 | DIN : in std_logic_vector(3 downto 0); | |
172 | Ready : in std_logic; |
|
172 | Ready : in std_logic; | |
173 | Format : out std_logic_vector(2 downto 0); |
|
173 | Format : out std_logic_vector(2 downto 0); | |
174 | Mode : out std_logic_vector(1 downto 0); |
|
174 | Mode : out std_logic_vector(1 downto 0); | |
175 | ClkDiv : out std_logic; |
|
175 | ClkDiv : out std_logic; | |
176 | PWDOWN : out std_logic_vector(3 downto 0); |
|
176 | PWDOWN : out std_logic_vector(3 downto 0); | |
177 | SmplClk : in std_logic; |
|
177 | SmplClk : in std_logic; | |
178 | OUT0 : out std_logic_vector(23 downto 0); |
|
178 | OUT0 : out std_logic_vector(23 downto 0); | |
179 | OUT1 : 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); |
|
180 | OUT2 : out std_logic_vector(23 downto 0); | |
181 | OUT3 : out std_logic_vector(23 downto 0); |
|
181 | OUT3 : out std_logic_vector(23 downto 0); | |
182 | FSynch : out std_logic; |
|
182 | FSynch : out std_logic; | |
183 | test : out std_logic |
|
183 | test : out std_logic | |
184 | ); |
|
184 | ); | |
185 | end COMPONENT; |
|
185 | end COMPONENT; | |
186 |
|
186 | |||
187 |
|
187 |
General Comments 0
You need to be logged in to leave comments.
Login now