00001 ------------------------------------------------------------------------------ 00002 -- This file is a part of the LPP VHDL IP LIBRARY 00003 -- Copyright (C) 2009 - 2010, Laboratory of Plasmas Physic - CNRS 00004 -- 00005 -- This program is free software; you can redistribute it and/or modify 00006 -- it under the terms of the GNU General Public License as published by 00007 -- the Free Software Foundation; either version 3 of the License, or 00008 -- (at your option) any later version. 00009 -- 00010 -- This program is distributed in the hope that it will be useful, 00011 -- but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 -- GNU General Public License for more details. 00014 -- 00015 -- You should have received a copy of the GNU General Public License 00016 -- along with this program; if not, write to the Free Software 00017 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 ------------------------------------------------------------------------------- 00019 -- Author : Alexis Jeandet 00020 -- Mail : alexis.jeandet@lpp.polytechnique.fr 00021 ---------------------------------------------------------------------------- 00022 library IEEE; 00023 use IEEE.STD_LOGIC_1164.ALL; 00024 library lpp; 00025 use lpp.lpp_ad_conv.all; 00026 use lpp.general_purpose.Clk_divider; 00027 00028 00032 00033 entity AD7688_drvr is 00034 generic( 00035 ChanelCount :integer; 00036 clkkHz :integer 00037 ); 00038 Port( 00039 clk : in STD_LOGIC; 00040 reset : in STD_LOGIC; 00041 smplClk : in STD_LOGIC; 00042 DataReady : out std_logic; 00043 smpout : out Samples_out(ChanelCount-1 downto 0); 00044 AD_in : in AD7688_in(ChanelCount-1 downto 0); 00045 AD_out : out AD7688_out 00046 ); 00047 end AD7688_drvr; 00048 00049 architecture ar_AD7688_drvr of AD7688_drvr is 00050 00051 constant convTrigger : integer:= clkkHz*16/10000; --tconv = 1.6µs 00052 00053 signal i : integer range 0 to convTrigger :=0; 00054 signal clk_int : std_logic; 00055 signal smplClk_reg : std_logic; 00056 signal cnv_int : std_logic; 00057 00058 begin 00059 00060 clkdiv: if clkkHz>=66000 generate 00061 clkdivider: Clk_divider 00062 generic map(clkkHz*1000,60000000) 00063 Port map( clk ,reset,clk_int); 00064 end generate; 00065 00066 clknodiv: if clkkHz<66000 generate 00067 nodiv: clk_int <= clk; 00068 end generate; 00069 00070 AD_out.CNV <= cnv_int; 00071 AD_out.SCK <= clk_int; 00072 00073 00074 sckgen: process(clk,reset) 00075 begin 00076 if reset = '0' then 00077 i <= 0; 00078 cnv_int <= '0'; 00079 smplClk_reg <= '0'; 00080 elsif clk'event and clk = '1' then 00081 if smplClk = '1' and smplClk_reg = '0' then 00082 if i = convTrigger then 00083 smplClk_reg <= '1'; 00084 i <= 0; 00085 cnv_int <= '0'; 00086 else 00087 i <= i+1; 00088 cnv_int <= '1'; 00089 end if; 00090 elsif smplClk = '0' and smplClk_reg = '1' then 00091 smplClk_reg <= '0'; 00092 end if; 00093 end if; 00094 end process; 00095 00096 00097 00098 spidrvr: AD7688_spi_if 00099 generic map(ChanelCount) 00100 Port map(clk_int,reset,cnv_int,DataReady,AD_in,smpout); 00101 00102 00103 00104 end ar_AD7688_drvr; 00105 00106 00107 00108 00109 00110
© Copyright 2011 LPP-CNRS | Design by Alexis Jeandet