##// END OF EJS Templates
Correction ADS TestModule
pellion -
r151:5bc2697e3c21 JC
parent child
Show More
@@ -1,70 +1,70
1 1 ------------------------------------------------------------------------------
2 2 -- This file is a part of the LPP VHDL IP LIBRARY
3 3 -- Copyright (C) 2009 - 2010, Laboratory of Plasmas Physic - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 3 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------
19 19 -- Author : Jean-christophe PELLION
20 20 -- Mail : jean-christophe.pellion@lpp.polytechnique.fr
21 21 -------------------------------------------------------------------------------
22 22 LIBRARY IEEE;
23 23 USE IEEE.STD_LOGIC_1164.ALL;
24 24 USE IEEE.std_logic_arith.ALL;
25 25 USE IEEE.std_logic_signed.ALL;
26 26 USE IEEE.MATH_real.ALL;
27 27
28 28 ENTITY TestModule_ADS7886 IS
29 29 GENERIC (
30 30 freq : INTEGER := 24;
31 31 amplitude : INTEGER := 3000;
32 32 impulsion : INTEGER := 0 -- 1 => impulsion generation
33 33 );
34 34 PORT (
35 35 -- CONV --
36 36 cnv_run : IN STD_LOGIC;
37 37 cnv : IN STD_LOGIC;
38 38
39 39 -- DATA --
40 40 sck : IN STD_LOGIC;
41 41 sdo : OUT STD_LOGIC
42 42 );
43 43 END TestModule_ADS7886;
44 44
45 45 ARCHITECTURE beh OF TestModule_ADS7886 IS
46 46 SIGNAL reg : STD_LOGIC_VECTOR(15 DOWNTO 0);
47 47 SIGNAL n : INTEGER := 0;
48 48 BEGIN -- beh
49 49
50 50 PROCESS (cnv, sck)
51 51 BEGIN -- PROCESS
52 52 IF cnv = '0' AND cnv'EVENT THEN
53 53 n <= n + 1;
54 54 IF impulsion = 1 THEN
55 55 IF n = 1 THEN
56 56 reg <= conv_std_logic_vector(integer(REAL(amplitude)) , 16);
57 57 ELSE
58 58 reg <= conv_std_logic_vector(integer(REAL(0)) , 16);
59 59 END IF;
60 60 ELSE
61 61 reg <= conv_std_logic_vector(integer(REAL(amplitude) * SIN(MATH_2_PI*REAL(n)/REAL(freq))) , 16);
62 62 END IF;
63 63 ELSIF sck'EVENT AND sck = '0' THEN -- rising clock edge
64 reg(15) <= 'X';
65 reg(14 DOWNTO 0) <= reg(15 DOWNTO 1);
64 reg(0) <= 'X';
65 reg(15 DOWNTO 1) <= reg(14 DOWNTO 0);
66 66 END IF;
67 67 END PROCESS;
68 sdo <= reg(0);
68 sdo <= reg(15);
69 69
70 70 END beh;
General Comments 0
You need to be logged in to leave comments. Login now