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

Subversion Repositories saturn

[/] [saturn/] [trunk/] [FPGA Concentrateur SIL4/] [fpga_cosil4/] [top_fpgacosil4.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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