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

Subversion Repositories saturn

[/] [saturn/] [trunk/] [FPGA Concentrateur SIL2/] [fpga_cosil2/] [top_fpgacosil2.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 DavidRAMBA
--============================================================================= 
2
--  TITRE : TOP_FPGACOSIL2
3
--  DESCRIPTION : 
4
--        Module TOP du FPGA du Concentrateur SIL2
5
--
6
--  FICHIER :        top_fpgacosil2.vhd 
7
--=============================================================================
8
--  CREATION 
9
--  DATE              AUTEUR    PROJET  REVISION 
10
--  10/04/2014  DRA        SATURN       V1.0 
11
--=============================================================================
12
--  HISTORIQUE  DES  MODIFICATIONS :
13
--  DATE              AUTEUR    PROJET  REVISION 
14
--  16/01/2015 DRA      SATURN   V1.1
15
--    Evolution de filter_dbl_frame dans le module con_communication
16
--  03/03/2015 DRA      SATURN   V1.2
17
--    Rajout du bit de status PCIe indiquant à la passerelle si le concentrateur
18
--    est actif ou passif
19
--  27/04/2015 DRA      SATURN   V1.2
20
--    Augmentation de la taille des FIFO Tx (module con_communication_sil) pour absorber 
21
--    toutes les trmaes de commandes émises si le réseau sSATURN est important
22
--    Suppression du test de FIFO vide en fin d'émission dans le module con_layer2_tx  
23
--  23/09/2015 YGO      SATURN   V1.3
24
--    Suppression du reset_switch sur activation du reset_fpga 
25
--=============================================================================
26
 
27
LIBRARY IEEE;
28
USE IEEE.STD_LOGIC_1164.ALL;
29
USE IEEE.STD_LOGIC_ARITH.ALL;
30
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
31
LIBRARY UNISIM;
32
USE UNISIM.VComponents.ALL;
33
 
34
LIBRARY work;
35
USE work.package_saturn.ALL;
36
 
37
ENTITY top_fpgacosil2 IS
38
   GENERIC (
39
      reg_version : STD_LOGIC_VECTOR(7 DOWNTO 0) := x"13"    -- Version du firmware
40
      );
41
   PORT (
42
      clk_24      : IN  STD_LOGIC;     -- Horloge principale à 24MHz
43
      clk_25      : IN  STD_LOGIC;     -- Horloge spare à 25MHz
44
      rst_n       : IN  STD_LOGIC;     -- Reset principal de la carte
45
      rst_fpgan   : IN  STD_LOGIC;     -- Reset issu du PIC32
46
      led_confok  : OUT STD_LOGIC;     -- Pilotage de la led rouge
47
      led_run     : OUT STD_LOGIC;     -- Pilotage de la 1ère LED verte
48
      led_fail    : OUT STD_LOGIC;     -- Pilotage de la 2ème LED verte
49
      power_rstn  : IN  STD_LOGIC;     -- Indique que l'alim 3.3V du PIC est coupée
50
      rst_switchn : OUT STD_LOGIC;     -- Gestion du reset du SWITCH
51
      interrupt   : IN  STD_LOGIC;     -- Signal d'interruption issu du SWITCH
52
      prog_b      : IN  STD_LOGIC;     -- Force la reprog du FPGA
53
 
54
      -- Interfaces ports séries
55
      ls485_de1   : OUT STD_LOGIC;     -- Signal d'autorisation à émettre de la LS1
56
      ls485_ren1  : OUT STD_LOGIC;     -- Signal d'autorisation à émettre de la LS1
57
      ls485_rx1   : IN  STD_LOGIC;     -- Signal de réception de la LS1
58
      ls485_tx1   : OUT STD_LOGIC;     -- Signal d'émission de la LS1
59
 
60
      ls485_de2   : OUT STD_LOGIC;     -- Signal d'autorisation à émettre de la LS2
61
      ls485_ren2  : OUT STD_LOGIC;     -- Signal d'autorisation à émettre de la LS2
62
      ls485_rx2   : IN  STD_LOGIC;     -- Signal de réception de la LS2
63
      ls485_tx2   : OUT STD_LOGIC;     -- Signal d'émission de la LS2
64
 
65
      -- Interface PMP (Interface PIC)
66
      pmd            : INOUT STD_LOGIC_VECTOR(7 DOWNTO 0);  -- Bus Data / Adresse
67
      pmall          : IN STD_LOGIC;   -- Latch des LSB de l'adresse
68
      pmalh          : IN STD_LOGIC;   -- Latch des MSB de l'adresse
69
      pmrd           : IN STD_LOGIC;   -- Signal de read
70
      pmwr           : IN STD_LOGIC;   -- Signal de write
71
 
72
      -- Interface de pilotage des Alim isolées
73
      cdehigh_5vid   : OUT STD_LOGIC;  -- Commande du 5V de la puce Dallas
74
      cdelow_5vid    : OUT STD_LOGIC;
75
      cdehigh_5vls1  : OUT STD_LOGIC;  -- Commande du 5V du port série LS1 + Maintenance 1
76
      cdelow_5vls1   : OUT STD_LOGIC;
77
      cdehigh_5vls2  : OUT STD_LOGIC;  -- Commande du 5V du port série LS2
78
      cdelow_5vls2   : OUT STD_LOGIC;
79
      cdehigh_5vlsm2 : OUT STD_LOGIC;  -- Commande du 5V maintenance 2
80
      cdelow_5vlsm2  : OUT STD_LOGIC;
81
      cdehigh_5vcan  : OUT STD_LOGIC;  -- Commande du 5V CAN
82
      cdelow_5vcan   : OUT STD_LOGIC;
83
 
84
      -- Interface PCIe
85
      pci_rstn    : IN  STD_LOGIC;     -- Reset de l'interface PCIe
86
      pci_exp_txp : OUT STD_LOGIC;     -- Signal différentiel Tx PCIe
87
      pci_exp_txn : OUT STD_LOGIC;
88
      pci_exp_rxp : IN  STD_LOGIC;     -- Signal différentiel Rx PCIe
89
      pci_exp_rxn : IN  STD_LOGIC;
90
      pci_clk_p   : IN  STD_LOGIC;     -- Signal différentiel Clock PCIe
91
      pci_clk_n   : IN  STD_LOGIC;
92
      pci_waken   : OUT STD_LOGIC;     -- Signal de réveil PCIe (RFU)
93
      pci_spare   : IN  STD_LOGIC;     -- Signal en spare
94
 
95
      -- Interface SPI (programmation de la flash de configuration)
96
      wp_flashn      : OUT STD_LOGIC;  -- Autorisation d'écriture dans la flash SPI
97
      cclk           : OUT STD_LOGIC;  -- Horloge d'accès à la flash SPI
98
      din_miso       : IN  STD_LOGIC;  -- Data série en lecture SPI
99
      mosi           : OUT STD_LOGIC;  -- Data série en écriture SPI
100
      cso_b          : OUT STD_LOGIC;  -- Chip select SPI
101
 
102
      -- Interface PMP Spare avec la passerelle
103
      uc_pmd      : INOUT STD_LOGIC_VECTOR(7 DOWNTO 0);
104
      uc_pmrd     : IN STD_LOGIC;
105
      uc_pmwr     : IN STD_LOGIC;
106
      uc_pmall    : IN STD_LOGIC;
107
      uc_pmalh    : IN STD_LOGIC;
108
      uc_pmacs1   : IN STD_LOGIC;
109
      uc_pmacs2   : IN STD_LOGIC;
110
 
111
      -- Interface SPI Spare avec la passerelle
112
      uc_sck      : IN STD_LOGIC;
113
      uc_ssn      : IN STD_LOGIC;
114
      uc_sdi      : IN STD_LOGIC;
115
      uc_sdo      : IN STD_LOGIC;
116
 
117
      -- Interface Spare I2C
118
      sda         : IN STD_LOGIC;
119
      scl         : IN STD_LOGIC;
120
 
121
      -- Interface Spare avec le PIC
122
      pic_rx         : IN  STD_LOGIC;
123
      pic_tx         : OUT STD_LOGIC;
124
      pic_spare      : IN  STD_LOGIC_VECTOR(3 DOWNTO 0);
125
      pic_sck        : IN  STD_LOGIC;
126
      pic_sdi        : IN  STD_LOGIC;
127
      pic_sdo        : OUT STD_LOGIC;
128
      pic_ssn        : IN  STD_LOGIC;
129
 
130
      -- Spare
131
      tp             : OUT STD_LOGIC_VECTOR(28 DOWNTO 22);
132
      spare          : OUT STD_LOGIC_VECTOR(7 DOWNTO 0)
133
      );
134
END top_fpgacosil2;
135
 
136
ARCHITECTURE rtl of top_fpgacosil2 is
137
   -- signaux utilisés pour les fonctions systèmes
138
   SIGNAL clk_sys        : STD_LOGIC:= '0';              -- Horloge système = 2 x clk_24
139
   SIGNAL clk_48         : STD_LOGIC:= '0';              -- Pour récupérer l'horloge CLKx2 à la sortie du DCM
140
   SIGNAL clk_96         : STD_LOGIC:= '0';              -- Pour récupérer l'horloge CLKFX à la sortie du DCM
141
   SIGNAL clk_dna        : STD_LOGIC:= '0';              -- Horloge à 1 MHz pour lire le DNA
142
   SIGNAL clk_pcie       : STD_LOGIC:= '0';              -- Horloge à 62.5 MHz issue de l'I/F PCIe
143
   SIGNAL rst_dcm        : STD_LOGIC:= '0';              -- Signal de reset du DCM
144
   SIGNAL rstdna_n       : STD_LOGIC:= '0';              -- reset resynchronisé sur clk_dna
145
   SIGNAL rst96_n        : STD_LOGIC:= '0';              -- reset resynchronisé sur clk96
146
   SIGNAL rstpcie_n      : STD_LOGIC := '0';             -- Pour filtrer le reset entrant
147
   SIGNAL dcm_locked     : STD_LOGIC:= '0';              -- Signal de lock du DCM
148
   SIGNAL cpt_blink      : STD_LOGIC_VECTOR(23 DOWNTO 0); -- Compteur pour le blink de la led run
149
   SIGNAL iid            : STD_LOGIC_VECTOR(63 DOWNTO 0); -- Valeur d'IID
150
   SIGNAL iid_rdy        : STD_LOGIC;                    -- Indique que le IID a été récupéré
151
 
152
   -- Signaux d'interface entre le module de comm et le module spi PIC
153
   SIGNAL tid           : STD_LOGIC_VECTOR(7 DOWNTO 0);  -- TID utilisé par le concentrateur
154
   SIGNAL cpy1          : STD_LOGIC;                     -- Autorise la copie du port 1 sur le port 2
155
   SIGNAL cpy2          : STD_LOGIC;                     -- Autorise la copie du port 2 sur le port 1
156
   SIGNAL repli         : STD_LOGIC;                     -- Indique que le cocnentrateur est en mode repli
157
   SIGNAL topcyc        : STD_LOGIC;                     -- Un pulse à chaque début de cycle
158
   SIGNAL ena_filt_dble : STD_LOGIC;                     -- Autorise le filtrage des trames en double
159
   SIGNAL l7_rx1        : STD_LOGIC_VECTOR(7 DOWNTO 0);  -- Données applicatives sur port 1
160
   SIGNAL l7_soc1       : STD_LOGIC;                     -- Début de trame sur port 1
161
   SIGNAL l7_rd1        : STD_LOGIC;                     -- Signal de lecture des données applicatives port 1
162
   SIGNAL l7_comdispo1  : STD_LOGIC;                     -- Indique une trame dispo sur le port 1
163
   SIGNAL l7_newframe1  : STD_LOGIC;                     -- Indique la réception d'une nouvelle trame sur le port 1
164
   SIGNAL l7_l2ok1      : STD_LOGIC;                     -- Indique que la trmae reçue est correcte sur prot 1
165
   SIGNAL l7_overflow1  : STD_LOGIC;                     -- Indique un overflow de réception sur port 1
166
   SIGNAL l7_rx2        : STD_LOGIC_VECTOR(7 DOWNTO 0);  -- Idem pour port 2
167
   SIGNAL l7_soc2       : STD_LOGIC;
168
   SIGNAL l7_rd2        : STD_LOGIC;
169
   SIGNAL l7_comdispo2  : STD_LOGIC;
170
   SIGNAL l7_newframe2  : STD_LOGIC;
171
   SIGNAL l7_l2ok2      : STD_LOGIC;
172
   SIGNAL l7_overflow2  : STD_LOGIC;
173
   SIGNAL tx_dat        : STD_LOGIC_VECTOR(7 DOWNTO 0);  -- Données applicatives à transmettre sur réseau privé
174
   SIGNAL val_txdat     : STD_LOGIC;                     -- Validant de tx_dat
175
   SIGNAL tx_sof        : STD_LOGIC;                     -- Début de trame à transmettre
176
   SIGNAL tx_eof        : STD_LOGIC;                     -- Fin de trame à transmettre
177
   SIGNAL txdat_free    : STD_LOGIC;                     -- Indique que la donnée sur tx_dat a été prise en compte par le module layer2_tx
178
   SIGNAL clr_fifo_tx   : STD_LOGIC;                     -- Pour vider la FIFO Tx
179
   SIGNAL stuf_phys     : STD_LOGIC;                     -- Signal de génération d'un train de fanions 7Fh sur les LS1 et LS2
180
   SIGNAL acq_stuf      : STD_LOGIC;                     -- Signal d'acquittement du train de fanions 7Fh
181
 
182
   SIGNAL cpt_cde       : STD_LOGIC_VECTOR(5 DOWNTO 0);  -- Compteur pour générer les pulses de commande des alims isolées
183
   SIGNAL toggle_cde    : STD_LOGIC;                     -- Pour savoir quelle voie de la commadne alim est active
184
   SIGNAL cde_high      : STD_LOGIC;                     -- Commande directe pour les alims isolées
185
   SIGNAL cde_low       : STD_LOGIC;                     -- Commande inverse pour les alims isolées
186
 
187
   -- Signaux du bus local de l'interface PCIe
188
   SIGNAL rd_addr       : STD_LOGIC_VECTOR(NBBIT_ADD_LOCAL-1 downto 0); -- Bus d'@ en lecture
189
   SIGNAL rd_data       : STD_LOGIC_VECTOR(31 downto 0);                -- Données lues sur le bus local
190
   SIGNAL rd_be         : STD_LOGIC_VECTOR(3 downto 0);                 -- Byte Enable en lecture
191
   SIGNAL rd_en         : STD_LOGIC;                                    -- Signal d'ordre de lecture
192
   SIGNAL wr_addr       : STD_LOGIC_VECTOR(NBBIT_ADD_LOCAL-1 downto 0); -- Bus d'@ en écriture
193
   SIGNAL wr_data       : STD_LOGIC_VECTOR(31 downto 0);                -- Données à écrire sur le bus local
194
   SIGNAL wr_be         : STD_LOGIC_VECTOR(3 downto 0);                 -- Byte enable en écriture
195
   SIGNAL wr_en         : STD_LOGIC;                                    -- Signal d'ordre d'écriture
196
   SIGNAL wr_busy       : STD_LOGIC;                                    -- Indique que le bus local est occupé en écriture
197
   SIGNAL link_up_n     : STD_LOGIC;                                    -- Indique le lien PCIe est établi avec le host
198
   SIGNAL dma_req       : STD_LOGIC;                     -- Requête d'un DMA
199
   SIGNAL dma_add_dest  : STD_LOGIC_VECTOR(31 downto 0); -- Adresse de estination (coté PC) pour le DMA
200
   SIGNAL dma_compl     : STD_LOGIC;                     -- Indique que le DMA est fini
201
   SIGNAL dma_read      : STD_LOGIC;                     -- Ordre de lecture pour fetcher une donnée supplémentaire à envoyer par DMA
202
   SIGNAL dma_ack       : STD_LOGIC;                     -- Indique que la demande de DMA est acceptée         
203
   SIGNAL dma_size      : STD_LOGIC_VECTOR(7 downto 0);  -- Nombre de mots de 32 bits à tansférer par DMA
204
   SIGNAL dma_data      : STD_LOGIC_VECTOR(31 DOWNTO 0); -- Données à transmettre par DMA (fetchée par dma_read)
205
   SIGNAL dma_timestamp : STD_LOGIC_VECTOR(7 DOWNTO 0);  -- LSB du numéro de cycle en cours
206
 
207
   -- Signaux de gestion du module memory_map
208
   SIGNAL rst_regn      : STD_LOGIC;                     -- Reset interne piloté par registre
209
   SIGNAL actif         : STD_LOGIC;                     -- Indique que le concentrateur est actif
210
   SIGNAL store_enable  : STD_LOGIC;                     -- Autorise le transfert DMA des trames incidentes
211
   SIGNAL rx_flushn     : STD_LOGIC;                     -- Reset du module DMA
212
   SIGNAL dma_inprogress: STD_LOGIC;                     -- A 1 tant que le module DMA est en cours de transfert
213
   SIGNAL update_ena    : STD_LOGIC;                     -- Autorise la mise à jour de la mémoire TX_PER
214
   SIGNAL baudrate      : STD_LOGIC_VECTOR(2 DOWNTO 0);  -- Code du baudrate de communication (entre 50Kbits et 12MBits)
215
   SIGNAL tx_ena_periodic:STD_LOGIC_VECTOR(31 DOWNTO 0); -- Autorisation à émettre d'une zone périodique
216
   SIGNAL tx_ena_aper   : STD_LOGIC_VECTOR(31 DOWNTO 0); -- Autorisation à émettre d'une zone apériodique
217
   SIGNAL clr_txena_aper: STD_LOGIC_VECTOR(31 DOWNTO 0); -- Ordre de remise à 0 d'une zone de transmission apériodique
218
   SIGNAL dma_base_pa   : STD_LOGIC_VECTOR(31 DOWNTO 0); -- Adresse physique de base pour les DMA (coté PC)
219
   SIGNAL bufferrx1_full: STD_LOGIC_VECTOR(31 DOWNTO 0); -- Indique les zones de stockages des trames Rx1 encore pleines
220
   SIGNAL bufferrx2_full: STD_LOGIC_VECTOR(31 DOWNTO 0); -- Indique les zones de stockages des trames Rx2 encore pleines
221
   SIGNAL buffertx_full : STD_LOGIC_VECTOR(31 DOWNTO 0); -- Indique les zones de stockages des trames Tx encore pleines
222
   SIGNAL newframe_rx1  : STD_LOGIC_VECTOR(31 DOWNTO 0); -- Indique la zone de stockage d'une nouvelle trame Rx1
223
   SIGNAL newframe_rx2  : STD_LOGIC_VECTOR(31 DOWNTO 0); -- Indique la zone de stockage d'une nouvelle trame Rx2
224
   SIGNAL newframe_tx   : STD_LOGIC_VECTOR(31 DOWNTO 0); -- Indique la zone de stockage d'une nouvelle trame Tx
225
   SIGNAL rx1_overflow  : STD_LOGIC;                     -- Indique la perte d'une trame sur RX1 faute de place en mémoire
226
   SIGNAL rx2_overflow  : STD_LOGIC;                     -- Indique la perte d'une trame sur RX2 faute de place en mémoire
227
   SIGNAL tx_overflow   : STD_LOGIC;                     -- Indique la perte d'une trame sur TX faute de place en mémoire
228
   SIGNAL rx1_badformat : STD_LOGIC;                     -- Indique une trame reçue avec un mauvais format ou mauvais CRC sur Rx1
229
   SIGNAL rx2_badformat : STD_LOGIC;                     -- Indique une trame reçue avec un mauvais format ou mauvais CRC sur Rx2
230
   SIGNAL addrr_tx      : STD_LOGIC_VECTOR(14 DOWNTO 0); -- @ de lecture des zones TXAPER et TXPER
231
   SIGNAL data_tx       : STD_LOGIC_VECTOR(7 DOWNTO 0);  -- Données lues dans les zones TXAPER et TXPER
232
   SIGNAL rd_datatx     : STD_LOGIC;                     -- Signal de lecture dans une res mémoire APER ou PER
233
        SIGNAL rd_force         : STD_LOGIC;                                                    -- Signal de lecture d'un octet dans la FIFO des I/O forcées
234
        SIGNAL data_force               : STD_LOGIC_VECTOR(7 DOWNTO 0);  -- Octet lu dans la FIFO des I/O forcées
235
        SIGNAL empty_force      : STD_LOGIC;                                                    -- Indique que la FIFO des I/O forcées est vide
236
   SIGNAL actif_passifn : STD_LOGIC;                     -- Signale à la passerelle si le cocnentrateur est actif ou pas
237
   SIGNAL cpy_r1, cpy_r2: STD_LOGIC;                     -- Pour changemenet d'horloge de cpy1/cpy2 vers actif_passifn
238
 
239
   -- Signaux du flux de données entrant sur les LS pour envoyer vers PCIe synchrone de clk_96
240
   SIGNAL data_storerx1 : STD_LOGIC_VECTOR(7 DOWNTO 0);  -- Données à stocker en mémoire avant DMA
241
   SIGNAL val_storerx1  : STD_LOGIC;                     -- Validant du bus data_store(signal write)
242
   SIGNAL sof_storerx1  : STD_LOGIC;                     -- Indique un début de trame (nouvelle trame). Synchrone du 1er octet envoyé
243
   SIGNAL eof_storerx1  : STD_LOGIC;                     -- Indique que la trame est finie (plus de données à envoyer)
244
   SIGNAL crcok_storerx1: STD_LOGIC;                     -- Indique que le CRC et le format est bon (sycnhrone de eof) 
245
   SIGNAL data_storerx2 : STD_LOGIC_VECTOR(7 DOWNTO 0);  -- Idem pour RX2  
246
   SIGNAL val_storerx2  : STD_LOGIC;
247
   SIGNAL sof_storerx2  : STD_LOGIC;
248
   SIGNAL eof_storerx2  : STD_LOGIC;
249
   SIGNAL crcok_storerx2: STD_LOGIC;
250
   SIGNAL tx_val        : STD_LOGIC;                     -- Pour valider les données Tx vers le PCIe
251
 
252
   -- Signaux des flux de données entrant et sortant sur les LS pour envoyer vers PCIe synchrone de clk_pcie
253
   SIGNAL data_pcie_rx1 : STD_LOGIC_VECTOR(7 DOWNTO 0);  -- Données à stocker en mémoire avant DMA
254
   SIGNAL val_pcie_rx1  : STD_LOGIC;                     -- Validant du bus data_store(signal write)
255
   SIGNAL sof_pcie_rx1  : STD_LOGIC;                     -- Indique un début de trame (nouvelle trame). Synchrone du 1er octet envoyé
256
   SIGNAL eof_pcie_rx1  : STD_LOGIC;                     -- Indique que la trame est finie (plus de données à envoyer)
257
   SIGNAL crcok_pcie_rx1: STD_LOGIC;                     -- Indique que le CRC et le format est bon (sycnhrone de eof) 
258
   SIGNAL data_pcie_rx2 : STD_LOGIC_VECTOR(7 DOWNTO 0);  -- Idem pour RX2  
259
   SIGNAL val_pcie_rx2  : STD_LOGIC;
260
   SIGNAL sof_pcie_rx2  : STD_LOGIC;
261
   SIGNAL eof_pcie_rx2  : STD_LOGIC;
262
   SIGNAL crcok_pcie_rx2: STD_LOGIC;
263
   SIGNAL data_pcie_tx  : STD_LOGIC_VECTOR(7 DOWNTO 0);  -- Idem pour TX  
264
   SIGNAL val_pcie_tx   : STD_LOGIC;
265
   SIGNAL sof_pcie_tx   : STD_LOGIC;
266
   SIGNAL eof_pcie_tx   : STD_LOGIC;
267
 
268
   -- Signaux de gestion du module d'accès à la PROM de cofniguration FPGA
269
   SIGNAL txprom_dat  : STD_LOGIC_VECTOR(7 downto 0);    -- Donnée/commande à écrire
270
   SIGNAL txprom_val  : STD_LOGIC;                       -- Indique une donnée disponible sur txprom_dat
271
   SIGNAL rxprom_dat  : STD_LOGIC_VECTOR(7 downto 0);    -- Donnée lue dans la PROM
272
   SIGNAL rxprom_val  : STD_LOGIC;                       -- Indique une donnée disponible sur rxprom_dat
273
   SIGNAL rxprom_next : STD_LOGIC;                       -- Demande une dnouvelle donnée sur rxprom_dat
274
   SIGNAL prom_type_com: STD_LOGIC;                      -- Définit le type de commande à exécuter (R ou W)
275
   SIGNAL prom_exec_com: STD_LOGIC;                      -- Lance l'exécution d'une commande d'accès à la PROM
276
   SIGNAL prom_busy   : STD_LOGIC;                       -- Indique que le module est occupé
277
   SIGNAL prom_nbread : STD_LOGIC_VECTOR(7 DOWNTO 0);    -- Nombre d 'octets à lire avec une commande de lecture
278
   SIGNAL prom_rstn   : STD_LOGIC;                       -- reset du module d'accès à la PROM
279
 
280
   COMPONENT if_pcie
281
   GENERIC
282
   (
283
      fast_train : BOOLEAN := FALSE;
284
      nbbit_add  : INTEGER := 13
285
   );
286
   PORT
287
   (
288
      pci_exp_txp : OUT STD_LOGIC;
289
      pci_exp_txn : OUT STD_LOGIC;
290
      pci_exp_rxp : IN  STD_LOGIC;
291
      pci_exp_rxn : IN  STD_LOGIC;
292
 
293
      sys_clk_p   : IN  STD_LOGIC;
294
      sys_clk_n   : IN  STD_LOGIC;
295
      sys_reset_n : IN  STD_LOGIC;
296
 
297
      dma_req     : IN  STD_LOGIC;
298
      dma_compl   : OUT STD_LOGIC;
299
      dma_ack     : OUT STD_LOGIC;
300
      dma_add_dest: IN  STD_LOGIC_VECTOR(31 downto 0);
301
      dma_data    : IN  STD_LOGIC_VECTOR(31 DOWNTO 0);
302
      dma_read    : OUT STD_LOGIC;
303
      dma_size    : IN  STD_LOGIC_VECTOR(7 downto 0);
304
 
305
      --Local Bus
306
      rd_addr     : OUT STD_LOGIC_VECTOR(nbbit_add-1 downto 0);
307
      rd_data     : IN STD_LOGIC_VECTOR(31 downto 0);
308
      rd_be       : OUT STD_LOGIC_VECTOR(3 downto 0);
309
      rd_en       : OUT STD_LOGIC;
310
      wr_addr     : OUT STD_LOGIC_VECTOR(nbbit_add-1 downto 0);
311
      wr_data     : OUT STD_LOGIC_VECTOR(31 downto 0);
312
      wr_be       : OUT STD_LOGIC_VECTOR(3 downto 0);
313
      wr_en       : OUT STD_LOGIC;
314
      wr_busy     : IN STD_LOGIC;
315
      clk_local   : OUT STD_LOGIC;
316
      rst_local_n : OUT STD_LOGIC;
317
      link_up_n   : OUT STD_LOGIC
318
   );
319
   END COMPONENT;
320
 
321
   COMPONENT memory_map IS
322
   GENERIC (
323
      reg_version : STD_LOGIC_VECTOR(7 DOWNTO 0) := x"10"
324
      );
325
   PORT (
326
      clk_sys        : IN  STD_LOGIC;
327
      rst_n          : IN  STD_LOGIC;
328
      iid            : IN  STD_LOGIC_VECTOR(63 DOWNTO 0);
329
      actif_passifn  : IN  STD_LOGIC;
330
      rd_addr        : IN  STD_LOGIC_VECTOR(NBBIT_ADD_LOCAL-1 DOWNTO 0);
331
      rd_data        : OUT STD_LOGIC_VECTOR(31 DOWNTO 0);
332
      rd_be          : IN  STD_LOGIC_VECTOR(3 DOWNTO 0);
333
      rd_en          : IN  STD_LOGIC;
334
      wr_addr        : IN  STD_LOGIC_VECTOR(NBBIT_ADD_LOCAL-1 DOWNTO 0);
335
      wr_data        : IN  STD_LOGIC_VECTOR(31 DOWNTO 0);
336
      wr_be          : IN  STD_LOGIC_VECTOR(3 DOWNTO 0);
337
      wr_en          : IN  STD_LOGIC;
338
      wr_busy        : OUT STD_LOGIC;
339
      rst_regn       : OUT STD_LOGIC;
340
      store_enable   : OUT STD_LOGIC;
341
      dma_inprogress : IN  STD_LOGIC;
342
      update_ena     : IN  STD_LOGIC;
343
      rx_flushn      : OUT STD_LOGIC;
344
      topcyc         : IN  STD_LOGIC;
345
      tx_ena_periodic: OUT STD_LOGIC_VECTOR(31 DOWNTO 0);
346
      tx_ena_aper    : OUT STD_LOGIC_VECTOR(31 DOWNTO 0);
347
      clr_txena_aper : IN  STD_LOGIC_VECTOR(31 DOWNTO 0);
348
      dma_base_pa    : OUT STD_LOGIC_VECTOR(31 DOWNTO 0);
349
      dma_timestamp  : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
350
      bufferrx1_full : OUT STD_LOGIC_VECTOR(31 DOWNTO 0);
351
      bufferrx2_full : OUT STD_LOGIC_VECTOR(31 DOWNTO 0);
352
      buffertx_full  : OUT STD_LOGIC_VECTOR(31 DOWNTO 0);
353
      newframe_rx1   : IN  STD_LOGIC_VECTOR(31 DOWNTO 0);
354
      newframe_rx2   : IN  STD_LOGIC_VECTOR(31 DOWNTO 0);
355
      newframe_tx    : IN  STD_LOGIC_VECTOR(31 DOWNTO 0);
356
      rx1_overflow   : IN  STD_LOGIC;
357
      rx2_overflow   : IN  STD_LOGIC;
358
      tx_overflow    : IN  STD_LOGIC;
359
      rx1_badformat  : IN  STD_LOGIC;
360
      rx2_badformat  : IN  STD_LOGIC;
361
                clk_96                  : IN  STD_LOGIC;
362
                rd_force                        : IN  STD_LOGIC;
363
                data_force              : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
364
                empty_force             : OUT STD_LOGIC;
365
      addrr_tx       : IN  STD_LOGIC_VECTOR(14 DOWNTO 0);
366
      data_tx        : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
367
      rd_datatx      : IN  STD_LOGIC;
368
      testpoint      : OUT STD_LOGIC_VECTOR(7 DOWNTO 0)
369
   );
370
   END COMPONENT;
371
 
372
   COMPONENT manage_dma
373
   PORT (
374
      clk_sys           : IN  STD_LOGIC;
375
      rst_n             : IN  STD_LOGIC;
376
      store_enable      : IN  STD_LOGIC;
377
      data_storerx1     : IN  STD_LOGIC_VECTOR(7 DOWNTO 0);
378
      val_storerx1      : IN  STD_LOGIC;
379
      sof_storerx1      : IN  STD_LOGIC;
380
      eof_storerx1      : IN  STD_LOGIC;
381
      crcok_storerx1    : IN  STD_LOGIC;
382
      data_storerx2     : IN  STD_LOGIC_VECTOR(7 DOWNTO 0);
383
      val_storerx2      : IN  STD_LOGIC;
384
      sof_storerx2      : IN  STD_LOGIC;
385
      eof_storerx2      : IN  STD_LOGIC;
386
      crcok_storerx2    : IN  STD_LOGIC;
387
      data_storetx      : IN  STD_LOGIC_VECTOR(7 DOWNTO 0);
388
      val_storetx       : IN  STD_LOGIC;
389
      sof_storetx       : IN  STD_LOGIC;
390
      eof_storetx       : IN  STD_LOGIC;
391
      newframe_rx1      : OUT STD_LOGIC_VECTOR(31 DOWNTO 0);
392
      newframe_rx2      : OUT STD_LOGIC_VECTOR(31 DOWNTO 0);
393
      newframe_tx       : OUT STD_LOGIC_VECTOR(31 DOWNTO 0);
394
      bufferrx1_full    : IN  STD_LOGIC_VECTOR(31 DOWNTO 0);
395
      bufferrx2_full    : IN  STD_LOGIC_VECTOR(31 DOWNTO 0);
396
      buffertx_full     : IN  STD_LOGIC_VECTOR(31 DOWNTO 0);
397
      rx1_overflow      : OUT STD_LOGIC;
398
      rx2_overflow      : OUT STD_LOGIC;
399
      tx_overflow       : OUT STD_LOGIC;
400
      rx1_badformat     : OUT STD_LOGIC;
401
      rx2_badformat     : OUT STD_LOGIC;
402
      dma_inprogress    : OUT STD_LOGIC;
403
      dma_req           : OUT STD_LOGIC;
404
      dma_size          : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
405
      dma_ack           : IN  STD_LOGIC;
406
      dma_compl         : IN  STD_LOGIC;
407
      dma_read          : IN  STD_LOGIC;
408
      dma_data          : OUT STD_LOGIC_VECTOR(31 DOWNTO 0);
409
      dma_add_dest      : OUT STD_LOGIC_VECTOR(31 DOWNTO 0);
410
      dma_base_pa       : IN  STD_LOGIC_VECTOR(31 DOWNTO 0);
411
      dma_timestamp     : IN STD_LOGIC_VECTOR(7 DOWNTO 0)
412
   );
413
   END COMPONENT;
414
 
415
   COMPONENT con_communication_sil
416
   PORT (
417
      clk_sys           : IN  STD_LOGIC;
418
      rst_n             : IN  STD_LOGIC;
419
      baudrate          : IN  STD_LOGIC_VECTOR(2 DOWNTO 0);
420
      actif             : IN  STD_LOGIC;
421
      ad_con            : IN  STD_LOGIC_VECTOR(7 DOWNTO 0);
422
      top_cycle         : IN  STD_LOGIC;
423
      ena_filt_dble     : IN  STD_LOGIC;
424
      rx1               : IN  STD_LOGIC;
425
      tx1               : OUT STD_LOGIC;
426
      rx2               : IN  STD_LOGIC;
427
      tx2               : OUT STD_LOGIC;
428
      copy_ena1         : IN  STD_LOGIC;
429
      copy_ena2         : IN  STD_LOGIC;
430
      filt_rx1          : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
431
      filt_soc1         : OUT STD_LOGIC;
432
      filt_rd1          : IN  STD_LOGIC;
433
      filt_comdispo1    : OUT STD_LOGIC;
434
      layer7_newframe1  : OUT STD_LOGIC;
435
      layer7_l2ok1      : OUT STD_LOGIC;
436
      layer7_overflow1  : OUT STD_LOGIC;
437
      filt_rx2          : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
438
      filt_soc2         : OUT STD_LOGIC;
439
      filt_rd2          : IN  STD_LOGIC;
440
      filt_comdispo2    : OUT STD_LOGIC;
441
      layer7_newframe2  : OUT STD_LOGIC;
442
      layer7_l2ok2      : OUT STD_LOGIC;
443
      layer7_overflow2  : OUT STD_LOGIC;
444
      data_storerx1     : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
445
      val_storerx1      : OUT STD_LOGIC;
446
      sof_storerx1      : OUT STD_LOGIC;
447
      eof_storerx1      : OUT STD_LOGIC;
448
      crcok_storerx1    : OUT STD_LOGIC;
449
      data_storerx2     : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
450
      val_storerx2      : OUT STD_LOGIC;
451
      sof_storerx2      : OUT STD_LOGIC;
452
      eof_storerx2      : OUT STD_LOGIC;
453
      crcok_storerx2    : OUT STD_LOGIC;
454
      tx_dat            : IN  STD_LOGIC_VECTOR(7 DOWNTO 0);
455
      val_txdat         : IN  STD_LOGIC;
456
      tx_sof            : IN  STD_LOGIC;
457
      tx_eof            : IN  STD_LOGIC;
458
      txdat_free        : OUT STD_LOGIC;
459
      clr_fifo_tx       : IN  STD_LOGIC;
460
      stuf_phys         : IN  STD_LOGIC;
461
      acq_stuf          : OUT STD_LOGIC
462
      );
463
   END COMPONENT;
464
 
465
   COMPONENT if_picpmp
466
   GENERIC (
467
      version : STD_LOGIC_VECTOR(7 DOWNTO 0));
468
   PORT (
469
      clk_sys     : IN  STD_LOGIC;
470
      rst_n       : IN  STD_LOGIC;
471
      pmd         : INOUT STD_LOGIC_VECTOR(7 DOWNTO 0);
472
      pmall       : IN STD_LOGIC;
473
      pmalh       : IN STD_LOGIC;
474
      pmrd        : IN STD_LOGIC;
475
      pmwr        : IN STD_LOGIC;
476
      iid         : IN  STD_LOGIC_VECTOR(63 DOWNTO 0);
477
      tid         : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
478
      cpy1        : OUT STD_LOGIC;
479
      cpy2        : OUT STD_LOGIC;
480
      repli       : OUT STD_LOGIC;
481
      baudrate    : OUT STD_LOGIC_VECTOR(2 DOWNTO 0);
482
      actif       : OUT STD_LOGIC;
483
      topcyc      : OUT STD_LOGIC;
484
      enafiltdble : OUT STD_LOGIC;
485
      l7_rx1      : IN  STD_LOGIC_VECTOR(7 DOWNTO 0);
486
      l7_soc1     : IN  STD_LOGIC;
487
      l7_rd1      : OUT STD_LOGIC;
488
      l7_comdispo1: IN  STD_LOGIC;
489
      l7_newframe1: IN  STD_LOGIC;
490
      l7_l2ok1    : IN  STD_LOGIC;
491
      l7_overflow1: IN  STD_LOGIC;
492
      l7_rx2      : IN  STD_LOGIC_VECTOR(7 DOWNTO 0);
493
      l7_soc2     : IN  STD_LOGIC;
494
      l7_rd2      : OUT STD_LOGIC;
495
      l7_comdispo2: IN  STD_LOGIC;
496
      l7_newframe2: IN  STD_LOGIC;
497
      l7_l2ok2    : IN  STD_LOGIC;
498
      l7_overflow2: IN  STD_LOGIC;
499
      tx_dat      : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
500
      val_txdat   : OUT STD_LOGIC;
501
      tx_sof      : OUT STD_LOGIC;
502
      tx_eof      : OUT STD_LOGIC;
503
      txdat_free  : IN  STD_LOGIC;
504
      clr_fifo_tx : OUT STD_LOGIC;
505
      stuf_phys   : OUT STD_LOGIC;
506
      acq_stuf    : IN  STD_LOGIC;
507
      txprom_dat  : OUT STD_LOGIC_VECTOR(7 downto 0);
508
      txprom_val  : OUT STD_LOGIC;
509
      rxprom_dat  : IN  STD_LOGIC_VECTOR(7 downto 0);
510
      rxprom_val  : IN  STD_LOGIC;
511
      rxprom_next : OUT STD_LOGIC;
512
      prom_type_com: OUT STD_LOGIC;
513
      prom_exec_com: OUT STD_LOGIC;
514
      prom_busy   : IN  STD_LOGIC;
515
      prom_nbread : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
516
      prom_rstn   : OUT STD_LOGIC;
517
                rd_force                : OUT STD_LOGIC;
518
                data_force      : IN  STD_LOGIC_VECTOR(7 DOWNTO 0);
519
                empty_force     : IN  STD_LOGIC
520
      );
521
   END COMPONENT;
522
 
523
   COMPONENT flux_chgclk
524
   PORT (
525
      clks     : IN  STD_LOGIC;
526
      clkd     : IN  STD_LOGIC;
527
      rst_n    : IN  STD_LOGIC;
528
      datas    : IN  STD_LOGIC_VECTOR(7 DOWNTO 0);
529
      vals     : IN  STD_LOGIC;
530
      sofs     : IN  STD_LOGIC;
531
      eofs     : IN  STD_LOGIC;
532
      crcoks   : IN  STD_LOGIC;
533
      datad    : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
534
      vald     : OUT STD_LOGIC;
535
      sofd     : OUT STD_LOGIC;
536
      eofd     : OUT STD_LOGIC;
537
      crcokd   : OUT STD_LOGIC
538
      );
539
   END COMPONENT;
540
 
541
   COMPONENT readmac
542
   GENERIC (
543
      sim_dna_value : STD_LOGIC_VECTOR(59 DOWNTO 0) :=  X"123456789ABCDEF");
544
   PORT (
545
      clk_sys  : IN  STD_LOGIC;
546
      rst_n    : IN  STD_LOGIC;
547
      mac      : OUT  STD_LOGIC_VECTOR(63 downto 0);
548
      mac_rdy  : OUT  STD_LOGIC
549
      );
550
   END COMPONENT;
551
 
552
   COMPONENT if_promspi
553
   GENERIC (
554
      div_rate    : INTEGER := 1;
555
      spiclk_freq : INTEGER := 10
556
      );
557
   PORT (
558
      clk_sys     : IN  STD_LOGIC;
559
      rst_n       : IN  STD_LOGIC;
560
      spi_csn     : OUT STD_LOGIC;
561
      spi_wpn     : OUT STD_LOGIC;
562
      spi_sdo     : OUT STD_LOGIC;
563
      spi_sdi     : IN  STD_LOGIC;
564
      spi_clk     : OUT STD_LOGIC;
565
      tx_dat      : IN  STD_LOGIC_VECTOR(7 downto 0);
566
      tx_val      : IN  STD_LOGIC;
567
      rx_dat      : OUT STD_LOGIC_VECTOR(7 downto 0);
568
      rx_val      : OUT STD_LOGIC;
569
      rx_next     : IN  STD_LOGIC;
570
      type_com    : IN  STD_LOGIC;
571
      exec_com    : IN  STD_LOGIC;
572
      spi_busy    : OUT STD_LOGIC;
573
      nb_read     : IN  STD_LOGIC_VECTOR(7 DOWNTO 0)
574
      );
575
   END COMPONENT;
576
 
577
BEGIN
578
   ---------------------------------------------------
579
   -- Gestion des interfaces système
580
   ---------------------------------------------------
581
   -- rst_switchn <= rst_fpgan;              -- Reset du switch Ethernet contrôlé par le PIC
582
   rst_switchn <= '1';                                           -- Pas de reset switch lors d'un reset FPGA par le PIC pour éviter à la passerelle de perdre le réseau
583
   rst_dcm <= NOT(rst_fpgan);                -- Le reset DCM est actif à '1'
584
 
585
   DCM_SP_inst : DCM_SP
586
   generic map (
587
      CLKDV_DIVIDE => 16.0,                  -- CLKDV divide value
588
                                             -- (1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7,7.5,8,9,10,11,12,13,14,15,16).
589
      CLKFX_DIVIDE => 1,                     -- Divide value on CLKFX outputs - D - (1-32)
590
      CLKFX_MULTIPLY => 4,                   -- Multiply value on CLKFX outputs - M - (2-32)
591
      CLKIN_DIVIDE_BY_2 => FALSE,            -- CLKIN divide by two (TRUE/FALSE)
592
      CLKIN_PERIOD => 41.7,                  -- Input clock period specified in nS
593
      CLKOUT_PHASE_SHIFT => "NONE",          -- Output phase shift (NONE, FIXED, VARIABLE)
594
      CLK_FEEDBACK => "2X",                  -- Feedback source (NONE, 1X, 2X)
595
      DESKEW_ADJUST => "SYSTEM_SYNCHRONOUS", -- SYSTEM_SYNCHRNOUS or SOURCE_SYNCHRONOUS
596
      DFS_FREQUENCY_MODE => "LOW",           -- Unsupported - Do not change value
597
      DLL_FREQUENCY_MODE => "LOW",           -- Unsupported - Do not change value
598
      DSS_MODE => "NONE",                    -- Unsupported - Do not change value
599
      DUTY_CYCLE_CORRECTION => TRUE,         -- Unsupported - Do not change value
600
      FACTORY_JF => X"c080",                 -- Unsupported - Do not change value
601
      PHASE_SHIFT => 0,                      -- Amount of fixed phase shift (-255 to 255)
602
      STARTUP_WAIT => FALSE                  -- Delay config DONE until DCM_SP LOCKED (TRUE/FALSE)
603
   )
604
   port map (
605
      CLK0 => OPEN,           -- 1-bit output: 0 degree clock output
606
      CLK180 => OPEN,         -- 1-bit output: 180 degree clock output
607
      CLK270 => OPEN,         -- 1-bit output: 270 degree clock output
608
      CLK2X => clk_48,        -- 1-bit output: 2X clock frequency clock output
609
      CLK2X180 => OPEN,       -- 1-bit output: 2X clock frequency, 180 degree clock output
610
      CLK90 => OPEN,          -- 1-bit output: 90 degree clock output
611
      CLKDV => clk_dna,       -- 1-bit output: Divided clock output
612
      CLKFX => clk_96,        -- 1-bit output: Digital Frequency Synthesizer output (DFS)
613
      CLKFX180 => OPEN,       -- 1-bit output: 180 degree CLKFX output
614
      LOCKED => dcm_locked,   -- 1-bit output: DCM_SP Lock Output
615
      PSDONE => OPEN,         -- 1-bit output: Phase shift done output
616
      STATUS => OPEN,         -- 8-bit output: DCM_SP status output
617
      CLKFB => clk_sys,       -- 1-bit input: Clock feedback input
618
      CLKIN => clk_24,        -- 1-bit input: Clock input
619
      DSSEN => '0',           -- 1-bit input: Unsupported, specify to GND.
620
      PSCLK => '0',           -- 1-bit input: Phase shift clock input
621
      PSEN => '0',            -- 1-bit input: Phase shift enable
622
      PSINCDEC => '0',        -- 1-bit input: Phase shift increment/decrement input
623
      RST => rst_dcm          -- 1-bit input: Active high reset input
624
   );
625
 
626
   BUFG_inst : BUFG
627
   port map (
628
      O => clk_sys,
629
      I => clk_48
630
   );
631
 
632
   --Resynhcronisation du signal DCM_LOCKED sur clk_dna
633
   PROCESS (clk_dna, rst_fpgan)
634
   BEGIN
635
      IF (rst_fpgan = '0') THEN
636
         rstdna_n <= '0';
637
      ELSIF (clk_dna'EVENT AND clk_dna = '1') THEN
638
         rstdna_n <= dcm_locked;
639
      END IF;
640
   END PROCESS;
641
 
642
   --Compteur en free running pour la LED OK à 2Hz
643
   PROCESS (clk_24, rst_n)
644
   BEGIN
645
      IF (rst_n = '0') THEN
646
         cpt_blink <= (OTHERS => '0');
647
      ELSIF (clk_24'EVENT AND clk_24 = '1') THEN
648
         cpt_blink <= cpt_blink + 1;
649
      END IF;
650
   END PROCESS;
651
 
652
   led_fail <= NOT(repli);                   -- quand repli = '1' on affiche du rouge fixe
653
   led_run  <= '1' WHEN (repli = '1') ELSE   -- Si repli = '0' on affiche du vert à 2Hz
654
               cpt_blink(cpt_blink'LEFT);    -- Période de la led run à 700ms
655
   led_confok <= '0';                        -- Dès que le FPGA est configuré on allume la LED verte 
656
 
657
   -----------------------------------------------
658
   -- Instantiation du module de récupération de l'@ IID
659
   -----------------------------------------------
660
   inst_readiid : readmac
661
   GENERIC MAP(
662
      sim_dna_value => X"123456789ABCDEF")
663
   PORT MAP (
664
      clk_sys  => clk_dna,    -- Utilise une horloge à 2MHz MAX
665
      rst_n    => rstdna_n,
666
      mac      => iid,
667
      mac_rdy  => iid_rdy
668
      );
669
 
670
   --Resynhcronisation du signal IID_RDY sur clk_96
671
   PROCESS (clk_96, rst_fpgan)
672
   BEGIN
673
      IF (rst_fpgan = '0') THEN
674
         rst96_n <= '0';
675
      ELSIF (clk_96'EVENT AND clk_96 = '1') THEN
676
         rst96_n <= iid_rdy;
677
      END IF;
678
   END PROCESS;
679
 
680
   ------------------------------
681
   -- Instantiation du module PCIe
682
   ------------------------------
683
   inst_pcieif : if_pcie
684
   GENERIC MAP (
685
      nbbit_add => NBBIT_ADD_LOCAL
686
      )
687
   PORT MAP(
688
      pci_exp_txp => pci_exp_txp,
689
      pci_exp_txn => pci_exp_txn,
690
      pci_exp_rxp => pci_exp_rxp,
691
      pci_exp_rxn => pci_exp_rxn,
692
      sys_clk_p   => pci_clk_p,
693
      sys_clk_n   => pci_clk_n,
694
      -- Le GPIO pci_rstn est mal géré par la passerelle. On utlise n gusie de reset le signal
695
      -- sda qui est RFU et qui a une pull up externe.
696
      sys_reset_n => sda,               --pci_rstn,
697
      dma_req     => dma_req,
698
      dma_compl   => dma_compl,
699
      dma_ack     => dma_ack,
700
      dma_add_dest=> dma_add_dest,
701
      dma_data    => dma_data,
702
      dma_read    => dma_read,
703
      dma_size    => dma_size,
704
      rd_addr     => rd_addr,
705
      rd_data     => rd_data,
706
      rd_be       => rd_be,
707
      rd_en       => rd_en,
708
      wr_addr     => wr_addr,
709
      wr_data     => wr_data,
710
      wr_be       => wr_be,
711
      wr_en       => wr_en,
712
      wr_busy     => wr_busy,
713
      clk_local   => clk_pcie,
714
      rst_local_n => rstpcie_n,
715
      link_up_n   => link_up_n
716
   );
717
   pci_waken <= '0';
718
 
719
   ------------------------------
720
   -- Instantiation du module mapping mémoire
721
   ------------------------------
722
   PROCESS (clk_pcie, rstpcie_n)
723
   BEGIN
724
      IF (rstpcie_n = '0') THEN
725
         cpy_r1 <= '1';
726
         cpy_r2 <= '1';
727
         actif_passifn <= '1';
728
      ELSIF (clk_pcie'EVENT AND clk_pcie = '1') THEN
729
         cpy_r1 <= NOT(cpy1 AND cpy2);
730
         cpy_r2 <= cpy_r1;
731
         actif_passifn <= cpy_r2;
732
      END IF;
733
   END PROCESS;
734
 
735
   inst_mem : memory_map
736
   GENERIC MAP(
737
      reg_version => reg_version)
738
   PORT MAP (
739
      clk_sys        => clk_pcie,
740
      rst_n          => rstpcie_n,
741
      iid            => iid,
742
      actif_passifn  => actif_passifn,
743
      rd_addr        => rd_addr,
744
      rd_data        => rd_data,
745
      rd_be          => rd_be,
746
      rd_en          => rd_en,
747
      wr_addr        => wr_addr,
748
      wr_data        => wr_data,
749
      wr_be          => wr_be,
750
      wr_en          => wr_en,
751
      wr_busy        => wr_busy,
752
      rst_regn       => rst_regn,
753
      store_enable   => store_enable,
754
      dma_inprogress => dma_inprogress,
755
      update_ena     => '1',
756
      rx_flushn      => rx_flushn,
757
      topcyc         => topcyc,
758
      tx_ena_periodic=> tx_ena_periodic,
759
      tx_ena_aper    => tx_ena_aper,
760
      clr_txena_aper => clr_txena_aper,
761
      dma_base_pa    => dma_base_pa,
762
      dma_timestamp  => dma_timestamp,
763
      bufferrx1_full => bufferrx1_full,
764
      bufferrx2_full => bufferrx2_full,
765
      buffertx_full  => buffertx_full,
766
      newframe_rx1   => newframe_rx1,
767
      newframe_rx2   => newframe_rx2,
768
      newframe_tx    => newframe_tx,
769
      rx1_overflow   => rx1_overflow,
770
      rx2_overflow   => rx2_overflow,
771
      tx_overflow    => tx_overflow,
772
      rx1_badformat  => rx1_badformat,
773
      rx2_badformat  => rx2_badformat,
774
                clk_96                  => clk_96,
775
                rd_force                        => rd_force,
776
                data_force              => data_force,
777
                empty_force             => empty_force,
778
      addrr_tx       => addrr_tx,
779
      data_tx        => data_tx,
780
      rd_datatx      => rd_datatx,
781
      testpoint      => OPEN --spare
782
   );
783
 
784
   -----------------------------------------
785
   -- Interface permettant à la passerelle d'injecter des trames sur le réseau 
786
   -- Interface non utilisée pour l'instant
787
   -----------------------------------------
788
   clr_txena_aper <= (OTHERS => '0');
789
   addrr_tx <= (OTHERS => '0');
790
   rd_datatx <= '0';
791
 
792
   ------------------------------
793
   -- Gestion du DMA
794
   ------------------------------
795
   inst_dma : manage_dma
796
   PORT MAP (
797
      clk_sys        => clk_pcie,
798
      rst_n          => rx_flushn,
799
      store_enable   => store_enable,
800
      data_storerx1  => data_pcie_rx1,
801
      val_storerx1   => val_pcie_rx1,
802
      sof_storerx1   => sof_pcie_rx1,
803
      eof_storerx1   => eof_pcie_rx1,
804
      crcok_storerx1 => crcok_pcie_rx1,
805
      data_storerx2  => data_pcie_rx2,
806
      val_storerx2   => val_pcie_rx2,
807
      sof_storerx2   => sof_pcie_rx2,
808
      eof_storerx2   => eof_pcie_rx2,
809
      crcok_storerx2 => crcok_pcie_rx2,
810
      data_storetx   => data_pcie_tx,
811
      val_storetx    => val_pcie_tx,
812
      sof_storetx    => sof_pcie_tx,
813
      eof_storetx    => eof_pcie_tx,
814
      newframe_rx1   => newframe_rx1,
815
      newframe_rx2   => newframe_rx2,
816
      newframe_tx    => newframe_tx,
817
      bufferrx1_full => bufferrx1_full,
818
      bufferrx2_full => bufferrx2_full,
819
      buffertx_full  => buffertx_full,
820
      rx1_overflow   => rx1_overflow,
821
      rx2_overflow   => rx2_overflow,
822
      tx_overflow    => tx_overflow,
823
      rx1_badformat  => rx1_badformat,
824
      rx2_badformat  => rx2_badformat,
825
      dma_inprogress => dma_inprogress,
826
      dma_req        => dma_req,
827
      dma_size       => dma_size,
828
      dma_ack        => dma_ack,
829
      dma_compl      => dma_compl,
830
      dma_read       => dma_read,
831
      dma_data       => dma_data,
832
      dma_add_dest   => dma_add_dest,
833
      dma_base_pa    => dma_base_pa,
834
      dma_timestamp  => dma_timestamp
835
   );
836
 
837
   -----------------------------------------------
838
   -- Instantiation du module de communication
839
   -----------------------------------------------
840
   -- Les 2 drivers RS485 sont toujours autorisés à émettre
841
   ls485_de1 <= '1';
842
   ls485_de2 <= '1';
843
   -- Les 2 drivers RS485 sont toujorus autorisés à recevoir
844
   ls485_ren1 <= '0';
845
   ls485_ren2 <= '0';
846
 
847
   inst_comm : con_communication_sil
848
   PORT MAP (
849
      clk_sys        => clk_96,
850
      rst_n          => rst96_n,
851
      baudrate       => baudrate,
852
      actif          => actif,
853
      ad_con         => tid,
854
      top_cycle      => topcyc,
855
      ena_filt_dble  => ena_filt_dble,
856
      rx1            => ls485_rx1,
857
      tx1            => ls485_tx1,
858
      rx2            => ls485_rx2,
859
      tx2            => ls485_tx2,
860
      copy_ena1      => cpy1,
861
      copy_ena2      => cpy2,
862
      filt_rx1       => l7_rx1,
863
      filt_soc1      => l7_soc1,
864
      filt_rd1       => l7_rd1,
865
      filt_comdispo1 => l7_comdispo1,
866
      layer7_newframe1  => l7_newframe1,
867
      layer7_l2ok1      => l7_l2ok1,
868
      layer7_overflow1  => l7_overflow1,
869
      filt_rx2          => l7_rx2,
870
      filt_soc2         => l7_soc2,
871
      filt_rd2          => l7_rd2,
872
      filt_comdispo2    => l7_comdispo2,
873
      layer7_newframe2  => l7_newframe2,
874
      layer7_l2ok2      => l7_l2ok2,
875
      layer7_overflow2  => l7_overflow2,
876
      data_storerx1     => data_storerx1,
877
      val_storerx1      => val_storerx1,
878
      sof_storerx1      => sof_storerx1,
879
      eof_storerx1      => eof_storerx1,
880
      crcok_storerx1    => crcok_storerx1,
881
      data_storerx2     => data_storerx2,
882
      val_storerx2      => val_storerx2,
883
      sof_storerx2      => sof_storerx2,
884
      eof_storerx2      => eof_storerx2,
885
      crcok_storerx2    => crcok_storerx2,
886
      tx_dat            => tx_dat,
887
      val_txdat         => val_txdat,
888
      tx_sof            => tx_sof,
889
      tx_eof            => tx_eof,
890
      txdat_free        => txdat_free,
891
      clr_fifo_tx       => clr_fifo_tx,
892
      stuf_phys         => stuf_phys,
893
      acq_stuf          => acq_stuf
894
   );
895
 
896
   -----------------------------------------------
897
   -- Instantiation du module d'interface PIC PMP
898
   -----------------------------------------------
899
   inst_pic : if_picpmp
900
   GENERIC MAP (
901
      version => reg_version)
902
   PORT MAP (
903
      clk_sys      => clk_96,
904
      rst_n        => rst96_n,
905
      pmd          => pmd,
906
      pmall        => pmall,
907
      pmalh        => pmalh,
908
      pmrd         => pmrd,
909
      pmwr         => pmwr,
910
      iid          => iid,
911
      tid          => tid,
912
      cpy1         => cpy1,
913
      cpy2         => cpy2,
914
      repli        => repli,
915
      baudrate     => baudrate,
916
      actif        => actif,
917
      topcyc       => topcyc,
918
      enafiltdble  => ena_filt_dble,
919
      l7_rx1       => l7_rx1,
920
      l7_soc1      => l7_soc1,
921
      l7_rd1       => l7_rd1,
922
      l7_comdispo1 => l7_comdispo1,
923
      l7_newframe1 => l7_newframe1,
924
      l7_l2ok1     => l7_l2ok1,
925
      l7_overflow1 => l7_overflow1,
926
      l7_rx2       => l7_rx2,
927
      l7_soc2      => l7_soc2,
928
      l7_rd2       => l7_rd2,
929
      l7_comdispo2 => l7_comdispo2,
930
      l7_newframe2 => l7_newframe2,
931
      l7_l2ok2     => l7_l2ok2,
932
      l7_overflow2 => l7_overflow2,
933
      tx_dat       => tx_dat,
934
      val_txdat    => val_txdat,
935
      tx_sof       => tx_sof,
936
      tx_eof       => tx_eof,
937
      txdat_free   => txdat_free,
938
      clr_fifo_tx  => clr_fifo_tx,
939
      stuf_phys    => stuf_phys,
940
      acq_stuf     => acq_stuf,
941
      txprom_dat   => txprom_dat,
942
      txprom_val   => txprom_val,
943
      rxprom_dat   => rxprom_dat,
944
      rxprom_val   => rxprom_val,
945
      rxprom_next  => rxprom_next,
946
      prom_type_com=> prom_type_com,
947
      prom_exec_com=> prom_exec_com,
948
      prom_busy    => prom_busy,
949
      prom_nbread  => prom_nbread,
950
      prom_rstn    => prom_rstn,
951
                rd_force                 => rd_force,
952
                data_force       => data_force,
953
                empty_force      => empty_force
954
      );
955
 
956
   --------------------------------------------
957
   -- Changement d'horloge des flux RX1, RX2, TX
958
   --------------------------------------------
959
   inst_chgclk_rx1 : flux_chgclk
960
   PORT MAP(
961
      clks     => clk_96,
962
      clkd     => clk_pcie,
963
      rst_n    => rst96_n,
964
      datas    => data_storerx1,
965
      vals     => val_storerx1,
966
      sofs     => sof_storerx1,
967
      eofs     => eof_storerx1,
968
      crcoks   => crcok_storerx1,
969
      datad    => data_pcie_rx1,
970
      vald     => val_pcie_rx1,
971
      sofd     => sof_pcie_rx1,
972
      eofd     => eof_pcie_rx1,
973
      crcokd   => crcok_pcie_rx1
974
      );
975
 
976
   inst_chgclk_rx2 : flux_chgclk
977
   PORT MAP(
978
      clks     => clk_96,
979
      clkd     => clk_pcie,
980
      rst_n    => rst96_n,
981
      datas    => data_storerx2,
982
      vals     => val_storerx2,
983
      sofs     => sof_storerx2,
984
      eofs     => eof_storerx2,
985
      crcoks   => crcok_storerx2,
986
      datad    => data_pcie_rx2,
987
      vald     => val_pcie_rx2,
988
      sofd     => sof_pcie_rx2,
989
      eofd     => eof_pcie_rx2,
990
      crcokd   => crcok_pcie_rx2
991
      );
992
 
993
   tx_val <= txdat_free AND val_txdat;   -- On assure que chaque donnée n'est stockée qu'une seule fois
994
   inst_chgclk_tx : flux_chgclk
995
   PORT MAP(
996
      clks     => clk_96,
997
      clkd     => clk_pcie,
998
      rst_n    => rst96_n,
999
      datas    => tx_dat,
1000
      vals     => tx_val,
1001
      sofs     => tx_sof,
1002
      eofs     => tx_eof,
1003
      crcoks   => '1',
1004
      datad    => data_pcie_tx,
1005
      vald     => val_pcie_tx,
1006
      sofd     => sof_pcie_tx,
1007
      eofd     => eof_pcie_tx,
1008
      crcokd   => OPEN
1009
      );
1010
 
1011
   -----------------------------------------------
1012
   -- Instantiation du module d'interface SPI de programmation de la PROM
1013
   -----------------------------------------------
1014
   int_promspi :  if_promspi
1015
   GENERIC MAP(
1016
      div_rate    => 3,          -- Diviseur de l'horlgoe système
1017
      spiclk_freq => 12          -- Fréquence de l'horlgoe du SPI
1018
      )
1019
   PORT MAP(
1020
      clk_sys     => clk_96,
1021
      rst_n       => prom_rstn,
1022
      spi_csn     => cso_b,
1023
      spi_wpn     => wp_flashn,
1024
      spi_sdo     => mosi,
1025
      spi_sdi     => din_miso,
1026
      spi_clk     => cclk,
1027
      tx_dat      => txprom_dat,
1028
      tx_val      => txprom_val,
1029
      rx_dat      => rxprom_dat,
1030
      rx_val      => rxprom_val,
1031
      rx_next     => rxprom_next,
1032
      type_com    => prom_type_com,
1033
      exec_com    => prom_exec_com,
1034
      spi_busy    => prom_busy,
1035
      nb_read     => prom_nbread
1036
      );
1037
 
1038
   ---------------------------------------
1039
   -- Compteur en free running pour la génération à 300KHz de la commande des alims isolées des RS
1040
   ---------------------------------------
1041
   PROCESS (clk_24, rst_n)
1042
   BEGIN
1043
      IF (rst_n = '0') THEN
1044
         cpt_cde <= (OTHERS => '0');
1045
         toggle_cde <= '0';
1046
         cde_high <= '0';
1047
         cde_low <= '0';
1048
      ELSIF (clk_24'EVENT AND clk_24 = '1') THEN
1049
         IF (cpt_cde = CONV_STD_LOGIC_VECTOR(41, cpt_cde'LENGTH)) THEN
1050
         -- A la demi période (i.e = 42 x 40ns)
1051
            cpt_cde <= (OTHERS => '0');
1052
            cde_high <= '0';              -- Commande directe
1053
            cde_low <= '0';               -- Commande à 180°
1054
            toggle_cde <= NOT(toggle_cde);
1055
         ELSE
1056
            cpt_cde <= cpt_cde + 1;
1057
            IF (cpt_cde = CONV_STD_LOGIC_VECTOR(0, cpt_cde'LENGTH)) THEN
1058
               cde_high <= toggle_cde;
1059
               cde_low <= NOT(toggle_cde);
1060
            END IF;
1061
         END IF;
1062
      END IF;
1063
   END PROCESS;
1064
   cdehigh_5vid   <= cde_high;
1065
   cdelow_5vid    <= cde_low;
1066
   cdehigh_5vls1  <= cde_high;
1067
   cdelow_5vls1   <= cde_low;
1068
   cdehigh_5vls2  <= cde_high;
1069
   cdelow_5vls2   <= cde_low;
1070
   cdehigh_5vlsm2 <= cde_high;
1071
   cdelow_5vlsm2  <= cde_low;
1072
   cdehigh_5vcan  <= cde_high;
1073
   cdelow_5vcan   <= cde_low;
1074
 
1075
   ----------------------------------------
1076
   -- Signaux Spare
1077
   ----------------------------------------
1078
   spare    <= "00000000";
1079
   uc_pmd   <= (OTHERS => 'Z');
1080
   pic_tx   <= 'Z';
1081
   pic_sdo  <= 'Z';
1082
   tp(28)   <= pic_ssn OR pic_sdi OR pic_sck OR pic_spare(0) OR pic_spare(1) OR pic_spare(2) OR pic_spare(3) OR
1083
               pic_rx OR uc_sdo OR uc_sdi OR uc_ssn OR uc_sck OR uc_pmacs2 OR uc_pmacs1 OR uc_pmalh OR uc_pmall OR
1084
               uc_pmwr OR uc_pmrd OR pci_spare OR prog_b OR interrupt OR power_rstn OR clk_25;
1085
   tp(27 DOWNTO 22) <= (OTHERS => '0');
1086
 
1087
END rtl;
1088
 

powered by: WebSVN 2.1.0

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