Free VHDL library

  • Main Page
  • Related Pages
  • Design Unit List
  • Files
  • File List

lpp_cna/Serialize.vhd

Go to the documentation of this file.
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 : Martin Morlot
00020 --                     Mail : martin.morlot@lpp.polytechnique.fr
00021 ------------------------------------------------------------------------------
00022 library IEEE;
00023 use IEEE.numeric_std.all;
00024 use IEEE.std_logic_1164.all;
00025 
00027 
00028 entity Serialize is
00029   port(
00030     clk,raz : in std_logic;
00031     sclk    : in std_logic;
00032     vectin  : in std_logic_vector(15 downto 0);
00033     send    : in std_logic;
00034     sended  : out std_logic;
00035     Data    : out std_logic
00036     );
00037 end Serialize;
00038 
00039 
00040 architecture ar_Serialize of Serialize is
00041 
00042 type etat is (attente,serialize);
00043 signal ect      : etat;
00044 
00045 signal vector_int   : std_logic_vector(16 downto 0);
00046 signal vectin_reg   : std_logic_vector(15 downto 0);
00047 signal load         : std_logic;
00048 signal N            : integer range 0 to 16;
00049 signal CPT_ended    : std_logic:='0';
00050 
00051 begin
00052     process(clk,raz)
00053         begin
00054         if(raz='0')then           
00055             ect         <= attente;
00056             vectin_reg  <= (others=> '0');
00057             load        <= '0';
00058             sended      <= '1';            
00059 
00060         elsif(clk'event and clk='1')then
00061             vectin_reg <= vectin;
00062           
00063             case ect is
00064                 when attente =>                     
00065                     if (send='1') then 
00066                         sended  <= '0'; 
00067                         load    <= '1';                   
00068                         ect     <= serialize;                        
00069                     else
00070                         ect <= attente;                       
00071                     end if;
00072                 
00073                 when serialize => 
00074                     load <= '0';                    
00075                     if(CPT_ended='1')then 
00076                         ect     <= attente;
00077                         sended  <= '1';                        
00078                     end if;
00079 
00080             end case;
00081         end if;
00082     end process;
00083 
00084     process(sclk,load,raz)
00085         begin
00086         if (raz='0')then
00087             vector_int <= (others=> '0');
00088             N <= 16;
00089         elsif(load='1')then
00090             vector_int <= vectin & '0';
00091             N <= 0;
00092         elsif(sclk'event and sclk='1')then        
00093             if (CPT_ended='0') then
00094                 vector_int <= vector_int(15 downto 0) & '0'; 
00095                 N <= N+1;
00096             end if; 
00097         end if;
00098     end process;
00099 
00100 CPT_ended   <=  '1' when N = 16 else '0';
00101 
00102 with ect select
00103     Data <=  vector_int(16) when serialize,
00104             '0' when others;
00105      
00106 end ar_Serialize;
00107             

© Copyright 2011 LPP-CNRS | Design by Alexis Jeandet