1 |
5 |
pas. |
--//// This file is part of the GNExtrapolator project ////
|
2 |
|
|
--//// http://opencores.org/project,gnextrapolator ////
|
3 |
|
|
--//// ////
|
4 |
|
|
--//// Description ////
|
5 |
|
|
--//// Implementation of Algoritm for extrapolation functions ////
|
6 |
|
|
--//// ////
|
7 |
|
|
--//// ////
|
8 |
|
|
--//// To Do: ////
|
9 |
|
|
--//// - ////
|
10 |
|
|
--//// ////
|
11 |
|
|
--//// Author(s): ////
|
12 |
|
|
--//// - Rodrigo Villegas, ruyvillegas@gmail.com, designer ////
|
13 |
|
|
--//// - Iván Millán, ivanmillan36@gmail.com, designer ////
|
14 |
|
|
--//// - Pablo A. Salvadeo, pas.@opencores, manager ////
|
15 |
|
|
--//// ////
|
16 |
|
|
--//////////////////////////////////////////////////////////////////////
|
17 |
|
|
--//// ////
|
18 |
|
|
--//// Copyright (C) 2011 Authors and OPENCORES.ORG ////
|
19 |
|
|
--//// ////
|
20 |
|
|
--//// This source file may be used and distributed without ////
|
21 |
|
|
--//// restriction provided that this copyright statement is not ////
|
22 |
|
|
--//// removed from the file and that any derivative work contains ////
|
23 |
|
|
--//// the original copyright notice and the associated disclaimer. ////
|
24 |
|
|
--//// ////
|
25 |
|
|
--//// This source file is free software; you can redistribute it ////
|
26 |
|
|
--//// and/or modify it under the terms of the GNU Lesser General ////
|
27 |
|
|
--//// Public License as published by the Free Software Foundation; ////
|
28 |
|
|
--//// either version 2.1 of the License, or (at your option) any ////
|
29 |
|
|
--//// later version. ////
|
30 |
|
|
--//// ////
|
31 |
|
|
--//// This source is distributed in the hope that it will be ////
|
32 |
|
|
--//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
33 |
|
|
--//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
34 |
|
|
--//// PURPOSE. See the GNU Lesser General Public License for more ////
|
35 |
|
|
--//// details. ////
|
36 |
|
|
--//// ////
|
37 |
|
|
--//// You should have received a copy of the GNU Lesser General ////
|
38 |
|
|
--//// Public License along with this source; if not, download it ////
|
39 |
|
|
--//// from http://www.opencores.org/lgpl.shtml ////
|
40 |
|
|
--//// ////
|
41 |
|
|
--//////////////////////////////////////////////////////////////////////
|
42 |
|
|
|
43 |
|
|
LIBRARY ieee;
|
44 |
|
|
USE ieee.std_logic_1164.all;
|
45 |
|
|
USE ieee.std_logic_signed.all;
|
46 |
|
|
USE ieee.std_logic_arith.all;
|
47 |
|
|
|
48 |
|
|
entity gnextrapolator is
|
49 |
|
|
port
|
50 |
|
|
(
|
51 |
|
|
rst_i : in std_logic;
|
52 |
|
|
clk_i : in std_logic;
|
53 |
|
|
distancia_i: in std_logic_vector(7 downto 0);
|
54 |
|
|
extrapolar_i: in std_logic;
|
55 |
|
|
indice_p_o: out std_logic_vector(4 downto 0);
|
56 |
|
|
fxx_o: out std_logic_vector(15 downto 0);
|
57 |
|
|
fxx1_o: out std_logic_vector(15 downto 0);
|
58 |
|
|
fxx2_o: out std_logic_vector(15 downto 0);
|
59 |
|
|
fxx3_o: out std_logic_vector(15 downto 0);
|
60 |
|
|
fxx4_o: out std_logic_vector(15 downto 0);
|
61 |
|
|
resul_o: out std_logic_vector(15 downto 0)
|
62 |
|
|
);
|
63 |
|
|
end gnextrapolator;
|
64 |
|
|
|
65 |
|
|
|
66 |
|
|
architecture grenew of gnextrapolator is
|
67 |
|
|
-------------------------------------------------------------------------------------------------------
|
68 |
|
|
type columna is array(0 to 2) of std_logic_vector(15 downto 0);
|
69 |
|
|
signal sfx: columna;
|
70 |
|
|
signal indice: integer range 0 to 31;
|
71 |
|
|
signal sram: std_logic_vector(15 downto 0);
|
72 |
|
|
|
73 |
|
|
-------------------------------------------------------------------------------------------------------
|
74 |
|
|
subtype word_t is std_logic_vector(15 downto 0);
|
75 |
|
|
type memory_t is array(0 to 31) of word_t;
|
76 |
|
|
signal ram : memory_t;
|
77 |
|
|
attribute romstyle : string;
|
78 |
|
|
attribute romstyle of ram : signal is "M512";
|
79 |
|
|
attribute ram_init_file : string;
|
80 |
|
|
attribute ram_init_file of ram :signal is "gnextrapolator.mif";
|
81 |
|
|
-------------------------------------------------------------------------------------------------------
|
82 |
|
|
|
83 |
|
|
|
84 |
|
|
|
85 |
|
|
begin
|
86 |
|
|
process(rst_i,clk_i)
|
87 |
|
|
variable i:integer range 0 to 2 ;
|
88 |
|
|
variable resultado:std_logic_vector(15 downto 0);
|
89 |
|
|
variable fx: columna;
|
90 |
|
|
variable nabla1fx: columna;
|
91 |
|
|
variable nabla2fx: columna;
|
92 |
|
|
variable nabla3fx: columna;
|
93 |
|
|
variable nabla4fx: columna;
|
94 |
|
|
variable compensacion: columna;
|
95 |
|
|
variable cont:integer range 0 to 65535;
|
96 |
|
|
|
97 |
|
|
begin
|
98 |
|
|
if (rst_i='1') then
|
99 |
|
|
i:=0;
|
100 |
|
|
cont:=0;
|
101 |
|
|
fx(0):= (others=>'0');
|
102 |
|
|
nabla1fx(0):= (others=>'0');
|
103 |
|
|
nabla2fx(0):= (others=>'0');
|
104 |
|
|
nabla3fx(0):= (others=>'0');
|
105 |
|
|
nabla4fx(0):= (others=>'0');
|
106 |
|
|
indice<=0;
|
107 |
|
|
elsif(rising_edge(clk_i)) then
|
108 |
|
|
|
109 |
|
|
if(extrapolar_i = '0') then
|
110 |
|
|
fx(i):= sram;
|
111 |
|
|
--
|
112 |
|
|
-- Se resiben los datos hasta que se ponga en alto el pin
|
113 |
|
|
elsif(extrapolar_i = '1') then -- 'extrapolar', con lo cual, se comienza a usar como valores
|
114 |
|
|
fx(i):=resultado; --
|
115 |
|
|
cont:= cont+1; -- de la funcion los resultados calculados, y se deja de tomar datos
|
116 |
|
|
end if; -- de la entrada.
|
117 |
|
|
|
118 |
|
|
|
119 |
|
|
nabla1fx(i):=(fx(i)-fx(i-1)); -- Se calculan los nablas y el resultado
|
120 |
|
|
nabla2fx(i):=(nabla1fx(i)-nabla1fx(i-1)); -- de sumar la ultima fila de vaores de
|
121 |
|
|
nabla3fx(i):=(nabla2fx(i)-nabla2fx(i-1)); -- la tabla.
|
122 |
|
|
nabla4fx(i):=(nabla3fx(i)-nabla3fx(i-1)); --
|
123 |
|
|
--
|
124 |
|
|
resultado:=fx(i)+nabla1fx(i)+nabla2fx(i)+nabla3fx(i)+nabla4fx(i); --
|
125 |
|
|
|
126 |
|
|
fxx_o <= fx(i); --
|
127 |
|
|
fxx1_o<= nabla1fx(i); -- Se envian los datos a salidas para su observacion,
|
128 |
|
|
fxx2_o<= nabla2fx(i); -- el resultado se envia cada cierta cantidad de muestras
|
129 |
|
|
fxx3_o<= nabla3fx(i); -- definida por el usuario.
|
130 |
|
|
fxx4_o<= nabla4fx(i); --
|
131 |
|
|
if(cont = distancia_i) then --
|
132 |
|
|
resul_o<=resultado; --
|
133 |
|
|
cont:=0; --
|
134 |
|
|
end if; --
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
fx(0):= fx(i); -- se desplaza la fila hacia atras para poder calcular la siguiente
|
138 |
|
|
nabla1fx(0):= nabla1fx(i); --
|
139 |
|
|
nabla2fx(0):= nabla2fx(i); --
|
140 |
|
|
nabla3fx(0):= nabla3fx(i); --
|
141 |
|
|
nabla4fx(0):= nabla4fx(i); --
|
142 |
|
|
|
143 |
|
|
i:=1;
|
144 |
|
|
indice <= indice+1;
|
145 |
|
|
end if;
|
146 |
|
|
|
147 |
|
|
end process;
|
148 |
|
|
indice_p_o <= std_logic_vector(to_signed(indice));
|
149 |
|
|
--------------------------------------------------------------------------------------------------------------
|
150 |
|
|
process(clk_i)
|
151 |
|
|
begin
|
152 |
|
|
if(falling_edge(clk_i)) then
|
153 |
|
|
sram <= ram(indice);
|
154 |
|
|
end if;
|
155 |
|
|
end process;
|
156 |
|
|
-----------------------------------------------------------------------------------------------------------------
|
157 |
|
|
end grenew;
|