1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
@@ -0,0 +1,19 | |||||
|
1 | #include <stdio.h> | |||
|
2 | #include "lpp_apb_functions.h" | |||
|
3 | #include "apb_uart_Driver.h" | |||
|
4 | ||||
|
5 | ||||
|
6 | int main() | |||
|
7 | { | |||
|
8 | printf("Debut Main\n\n"); | |||
|
9 | UART_Device* dev = openUART(0); | |||
|
10 | printf("addr: %x\n",(unsigned int)dev); | |||
|
11 | printf("cfg: %x\n",dev->ConfigReg); | |||
|
12 | char* a = "hello world\n"; | |||
|
13 | uartputs(dev,a); | |||
|
14 | printf("Try #1 done\n"); | |||
|
15 | uartputs(dev,"salut monde\n"); | |||
|
16 | printf("Try #2 done\n"); | |||
|
17 | return 0; | |||
|
18 | } | |||
|
19 |
@@ -0,0 +1,60 | |||||
|
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 : Martin Morlot | |||
|
20 | -- Mail : martin.morlot@lpp.polytechnique.fr | |||
|
21 | -----------------------------------------------------------------------------*/ | |||
|
22 | #ifndef APB_CNA_DRIVER_H | |||
|
23 | #define APB_CNA_DRIVER_H | |||
|
24 | ||||
|
25 | #define DAC_ready 3 | |||
|
26 | #define DAC_enable 1 | |||
|
27 | #define DAC_disable 0 | |||
|
28 | ||||
|
29 | ||||
|
30 | /*=================================================== | |||
|
31 | T Y P E S D E F | |||
|
32 | ====================================================*/ | |||
|
33 | ||||
|
34 | /** Structure reprοΏ½sentant le registre du CNA */ | |||
|
35 | struct DAC_Driver | |||
|
36 | { | |||
|
37 | int configReg; /**< Registre de configuration: Flag Ready [1] ; Flag Enable [0] */ | |||
|
38 | int dataReg; /**< Registre de donnοΏ½e sur 16 bits */ | |||
|
39 | }; | |||
|
40 | ||||
|
41 | typedef struct DAC_Driver DAC_Device; | |||
|
42 | ||||
|
43 | /*=================================================== | |||
|
44 | F U N C T I O N S | |||
|
45 | ====================================================*/ | |||
|
46 | ||||
|
47 | /** Ouvre l'accοΏ½ au CNA */ | |||
|
48 | DAC_Device* DacOpen(int count); | |||
|
49 | ||||
|
50 | //DAC_Device* DacClose(int count); | |||
|
51 | ||||
|
52 | /** Les donnοΏ½es sont lus a partir d'un tableau pour obtenir le signal de CAL (10Khz + 625hz) */ | |||
|
53 | int DacTable(); | |||
|
54 | ||||
|
55 | /** Les donnοΏ½es sont entrοΏ½e par l'utilisateur, la conversion se fait a chaque nouvelle donnοΏ½e */ | |||
|
56 | int DacConst(); | |||
|
57 | ||||
|
58 | ||||
|
59 | ||||
|
60 | #endif |
@@ -0,0 +1,60 | |||||
|
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 : Martin Morlot | |||
|
20 | -- Mail : martin.morlot@lpp.polytechnique.fr | |||
|
21 | -----------------------------------------------------------------------------*/ | |||
|
22 | #include "apb_uart_Driver.h" | |||
|
23 | #include "lpp_apb_functions.h" | |||
|
24 | #include <stdio.h> | |||
|
25 | ||||
|
26 | ||||
|
27 | UART_Device* openUART(int count) | |||
|
28 | { | |||
|
29 | UART_Device* uart0; | |||
|
30 | uart0 = (UART_Device*) apbgetdevice(LPP_UART_CTRLR,VENDOR_LPP,count); | |||
|
31 | uart0->ConfigReg = BaudGenOnDuty; | |||
|
32 | return uart0; | |||
|
33 | } | |||
|
34 | ||||
|
35 | ||||
|
36 | void uartputc(UART_Device* dev,char c) | |||
|
37 | { | |||
|
38 | //while (!(dev->ConfigReg & (1<<5))); | |||
|
39 | while (!((dev->ConfigReg & DataSended) == DataSended)); | |||
|
40 | dev->DataWReg = c; | |||
|
41 | printf(" "); | |||
|
42 | } | |||
|
43 | ||||
|
44 | void uartputs(UART_Device* dev,char* s) | |||
|
45 | { | |||
|
46 | while (*s) uartputc(dev,*(s++)); | |||
|
47 | } | |||
|
48 | ||||
|
49 | char uartgetc(UART_Device* dev) | |||
|
50 | { | |||
|
51 | //while (!((dev->ConfigReg & (1<<2)))); | |||
|
52 | while (!((dev->ConfigReg & NewData) == NewData)); | |||
|
53 | return dev->DataRReg; | |||
|
54 | } | |||
|
55 | ||||
|
56 | void uartgets(UART_Device* dev,char* s) | |||
|
57 | { | |||
|
58 | while (*s && (*s!=0xd)) *s++ = uartgetc(dev); | |||
|
59 | } | |||
|
60 |
@@ -0,0 +1,56 | |||||
|
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 : Martin Morlot | |||
|
20 | -- Mail : martin.morlot@lpp.polytechnique.fr | |||
|
21 | -----------------------------------------------------------------------------*/ | |||
|
22 | #ifndef APB_UART_DRIVER_H | |||
|
23 | #define APB_UART_DRIVER_H | |||
|
24 | ||||
|
25 | ||||
|
26 | #define BaudGenOnDuty 0 | |||
|
27 | #define DataSended 0x10 | |||
|
28 | #define NewData 0x100 | |||
|
29 | ||||
|
30 | /*=================================================== | |||
|
31 | T Y P E S D E F | |||
|
32 | ====================================================*/ | |||
|
33 | ||||
|
34 | struct UART_Driver | |||
|
35 | { | |||
|
36 | int ConfigReg; | |||
|
37 | int DataWReg; | |||
|
38 | int DataRReg; | |||
|
39 | }; | |||
|
40 | ||||
|
41 | typedef struct UART_Driver UART_Device; | |||
|
42 | ||||
|
43 | ||||
|
44 | /*=================================================== | |||
|
45 | F U N C T I O N S | |||
|
46 | ====================================================*/ | |||
|
47 | ||||
|
48 | ||||
|
49 | UART_Device* openUART(int count); | |||
|
50 | void uartputc(UART_Device* dev,char c); | |||
|
51 | void uartputs(UART_Device* dev,char* s); | |||
|
52 | char uartgetc(UART_Device* dev); | |||
|
53 | void uartgets(UART_Device* dev,char* s); | |||
|
54 | ||||
|
55 | ||||
|
56 | #endif |
@@ -1,26 +1,27 | |||||
1 | #------------------------------------------------------------------------------ |
|
1 | #------------------------------------------------------------------------------ | |
2 | #-- This file is a part of the LPP VHDL IP LIBRARY |
|
2 | #-- This file is a part of the LPP VHDL IP LIBRARY | |
3 | #-- Copyright (C) 2010, Laboratory of Plasmas Physic - CNRS |
|
3 | #-- Copyright (C) 2010, Laboratory of Plasmas Physic - CNRS | |
4 | #-- |
|
4 | #-- | |
5 | #-- This program is free software; you can redistribute it and/or modify |
|
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 |
|
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 |
|
7 | #-- the Free Software Foundation; either version 3 of the License, or | |
8 | #-- (at your option) any later version. |
|
8 | #-- (at your option) any later version. | |
9 | #-- |
|
9 | #-- | |
10 | #-- This program is distributed in the hope that it will be useful, |
|
10 | #-- This program is distributed in the hope that it will be useful, | |
11 | #-- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | #-- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | #-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | #-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | #-- GNU General Public License for more details. |
|
13 | #-- GNU General Public License for more details. | |
14 | #-- |
|
14 | #-- | |
15 | #-- You should have received a copy of the GNU General Public License |
|
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 |
|
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 |
|
17 | #-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | #------------------------------------------------------------------------------ |
|
18 | #------------------------------------------------------------------------------ | |
19 |
|
19 | |||
20 |
|
20 | |||
21 |
|
21 | |||
22 | all: |
|
22 | all: | |
23 | make all -C ScanAPB |
|
23 | make all -C ScanAPB | |
24 | make all -C APB_lcd_ctrlr |
|
24 | make all -C APB_lcd_ctrlr | |
25 | make all -C BenchFIFO |
|
25 | make all -C BenchFIFO | |
|
26 | make all -C BenchUART | |||
26 |
|
27 |
@@ -1,36 +1,38 | |||||
1 | #------------------------------------------------------------------------------ |
|
1 | #------------------------------------------------------------------------------ | |
2 | #-- This file is a part of the LPP VHDL IP LIBRARY |
|
2 | #-- This file is a part of the LPP VHDL IP LIBRARY | |
3 | #-- Copyright (C) 2010, Laboratory of Plasmas Physic - CNRS |
|
3 | #-- Copyright (C) 2010, Laboratory of Plasmas Physic - CNRS | |
4 | #-- |
|
4 | #-- | |
5 | #-- This program is free software; you can redistribute it and/or modify |
|
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 |
|
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 |
|
7 | #-- the Free Software Foundation; either version 3 of the License, or | |
8 | #-- (at your option) any later version. |
|
8 | #-- (at your option) any later version. | |
9 | #-- |
|
9 | #-- | |
10 | #-- This program is distributed in the hope that it will be useful, |
|
10 | #-- This program is distributed in the hope that it will be useful, | |
11 | #-- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | #-- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | #-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | #-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | #-- GNU General Public License for more details. |
|
13 | #-- GNU General Public License for more details. | |
14 | #-- |
|
14 | #-- | |
15 | #-- You should have received a copy of the GNU General Public License |
|
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 |
|
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 |
|
17 | #-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | #------------------------------------------------------------------------------ |
|
18 | #------------------------------------------------------------------------------ | |
19 |
|
19 | |||
20 | include ../rules.mk |
|
20 | include ../rules.mk | |
21 |
|
21 | |||
22 |
|
22 | |||
23 |
|
23 | |||
24 | all: |
|
24 | all: | |
25 | make all -C AMBA |
|
25 | make all -C AMBA | |
26 | make all -C LCD |
|
26 | make all -C LCD | |
27 | make all -C DAC |
|
27 | make all -C DAC | |
28 | make all -C FIFO |
|
28 | make all -C FIFO | |
|
29 | make all -C UART | |||
29 |
|
30 | |||
30 |
|
31 | |||
31 | cleanall: |
|
32 | cleanall: | |
32 | make clean -C AMBA |
|
33 | make clean -C AMBA | |
33 | make clean -C LCD |
|
34 | make clean -C LCD | |
34 | make clean -C DAC |
|
35 | make clean -C DAC | |
35 | make clean -C FIFO |
|
36 | make clean -C FIFO | |
|
37 | make clean -C UART | |||
36 |
|
38 |
@@ -1,115 +1,115 | |||||
1 | ------------------------------------------------------------------------------ |
|
1 | ------------------------------------------------------------------------------ | |
2 | -- This file is a part of the LPP VHDL IP LIBRARY |
|
2 | -- This file is a part of the LPP VHDL IP LIBRARY | |
3 | -- Copyright (C) 2009 - 2010, Laboratory of Plasmas Physic - CNRS |
|
3 | -- Copyright (C) 2009 - 2010, Laboratory of Plasmas Physic - CNRS | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
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 |
|
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 |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
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 |
|
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 |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | ------------------------------------------------------------------------------- |
|
18 | ------------------------------------------------------------------------------- | |
19 | -- Author : Alexis Jeandet |
|
19 | -- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@lpp.polytechnique.fr |
|
20 | -- Mail : alexis.jeandet@lpp.polytechnique.fr | |
21 | ---------------------------------------------------------------------------- |
|
21 | ---------------------------------------------------------------------------- | |
22 | library IEEE; |
|
22 | library IEEE; | |
23 | use IEEE.numeric_std.all; |
|
23 | use IEEE.numeric_std.all; | |
24 | use IEEE.std_logic_1164.all; |
|
24 | use IEEE.std_logic_1164.all; | |
25 |
|
25 | |||
26 | --! Gestion Reception/Transmission |
|
26 | --! Gestion Reception/Transmission | |
27 |
|
27 | |||
28 | entity Shift_REG is |
|
28 | entity Shift_REG is | |
29 | generic(Data_sz : integer := 10); |
|
29 | generic(Data_sz : integer := 10); | |
30 | port( |
|
30 | port( | |
31 | clk : in std_logic; |
|
31 | clk : in std_logic; | |
32 | Sclk : in std_logic; |
|
32 | Sclk : in std_logic; | |
33 | reset : in std_logic; |
|
33 | reset : in std_logic; | |
34 | SIN : in std_logic; |
|
34 | SIN : in std_logic; | |
35 | SOUT : out std_logic; |
|
35 | SOUT : out std_logic; | |
36 | Serialize : in std_logic; |
|
36 | Serialize : in std_logic; | |
37 | Serialized : out std_logic; |
|
37 | Serialized : out std_logic; | |
38 | D : in std_logic_vector(Data_sz-1 downto 0); |
|
38 | D : in std_logic_vector(Data_sz-1 downto 0); | |
39 | Q : out std_logic_vector(Data_sz-1 downto 0) |
|
39 | Q : out std_logic_vector(Data_sz-1 downto 0) | |
40 | ); |
|
40 | ); | |
41 | end entity; |
|
41 | end entity; | |
42 |
|
42 | |||
43 |
|
43 | |||
44 | architecture ar_Shift_REG of Shift_REG is |
|
44 | architecture ar_Shift_REG of Shift_REG is | |
45 |
|
45 | |||
46 | signal REG : std_logic_vector(Data_sz-1 downto 0); |
|
46 | signal REG : std_logic_vector(Data_sz-1 downto 0); | |
47 | signal Serialized_int : std_logic; |
|
47 | signal Serialized_int : std_logic; | |
48 | signal Serialize_reg : std_logic; |
|
48 | signal Serialize_reg : std_logic; | |
49 | signal Serial_reg : std_logic; |
|
49 | signal Serial_reg : std_logic; | |
50 | signal CptBits : std_logic_vector(Data_sz-1 downto 0); |
|
50 | signal CptBits : std_logic_vector(Data_sz-1 downto 0); | |
51 | constant CptBits_trig : std_logic_vector(Data_sz-1 downto 0) := (others => '1'); |
|
51 | constant CptBits_trig : std_logic_vector(Data_sz-1 downto 0) := (others => '1'); | |
52 | signal CptBits_flag : std_logic; |
|
52 | signal CptBits_flag : std_logic; | |
53 | signal CptBits_flag_reg : std_logic; |
|
53 | signal CptBits_flag_reg : std_logic; | |
54 |
|
54 | |||
55 | begin |
|
55 | begin | |
56 |
|
56 | |||
57 | Serialized <= Serialized_int; |
|
57 | Serialized <= Serialized_int; | |
58 | CptBits_flag <= '1' when CptBits = CptBits_trig else '0'; |
|
58 | CptBits_flag <= '1' when CptBits = CptBits_trig else '0'; | |
59 |
|
59 | |||
60 | process(reset,clk) |
|
60 | process(reset,clk) | |
61 | begin |
|
61 | begin | |
62 | if reset = '0' then |
|
62 | if reset = '0' then | |
63 | Serialized_int <= '1'; |
|
63 | Serialized_int <= '1'; | |
64 | CptBits_flag_reg <= '0'; |
|
64 | CptBits_flag_reg <= '0'; | |
65 | Serial_reg <= '0'; |
|
65 | Serial_reg <= '0'; | |
66 | Q <= (others => '0'); |
|
66 | Q <= (others => '0'); | |
67 | elsif clk'event and clk = '1' then |
|
67 | elsif clk'event and clk = '1' then | |
68 | CptBits_flag_reg <= CptBits_flag; |
|
68 | CptBits_flag_reg <= CptBits_flag; | |
69 | Serial_reg <= Serialize; |
|
69 | Serial_reg <= Serialize; | |
70 |
|
70 | |||
71 | if CptBits_flag = '1' and CptBits_flag_reg = '0' then |
|
71 | if CptBits_flag = '1' and CptBits_flag_reg = '0' then | |
72 | Serialized_int <= '1'; |
|
72 | Serialized_int <= '1'; | |
73 | Q <= REG; |
|
73 | Q <= REG; | |
74 | elsif(Serial_reg='0' and Serialize='1')then |
|
74 | elsif(Serial_reg='0' and Serialize='1')then | |
75 | Serialized_int <= '0'; |
|
75 | Serialized_int <= '0'; | |
76 | end if; |
|
76 | end if; | |
77 | end if; |
|
77 | end if; | |
78 | end process; |
|
78 | end process; | |
79 |
|
79 | |||
80 |
|
80 | |||
81 | process(reset,Sclk) |
|
81 | process(reset,Sclk) | |
82 | begin |
|
82 | begin | |
83 | if reset = '0' then |
|
83 | if reset = '0' then | |
84 | CptBits <= (others => '0'); |
|
84 | CptBits <= (others => '0'); | |
85 | REG <= (others => '0'); |
|
85 | REG <= (others => '0'); | |
86 | SOUT <= '1'; |
|
86 | SOUT <= '1'; | |
87 | Serialize_reg <= '0'; |
|
87 | Serialize_reg <= '0'; | |
88 | elsif Sclk'event and Sclk = '1' then |
|
88 | elsif Sclk'event and Sclk = '1' then | |
89 | Serialize_reg <= Serialized_int; |
|
89 | Serialize_reg <= Serialized_int; | |
90 | if (Serialized_int = '0' and Serialize_reg ='1') then |
|
90 | if (Serialized_int = '0' and Serialize_reg ='1') then | |
91 | REG <= SIN & D(Data_sz-1 downto 1); |
|
91 | REG <= SIN & D(Data_sz-1 downto 1); | |
92 | SOUT <= D(0); |
|
92 | SOUT <= D(0); | |
93 | elsif CptBits_flag ='1' then |
|
93 | -- elsif CptBits_flag ='1' then | |
94 | REG <= SIN & D(Data_sz-1 downto 1); |
|
94 | -- REG <= SIN & D(Data_sz-1 downto 1); | |
95 | SOUT <= D(0); |
|
95 | -- SOUT <= D(0); | |
96 | elsif Serialized_int = '0' then |
|
96 | elsif Serialized_int = '0' then | |
97 | REG <= SIN & REG(Data_sz-1 downto 1); |
|
97 | REG <= SIN & REG(Data_sz-1 downto 1); | |
98 | SOUT <= REG(0); |
|
98 | SOUT <= REG(0); | |
99 | else |
|
99 | else | |
100 | SOUT <= '1'; |
|
100 | SOUT <= '1'; | |
101 | end if; |
|
101 | end if; | |
102 | if Serialized_int = '0' then |
|
102 | if Serialized_int = '0' then | |
103 | if CptBits_flag = '1' then |
|
103 | if CptBits_flag = '1' then | |
104 | CptBits <= (others => '0'); |
|
104 | CptBits <= (others => '0'); | |
105 | else |
|
105 | else | |
106 | CptBits <= '1' & CptBits(Data_sz-1 downto 1); |
|
106 | CptBits <= '1' & CptBits(Data_sz-1 downto 1); | |
107 | end if; |
|
107 | end if; | |
108 | else |
|
108 | else | |
109 | CptBits <= (others => '0'); |
|
109 | CptBits <= (others => '0'); | |
110 | end if; |
|
110 | end if; | |
111 |
|
111 | |||
112 | end if; |
|
112 | end if; | |
113 | end process; |
|
113 | end process; | |
114 |
|
114 | |||
115 | end ar_Shift_REG; |
|
115 | end ar_Shift_REG; |
@@ -1,106 +1,106 | |||||
1 | ------------------------------------------------------------------------------ |
|
1 | ------------------------------------------------------------------------------ | |
2 | -- This file is a part of the LPP VHDL IP LIBRARY |
|
2 | -- This file is a part of the LPP VHDL IP LIBRARY | |
3 | -- Copyright (C) 2009 - 2010, Laboratory of Plasmas Physic - CNRS |
|
3 | -- Copyright (C) 2009 - 2010, Laboratory of Plasmas Physic - CNRS | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
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 |
|
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 |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
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 |
|
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 |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | ------------------------------------------------------------------------------- |
|
18 | ------------------------------------------------------------------------------- | |
19 | -- Author : Alexis Jeandet |
|
19 | -- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@lpp.polytechnique.fr |
|
20 | -- Mail : alexis.jeandet@lpp.polytechnique.fr | |
21 | ---------------------------------------------------------------------------- |
|
21 | ---------------------------------------------------------------------------- | |
22 | library IEEE; |
|
22 | library IEEE; | |
23 | use IEEE.numeric_std.all; |
|
23 | use IEEE.numeric_std.all; | |
24 | use IEEE.std_logic_1164.all; |
|
24 | use IEEE.std_logic_1164.all; | |
25 | library lpp; |
|
25 | library lpp; | |
26 | use lpp.lpp_uart.all; |
|
26 | use lpp.lpp_uart.all; | |
27 |
|
27 | |||
28 | --! Programme qui va gerer toute la communication entre le PC et le FPGA |
|
28 | --! Programme qui va gerer toute la communication entre le PC et le FPGA | |
29 |
|
29 | |||
30 | entity UART is |
|
30 | entity UART is | |
31 | generic(Data_sz : integer := 8); --! Constante de taille pour un mot de donnee |
|
31 | generic(Data_sz : integer := 8); --! Constante de taille pour un mot de donnee | |
32 | port( |
|
32 | port( | |
33 | clk : in std_logic; --! Horloge a 25Mhz du systeme |
|
33 | clk : in std_logic; --! Horloge a 25Mhz du systeme | |
34 | reset : in std_logic; --! Reset du systeme |
|
34 | reset : in std_logic; --! Reset du systeme | |
35 | TXD : out std_logic; --! Transmission, cote PC |
|
35 | TXD : out std_logic; --! Transmission, cote PC | |
36 | RXD : in std_logic; --! Reception, cote PC |
|
36 | RXD : in std_logic; --! Reception, cote PC | |
37 | Capture : in std_logic; --! "Reset" cible pour le generateur de bauds, ici indissocie du reset global |
|
37 | Capture : in std_logic; --! "Reset" cible pour le generateur de bauds, ici indissocie du reset global | |
38 | NwDat : out std_logic; --! Flag, Nouvelle donnee presente |
|
38 | NwDat : out std_logic; --! Flag, Nouvelle donnee presente | |
39 | ACK : in std_logic; --! Flag, Reponse au flag precedent |
|
39 | ACK : in std_logic; --! Flag, Reponse au flag precedent | |
40 | Send : in std_logic; --! Flag, Demande d'envoi sur le bus |
|
40 | Send : in std_logic; --! Flag, Demande d'envoi sur le bus | |
41 | Sended : out std_logic; --! Flag, Envoi termine |
|
41 | Sended : out std_logic; --! Flag, Envoi termine | |
42 | BTrigger : out std_logic_vector(11 downto 0); --! Registre contenant la valeur du diviseur de frequence pour la transmission |
|
42 | BTrigger : out std_logic_vector(11 downto 0); --! Registre contenant la valeur du diviseur de frequence pour la transmission | |
43 | RDATA : out std_logic_vector(Data_sz-1 downto 0); --! Mot de donnee en provenance de l'utilisateur |
|
43 | RDATA : out std_logic_vector(Data_sz-1 downto 0); --! Mot de donnee en provenance de l'utilisateur | |
44 | WDATA : in std_logic_vector(Data_sz-1 downto 0) --! Mot de donnee a transmettre a l'utilisateur |
|
44 | WDATA : in std_logic_vector(Data_sz-1 downto 0) --! Mot de donnee a transmettre a l'utilisateur | |
45 | ); |
|
45 | ); | |
46 | end entity; |
|
46 | end entity; | |
47 |
|
47 | |||
48 | --! @details Gestion de la Reception/Transmission donc de la Vectorisation/Serialisation |
|
48 | --! @details Gestion de la Reception/Transmission donc de la Vectorisation/Serialisation | |
49 | --! ainsi que la detection et le reglage de le frequence de transmission optimale sur le bus (Generateur de Bauds) |
|
49 | --! ainsi que la detection et le reglage de le frequence de transmission optimale sur le bus (Generateur de Bauds) | |
50 |
|
50 | |||
51 | architecture ar_UART of UART is |
|
51 | architecture ar_UART of UART is | |
52 | signal Bclk : std_logic; |
|
52 | signal Bclk : std_logic; | |
53 |
|
53 | |||
54 | signal RDATA_int : std_logic_vector(Data_sz+1 downto 0); |
|
54 | signal RDATA_int : std_logic_vector(Data_sz+1 downto 0); | |
55 | signal WDATA_int : std_logic_vector(Data_sz+1 downto 0); |
|
55 | signal WDATA_int : std_logic_vector(Data_sz+1 downto 0); | |
56 |
|
56 | |||
57 | signal TXD_Dummy : std_logic; |
|
57 | signal TXD_Dummy : std_logic; | |
58 | signal NwDat_int : std_logic; |
|
58 | signal NwDat_int : std_logic; | |
59 | signal NwDat_int_reg : std_logic; |
|
59 | signal NwDat_int_reg : std_logic; | |
60 | signal receive : std_logic; |
|
60 | signal receive : std_logic; | |
61 | constant zeroVect : std_logic_vector(Data_sz+1 downto 0) := (others => '0'); |
|
61 | constant zeroVect : std_logic_vector(Data_sz+1 downto 0) := (others => '0'); | |
62 |
|
62 | |||
63 | begin |
|
63 | begin | |
64 |
|
64 | |||
65 |
|
65 | |||
66 |
|
66 | |||
67 | WDATA_int <= '1' & WDATA & '0'; |
|
67 | WDATA_int <= '1' & WDATA & '0'; | |
68 |
|
68 | |||
69 | BaudGenerator : BaudGen |
|
69 | BaudGenerator : entity work.BaudGen | |
70 | port map(clk,reset,Capture,Bclk,RXD,BTrigger); |
|
70 | port map(clk,reset,Capture,Bclk,RXD,BTrigger); | |
71 |
|
71 | |||
72 |
|
72 | |||
73 | RX_REG : Shift_REG |
|
73 | RX_REG : entity work.Shift_REG | |
74 | generic map(Data_sz+2) |
|
74 | generic map(Data_sz+2) | |
75 | port map(clk,Bclk,reset,RXD,TXD_Dummy,receive,NwDat_int,zeroVect,RDATA_int); |
|
75 | port map(clk,Bclk,reset,RXD,TXD_Dummy,receive,NwDat_int,zeroVect,RDATA_int); | |
76 |
|
76 | |||
77 | TX_REG : Shift_REG |
|
77 | TX_REG : entity work.Shift_REG | |
78 | generic map(Data_sz+2) |
|
78 | generic map(Data_sz+2) | |
79 | port map(clk,Bclk,reset,'1',TXD,Send,Sended,WDATA_int); |
|
79 | port map(clk,Bclk,reset,'1',TXD,Send,Sended,WDATA_int); | |
80 |
|
80 | |||
81 |
|
81 | |||
82 |
|
82 | |||
83 | process(clk,reset) |
|
83 | process(clk,reset) | |
84 | begin |
|
84 | begin | |
85 | if reset = '0' then |
|
85 | if reset = '0' then | |
86 | NwDat <= '0'; |
|
86 | NwDat <= '0'; | |
87 | elsif clk'event and clk = '1' then |
|
87 | elsif clk'event and clk = '1' then | |
88 | NwDat_int_reg <= NwDat_int; |
|
88 | NwDat_int_reg <= NwDat_int; | |
89 | if RXD = '1' and NwDat_int = '1' then |
|
89 | if RXD = '1' and NwDat_int = '1' then | |
90 | receive <= '0'; |
|
90 | receive <= '0'; | |
91 | elsif RXD = '0' then |
|
91 | elsif RXD = '0' then | |
92 | receive <= '1'; |
|
92 | receive <= '1'; | |
93 | end if; |
|
93 | end if; | |
94 | if NwDat_int_reg = '0' and NwDat_int = '1' then |
|
94 | if NwDat_int_reg = '0' and NwDat_int = '1' then | |
95 | NwDat <= '1'; |
|
95 | NwDat <= '1'; | |
96 | RDATA <= RDATA_int(8 downto 1); |
|
96 | RDATA <= RDATA_int(8 downto 1); | |
97 | elsif ack = '1' then |
|
97 | elsif ack = '1' then | |
98 | NwDat <= '0'; |
|
98 | NwDat <= '0'; | |
99 | end if; |
|
99 | end if; | |
100 | end if; |
|
100 | end if; | |
101 | end process; |
|
101 | end process; | |
102 |
|
102 | |||
103 | end ar_UART; |
|
103 | end ar_UART; | |
104 |
|
104 | |||
105 |
|
105 | |||
106 |
|
106 |
General Comments 0
You need to be logged in to leave comments.
Login now