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

Subversion Repositories saturn

[/] [saturn/] [trunk/] [FPGA MIOSIL4/] [fpga_miosil4/] [top_miosil4.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 DavidRAMBA
--============================================================================= 
2
--  TITRE : TOP_MIOSIL4
3
--  DESCRIPTION : 
4
--        Module TOP du FPGA MIO SIL4
5
--
6
--  FICHIER :        top_miosil4.vhd 
7
--=============================================================================
8
--  CREATION 
9
--  DATE              AUTEUR    PROJET  REVISION 
10
--  11/08/2015  DRA        SATURN       V1.0 
11
--=============================================================================
12
 
13
LIBRARY IEEE;
14
USE IEEE.STD_LOGIC_1164.ALL;
15
USE IEEE.STD_LOGIC_ARITH.ALL;
16
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
17
LIBRARY UNISIM;
18
USE UNISIM.VComponents.ALL;
19
 
20
ENTITY top_miosil4 IS
21
   GENERIC (
22
      reg_version : STD_LOGIC_VECTOR(7 DOWNTO 0) := x"10"    -- Version du firmware
23
      );
24
   PORT (
25
      -- Ports système
26
      clk_24      : IN  STD_LOGIC;     -- Clock principale à 24MHz
27
      rst_n       : IN  STD_LOGIC;     -- Reset principal de la carte
28
      rst_fpgan   : IN  STD_LOGIC;     -- Reset issu du PIC32
29
      led_confok  : OUT STD_LOGIC;     -- Pilotage de la led rouge
30
      led_run     : OUT STD_LOGIC;     -- Pilotage de la 1ère LED verte
31
      led_fail    : OUT STD_LOGIC;     -- Pilotage de la 2ème LED verte
32
      power_rstn  : IN  STD_LOGIC;     -- Indique que l'alim 3.3V du PIC est coupée
33
 
34
      -- Interfaces ports séries
35
      ls485_de1   : OUT STD_LOGIC;     -- Signal d'autorisation à émettre de la LS1
36
      ls485_ren1  : OUT STD_LOGIC;     -- Signal d'autorisation à émettre de la LS1
37
      ls485_rx1   : IN  STD_LOGIC;     -- Signal de réception de la LS1
38
      ls485_tx1   : OUT STD_LOGIC;     -- Signal d'émission de la LS1
39
 
40
      ls485_de2   : OUT STD_LOGIC;     -- Signal d'autorisation à émettre de la LS2
41
      ls485_ren2  : OUT STD_LOGIC;     -- Signal d'autorisation à émettre de la LS2
42
      ls485_rx2   : IN  STD_LOGIC;     -- Signal de réception de la LS2
43
      ls485_tx2   : OUT STD_LOGIC;     -- Signal d'émission de la LS2
44
 
45
      -- Interface SPI (Interface PIC 1)
46
      pic_sclk1   : IN  STD_LOGIC;
47
      pic_sdi1    : OUT STD_LOGIC;
48
      pic_sdo1    : IN  STD_LOGIC;
49
      pic_ssn1    : IN  STD_LOGIC;
50
 
51
      -- Interface SPI (Interface PIC 2)
52
      pic_sclk2   : IN  STD_LOGIC;
53
      pic_sdi2    : OUT STD_LOGIC;
54
      pic_sdo2    : IN  STD_LOGIC;
55
      pic_ssn2    : IN  STD_LOGIC;
56
 
57
      -- Interface de pilotage des Alim isolées
58
      cdehigh_5vid   : OUT STD_LOGIC;
59
      cdelow_5vid    : OUT STD_LOGIC;
60
      cdehigh_5vls1  : OUT STD_LOGIC;
61
      cdelow_5vls1   : OUT STD_LOGIC;
62
      cdehigh_5vls2  : OUT STD_LOGIC;
63
      cdelow_5vls2   : OUT STD_LOGIC;
64
 
65
      -- Interface SPI (programmation de la flash de configuration)
66
      wp_flashn      : OUT STD_LOGIC;     -- Autorisation d'écriture dans la flash SPI
67
      cclk           : OUT STD_LOGIC;     -- Horloge d'accès à la flash SPI
68
      din_miso       : IN  STD_LOGIC;     -- Data série en lecture SPI
69
      mosi           : OUT STD_LOGIC;     -- Data série en écriture SPI
70
      cso_b          : OUT STD_LOGIC;     -- Chip select SPI
71
 
72
      -- Spare et RFU
73
      cde_diag1      : IN STD_LOGIC;
74
      cde_diag2      : IN STD_LOGIC;
75
      pic_tx1        : IN STD_LOGIC;
76
      pic_rx1        : OUT STD_LOGIC;
77
      pic_tx2        : IN STD_LOGIC;
78
      pic_rx2        : OUT STD_LOGIC;
79
      pic_spare      : IN  STD_LOGIC_VECTOR(3 DOWNTO 0);
80
      prog_b         : IN  STD_LOGIC;
81
      tp9            : OUT STD_LOGIC;
82
      tp10           : OUT STD_LOGIC;
83
      tp11           : OUT STD_LOGIC;
84
      spare          : OUT STD_LOGIC_VECTOR(7 DOWNTO 0)
85
   );
86
END top_miosil4;
87
 
88
ARCHITECTURE rtl of top_miosil4 is
89
   -- signaux utilisés pour les fonctions systèmes
90
   SIGNAL clk_sys        : STD_LOGIC:= '0';      -- Horloge système = 2 x clk_24
91
   SIGNAL clk_48         : STD_LOGIC:= '0';      -- Pour récupérer l'horloge CLKx2 à la sortie du DCM
92
   SIGNAL clk_96         : STD_LOGIC:= '0';      -- Pour récupérer l'horloge CLKFX à la sortie du DCM
93
   SIGNAL clk_dna        : STD_LOGIC:= '0';      -- Horloge à 1 MHz pour lire le DNA
94
   SIGNAL rst_dcm        : STD_LOGIC:= '0';      -- Signal de reset du DCM
95
   SIGNAL rstdna_n       : STD_LOGIC:= '0';      -- reset resynchronisé sur clk_dna
96
   SIGNAL rst96_n        : STD_LOGIC:= '0';      -- reset resynchronisé sur clk96
97
   SIGNAL dcm_locked     : STD_LOGIC:= '0';      -- Signal de lock du DCM
98
   SIGNAL cpt_blink      : STD_LOGIC_VECTOR(23 DOWNTO 0); -- Compteur pour le blink de la led run
99
   SIGNAL iid            : STD_LOGIC_VECTOR(63 DOWNTO 0); -- Valeur DNA du FPGA
100
   SIGNAL iid_rdy        : STD_LOGIC;            -- Indique que le IID a été récupéré
101
 
102
   -- Signaux d'interface entre le module de communication et le module SPI PIC
103
   SIGNAL tid         : STD_LOGIC_VECTOR(7 DOWNTO 0); -- TID que la COM doit utiliser pour ce MIO
104
   SIGNAL cpy1        : STD_LOGIC;              -- Autorise la copie du port 1 sur le port 2
105
   SIGNAL cpy2        : STD_LOGIC;              -- Autorise la copie du port 2 sur le port 1
106
   SIGNAL repli       : STD_LOGIC;              -- Indique que le MIO est en mode repli
107
   -- Interface de gestion des données applicatives reçues sur le port 1, côté µC1
108
   SIGNAL l7_rx1_uc1  : STD_LOGIC_VECTOR(7 DOWNTO 0); -- Dbus de onnées extraites de la trame
109
   SIGNAL l7_soc1_uc1 : STD_LOGIC;              -- Indique un début de trame
110
   SIGNAL l7_rd1_uc1  : STD_LOGIC;              -- Demande une donnée applicative de plus
111
   SIGNAL l7_comdispo1_uc1: STD_LOGIC;          -- Indique que des données applicatives sont en attentes
112
   SIGNAL l7_newframe1_uc1: STD_LOGIC;          -- Indique la réception d'une nouvelle trame
113
   SIGNAL l7_l2ok1_uc1: STD_LOGIC;              -- Indique que la trame reçu est correcte (format + CRC)
114
   SIGNAL l7_overflow1_uc1: STD_LOGIC;          -- Indique que la mémoire de stockage a débordé
115
   SIGNAL activity1   : STD_LOGIC;              -- Indique du trafic sur le port 1
116
   -- Interface de gestion des données applicatives reçues sur le port 2, côté µC1
117
   SIGNAL l7_rx2_uc1  : STD_LOGIC_VECTOR(7 DOWNTO 0); -- Idem
118
   SIGNAL l7_soc2_uc1 : STD_LOGIC;
119
   SIGNAL l7_rd2_uc1  : STD_LOGIC;
120
   SIGNAL l7_comdispo2_uc1: STD_LOGIC;
121
   SIGNAL l7_newframe2_uc1: STD_LOGIC;
122
   SIGNAL l7_l2ok2_uc1: STD_LOGIC;
123
   SIGNAL l7_overflow2_uc1: STD_LOGIC;
124
   SIGNAL activity2   : STD_LOGIC;
125
   -- Interface de gestion des données applicatives reçues sur le port 1, côté µC2
126
   SIGNAL l7_rx1_uc2  : STD_LOGIC_VECTOR(7 DOWNTO 0); -- Dbus de onnées extraites de la trame
127
   SIGNAL l7_soc1_uc2 : STD_LOGIC;              -- Indique un début de trame
128
   SIGNAL l7_rd1_uc2  : STD_LOGIC;              -- Demande une donnée applicative de plus
129
   SIGNAL l7_comdispo1_uc2: STD_LOGIC;          -- Indique que des données applicatives sont en attentes
130
   SIGNAL l7_newframe1_uc2: STD_LOGIC;          -- Indique la réception d'une nouvelle trame
131
   SIGNAL l7_l2ok1_uc2: STD_LOGIC;              -- Indique que la trame reçu est correcte (format + CRC)
132
   SIGNAL l7_overflow1_uc2: STD_LOGIC;          -- Indique que la mémoire de stockage a débordé
133
   -- Interface de gestion des données applicatives reçues sur le port 2, côté µC2
134
   SIGNAL l7_rx2_uc2  : STD_LOGIC_VECTOR(7 DOWNTO 0); -- Idem
135
   SIGNAL l7_soc2_uc2 : STD_LOGIC;
136
   SIGNAL l7_rd2_uc2  : STD_LOGIC;
137
   SIGNAL l7_comdispo2_uc2: STD_LOGIC;
138
   SIGNAL l7_newframe2_uc2: STD_LOGIC;
139
   SIGNAL l7_l2ok2_uc2: STD_LOGIC;
140
   SIGNAL l7_overflow2_uc2: STD_LOGIC;
141
   -- Interface de gestion des données applicatives à transmettre coté µC1
142
   SIGNAL tx_dat_uc1  : STD_LOGIC_VECTOR(7 DOWNTO 0); -- Bis de données applicatives
143
   SIGNAL val_txdat_uc1: STD_LOGIC;             -- Indique une donnée valide sur tx_dat
144
   SIGNAL tx_sof_uc1  : STD_LOGIC;              -- Indique un début de trame à transmettre
145
   SIGNAL tx_eof_uc1  : STD_LOGIC;              -- Indique une fin de trame à transmettre
146
   SIGNAL clr_fifo_tx_uc1: STD_LOGIC;           -- Permet d'effacer la FIFO d'emission
147
   SIGNAL txdat_free  : STD_LOGIC;              -- Indique que le module transport en tx est dispo
148
   -- Interface de gestion des données applicatives à transmettre coté µC2
149
   SIGNAL tx_dat_uc2  : STD_LOGIC_VECTOR(7 DOWNTO 0); -- Bis de données applicatives
150
   SIGNAL val_txdat_uc2: STD_LOGIC;             -- Indique une donnée valide sur tx_dat
151
   SIGNAL tx_sof_uc2  : STD_LOGIC;              -- Indique un début de trame à transmettre
152
   SIGNAL tx_eof_uc2  : STD_LOGIC;              -- Indique une fin de trame à transmettre
153
   SIGNAL clr_fifo_tx_uc2: STD_LOGIC;           -- Permet d'effacer la FIFO d'emission
154
   -- Signaux de gestion des interfaces SPI
155
   SIGNAL sclk1       : STD_LOGIC;
156
   SIGNAL sdi1        : STD_LOGIC;
157
   SIGNAL sdo1        : STD_LOGIC;
158
   SIGNAL ssn1        : STD_LOGIC;
159
   SIGNAL sclk2       : STD_LOGIC;
160
   SIGNAL sdi2        : STD_LOGIC;
161
   SIGNAL sdo2        : STD_LOGIC;
162
   SIGNAL ssn2        : STD_LOGIC;
163
 
164
   -- Signaux de gestion du module d'accès à la PROM de configuration FPGA
165
   SIGNAL txprom_dat  : STD_LOGIC_VECTOR(7 downto 0); -- Donnée/commande à écrire
166
   SIGNAL txprom_val  : STD_LOGIC;                    -- Indique une donnée disponible sur txprom_dat
167
   SIGNAL rxprom_dat  : STD_LOGIC_VECTOR(7 downto 0); -- Donnée lue dans la PROM
168
   SIGNAL rxprom_val  : STD_LOGIC;                    -- Indique une donnée disponible sur rxprom_dat
169
   SIGNAL rxprom_next : STD_LOGIC;                    -- Demande une dnouvelle donnée sur rxprom_dat
170
   SIGNAL prom_type_com: STD_LOGIC;                   -- Définit le type de commande à exécuter (R ou W)
171
   SIGNAL prom_exec_com: STD_LOGIC;                   -- Lance l'exécution d'une commande d'accès à la PROM
172
   SIGNAL prom_busy   : STD_LOGIC;                    -- Indique que le module est occupé
173
   SIGNAL prom_nbread : STD_LOGIC_VECTOR(7 DOWNTO 0); -- Nombre d 'octets à lire avec une commande de lecture
174
   SIGNAL prom_rstn   : STD_LOGIC;                    -- reset du module d'accès à la PROM
175
 
176
   -- Pilotage des Alims (PWM)
177
   SIGNAL cpt_cde       : STD_LOGIC_VECTOR(5 DOWNTO 0);  -- Compteur pour générer les pulses de commande des alims isolées
178
   SIGNAL toggle_cde    : STD_LOGIC;                  -- Pour savoir quelle voie de la commadne alim est active
179
   SIGNAL cde_high      : STD_LOGIC;                  -- Signal de pilotage MOSFET
180
   SIGNAL cde_low       : STD_LOGIC;                  -- Signal de piltoage MOSFET
181
 
182
   COMPONENT communication_sil4
183
   PORT (
184
      clk_sys        : IN  STD_LOGIC;
185
      rst_n          : IN  STD_LOGIC;
186
      ad_mio         : IN  STD_LOGIC_VECTOR(7 DOWNTO 0);
187
      rx1            : IN  STD_LOGIC;
188
      tx1            : OUT STD_LOGIC;
189
      rx2            : IN  STD_LOGIC;
190
      tx2            : OUT STD_LOGIC;
191
      copy_ena1      : IN  STD_LOGIC;
192
      copy_ena2      : IN  STD_LOGIC;
193
      layer7_rx1_uc1       : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
194
      layer7_soc1_uc1      : OUT STD_LOGIC;
195
      layer7_rd1_uc1       : IN  STD_LOGIC;
196
      layer7_newframe1_uc1 : OUT STD_LOGIC;
197
      layer7_comdispo1_uc1 : OUT STD_LOGIC;
198
      layer7_l2ok1_uc1     : OUT STD_LOGIC;
199
      layer7_overflow1_uc1 : OUT STD_LOGIC;
200
      activity1            : OUT STD_LOGIC;
201
      layer7_rx2_uc1       : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
202
      layer7_soc2_uc1      : OUT STD_LOGIC;
203
      layer7_rd2_uc1       : IN  STD_LOGIC;
204
      layer7_newframe2_uc1 : OUT STD_LOGIC;
205
      layer7_comdispo2_uc1 : OUT STD_LOGIC;
206
      layer7_l2ok2_uc1     : OUT STD_LOGIC;
207
      layer7_overflow2_uc1 : OUT STD_LOGIC;
208
      activity2            : OUT STD_LOGIC;
209
      layer7_rx1_uc2       : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
210
      layer7_soc1_uc2      : OUT STD_LOGIC;
211
      layer7_rd1_uc2       : IN  STD_LOGIC;
212
      layer7_newframe1_uc2 : OUT STD_LOGIC;
213
      layer7_comdispo1_uc2 : OUT STD_LOGIC;
214
      layer7_l2ok1_uc2     : OUT STD_LOGIC;
215
      layer7_overflow1_uc2 : OUT STD_LOGIC;
216
      layer7_rx2_uc2       : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
217
      layer7_soc2_uc2      : OUT STD_LOGIC;
218
      layer7_rd2_uc2       : IN  STD_LOGIC;
219
      layer7_newframe2_uc2 : OUT STD_LOGIC;
220
      layer7_comdispo2_uc2 : OUT STD_LOGIC;
221
      layer7_l2ok2_uc2     : OUT STD_LOGIC;
222
      layer7_overflow2_uc2 : OUT STD_LOGIC;
223
      txdat_free           : OUT STD_LOGIC;
224
      tx_dat_uc1           : IN  STD_LOGIC_VECTOR(7 DOWNTO 0);
225
      val_txdat_uc1        : IN  STD_LOGIC;
226
      tx_sof_uc1           : IN  STD_LOGIC;
227
      tx_eof_uc1           : IN  STD_LOGIC;
228
      clr_fifo_tx_uc1      : IN  STD_LOGIC;
229
      tx_dat_uc2           : IN  STD_LOGIC_VECTOR(7 DOWNTO 0);
230
      val_txdat_uc2        : IN  STD_LOGIC;
231
      tx_sof_uc2           : IN  STD_LOGIC;
232
      tx_eof_uc2           : IN  STD_LOGIC;
233
      clr_fifo_tx_uc2      : IN  STD_LOGIC
234
      );
235
   END COMPONENT;
236
 
237
   COMPONENT readmac
238
   GENERIC (
239
      sim_dna_value : STD_LOGIC_VECTOR(59 DOWNTO 0) :=  X"023456789ABCDEF");
240
   PORT (
241
      clk_sys  : IN  STD_LOGIC;
242
      rst_n    : IN  STD_LOGIC;
243
      mac      : OUT  STD_LOGIC_VECTOR(63 downto 0);
244
      mac_rdy  : OUT  STD_LOGIC
245
      );
246
   END COMPONENT;
247
 
248
   COMPONENT if_picspi
249
   GENERIC (
250
      version : STD_LOGIC_VECTOR(7 DOWNTO 0);
251
      pic_num : INTEGER := 1);
252
   PORT (
253
      clk_sys  : IN  STD_LOGIC;
254
      rst_n    : IN  STD_LOGIC;
255
      sclk     : IN  STD_LOGIC;
256
      sdi      : IN  STD_LOGIC;
257
      sdo      : OUT STD_LOGIC;
258
      ssn      : IN  STD_LOGIC;
259
      iid      : IN  STD_LOGIC_VECTOR(63 DOWNTO 0);
260
      tid      : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
261
      cpy1     : OUT STD_LOGIC;
262
      cpy2     : OUT STD_LOGIC;
263
      repli        : OUT STD_LOGIC;
264
      l7_rx1       : IN  STD_LOGIC_VECTOR(7 DOWNTO 0);
265
      l7_soc1      : IN  STD_LOGIC;
266
      l7_rd1       : OUT STD_LOGIC;
267
      l7_comdispo1 : IN  STD_LOGIC;
268
      l7_newframe1 : IN  STD_LOGIC;
269
      l7_l2ok1     : IN  STD_LOGIC;
270
      l7_overflow1 : IN  STD_LOGIC;
271
      activity1    : IN  STD_LOGIC;
272
      l7_rx2       : IN  STD_LOGIC_VECTOR(7 DOWNTO 0);
273
      l7_soc2      : IN  STD_LOGIC;
274
      l7_rd2       : OUT STD_LOGIC;
275
      l7_comdispo2 : IN  STD_LOGIC;
276
      l7_newframe2 : IN  STD_LOGIC;
277
      l7_l2ok2     : IN  STD_LOGIC;
278
      l7_overflow2 : IN  STD_LOGIC;
279
      activity2    : IN  STD_LOGIC;
280
      tx_dat       : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
281
      val_txdat    : OUT STD_LOGIC;
282
      tx_sof       : OUT STD_LOGIC;
283
      tx_eof       : OUT STD_LOGIC;
284
      txdat_free   : IN  STD_LOGIC;
285
      clr_fifo_tx  : OUT STD_LOGIC;
286
      txprom_dat   : OUT STD_LOGIC_VECTOR(7 downto 0);
287
      txprom_val   : OUT STD_LOGIC;
288
      rxprom_dat   : IN  STD_LOGIC_VECTOR(7 downto 0);
289
      rxprom_val   : IN  STD_LOGIC;
290
      rxprom_next  : OUT STD_LOGIC;
291
      prom_type_com: OUT STD_LOGIC;
292
      prom_exec_com: OUT STD_LOGIC;
293
      prom_busy    : IN  STD_LOGIC;
294
      prom_nbread  : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
295
      prom_rstn    : OUT STD_LOGIC
296
      );
297
   END COMPONENT;
298
 
299
   COMPONENT if_promspi
300
   GENERIC (
301
      div_rate    : INTEGER := 1;
302
      spiclk_freq : INTEGER := 10
303
      );
304
   PORT (
305
      clk_sys     : IN  STD_LOGIC;
306
      rst_n       : IN  STD_LOGIC;
307
      spi_csn     : OUT STD_LOGIC;
308
      spi_wpn     : OUT STD_LOGIC;
309
      spi_sdo     : OUT STD_LOGIC;
310
      spi_sdi     : IN  STD_LOGIC;
311
      spi_clk     : OUT STD_LOGIC;
312
      tx_dat      : IN  STD_LOGIC_VECTOR(7 downto 0);
313
      tx_val      : IN  STD_LOGIC;
314
      rx_dat      : OUT STD_LOGIC_VECTOR(7 downto 0);
315
      rx_val      : OUT STD_LOGIC;
316
      rx_next     : IN  STD_LOGIC;
317
      type_com    : IN  STD_LOGIC;
318
      exec_com    : IN  STD_LOGIC;
319
      spi_busy    : OUT STD_LOGIC;
320
      nb_read     : IN  STD_LOGIC_VECTOR(7 DOWNTO 0)
321
      );
322
   END COMPONENT;
323
 
324
BEGIN
325
   ---------------------------------------------------
326
   -- Gestion des interfaces système
327
   ---------------------------------------------------
328
   rst_dcm <= NOT(rst_fpgan);                -- Le reset généré par le PIC déclenche un reset général
329
 
330
   DCM_SP_inst : DCM_SP
331
   generic map (
332
      CLKDV_DIVIDE => 16.0,                  -- CLKDV divide value
333
                                             -- (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).
334
      CLKFX_DIVIDE => 1,                     -- Divide value on CLKFX outputs - D - (1-32)
335
      CLKFX_MULTIPLY => 4,                   -- Multiply value on CLKFX outputs - M - (2-32)
336
      CLKIN_DIVIDE_BY_2 => FALSE,            -- CLKIN divide by two (TRUE/FALSE)
337
      CLKIN_PERIOD => 41.7,                  -- Input clock period specified in nS
338
      CLKOUT_PHASE_SHIFT => "NONE",          -- Output phase shift (NONE, FIXED, VARIABLE)
339
      CLK_FEEDBACK => "2X",                  -- Feedback source (NONE, 1X, 2X)
340
      DESKEW_ADJUST => "SYSTEM_SYNCHRONOUS", -- SYSTEM_SYNCHRNOUS or SOURCE_SYNCHRONOUS
341
      DFS_FREQUENCY_MODE => "LOW",           -- Unsupported - Do not change value
342
      DLL_FREQUENCY_MODE => "LOW",           -- Unsupported - Do not change value
343
      DSS_MODE => "NONE",                    -- Unsupported - Do not change value
344
      DUTY_CYCLE_CORRECTION => TRUE,         -- Unsupported - Do not change value
345
      FACTORY_JF => X"c080",                 -- Unsupported - Do not change value
346
      PHASE_SHIFT => 0,                      -- Amount of fixed phase shift (-255 to 255)
347
      STARTUP_WAIT => FALSE                  -- Delay config DONE until DCM_SP LOCKED (TRUE/FALSE)
348
   )
349
   port map (
350
      CLK0 => OPEN,           -- 1-bit output: 0 degree clock output
351
      CLK180 => OPEN,         -- 1-bit output: 180 degree clock output
352
      CLK270 => OPEN,         -- 1-bit output: 270 degree clock output
353
      CLK2X => clk_48,        -- 1-bit output: 2X clock frequency clock output
354
      CLK2X180 => OPEN,       -- 1-bit output: 2X clock frequency, 180 degree clock output
355
      CLK90 => OPEN,          -- 1-bit output: 90 degree clock output
356
      CLKDV => clk_dna,       -- 1-bit output: Divided clock output
357
      CLKFX => clk_96,        -- 1-bit output: Digital Frequency Synthesizer output (DFS)
358
      CLKFX180 => OPEN,       -- 1-bit output: 180 degree CLKFX output
359
      LOCKED => dcm_locked,   -- 1-bit output: DCM_SP Lock Output
360
      PSDONE => OPEN,         -- 1-bit output: Phase shift done output
361
      STATUS => OPEN,         -- 8-bit output: DCM_SP status output
362
      CLKFB => clk_sys,       -- 1-bit input: Clock feedback input
363
      CLKIN => clk_24,        -- 1-bit input: Clock input
364
      DSSEN => '0',           -- 1-bit input: Unsupported, specify to GND.
365
      PSCLK => '0',           -- 1-bit input: Phase shift clock input
366
      PSEN => '0',            -- 1-bit input: Phase shift enable
367
      PSINCDEC => '0',        -- 1-bit input: Phase shift increment/decrement input
368
      RST => rst_dcm          -- 1-bit input: Active high reset input
369
   );
370
 
371
   BUFG_inst : BUFG
372
   port map (
373
      O => clk_sys,
374
      I => clk_48
375
   );
376
 
377
   --Resynhcronisation du signal DCM_LOCKED sur clk_dna
378
   PROCESS (clk_dna, rst_fpgan)
379
   BEGIN
380
      IF (rst_fpgan = '0') THEN
381
         rstdna_n <= '0';
382
      ELSIF (clk_dna'EVENT AND clk_dna = '1') THEN
383
         rstdna_n <= dcm_locked;
384
      END IF;
385
   END PROCESS;
386
 
387
   --Compteur en free running pour la LED OK à 2Hz
388
   PROCESS (clk_24)
389
   BEGIN
390
      IF (clk_24'EVENT AND clk_24 = '1') THEN
391
         cpt_blink <= cpt_blink + 1;
392
      END IF;
393
   END PROCESS;
394
 
395
   led_fail <= NOT(repli);                   -- quand repli = '1' on affiche du rouge fixe
396
   led_run  <= '1' WHEN (repli = '1') ELSE   -- Si repli = '0' on affiche du vert à 2Hz
397
               cpt_blink(cpt_blink'LEFT);    -- Période de la led run à 700ms
398
   led_confok <= '0';                        -- Dès que le FPGA est configuré on allume la LED verte 
399
 
400
   -----------------------------------------------
401
   -- Instantiation du module de récupération de l'@ IID
402
   -----------------------------------------------
403
   inst_readiid : readmac
404
   GENERIC MAP(
405
      sim_dna_value => X"123456789ABCDEF")
406
   PORT MAP (
407
      clk_sys  => clk_dna,    -- Utilise une horloge à 2MHz MAX
408
      rst_n    => rstdna_n,   -- Autorisé dès que la DCM est lockée
409
      mac      => iid,
410
      mac_rdy  => iid_rdy
411
      );
412
 
413
   --Resynhcronisation sur l'horloge à 96MHz
414
   PROCESS (clk_96, rst_fpgan)
415
   BEGIN
416
      IF (rst_fpgan = '0') THEN
417
         rst96_n <= '0';
418
      ELSIF (clk_96'EVENT AND clk_96 = '1') THEN
419
         rst96_n <= iid_rdy;
420
      END IF;
421
   END PROCESS;
422
 
423
   -----------------------------------------------
424
   -- Instantiation du module de communication
425
   -----------------------------------------------
426
   -- Les 2 drivers RS485 sont toujours autorisés à émettre
427
   ls485_de1 <= '1';
428
   ls485_de2 <= '1';
429
   -- Les 2 drivers RS485 sont toujours autorisés à recevoir
430
   ls485_ren1 <= '0';
431
   ls485_ren2 <= '0';
432
 
433
   inst_comm : communication_sil4
434
   PORT MAP (
435
      clk_sys        => clk_96,
436
      rst_n          => rst96_n,
437
      ad_mio         => tid,
438
      rx1            => ls485_rx1,
439
      tx1            => ls485_tx1,
440
      rx2            => ls485_rx2,
441
      tx2            => ls485_tx2,
442
      copy_ena1      => cpy1,
443
      copy_ena2      => cpy2,
444
      layer7_rx1_uc1       => l7_rx1_uc1,
445
      layer7_soc1_uc1      => l7_soc1_uc1,
446
      layer7_rd1_uc1       => l7_rd1_uc1,
447
      layer7_newframe1_uc1 => l7_newframe1_uc1,
448
      layer7_comdispo1_uc1 => l7_comdispo1_uc1,
449
      layer7_l2ok1_uc1     => l7_l2ok1_uc1,
450
      layer7_overflow1_uc1 => l7_overflow1_uc1,
451
      activity1            => activity1,
452
      layer7_rx2_uc1       => l7_rx2_uc1,
453
      layer7_soc2_uc1      => l7_soc2_uc1,
454
      layer7_rd2_uc1       => l7_rd2_uc1,
455
      layer7_newframe2_uc1 => l7_newframe2_uc1,
456
      layer7_comdispo2_uc1 => l7_comdispo2_uc1,
457
      layer7_l2ok2_uc1     => l7_l2ok2_uc1,
458
      layer7_overflow2_uc1 => l7_overflow2_uc1,
459
      activity2            => activity2,
460
      layer7_rx1_uc2       => l7_rx1_uc2,
461
      layer7_soc1_uc2      => l7_soc1_uc2,
462
      layer7_rd1_uc2       => l7_rd1_uc2,
463
      layer7_newframe1_uc2 => l7_newframe1_uc2,
464
      layer7_comdispo1_uc2 => l7_comdispo1_uc2,
465
      layer7_l2ok1_uc2     => l7_l2ok1_uc2,
466
      layer7_overflow1_uc2 => l7_overflow1_uc2,
467
      layer7_rx2_uc2       => l7_rx2_uc2,
468
      layer7_soc2_uc2      => l7_soc2_uc2,
469
      layer7_rd2_uc2       => l7_rd2_uc2,
470
      layer7_newframe2_uc2 => l7_newframe2_uc2,
471
      layer7_comdispo2_uc2 => l7_comdispo2_uc2,
472
      layer7_l2ok2_uc2     => l7_l2ok2_uc2,
473
      layer7_overflow2_uc2 => l7_overflow2_uc2,
474
      txdat_free           => txdat_free,
475
      tx_dat_uc1           => tx_dat_uc1,
476
      val_txdat_uc1        => val_txdat_uc1,
477
      tx_sof_uc1           => tx_sof_uc1,
478
      tx_eof_uc1           => tx_eof_uc1,
479
      clr_fifo_tx_uc1      => clr_fifo_tx_uc1,
480
      tx_dat_uc2           => tx_dat_uc2,
481
      val_txdat_uc2        => val_txdat_uc2,
482
      tx_sof_uc2           => tx_sof_uc2,
483
      tx_eof_uc2           => tx_eof_uc2,
484
      clr_fifo_tx_uc2      => clr_fifo_tx_uc2
485
   );
486
 
487
   -----------------------------------------------
488
   -- Instantiation du module d'interface PIC1
489
   -----------------------------------------------
490
   inst_pic1 : if_picspi
491
   GENERIC MAP(
492
      version => reg_version,
493
      pic_num => 1)
494
   PORT MAP (
495
      clk_sys  => clk_96,
496
      rst_n    => rst96_n,
497
      sclk     => sclk1,
498
      sdi      => sdi1,
499
      sdo      => sdo1,
500
      ssn      => ssn1,
501
      iid      => iid,
502
      tid      => tid,
503
      cpy1     => cpy1,
504
      cpy2     => cpy2,
505
      repli    => repli,
506
      l7_rx1   => l7_rx1_uc1,
507
      l7_soc1  => l7_soc1_uc1,
508
      l7_rd1   => l7_rd1_uc1,
509
      l7_comdispo1 => l7_comdispo1_uc1,
510
      l7_newframe1 => l7_newframe1_uc1,
511
      l7_l2ok1     => l7_l2ok1_uc1,
512
      l7_overflow1 => l7_overflow1_uc1,
513
      activity1    => activity1,
514
      l7_rx2       => l7_rx2_uc1,
515
      l7_soc2      => l7_soc2_uc1,
516
      l7_rd2       => l7_rd2_uc1,
517
      l7_comdispo2 => l7_comdispo2_uc1,
518
      l7_newframe2 => l7_newframe2_uc1,
519
      l7_l2ok2     => l7_l2ok2_uc1,
520
      l7_overflow2 => l7_overflow2_uc1,
521
      activity2    => activity2,
522
      tx_dat       => tx_dat_uc1,
523
      val_txdat    => val_txdat_uc1,
524
      tx_sof       => tx_sof_uc1,
525
      tx_eof       => tx_eof_uc1,
526
      txdat_free   => txdat_free,
527
      clr_fifo_tx  => clr_fifo_tx_uc1,
528
      txprom_dat   => txprom_dat,
529
      txprom_val   => txprom_val,
530
      rxprom_dat   => rxprom_dat,
531
      rxprom_val   => rxprom_val,
532
      rxprom_next  => rxprom_next,
533
      prom_type_com=> prom_type_com,
534
      prom_exec_com=> prom_exec_com,
535
      prom_busy    => prom_busy,
536
      prom_nbread  => prom_nbread,
537
      prom_rstn    => prom_rstn
538
      );
539
 
540
   -----------------------------------------------
541
   -- Instantiation du module d'interface PIC2
542
   -----------------------------------------------
543
   inst_pic2 : if_picspi
544
   GENERIC MAP(
545
      version => reg_version,
546
      pic_num => 2)
547
   PORT MAP (
548
      clk_sys  => clk_96,
549
      rst_n    => rst96_n,
550
      sclk     => sclk2,
551
      sdi      => sdi2,
552
      sdo      => sdo2,
553
      ssn      => ssn2,
554
      iid      => iid,
555
      tid      => OPEN,
556
      cpy1     => OPEN,
557
      cpy2     => OPEN,
558
      repli    => OPEN,
559
      l7_rx1   => l7_rx1_uc2,
560
      l7_soc1  => l7_soc1_uc2,
561
      l7_rd1   => l7_rd1_uc2,
562
      l7_comdispo1 => l7_comdispo1_uc2,
563
      l7_newframe1 => l7_newframe1_uc2,
564
      l7_l2ok1     => l7_l2ok1_uc2,
565
      l7_overflow1 => l7_overflow1_uc2,
566
      activity1    => activity1,
567
      l7_rx2       => l7_rx2_uc2,
568
      l7_soc2      => l7_soc2_uc2,
569
      l7_rd2       => l7_rd2_uc2,
570
      l7_comdispo2 => l7_comdispo2_uc2,
571
      l7_newframe2 => l7_newframe2_uc2,
572
      l7_l2ok2     => l7_l2ok2_uc2,
573
      l7_overflow2 => l7_overflow2_uc2,
574
      activity2    => activity2,
575
      tx_dat       => tx_dat_uc2,
576
      val_txdat    => val_txdat_uc2,
577
      tx_sof       => tx_sof_uc2,
578
      tx_eof       => tx_eof_uc2,
579
      txdat_free   => txdat_free,
580
      clr_fifo_tx  => clr_fifo_tx_uc2,
581
      txprom_dat   => OPEN,
582
      txprom_val   => OPEN,
583
      rxprom_dat   => x"00",
584
      rxprom_val   => '0',
585
      rxprom_next  => OPEN,
586
      prom_type_com=> OPEN,
587
      prom_exec_com=> OPEN,
588
      prom_busy    => '0',
589
      prom_nbread  => OPEN,
590
      prom_rstn    => OPEN
591
      );
592
 
593
   -----------------------------------------------
594
   -- Instantiation du module d'interface SPI de programmation de la PROM
595
   -----------------------------------------------
596
   int_promspi :  if_promspi
597
   GENERIC MAP(
598
      div_rate    => 3,          -- Diviseur de l'horlgoe système
599
      spiclk_freq => 12          -- Fréquence de 'lhorlgoe du SPI
600
      )
601
   PORT MAP(
602
      clk_sys     => clk_96,
603
      rst_n       => prom_rstn,
604
      spi_csn     => cso_b,
605
      spi_wpn     => wp_flashn,
606
      spi_sdo     => mosi,
607
      spi_sdi     => din_miso,
608
      spi_clk     => cclk,
609
      tx_dat      => txprom_dat,
610
      tx_val      => txprom_val,
611
      rx_dat      => rxprom_dat,
612
      rx_val      => rxprom_val,
613
      rx_next     => rxprom_next,
614
      type_com    => prom_type_com,
615
      exec_com    => prom_exec_com,
616
      spi_busy    => prom_busy,
617
      nb_read     => prom_nbread
618
      );
619
 
620
   ---------------------------------------
621
   -- Compteur en free running pour la génération à 300KHz de la commande des alims isolées des LS
622
   ---------------------------------------
623
   PROCESS (clk_24)  -- Process nopn soumis au reset pour disposer des alims tout le temps
624
   BEGIN
625
      IF (clk_24'EVENT AND clk_24 = '1') THEN
626
         IF (cpt_cde = CONV_STD_LOGIC_VECTOR(41, cpt_cde'LENGTH)) THEN
627
         -- A la demi période (i.e = 42 x 40ns), on passe en temsp de repos pour les 2 MOSFET (non recouvrement)
628
            cpt_cde <= (OTHERS => '0');
629
            cde_high <= '0';              -- Commande directe
630
            cde_low <= '0';               -- Commande à 180°
631
            toggle_cde <= NOT(toggle_cde);
632
         ELSE
633
            cpt_cde <= cpt_cde + 1;
634
            IF (cpt_cde = CONV_STD_LOGIC_VECTOR(0, cpt_cde'LENGTH)) THEN
635
               cde_high <= toggle_cde;       -- high et low ne doivent jamais être à '1' en même temps
636
               cde_low <= NOT(toggle_cde);
637
            END IF;
638
         END IF;
639
      END IF;
640
   END PROCESS;
641
   cdehigh_5vid   <= cde_high;
642
   cdelow_5vid    <= cde_low;
643
   cdehigh_5vls1  <= cde_high;
644
   cdelow_5vls1   <= cde_low;
645
   cdehigh_5vls2  <= cde_high;
646
   cdelow_5vls2   <= cde_low;
647
 
648
   ----------------------------------------
649
   -- Isolation des signaux vers le PIC quand le 3.3V du PIC est off
650
   ----------------------------------------
651
   sclk1    <= pic_sclk1;
652
   sdi1     <= pic_sdo1;
653
   pic_sdi1 <= sdo1 WHEN (power_rstn = '1') ELSE 'Z';
654
   ssn1     <= pic_ssn1;
655
 
656
   -- Coté µC2, pas besoin d'isoler en cas de coupur de l'alim ÏC car FPGA et PIC sont isolés
657
   -- par des ADUM
658
   sclk2    <= pic_sclk2;
659
   sdi2     <= pic_sdo2;
660
   pic_sdi2 <= sdo2;
661
   ssn2     <= pic_ssn2;
662
   ----------------------------------------
663
   -- Gestion des SPARE et RFU
664
   ----------------------------------------
665
   pic_rx1<= 'Z';
666
   pic_rx2<= 'Z';
667
   tp11   <= '0';
668
   tp10   <= '0';
669
   tp9 <= rst_fpgan OR cde_diag1 OR cde_diag2 OR pic_tx1 OR pic_tx2 OR
670
          pic_spare(0) OR pic_spare(1) OR pic_spare(2) OR pic_spare(3) OR prog_b;
671
   spare  <= (OTHERS => '0');
672
 
673
END rtl;
674
 

powered by: WebSVN 2.1.0

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