OpenCores
URL https://opencores.org/ocsvn/saturn/saturn/trunk

Subversion Repositories saturn

[/] [saturn/] [trunk/] [IPCommunication/] [rxtx_tb.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 DavidRAMBA
--============================================================================= 
2
--  TITRE : SWITCH
3
--  DESCRIPTION : 
4
--        - Gère la réception et la transmission d'une ligne série
5
--                       - Copie octet par octet du port Rx sur le port Tx
6
--        - Gestion du switch entre les sources Tx (recopie du port Rx sur Tx ou tranmission d'une trame)
7
--        - Buffurise les données reçues pendant la transmission                
8
 
9
--  FICHIER :        switch2.vhd 
10
--=============================================================================
11
--  CREATION 
12
--  DATE              AUTEUR    PROJET  REVISION 
13
--  10/04/2014  DRA        SATURN       V1.0 
14
--=============================================================================
15
--  HISTORIQUE  DES  MODIFICATIONS :
16
--  DATE              AUTEUR    PROJET  REVISION 
17
--  18/09/2014 DRA      SATURN   V1.1
18
--       Prise en comtpe du SW_ENA pour détecter l'inter trame
19
--=============================================================================
20
 
21
LIBRARY IEEE;
22
USE IEEE.STD_LOGIC_1164.ALL;
23
USE IEEE.STD_LOGIC_ARITH.ALL;
24
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
25
LIBRARY UNISIM;
26
USE UNISIM.VComponents.ALL;
27
 
28
ENTITY rxtx_tb IS
29
END rxtx_tb;
30
 
31
ARCHITECTURE rtl of rxtx_tb is
32
   SIGNAL rx_dat    : STD_LOGIC_VECTOR(7 downto 0);  -- Donnée reçue déserialisée
33
   SIGNAL val     : STD_LOGIC;                     -- Pulse d'écriture d'un nouveau caractère reçu
34
   SIGNAL rx_encours       : STD_LOGIC;                     -- Indique qu'une déserialisation est en cours
35
   SIGNAL ser_rdy          : STD_LOGIC;                     -- Le sérialisateur est prêt à traiter un nouveau car
36
   SIGNAL start_ser          : STD_LOGIC;                     -- Sélection de la source parallèle pour le sérialisateur (FIFO de copy ou transmission)
37
   CONSTANT nbbit_div   : INTEGER := 10;   -- Nombre de bits pour coder le diviseur d'horloge 
38
   SIGNAL clk_sys1      :  STD_LOGIC := '1';  -- Clock système
39
   SIGNAL clk_sys2      :  STD_LOGIC := '1';  -- Clock système
40
   SIGNAL rst_n         :  STD_LOGIC := '0';  -- Reset général système
41
   SIGNAL baud_lock     :  STD_LOGIC := '1';  -- Indique que le baudrate est calé
42
   SIGNAL tc_divclk     :  STD_LOGIC_VECTOR (nbbit_div-1 DOWNTO 0):= "0000000111"; -- Diviseur de l'horloge système pour le baudrate
43
   SIGNAL rx            :  STD_LOGIC;  -- Réception série    
44
   SIGNAL datatx        :  STD_LOGIC_VECTOR (7 DOWNTO 0) := x"00";  -- Prochaine donnée à transmettre
45
 
46
 
47
   COMPONENT serial_tx
48
        GENERIC (
49
      nbbit_div : INTEGER := 10);
50
   PORT(
51
                clk_sys     : IN std_logic;
52
                rst_n       : IN std_logic;
53
                tc_divclk   : IN std_logic_vector(nbbit_div-1 downto 0);
54
                start_ser   : IN std_logic;
55
                tx_dat      : IN std_logic_vector(7 downto 0);
56
                tx          : OUT std_logic;
57
                ser_rdy     : OUT std_logic
58
                );
59
        END COMPONENT;
60
 
61
   -- Composant de déserialisation
62
        COMPONENT serial_rx2
63
        GENERIC (
64
      nbbit_div : INTEGER := 10);
65
        PORT(
66
                clk_sys     : IN std_logic;
67
                rst_n       : IN std_logic;
68
      baud_lock   : IN  STD_LOGIC;
69
                tc_divclk   : IN std_logic_vector(nbbit_div-1 downto 0);
70
                rx          : IN std_logic;
71
                tx          : OUT std_logic;
72
      busy        : OUT STD_LOGIC;
73
                val         : OUT std_logic;
74
                rx_dat      : OUT std_logic_vector(7 downto 0)
75
                );
76
        END COMPONENT;
77
 
78
 
79
BEGIN
80
   clk_sys1 <= NOT(clk_sys1) AFTER 3999 ps;
81
   clk_sys2 <= NOT(clk_sys2) AFTER 4001 ps;
82
   rst_n <= '0', '1' after 10 ns;
83
 
84
   inst_serial_rx: serial_rx2
85
   GENERIC MAP (
86
      nbbit_div => nbbit_div)
87
   PORT MAP(
88
                clk_sys => clk_sys2,
89
                rst_n => rst_n,
90
      baud_lock => baud_lock,
91
                tc_divclk => tc_divclk,
92
                tx => OPEN,
93
                rx => rx,
94
      busy => rx_encours,
95
                val => val,
96
                rx_dat => rx_dat
97
        );
98
 
99
   inst_serial_tx: serial_tx
100
   GENERIC MAP (
101
      nbbit_div => nbbit_div)
102
   PORT MAP(
103
                clk_sys => clk_sys1,
104
                rst_n => rst_n,
105
                tc_divclk => tc_divclk,
106
                tx => rx,
107
                ser_rdy => ser_rdy,
108
                start_ser => start_ser,
109
                tx_dat => datatx
110
        );
111
 
112
   start_ser <= ser_rdy;
113
   process(clk_sys1)
114
   begin
115
      IF (rising_edge(clk_sys1)) THEN
116
         IF (ser_rdy = '1') THEN
117
            datatx <= datatx + 1;
118
         END IF;
119
      END IF;
120
   end process;
121
 
122
 
123
END rtl;
124
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.