##// END OF EJS Templates
temp
pellion -
r602:ddd72636badb simu_with_Leon3
parent child
Show More
@@ -0,0 +1,2
1 window_function_pkg.vhd
2 window_function.vhd
@@ -0,0 +1,153
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 : Jean-christophe Pellion
20 -- Mail : jean-christophe.pellion@lpp.polytechnique.fr
21 -- jean-christophe.pellion@easii-ic.com
22 ----------------------------------------------------------------------------
23
24 LIBRARY ieee;
25 USE ieee.std_logic_1164.ALL;
26 USE ieee.numeric_std.ALL;
27
28 LIBRARY lpp;
29 USE lpp.general_purpose.ALL;
30 USE lpp.window_function_pkg.ALL;
31
32 ENTITY window_function IS
33 GENERIC (
34 DATA_SIZE : INTEGER := 16;
35 PARAM_SIZE : INTEGER := 10
36 );
37
38 PORT (
39 clk : IN STD_LOGIC;
40 rstn : IN STD_LOGIC;
41
42 restart_window : IN STD_LOGIC;
43
44 data_in : IN STD_LOGIC_VECTOR(DATA_SIZE-1 DOWNTO 0);
45 data_in_valid : IN STD_LOGIC;
46
47 data_out : OUT STD_LOGIC_VECTOR(DATA_SIZE-1 DOWNTO 0);
48 data_out_valid : OUT STD_LOGIC
49 );
50
51 END window_function;
52
53 ARCHITECTURE beh OF window_function IS
54
55 SUBTYPE RANGE_NB_BIT_BY_WINDOW_PARAM IS INTEGER RANGE 1 TO DATA_SIZE;
56 CONSTANT NB_BIT_BY_WINDOW_PARAM : RANGE_NB_BIT_BY_WINDOW_PARAM := 16;
57 CONSTANT NB_POINT_BY_WINDOW : INTEGER := 256;
58
59 TYPE WINDOWS_PARAM_TYPE IS ARRAY (INTEGER RANGE <>) OF STD_LOGIC_VECTOR(15 DOWNTO 0);
60 CONSTANT windows_param_lfr_sigmoide : WINDOWS_PARAM_TYPE(0 TO 32) :=
61 ( X"0000",X"0012",X"002E",X"005B", X"00A2",X"0113",X"01C7",X"02E0", --0 - 7
62 X"0498",X"073A",X"0B37",X"110D", X"193C",X"240F",X"3147",X"3FF7", --8 - 15
63 X"4EA7",X"5BDF",X"66B2",X"6EE1", X"74B7",X"78B4",X"7B56",X"7D0E", --16 - 23
64 X"7E27",X"7EDB",X"7F4C",X"7F93", X"7FC0",X"7FDC",X"7FEE",X"7FF9", --24 - 31
65 X"7FFF" ); --32
66 CONSTANT windows_param_lfr_rampe : WINDOWS_PARAM_TYPE(0 TO 32) :=
67 ( X"0000",X"03E1",X"07C2",X"0BA3", X"0F84",X"1365",X"1746",X"1B27",
68 X"1F08",X"22E8",X"26C9",X"2AAA", X"2E8B",X"326C",X"364D",X"3A2E",
69 X"3E0F",X"41F0",X"45D1",X"49B2", X"4D93",X"5174",X"5555",X"5936",
70 X"5D17",X"60F7",X"64D8",X"68B9", X"6C9A",X"707B",X"745C",X"783D",
71 X"7FFF" );
72 CONSTANT windows_param_lfr_echelon : WINDOWS_PARAM_TYPE(0 TO 32) :=
73 ( X"0000",X"0000",X"0000",X"0000", X"0000",X"0000",X"0000",X"0000",
74 X"0000",X"0000",X"0000",X"0000", X"0000",X"0000",X"0000",X"0000",
75 X"FFFF",X"FFFF",X"FFFF",X"FFFF", X"FFFF",X"FFFF",X"FFFF",X"FFFF",
76 X"FFFF",X"FFFF",X"FFFF",X"FFFF", X"FFFF",X"FFFF",X"FFFF",X"FFFF",
77 X"FFFF");
78
79 CONSTANT windows_param_lfr : WINDOWS_PARAM_TYPE(0 TO 32) := windows_param_lfr_sigmoide;
80
81 SIGNAL windows_param : WINDOWS_PARAM_TYPE(0 TO NB_POINT_BY_WINDOW-1);
82
83 SIGNAL param_counter : INTEGER RANGE 0 TO NB_POINT_BY_WINDOW-1;
84
85 SIGNAL data_x_param : STD_LOGIC_VECTOR(DATA_SIZE + PARAM_SIZE - 1 DOWNTO 0);
86
87 SIGNAL windows_param_selected_s : STD_LOGIC_VECTOR(15 DOWNTO 0);
88 SIGNAL windows_param_selected : STD_LOGIC_VECTOR(PARAM_SIZE-1 DOWNTO 0);
89 SIGNAL data_in_valid_s : STD_LOGIC;
90 SIGNAL data_in_s : STD_LOGIC_VECTOR(DATA_SIZE-1 DOWNTO 0);
91
92 BEGIN
93
94 all_windows_param_0: FOR I IN 0 TO 31 GENERATE
95 windows_param(I) <= windows_param_lfr(I);
96 END GENERATE all_windows_param_0;
97 all_windows_param_1: FOR I IN 32 TO 223 GENERATE
98 windows_param(I) <= windows_param_lfr(32);
99 END GENERATE all_windows_param_1;
100 all_windows_param_2: FOR I IN 224 TO 255 GENERATE
101 windows_param(I) <= windows_param_lfr(255-I);
102 END GENERATE all_windows_param_2;
103
104 PROCESS (clk, rstn)
105 BEGIN -- PROCESS
106 IF rstn = '0' THEN -- asynchronous reset (active low)
107 param_counter <= 0;
108 ELSIF clk'EVENT AND clk = '1' THEN -- rising clock edge
109 IF restart_window = '1' THEN
110 param_counter <= 0;
111 ELSE
112 IF data_in_valid = '1' THEN
113 IF param_counter < 255 THEN
114 param_counter <= param_counter + 1;
115 ELSE
116 param_counter <= 0;
117 END IF;
118 END IF;
119 END IF;
120 END IF;
121 END PROCESS;
122
123 data_in_valid_s <= data_in_valid;
124 data_in_s <= data_in;
125 windows_param_selected_s <= windows_param(param_counter);
126 windows_param_selected <= windows_param_selected_s(15 DOWNTO 16 - PARAM_SIZE);
127
128 WINDOWS_Multiplier : Multiplier
129 GENERIC MAP (
130 Input_SZ_A => DATA_SIZE,
131 Input_SZ_B => PARAM_SIZE)
132 PORT MAP (
133 clk => clk,
134 reset => rstn,
135
136 mult => data_in_valid_s,
137 OP1 => data_in_s,
138 OP2 => windows_param_selected,
139
140 RES => data_x_param);
141
142 data_out <= data_x_param(DATA_SIZE + PARAM_SIZE-1 DOWNTO PARAM_SIZE);
143
144 PROCESS (clk, rstn)
145 BEGIN -- PROCESS
146 IF rstn = '0' THEN -- asynchronous reset (active low)
147 data_out_valid <= '0';
148 ELSIF clk'EVENT AND clk = '1' THEN -- rising clock edge
149 data_out_valid <= data_in_valid_s;
150 END IF;
151 END PROCESS;
152
153 END beh; No newline at end of file
@@ -0,0 +1,44
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 : Jean-christophe Pellion
20 -- Mail : jean-christophe.pellion@lpp.polytechnique.fr
21 -- jean-christophe.pellion@easii-ic.com
22 ----------------------------------------------------------------------------
23 LIBRARY ieee;
24 USE ieee.std_logic_1164.ALL;
25 USE IEEE.NUMERIC_STD.ALL;
26
27 PACKAGE window_function_pkg IS
28
29 COMPONENT window_function
30 GENERIC (
31 DATA_SIZE : INTEGER;
32 PARAM_SIZE : INTEGER);
33 PORT (
34 clk : IN STD_LOGIC;
35 rstn : IN STD_LOGIC;
36 restart_window : IN STD_LOGIC;
37 data_in : IN STD_LOGIC_VECTOR(DATA_SIZE-1 DOWNTO 0);
38 data_in_valid : IN STD_LOGIC;
39 data_out : OUT STD_LOGIC_VECTOR(DATA_SIZE-1 DOWNTO 0);
40 data_out_valid : OUT STD_LOGIC);
41 END COMPONENT;
42
43
44 END window_function_pkg;
@@ -0,0 +1,115
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 : Jean-christophe Pellion
20 -- Mail : jean-christophe.pellion@lpp.polytechnique.fr
21 -- jean-christophe.pellion@easii-ic.com
22 ----------------------------------------------------------------------------
23 LIBRARY ieee;
24 USE ieee.std_logic_1164.ALL;
25 USE ieee.numeric_std.ALL;
26 USE ieee.math_real.ALL;
27
28 LIBRARY std;
29 USE std.textio.ALL;
30
31 LIBRARY lpp;
32 USE lpp.data_type_pkg.ALL;
33
34 PACKAGE reader_pkg IS
35
36 CONSTANT CHARACTER_COMMENT : CHARACTER := '#';
37
38 FUNCTION get_array_real (
39 file_in : TEXT;
40 nb_data_read : INTEGER)
41 RETURN array_real;
42
43 FUNCTION get_array_integer (
44 file_in : TEXT;
45 nb_data_read : INTEGER)
46 RETURN array_integer;
47
48
49 END reader_pkg;
50
51 PACKAGE BODY reader_pkg IS
52
53 FUNCTION get_array_real (
54 file_name : STRING;
55 nb_data_to_read : INTEGER)
56 RETURN array_real
57 IS
58 VARIABLE GOOD : BOOLEAN;
59 VARIABLE array_real_v : array_real(0 TO nb_data_to_read-1);
60 VARIABLE real_p : REAL;
61 VARIABLE nb_data_read : INTEGER := 0;
62 FILE file_p : TEXT;
63 VARIABLE line_p : LINE;
64 BEGIN
65 GOOD := false;
66 file_open(file_p, file_name, read_mode);
67 WHILE (NOT endfile(file_p)) AND (nb_data_read <nb_data_to_read) LOOP
68 readline(file_p, line_p);
69 read(line_p, real_p, GOOD);
70 IF GOOD THEN
71 array_real_v(nb_data_read) := real_p;
72 nb_data_read := nb_data_read + 1;
73 END IF;
74 END LOOP;
75 IF nb_data_read < nb_data_to_read THEN
76 GOOD := false;
77 ELSE
78 GOOD := true;
79 END IF;
80 RETURN array_real_v;
81 END get_array_real;
82
83 FUNCTION get_array_integer (
84 file_name : STRING;
85 nb_data_to_read : INTEGER)
86 RETURN array_integer
87 IS
88 VARIABLE GOOD : BOOLEAN;
89 VARIABLE array_integer_v : array_integer(0 TO nb_data_to_read-1);
90 VARIABLE integer_p : INTEGER;
91 VARIABLE nb_data_read : INTEGER := 0;
92 FILE file_p : TEXT;
93 VARIABLE line_p : LINE;
94 BEGIN
95 GOOD := false;
96 file_open(file_p, file_name, read_mode);
97 WHILE (NOT endfile(file_p)) AND (nb_data_read <nb_data_to_read) LOOP
98 readline(file_p, line_p);
99 read(line_p, integer_p, GOOD);
100 IF GOOD THEN
101 array_integer_v(nb_data_read) := integer_p;
102 nb_data_read := nb_data_read + 1;
103 END IF;
104 END LOOP;
105 IF nb_data_read < nb_data_to_read THEN
106 GOOD := false;
107 ELSE
108 GOOD := true;
109 END IF;
110 RETURN array_integer_v;
111 END get_array_integer;
112
113
114
115 END reader_pkg; No newline at end of file
@@ -0,0 +1,1
1 reader_pkg.vhd
@@ -30,3 +30,4
30 ./lpp_debug_lfr
30 ./lpp_debug_lfr
31 ./lpp_sim/CY7C1061DV33
31 ./lpp_sim/CY7C1061DV33
32 ./lpp_sim
32 ./lpp_sim
33 ./lpp_file
@@ -27,6 +27,8 USE ieee.std_logic_1164.ALL;
27 PACKAGE data_type_pkg IS
27 PACKAGE data_type_pkg IS
28
28
29 TYPE array_integer IS ARRAY (NATURAL RANGE <>) OF INTEGER;
29 TYPE array_integer IS ARRAY (NATURAL RANGE <>) OF INTEGER;
30 TYPE array_real IS ARRAY (NATURAL RANGE <>) OF REAL;
31 TYPE array_std_logic_vector_16b IS ARRAY (NATURAL RANGE <>) OF STD_LOGIC_VECTOR(15 DOWNTO 0);
30
32
31 TYPE sample_vector IS ARRAY(NATURAL RANGE <>, NATURAL RANGE <>) OF STD_LOGIC;
33 TYPE sample_vector IS ARRAY(NATURAL RANGE <>, NATURAL RANGE <>) OF STD_LOGIC;
32
34
General Comments 0
You need to be logged in to leave comments. Login now