##// END OF EJS Templates
Fixed some files
Alexis -
r37:81e639333c9d default
parent child
Show More
@@ -1,163 +1,164
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 library IEEE;
19 library IEEE;
20 use IEEE.STD_LOGIC_1164.ALL;
20 use IEEE.STD_LOGIC_1164.ALL;
21 use ieee.numeric_std.all;
21 use ieee.numeric_std.all;
22 library grlib;
22 library grlib;
23 use grlib.amba.all;
23 use grlib.amba.all;
24 use grlib.stdlib.all;
24 use grlib.stdlib.all;
25 use grlib.devices.all;
25 use grlib.devices.all;
26 library lpp;
26 library lpp;
27 use lpp.amba_lcd_16x2_ctrlr.all;
27 use lpp.amba_lcd_16x2_ctrlr.all;
28 use lpp.LCD_16x2_CFG.all;
28 use lpp.LCD_16x2_CFG.all;
29 use lpp.lpp_amba.all;
29 use lpp.lpp_amba.all;
30 use lpp.apb_devices_list.all;
30
31
31 entity apb_lcd_ctrlr is
32 entity apb_lcd_ctrlr is
32 generic (
33 generic (
33 pindex : integer := 0;
34 pindex : integer := 0;
34 paddr : integer := 0;
35 paddr : integer := 0;
35 pmask : integer := 16#fff#;
36 pmask : integer := 16#fff#;
36 pirq : integer := 0;
37 pirq : integer := 0;
37 abits : integer := 8);
38 abits : integer := 8);
38 port (
39 port (
39 rst : in std_ulogic;
40 rst : in std_ulogic;
40 clk : in std_ulogic;
41 clk : in std_ulogic;
41 apbi : in apb_slv_in_type;
42 apbi : in apb_slv_in_type;
42 apbo : out apb_slv_out_type;
43 apbo : out apb_slv_out_type;
43 LCD_data : out STD_LOGIC_VECTOR (7 downto 0);
44 LCD_data : out STD_LOGIC_VECTOR (7 downto 0);
44 LCD_RS : out STD_LOGIC;
45 LCD_RS : out STD_LOGIC;
45 LCD_RW : out STD_LOGIC;
46 LCD_RW : out STD_LOGIC;
46 LCD_E : out STD_LOGIC;
47 LCD_E : out STD_LOGIC;
47 LCD_RET : out STD_LOGIC;
48 LCD_RET : out STD_LOGIC;
48 LCD_CS1 : out STD_LOGIC;
49 LCD_CS1 : out STD_LOGIC;
49 LCD_CS2 : out STD_LOGIC;
50 LCD_CS2 : out STD_LOGIC;
50 SF_CE0 : out std_logic
51 SF_CE0 : out std_logic
51 );
52 );
52 end apb_lcd_ctrlr;
53 end apb_lcd_ctrlr;
53
54
54 architecture Behavioral of apb_lcd_ctrlr is
55 architecture Behavioral of apb_lcd_ctrlr is
55
56
56 signal FramBUFF : FRM_Buff_Space;
57 signal FramBUFF : FRM_Buff_Space;
57 signal CMD : std_logic_vector(10 downto 0);
58 signal CMD : std_logic_vector(10 downto 0);
58 signal Exec : std_logic;
59 signal Exec : std_logic;
59 signal Ready : std_logic;
60 signal Ready : std_logic;
60 signal LCD_CTRL : LCD_DRVR_CTRL_BUSS;
61 signal LCD_CTRL : LCD_DRVR_CTRL_BUSS;
61
62
62
63
63
64
64 constant REVISION : integer := 1;
65 constant REVISION : integer := 1;
65
66
66 constant pconfig : apb_config_type := (
67 constant pconfig : apb_config_type := (
67 0 => ahb_device_reg (VENDOR_LPP, LPP_LCD_CTRLR, 0, REVISION, 0),
68 0 => ahb_device_reg (VENDOR_LPP, LPP_LCD_CTRLR, 0, REVISION, 0),
68 1 => apb_iobar(paddr, pmask));
69 1 => apb_iobar(paddr, pmask));
69
70
70
71
71 --type FRM_Buff_El is std_logic_vector(31 downto 0);
72 --type FRM_Buff_El is std_logic_vector(31 downto 0);
72 type FRM_Buff_Reg is array(lcd_space_size-1 downto 0) of std_logic_vector(31 downto 0);
73 type FRM_Buff_Reg is array(lcd_space_size-1 downto 0) of std_logic_vector(31 downto 0);
73
74
74
75
75 type LCD_ctrlr_Reg is record
76 type LCD_ctrlr_Reg is record
76 CTRL_Reg : std_logic_vector(31 downto 0);
77 CTRL_Reg : std_logic_vector(31 downto 0);
77 FRAME_BUFF : FRM_Buff_Reg;
78 FRAME_BUFF : FRM_Buff_Reg;
78 end record;
79 end record;
79
80
80 signal r : LCD_ctrlr_Reg;
81 signal r : LCD_ctrlr_Reg;
81
82
82 signal Rdata : std_logic_vector(31 downto 0);
83 signal Rdata : std_logic_vector(31 downto 0);
83
84
84 begin
85 begin
85
86
86 LCD_data <= LCD_CTRL.LCD_DATA;
87 LCD_data <= LCD_CTRL.LCD_DATA;
87 LCD_RS <= LCD_CTRL.LCD_RS;
88 LCD_RS <= LCD_CTRL.LCD_RS;
88 LCD_RW <= LCD_CTRL.LCD_RW;
89 LCD_RW <= LCD_CTRL.LCD_RW;
89 LCD_E <= LCD_CTRL.LCD_E;
90 LCD_E <= LCD_CTRL.LCD_E;
90
91
91
92
92 LCD_RET <= '0';
93 LCD_RET <= '0';
93 LCD_CS1 <= '0';
94 LCD_CS1 <= '0';
94 LCD_CS2 <= '0';
95 LCD_CS2 <= '0';
95
96
96 SF_CE0 <= '1';
97 SF_CE0 <= '1';
97
98
98 CMD(7 downto 0) <= r.CTRL_Reg(7 downto 0); --CMD value
99 CMD(7 downto 0) <= r.CTRL_Reg(7 downto 0); --CMD value
99 CMD(9 downto 8) <= r.CTRL_Reg(9 downto 8); --CMD tempo value
100 CMD(9 downto 8) <= r.CTRL_Reg(9 downto 8); --CMD tempo value
100
101
101 r.CTRL_Reg(10) <= Ready;
102 r.CTRL_Reg(10) <= Ready;
102
103
103 Driver0 : LCD_16x2_ENGINE
104 Driver0 : LCD_16x2_ENGINE
104 generic map(50000)
105 generic map(50000)
105 Port map(clk,rst,FramBUFF,CMD,Exec,Ready,LCD_CTRL);
106 Port map(clk,rst,FramBUFF,CMD,Exec,Ready,LCD_CTRL);
106
107
107 FRM_BF : for i in 0 to lcd_space_size-1 generate
108 FRM_BF : for i in 0 to lcd_space_size-1 generate
108 FramBUFF(i) <= r.FRAME_BUFF(i)(7 downto 0);
109 FramBUFF(i) <= r.FRAME_BUFF(i)(7 downto 0);
109 end generate;
110 end generate;
110
111
111
112
112 process(rst,clk)
113 process(rst,clk)
113 begin
114 begin
114 if rst = '0' then
115 if rst = '0' then
115 r.CTRL_Reg(9 downto 0) <= (others => '0');
116 r.CTRL_Reg(9 downto 0) <= (others => '0');
116 Exec <= '0';
117 Exec <= '0';
117 elsif clk'event and clk = '1' then
118 elsif clk'event and clk = '1' then
118
119
119 --APB Write OP
120 --APB Write OP
120 if (apbi.psel(pindex) and apbi.penable and apbi.pwrite) = '1' then
121 if (apbi.psel(pindex) and apbi.penable and apbi.pwrite) = '1' then
121 case apbi.paddr(7 downto 2) is
122 case apbi.paddr(7 downto 2) is
122 when "000000" =>
123 when "000000" =>
123 r.CTRL_Reg(9 downto 0) <= apbi.pwdata(9 downto 0);
124 r.CTRL_Reg(9 downto 0) <= apbi.pwdata(9 downto 0);
124 Exec <= '1';
125 Exec <= '1';
125 when others =>
126 when others =>
126 writeC: for i in 1 to lcd_space_size loop
127 writeC: for i in 1 to lcd_space_size loop
127 if TO_INTEGER(unsigned(apbi.paddr(abits-1 downto 2))) =i then
128 if TO_INTEGER(unsigned(apbi.paddr(abits-1 downto 2))) =i then
128 r.FRAME_BUFF(i-1) <= apbi.pwdata;
129 r.FRAME_BUFF(i-1) <= apbi.pwdata;
129 end if;
130 end if;
130 Exec <= '0';
131 Exec <= '0';
131 end loop;
132 end loop;
132 end case;
133 end case;
133 else
134 else
134 Exec <= '0';
135 Exec <= '0';
135 end if;
136 end if;
136
137
137 --APB READ OP
138 --APB READ OP
138 if (apbi.psel(pindex) and (not apbi.pwrite)) = '1' then
139 if (apbi.psel(pindex) and (not apbi.pwrite)) = '1' then
139 case apbi.paddr(7 downto 2) is
140 case apbi.paddr(7 downto 2) is
140 when "000000" =>
141 when "000000" =>
141 Rdata <= r.CTRL_Reg;
142 Rdata <= r.CTRL_Reg;
142 when others =>
143 when others =>
143 readC: for i in 1 to lcd_space_size loop
144 readC: for i in 1 to lcd_space_size loop
144 if TO_INTEGER(unsigned(apbi.paddr(abits-1 downto 2))) =i then
145 if TO_INTEGER(unsigned(apbi.paddr(abits-1 downto 2))) =i then
145 Rdata(7 downto 0) <= r.FRAME_BUFF(i-1)(7 downto 0);
146 Rdata(7 downto 0) <= r.FRAME_BUFF(i-1)(7 downto 0);
146 end if;
147 end if;
147 end loop;
148 end loop;
148 end case;
149 end case;
149 end if;
150 end if;
150
151
151 end if;
152 end if;
152 apbo.pconfig <= pconfig;
153 apbo.pconfig <= pconfig;
153 end process;
154 end process;
154
155
155 apbo.prdata <= Rdata when apbi.penable = '1' ;
156 apbo.prdata <= Rdata when apbi.penable = '1' ;
156
157
157 end Behavioral;
158 end Behavioral;
158
159
159
160
160
161
161
162
162
163
163
164
@@ -1,208 +1,209
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 library ieee;
19 library ieee;
20 use ieee.std_logic_1164.all;
20 use ieee.std_logic_1164.all;
21 use ieee.numeric_std.all;
21 use ieee.numeric_std.all;
22 library grlib;
22 library grlib;
23 use grlib.amba.all;
23 use grlib.amba.all;
24 use grlib.stdlib.all;
24 use grlib.stdlib.all;
25 use grlib.devices.all;
25 use grlib.devices.all;
26 library lpp;
26 library lpp;
27 use lpp.iir_filter.all;
27 use lpp.iir_filter.all;
28 use lpp.general_purpose.all;
28 use lpp.general_purpose.all;
29 use lpp.lpp_amba.all;
29 use lpp.lpp_amba.all;
30 use lpp.apb_devices_list.all;
30
31
31 entity APB_IIR_CEL is
32 entity APB_IIR_CEL is
32 generic (
33 generic (
33 pindex : integer := 0;
34 pindex : integer := 0;
34 paddr : integer := 0;
35 paddr : integer := 0;
35 pmask : integer := 16#fff#;
36 pmask : integer := 16#fff#;
36 pirq : integer := 0;
37 pirq : integer := 0;
37 abits : integer := 8;
38 abits : integer := 8;
38 Sample_SZ : integer := 16;
39 Sample_SZ : integer := 16;
39 ChanelsCount : integer := 1;
40 ChanelsCount : integer := 1;
40 Coef_SZ : integer := 9;
41 Coef_SZ : integer := 9;
41 CoefCntPerCel: integer := 3;
42 CoefCntPerCel: integer := 3;
42 Cels_count : integer := 5;
43 Cels_count : integer := 5;
43 virgPos : integer := 3;
44 virgPos : integer := 3;
44 Mem_use : integer := use_RAM
45 Mem_use : integer := use_RAM
45 );
46 );
46 port (
47 port (
47 rst : in std_logic;
48 rst : in std_logic;
48 clk : in std_logic;
49 clk : in std_logic;
49 apbi : in apb_slv_in_type;
50 apbi : in apb_slv_in_type;
50 apbo : out apb_slv_out_type;
51 apbo : out apb_slv_out_type;
51 sample_clk : in std_logic;
52 sample_clk : in std_logic;
52 sample_clk_out : out std_logic;
53 sample_clk_out : out std_logic;
53 sample_in : in samplT(ChanelsCount-1 downto 0,Sample_SZ-1 downto 0);
54 sample_in : in samplT(ChanelsCount-1 downto 0,Sample_SZ-1 downto 0);
54 sample_out : out samplT(ChanelsCount-1 downto 0,Sample_SZ-1 downto 0)
55 sample_out : out samplT(ChanelsCount-1 downto 0,Sample_SZ-1 downto 0)
55 );
56 );
56 end;
57 end;
57
58
58
59
59 architecture AR_APB_IIR_CEL of APB_IIR_CEL is
60 architecture AR_APB_IIR_CEL of APB_IIR_CEL is
60
61
61 constant REVISION : integer := 1;
62 constant REVISION : integer := 1;
62
63
63 constant pconfig : apb_config_type := (
64 constant pconfig : apb_config_type := (
64 0 => ahb_device_reg (VENDOR_LPP, LPP_IIR_CEL_FILTER, 0, REVISION, 0),
65 0 => ahb_device_reg (VENDOR_LPP, LPP_IIR_CEL_FILTER, 0, REVISION, 0),
65 1 => apb_iobar(paddr, pmask));
66 1 => apb_iobar(paddr, pmask));
66
67
67
68
68
69
69 type FILTERreg is record
70 type FILTERreg is record
70 regin : in_IIR_CEL_reg;
71 regin : in_IIR_CEL_reg;
71 regout : out_IIR_CEL_reg;
72 regout : out_IIR_CEL_reg;
72 end record;
73 end record;
73
74
74 signal Rdata : std_logic_vector(31 downto 0);
75 signal Rdata : std_logic_vector(31 downto 0);
75 signal r : FILTERreg;
76 signal r : FILTERreg;
76 signal filter_reset : std_logic:='0';
77 signal filter_reset : std_logic:='0';
77 signal smp_cnt : integer :=0;
78 signal smp_cnt : integer :=0;
78 signal sample_clk_out_R : std_logic;
79 signal sample_clk_out_R : std_logic;
79
80
80
81
81 type CoefCelT is array(CoefCntPerCel-1 downto 0) of std_logic_vector(Coef_SZ-1 downto 0);
82 type CoefCelT is array(CoefCntPerCel-1 downto 0) of std_logic_vector(Coef_SZ-1 downto 0);
82 type CoefTblT is array(Cels_count-1 downto 0) of CoefCelT;
83 type CoefTblT is array(Cels_count-1 downto 0) of CoefCelT;
83
84
84 type CoefsRegT is record
85 type CoefsRegT is record
85 numCoefs : CoefTblT;
86 numCoefs : CoefTblT;
86 denCoefs : CoefTblT;
87 denCoefs : CoefTblT;
87 end record;
88 end record;
88
89
89 signal CoefsReg : CoefsRegT;
90 signal CoefsReg : CoefsRegT;
90
91
91 begin
92 begin
92
93
93 filter_reset <= rst and r.regin.config(0);
94 filter_reset <= rst and r.regin.config(0);
94 sample_clk_out <= sample_clk_out_R;
95 sample_clk_out <= sample_clk_out_R;
95
96
96 filter : IIR_CEL_FILTER
97 filter : IIR_CEL_FILTER
97 generic map(Sample_SZ,ChanelsCount,Coef_SZ,CoefCntPerCel,Cels_count,Mem_use)
98 generic map(Sample_SZ,ChanelsCount,Coef_SZ,CoefCntPerCel,Cels_count,Mem_use)
98 port map(
99 port map(
99 reset => filter_reset,
100 reset => filter_reset,
100 clk => clk,
101 clk => clk,
101 sample_clk => sample_clk,
102 sample_clk => sample_clk,
102 regs_in => r.regin,
103 regs_in => r.regin,
103 regs_out => r.regout,
104 regs_out => r.regout,
104 sample_in => sample_in,
105 sample_in => sample_in,
105 sample_out => sample_out
106 sample_out => sample_out
106 );
107 );
107
108
108 process(rst,sample_clk)
109 process(rst,sample_clk)
109 begin
110 begin
110 if rst = '0' then
111 if rst = '0' then
111 smp_cnt <= 0;
112 smp_cnt <= 0;
112 sample_clk_out_R <= '0';
113 sample_clk_out_R <= '0';
113 elsif sample_clk'event and sample_clk = '1' then
114 elsif sample_clk'event and sample_clk = '1' then
114 if smp_cnt = 1 then
115 if smp_cnt = 1 then
115 smp_cnt <= 0;
116 smp_cnt <= 0;
116 sample_clk_out_R <= not sample_clk_out_R;
117 sample_clk_out_R <= not sample_clk_out_R;
117 else
118 else
118 smp_cnt <= smp_cnt +1;
119 smp_cnt <= smp_cnt +1;
119 end if;
120 end if;
120 end if;
121 end if;
121 end process;
122 end process;
122
123
123
124
124 process(rst,clk)
125 process(rst,clk)
125 begin
126 begin
126 if rst = '0' then
127 if rst = '0' then
127 r.regin.virgPos <= std_logic_vector(to_unsigned(virgPos,5));
128 r.regin.virgPos <= std_logic_vector(to_unsigned(virgPos,5));
128
129
129 elsif clk'event and clk = '1' then
130 elsif clk'event and clk = '1' then
130
131
131
132
132 --APB Write OP
133 --APB Write OP
133 if (apbi.psel(pindex) and apbi.penable and apbi.pwrite) = '1' then
134 if (apbi.psel(pindex) and apbi.penable and apbi.pwrite) = '1' then
134 case apbi.paddr(7 downto 2) is
135 case apbi.paddr(7 downto 2) is
135 when "000000" =>
136 when "000000" =>
136 r.regin.config(0) <= apbi.pwdata(0);
137 r.regin.config(0) <= apbi.pwdata(0);
137 when "000001" =>
138 when "000001" =>
138 r.regin.virgPos <= apbi.pwdata(4 downto 0);
139 r.regin.virgPos <= apbi.pwdata(4 downto 0);
139 when others =>
140 when others =>
140 for i in 0 to Cels_count-1 loop
141 for i in 0 to Cels_count-1 loop
141 if conv_integer(apbi.paddr(7 downto 5)) = i+1 then
142 if conv_integer(apbi.paddr(7 downto 5)) = i+1 then
142 case apbi.paddr(4 downto 2) is
143 case apbi.paddr(4 downto 2) is
143 when "000" =>
144 when "000" =>
144 CoefsReg.numCoefs(i)(0) <= (apbi.pwdata(Coef_SZ-1 downto 0));
145 CoefsReg.numCoefs(i)(0) <= (apbi.pwdata(Coef_SZ-1 downto 0));
145 when "001" =>
146 when "001" =>
146 CoefsReg.numCoefs(i)(1) <= (apbi.pwdata(Coef_SZ-1 downto 0));
147 CoefsReg.numCoefs(i)(1) <= (apbi.pwdata(Coef_SZ-1 downto 0));
147 when "010" =>
148 when "010" =>
148 CoefsReg.numCoefs(i)(2) <= (apbi.pwdata(Coef_SZ-1 downto 0));
149 CoefsReg.numCoefs(i)(2) <= (apbi.pwdata(Coef_SZ-1 downto 0));
149 when "011" =>
150 when "011" =>
150 CoefsReg.denCoefs(i)(0) <= (apbi.pwdata(Coef_SZ-1 downto 0));
151 CoefsReg.denCoefs(i)(0) <= (apbi.pwdata(Coef_SZ-1 downto 0));
151 when "100" =>
152 when "100" =>
152 CoefsReg.denCoefs(i)(1) <= (apbi.pwdata(Coef_SZ-1 downto 0));
153 CoefsReg.denCoefs(i)(1) <= (apbi.pwdata(Coef_SZ-1 downto 0));
153 when "101" =>
154 when "101" =>
154 CoefsReg.denCoefs(i)(2) <= (apbi.pwdata(Coef_SZ-1 downto 0));
155 CoefsReg.denCoefs(i)(2) <= (apbi.pwdata(Coef_SZ-1 downto 0));
155 when others =>
156 when others =>
156 end case;
157 end case;
157 end if;
158 end if;
158 end loop;
159 end loop;
159 end case;
160 end case;
160 end if;
161 end if;
161
162
162 --APB READ OP
163 --APB READ OP
163 if (apbi.psel(pindex) and (not apbi.pwrite)) = '1' then
164 if (apbi.psel(pindex) and (not apbi.pwrite)) = '1' then
164 case apbi.paddr(7 downto 2) is
165 case apbi.paddr(7 downto 2) is
165 when "000000" =>
166 when "000000" =>
166
167
167 when "000001" =>
168 when "000001" =>
168 Rdata(4 downto 0) <= r.regin.virgPos;
169 Rdata(4 downto 0) <= r.regin.virgPos;
169 when others =>
170 when others =>
170 for i in 0 to Cels_count-1 loop
171 for i in 0 to Cels_count-1 loop
171 if conv_integer(apbi.paddr(7 downto 5)) = i+1 then
172 if conv_integer(apbi.paddr(7 downto 5)) = i+1 then
172 case apbi.paddr(4 downto 2) is
173 case apbi.paddr(4 downto 2) is
173 when "000" =>
174 when "000" =>
174 Rdata(Coef_SZ-1 downto 0) <= std_logic_vector(CoefsReg.numCoefs(i)(0));
175 Rdata(Coef_SZ-1 downto 0) <= std_logic_vector(CoefsReg.numCoefs(i)(0));
175 when "001" =>
176 when "001" =>
176 Rdata(Coef_SZ-1 downto 0) <= std_logic_vector(CoefsReg.numCoefs(i)(1));
177 Rdata(Coef_SZ-1 downto 0) <= std_logic_vector(CoefsReg.numCoefs(i)(1));
177 when "010" =>
178 when "010" =>
178 Rdata(Coef_SZ-1 downto 0) <= std_logic_vector(CoefsReg.numCoefs(i)(2));
179 Rdata(Coef_SZ-1 downto 0) <= std_logic_vector(CoefsReg.numCoefs(i)(2));
179 when "011" =>
180 when "011" =>
180 Rdata(Coef_SZ-1 downto 0) <= std_logic_vector(CoefsReg.denCoefs(i)(0));
181 Rdata(Coef_SZ-1 downto 0) <= std_logic_vector(CoefsReg.denCoefs(i)(0));
181 when "100" =>
182 when "100" =>
182 Rdata(Coef_SZ-1 downto 0) <= std_logic_vector(CoefsReg.denCoefs(i)(1));
183 Rdata(Coef_SZ-1 downto 0) <= std_logic_vector(CoefsReg.denCoefs(i)(1));
183 when "101" =>
184 when "101" =>
184 Rdata(Coef_SZ-1 downto 0) <= std_logic_vector(CoefsReg.denCoefs(i)(2));
185 Rdata(Coef_SZ-1 downto 0) <= std_logic_vector(CoefsReg.denCoefs(i)(2));
185 when others =>
186 when others =>
186 end case;
187 end case;
187 end if;
188 end if;
188 end loop;
189 end loop;
189 end case;
190 end case;
190 end if;
191 end if;
191
192
192 end if;
193 end if;
193 apbo.pconfig <= pconfig;
194 apbo.pconfig <= pconfig;
194 end process;
195 end process;
195
196
196 apbo.prdata <= Rdata when apbi.penable = '1' ;
197 apbo.prdata <= Rdata when apbi.penable = '1' ;
197
198
198 -- pragma translate_off
199 -- pragma translate_off
199 bootmsg : report_version
200 bootmsg : report_version
200 generic map ("apbuart" & tost(pindex) &
201 generic map ("apbuart" & tost(pindex) &
201 ": Generic UART rev " & tost(REVISION) & ", fifo " & tost(fifosize) &
202 ": Generic UART rev " & tost(REVISION) & ", fifo " & tost(fifosize) &
202 ", irq " & tost(pirq));
203 ", irq " & tost(pirq));
203 -- pragma translate_on
204 -- pragma translate_on
204
205
205
206
206
207
207 end ar_APB_IIR_CEL;
208 end ar_APB_IIR_CEL;
208
209
@@ -1,142 +1,143
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 library IEEE;
19 library IEEE;
20 use IEEE.STD_LOGIC_1164.ALL;
20 use IEEE.STD_LOGIC_1164.ALL;
21 use ieee.numeric_std.all;
21 use ieee.numeric_std.all;
22 library grlib;
22 library grlib;
23 use grlib.amba.all;
23 use grlib.amba.all;
24 use grlib.stdlib.all;
24 use grlib.stdlib.all;
25 use grlib.devices.all;
25 use grlib.devices.all;
26 library lpp;
26 library lpp;
27 use lpp.lpp_ad_conv.all;
27 use lpp.lpp_ad_conv.all;
28 use lpp.lpp_amba.all;
28 use lpp.lpp_amba.all;
29 use lpp.apb_devices_list.all;
29 use lpp.general_purpose.Clk_divider;
30 use lpp.general_purpose.Clk_divider;
30
31
31 entity lpp_apb_ad_conv is
32 entity lpp_apb_ad_conv is
32 generic(
33 generic(
33 pindex : integer := 0;
34 pindex : integer := 0;
34 paddr : integer := 0;
35 paddr : integer := 0;
35 pmask : integer := 16#fff#;
36 pmask : integer := 16#fff#;
36 pirq : integer := 0;
37 pirq : integer := 0;
37 abits : integer := 8;
38 abits : integer := 8;
38 ChanelCount : integer := 1;
39 ChanelCount : integer := 1;
39 clkkHz : integer := 50000;
40 clkkHz : integer := 50000;
40 smpClkHz : integer := 100;
41 smpClkHz : integer := 100;
41 ADCref : integer := AD7688);
42 ADCref : integer := AD7688);
42 Port (
43 Port (
43 clk : in STD_LOGIC;
44 clk : in STD_LOGIC;
44 reset : in STD_LOGIC;
45 reset : in STD_LOGIC;
45 apbi : in apb_slv_in_type;
46 apbi : in apb_slv_in_type;
46 apbo : out apb_slv_out_type;
47 apbo : out apb_slv_out_type;
47 AD_in : in AD7688_in(ChanelCount-1 downto 0);
48 AD_in : in AD7688_in(ChanelCount-1 downto 0);
48 AD_out : out AD7688_out);
49 AD_out : out AD7688_out);
49 end lpp_apb_ad_conv;
50 end lpp_apb_ad_conv;
50
51
51
52
52 architecture ar_lpp_apb_ad_conv of lpp_apb_ad_conv is
53 architecture ar_lpp_apb_ad_conv of lpp_apb_ad_conv is
53 constant REVISION : integer := 1;
54 constant REVISION : integer := 1;
54
55
55 constant pconfig : apb_config_type := (
56 constant pconfig : apb_config_type := (
56 0 => ahb_device_reg (VENDOR_LPP, LPP_APB_ADC, 0, REVISION, 0),
57 0 => ahb_device_reg (VENDOR_LPP, LPP_APB_ADC, 0, REVISION, 0),
57 1 => apb_iobar(paddr, pmask));
58 1 => apb_iobar(paddr, pmask));
58
59
59 signal Rdata : std_logic_vector(31 downto 0);
60 signal Rdata : std_logic_vector(31 downto 0);
60 signal smpout : Samples_out(ChanelCount-1 downto 0);
61 signal smpout : Samples_out(ChanelCount-1 downto 0);
61 signal smplClk : STD_LOGIC;
62 signal smplClk : STD_LOGIC;
62 signal DataReady : STD_LOGIC;
63 signal DataReady : STD_LOGIC;
63
64
64 type lpp_apb_ad_conv_Reg is record
65 type lpp_apb_ad_conv_Reg is record
65 CTRL_Reg : std_logic_vector(31 downto 0);
66 CTRL_Reg : std_logic_vector(31 downto 0);
66 sample : Samples_out(ChanelCount-1 downto 0);
67 sample : Samples_out(ChanelCount-1 downto 0);
67 end record;
68 end record;
68
69
69 signal r : lpp_apb_ad_conv_Reg;
70 signal r : lpp_apb_ad_conv_Reg;
70
71
71 begin
72 begin
72
73
73
74
74 caseAD7688: if ADCref = AD7688 generate
75 caseAD7688: if ADCref = AD7688 generate
75 AD7688: AD7688_drvr
76 AD7688: AD7688_drvr
76 generic map(ChanelCount,clkkHz)
77 generic map(ChanelCount,clkkHz)
77 Port map(clk,reset,smplClk,DataReady,smpout,AD_in,AD_out);
78 Port map(clk,reset,smplClk,DataReady,smpout,AD_in,AD_out);
78 end generate;
79 end generate;
79
80
80 caseADS786: if ADCref = ADS7886 generate
81 caseADS786: if ADCref = ADS7886 generate
81 ADS7886: ADS7886_drvr
82 ADS7886: ADS7886_drvr
82 generic map(ChanelCount,clkkHz)
83 generic map(ChanelCount,clkkHz)
83 Port map(clk,reset,smplClk,DataReady,smpout,AD_in,AD_out);
84 Port map(clk,reset,smplClk,DataReady,smpout,AD_in,AD_out);
84 end generate;
85 end generate;
85
86
86
87
87 clkdivider: Clk_divider
88 clkdivider: Clk_divider
88 generic map(clkkHz*1000,smpClkHz)
89 generic map(clkkHz*1000,smpClkHz)
89 Port map( clk ,reset,smplClk);
90 Port map( clk ,reset,smplClk);
90
91
91
92
92
93
93 r.CTRL_Reg(0) <= DataReady;
94 r.CTRL_Reg(0) <= DataReady;
94
95
95 r.sample <= smpout;
96 r.sample <= smpout;
96
97
97
98
98 process(reset,clk)
99 process(reset,clk)
99 begin
100 begin
100 if reset = '0' then
101 if reset = '0' then
101 --r.CTRL_Reg(9 downto 0) <= (others => '0');
102 --r.CTRL_Reg(9 downto 0) <= (others => '0');
102 elsif clk'event and clk = '1' then
103 elsif clk'event and clk = '1' then
103
104
104 --APB Write OP
105 --APB Write OP
105 if (apbi.psel(pindex) and apbi.penable and apbi.pwrite) = '1' then
106 if (apbi.psel(pindex) and apbi.penable and apbi.pwrite) = '1' then
106 case apbi.paddr(7 downto 2) is
107 case apbi.paddr(7 downto 2) is
107 when "000000" =>
108 when "000000" =>
108 --r.CTRL_Reg(9 downto 0) <= apbi.pwdata(9 downto 0);
109 --r.CTRL_Reg(9 downto 0) <= apbi.pwdata(9 downto 0);
109 when others =>
110 when others =>
110 end case;
111 end case;
111 end if;
112 end if;
112
113
113 --APB READ OP
114 --APB READ OP
114 if (apbi.psel(pindex) and (not apbi.pwrite)) = '1' then
115 if (apbi.psel(pindex) and (not apbi.pwrite)) = '1' then
115 case apbi.paddr(7 downto 2) is
116 case apbi.paddr(7 downto 2) is
116 when "000000" =>
117 when "000000" =>
117 Rdata <= r.CTRL_Reg;
118 Rdata <= r.CTRL_Reg;
118 when others =>
119 when others =>
119 readC: for i in 1 to ChanelCount loop
120 readC: for i in 1 to ChanelCount loop
120 if TO_INTEGER(unsigned(apbi.paddr(abits-1 downto 2))) =i then
121 if TO_INTEGER(unsigned(apbi.paddr(abits-1 downto 2))) =i then
121 Rdata(15 downto 0) <= r.sample(i-1)(15 downto 0);
122 Rdata(15 downto 0) <= r.sample(i-1)(15 downto 0);
122 end if;
123 end if;
123 end loop;
124 end loop;
124 end case;
125 end case;
125 end if;
126 end if;
126 end if;
127 end if;
127 apbo.pconfig <= pconfig;
128 apbo.pconfig <= pconfig;
128 end process;
129 end process;
129
130
130 apbo.prdata <= Rdata when apbi.penable = '1' ;
131 apbo.prdata <= Rdata when apbi.penable = '1' ;
131
132
132
133
133 end ar_lpp_apb_ad_conv;
134 end ar_lpp_apb_ad_conv;
134
135
135
136
136
137
137
138
138
139
139
140
140
141
141
142
142
143
@@ -1,100 +1,101
1 -- APB_CNA.vhd
1 -- APB_CNA.vhd
2
2
3 library ieee;
3 library ieee;
4 use ieee.std_logic_1164.all;
4 use ieee.std_logic_1164.all;
5 library grlib;
5 library grlib;
6 use grlib.amba.all;
6 use grlib.amba.all;
7 use grlib.stdlib.all;
7 use grlib.stdlib.all;
8 use grlib.devices.all;
8 use grlib.devices.all;
9 library lpp;
9 library lpp;
10 use lpp.lpp_amba.all;
10 use lpp.lpp_amba.all;
11 use lpp.apb_devices_list.all;
11 use lpp.lpp_cna.all;
12 use lpp.lpp_cna.all;
12
13
13
14
14 entity APB_CNA is
15 entity APB_CNA is
15 generic (
16 generic (
16 pindex : integer := 0;
17 pindex : integer := 0;
17 paddr : integer := 0;
18 paddr : integer := 0;
18 pmask : integer := 16#fff#;
19 pmask : integer := 16#fff#;
19 pirq : integer := 0;
20 pirq : integer := 0;
20 abits : integer := 8);
21 abits : integer := 8);
21 port (
22 port (
22 clk : in std_logic;
23 clk : in std_logic;
23 rst : in std_logic;
24 rst : in std_logic;
24 apbi : in apb_slv_in_type;
25 apbi : in apb_slv_in_type;
25 apbo : out apb_slv_out_type;
26 apbo : out apb_slv_out_type;
26 SYNC : out std_logic;
27 SYNC : out std_logic;
27 SCLK : out std_logic;
28 SCLK : out std_logic;
28 DATA : out std_logic
29 DATA : out std_logic
29 );
30 );
30 end APB_CNA;
31 end APB_CNA;
31
32
32
33
33 architecture ar_APB_CNA of APB_CNA is
34 architecture ar_APB_CNA of APB_CNA is
34
35
35 constant REVISION : integer := 1;
36 constant REVISION : integer := 1;
36
37
37 constant pconfig : apb_config_type := (
38 constant pconfig : apb_config_type := (
38 0 => ahb_device_reg (VENDOR_LPP, LPP_CNA, 0, REVISION, 0),
39 0 => ahb_device_reg (VENDOR_LPP, LPP_CNA, 0, REVISION, 0),
39 1 => apb_iobar(paddr, pmask));
40 1 => apb_iobar(paddr, pmask));
40
41
41 signal enable : std_logic;
42 signal enable : std_logic;
42 signal flag_sd : std_logic;
43 signal flag_sd : std_logic;
43
44
44 type CNA_ctrlr_Reg is record
45 type CNA_ctrlr_Reg is record
45 CNA_Cfg : std_logic_vector(1 downto 0);
46 CNA_Cfg : std_logic_vector(1 downto 0);
46 CNA_Data : std_logic_vector(15 downto 0);
47 CNA_Data : std_logic_vector(15 downto 0);
47 end record;
48 end record;
48
49
49 signal Rec : CNA_ctrlr_Reg;
50 signal Rec : CNA_ctrlr_Reg;
50 signal Rdata : std_logic_vector(31 downto 0);
51 signal Rdata : std_logic_vector(31 downto 0);
51
52
52 begin
53 begin
53
54
54 enable <= Rec.CNA_Cfg(0);
55 enable <= Rec.CNA_Cfg(0);
55 Rec.CNA_Cfg(1) <= flag_sd;
56 Rec.CNA_Cfg(1) <= flag_sd;
56
57
57 CONVERTER : entity Work.CNA_TabloC
58 CONVERTER : entity Work.CNA_TabloC
58 port map(clk,rst,enable,Rec.CNA_Data,SYNC,SCLK,flag_sd,Data);
59 port map(clk,rst,enable,Rec.CNA_Data,SYNC,SCLK,flag_sd,Data);
59
60
60
61
61 process(rst,clk)
62 process(rst,clk)
62 begin
63 begin
63 if(rst='0')then
64 if(rst='0')then
64 Rec.CNA_Data <= (others => '0');
65 Rec.CNA_Data <= (others => '0');
65
66
66 elsif(clk'event and clk='1')then
67 elsif(clk'event and clk='1')then
67
68
68
69
69 --APB Write OP
70 --APB Write OP
70 if (apbi.psel(pindex) and apbi.penable and apbi.pwrite) = '1' then
71 if (apbi.psel(pindex) and apbi.penable and apbi.pwrite) = '1' then
71 case apbi.paddr(abits-1 downto 2) is
72 case apbi.paddr(abits-1 downto 2) is
72 when "000000" =>
73 when "000000" =>
73 Rec.CNA_Cfg(0) <= apbi.pwdata(0);
74 Rec.CNA_Cfg(0) <= apbi.pwdata(0);
74 when "000001" =>
75 when "000001" =>
75 Rec.CNA_Data <= apbi.pwdata(15 downto 0);
76 Rec.CNA_Data <= apbi.pwdata(15 downto 0);
76 when others =>
77 when others =>
77 null;
78 null;
78 end case;
79 end case;
79 end if;
80 end if;
80
81
81 --APB READ OP
82 --APB READ OP
82 if (apbi.psel(pindex) and (not apbi.pwrite)) = '1' then
83 if (apbi.psel(pindex) and (not apbi.pwrite)) = '1' then
83 case apbi.paddr(abits-1 downto 2) is
84 case apbi.paddr(abits-1 downto 2) is
84 when "000000" =>
85 when "000000" =>
85 Rdata(31 downto 2) <= X"ABCDEF5" & "00";
86 Rdata(31 downto 2) <= X"ABCDEF5" & "00";
86 Rdata(1 downto 0) <= Rec.CNA_Cfg;
87 Rdata(1 downto 0) <= Rec.CNA_Cfg;
87 when "000001" =>
88 when "000001" =>
88 Rdata(31 downto 16) <= X"FD18";
89 Rdata(31 downto 16) <= X"FD18";
89 Rdata(15 downto 0) <= Rec.CNA_Data;
90 Rdata(15 downto 0) <= Rec.CNA_Data;
90 when others =>
91 when others =>
91 Rdata <= (others => '0');
92 Rdata <= (others => '0');
92 end case;
93 end case;
93 end if;
94 end if;
94
95
95 end if;
96 end if;
96 apbo.pconfig <= pconfig;
97 apbo.pconfig <= pconfig;
97 end process;
98 end process;
98
99
99 apbo.prdata <= Rdata when apbi.penable = '1';
100 apbo.prdata <= Rdata when apbi.penable = '1';
100 end ar_APB_CNA; No newline at end of file
101 end ar_APB_CNA;
@@ -1,135 +1,136
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 library ieee;
19 library ieee;
20 use ieee.std_logic_1164.all;
20 use ieee.std_logic_1164.all;
21 library grlib;
21 library grlib;
22 use grlib.amba.all;
22 use grlib.amba.all;
23 use grlib.stdlib.all;
23 use grlib.stdlib.all;
24 use grlib.devices.all;
24 use grlib.devices.all;
25 library lpp;
25 library lpp;
26 use lpp.lpp_amba.all;
26 use lpp.lpp_amba.all;
27 use lpp.apb_devices_list.all;
27 use lpp.lpp_uart.all;
28 use lpp.lpp_uart.all;
28
29
29 entity APB_UART is
30 entity APB_UART is
30 generic (
31 generic (
31 pindex : integer := 0;
32 pindex : integer := 0;
32 paddr : integer := 0;
33 paddr : integer := 0;
33 pmask : integer := 16#fff#;
34 pmask : integer := 16#fff#;
34 pirq : integer := 0;
35 pirq : integer := 0;
35 abits : integer := 8;
36 abits : integer := 8;
36 Data_sz : integer := 8);
37 Data_sz : integer := 8);
37 port (
38 port (
38 clk : in std_logic;
39 clk : in std_logic;
39 rst : in std_logic;
40 rst : in std_logic;
40 apbi : in apb_slv_in_type;
41 apbi : in apb_slv_in_type;
41 apbo : out apb_slv_out_type;
42 apbo : out apb_slv_out_type;
42 TXD : out std_logic;
43 TXD : out std_logic;
43 RXD : in std_logic
44 RXD : in std_logic
44 );
45 );
45 end APB_UART;
46 end APB_UART;
46
47
47
48
48 architecture ar_APB_UART of APB_UART is
49 architecture ar_APB_UART of APB_UART is
49
50
50 constant REVISION : integer := 1;
51 constant REVISION : integer := 1;
51
52
52 constant pconfig : apb_config_type := (
53 constant pconfig : apb_config_type := (
53 0 => ahb_device_reg (VENDOR_LPP, LPP_UART, 0, REVISION, 0),
54 0 => ahb_device_reg (VENDOR_LPP, LPP_UART, 0, REVISION, 0),
54 1 => apb_iobar(paddr, pmask));
55 1 => apb_iobar(paddr, pmask));
55
56
56 signal NwData : std_logic;
57 signal NwData : std_logic;
57 signal ACK : std_logic;
58 signal ACK : std_logic;
58 signal Capture : std_logic;
59 signal Capture : std_logic;
59 signal Send : std_logic;
60 signal Send : std_logic;
60 signal Sended : std_logic;
61 signal Sended : std_logic;
61
62
62 type UART_ctrlr_Reg is record
63 type UART_ctrlr_Reg is record
63 UART_Cfg : std_logic_vector(4 downto 0);
64 UART_Cfg : std_logic_vector(4 downto 0);
64 UART_Wdata : std_logic_vector(7 downto 0);
65 UART_Wdata : std_logic_vector(7 downto 0);
65 UART_Rdata : std_logic_vector(7 downto 0);
66 UART_Rdata : std_logic_vector(7 downto 0);
66 UART_BTrig : std_logic_vector(11 downto 0);
67 UART_BTrig : std_logic_vector(11 downto 0);
67 end record;
68 end record;
68
69
69 signal Rec : UART_ctrlr_Reg;
70 signal Rec : UART_ctrlr_Reg;
70 signal Rdata : std_logic_vector(31 downto 0);
71 signal Rdata : std_logic_vector(31 downto 0);
71
72
72 begin
73 begin
73
74
74 Capture <= Rec.UART_Cfg(0);
75 Capture <= Rec.UART_Cfg(0);
75 --ACK <= Rec.UART_Cfg(1);
76 --ACK <= Rec.UART_Cfg(1);
76 --Send <= Rec.UART_Cfg(2);
77 --Send <= Rec.UART_Cfg(2);
77 Rec.UART_Cfg(3) <= Sended;
78 Rec.UART_Cfg(3) <= Sended;
78 Rec.UART_Cfg(4) <= NwData;
79 Rec.UART_Cfg(4) <= NwData;
79
80
80
81
81 COM0 : entity work.UART
82 COM0 : entity work.UART
82 generic map (Data_sz)
83 generic map (Data_sz)
83 port map (clk,rst,TXD,RXD,Capture,NwData,ACK,Send,Sended,Rec.UART_BTrig,Rec.UART_Rdata,Rec.UART_Wdata);
84 port map (clk,rst,TXD,RXD,Capture,NwData,ACK,Send,Sended,Rec.UART_BTrig,Rec.UART_Rdata,Rec.UART_Wdata);
84
85
85
86
86 process(rst,clk)
87 process(rst,clk)
87 begin
88 begin
88 if(rst='0')then
89 if(rst='0')then
89 Rec.UART_Wdata <= (others => '0');
90 Rec.UART_Wdata <= (others => '0');
90
91
91
92
92 elsif(clk'event and clk='1')then
93 elsif(clk'event and clk='1')then
93
94
94
95
95 --APB Write OP
96 --APB Write OP
96 if (apbi.psel(pindex) and apbi.penable and apbi.pwrite) = '1' then
97 if (apbi.psel(pindex) and apbi.penable and apbi.pwrite) = '1' then
97 case apbi.paddr(7 downto 2) is
98 case apbi.paddr(7 downto 2) is
98 when "000000" =>
99 when "000000" =>
99 Rec.UART_Cfg(2 downto 0) <= apbi.pwdata(2 downto 0);
100 Rec.UART_Cfg(2 downto 0) <= apbi.pwdata(2 downto 0);
100 when "000001" =>
101 when "000001" =>
101 Rec.UART_Wdata <= apbi.pwdata(7 downto 0);
102 Rec.UART_Wdata <= apbi.pwdata(7 downto 0);
102 Send <= '1';
103 Send <= '1';
103 when others =>
104 when others =>
104 null;
105 null;
105 end case;
106 end case;
106 else
107 else
107 Send <= '0';
108 Send <= '0';
108 end if;
109 end if;
109
110
110 --APB READ OP
111 --APB READ OP
111 if (apbi.psel(pindex) and (not apbi.pwrite)) = '1' then
112 if (apbi.psel(pindex) and (not apbi.pwrite)) = '1' then
112 case apbi.paddr(7 downto 2) is
113 case apbi.paddr(7 downto 2) is
113 when "000000" =>
114 when "000000" =>
114 Rdata(4 downto 0) <= Rec.UART_Cfg;
115 Rdata(4 downto 0) <= Rec.UART_Cfg;
115 Rdata(26 downto 12) <= (others => '0');
116 Rdata(26 downto 12) <= (others => '0');
116 Rdata(27 downto 16) <= Rec.UART_BTrig;
117 Rdata(27 downto 16) <= Rec.UART_BTrig;
117 when "000001" =>
118 when "000001" =>
118 Rdata(7 downto 0) <= Rec.UART_Wdata;
119 Rdata(7 downto 0) <= Rec.UART_Wdata;
119 when "000010" =>
120 when "000010" =>
120 Rdata(7 downto 0) <= Rec.UART_Rdata;
121 Rdata(7 downto 0) <= Rec.UART_Rdata;
121 Ack <= '1';
122 Ack <= '1';
122 when others =>
123 when others =>
123 Rdata <= (others => '0');
124 Rdata <= (others => '0');
124 end case;
125 end case;
125 else
126 else
126 Ack <= '0';
127 Ack <= '0';
127 end if;
128 end if;
128
129
129 end if;
130 end if;
130 apbo.pconfig <= pconfig;
131 apbo.pconfig <= pconfig;
131 end process;
132 end process;
132
133
133 apbo.prdata <= Rdata when apbi.penable = '1';
134 apbo.prdata <= Rdata when apbi.penable = '1';
134
135
135 end ar_APB_UART;
136 end ar_APB_UART;
General Comments 0
You need to be logged in to leave comments. Login now