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

Subversion Repositories mips_enhanced

[/] [mips_enhanced/] [trunk/] [grlib-gpl-1.0.19-b3188/] [lib/] [tech/] [unisim/] [simprims/] [xilinx_simprims.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dimamali
----------------------------------------------------------------------------
2
-- Simple simulation models for some Xilinx blocks
3
----------------------------------------------------------------------------
4
 
5
-- pragma translate_off
6
 
7
library ieee;
8
use ieee.std_logic_1164.all;
9
library STD;
10
use STD.TEXTIO.all;
11
 
12
package vpkg is
13
signal GSR : std_logic := '0';
14
signal GTS : std_logic := '0';
15
 
16
  PROCEDURE GenericValueCheckMessage (
17
    CONSTANT HeaderMsg      : IN STRING := " Attribute Syntax Error ";
18
    CONSTANT GenericName : IN STRING := "";
19
    CONSTANT EntityName : IN STRING := "";
20
    CONSTANT InstanceName : IN STRING := "";
21
    CONSTANT GenericValue : IN STRING := "";
22
    Constant Unit : IN STRING := "";
23
    Constant ExpectedValueMsg : IN STRING := "";
24
    Constant ExpectedGenericValue : IN STRING := "";
25
    CONSTANT TailMsg      : IN STRING;
26
 
27
    CONSTANT MsgSeverity    : IN SEVERITY_LEVEL := WARNING
28
 
29
    );
30
 
31
  PROCEDURE GenericValueCheckMessage (
32
    CONSTANT HeaderMsg      : IN STRING := " Attribute Syntax Error ";
33
    CONSTANT GenericName : IN STRING := "";
34
    CONSTANT EntityName : IN STRING := "";
35
    CONSTANT InstanceName : IN STRING := "";
36
    CONSTANT GenericValue : IN INTEGER;
37
    Constant Unit : IN STRING := "";
38
    Constant ExpectedValueMsg : IN STRING := "";
39
    Constant ExpectedGenericValue : IN INTEGER;
40
    CONSTANT TailMsg      : IN STRING;
41
 
42
    CONSTANT MsgSeverity    : IN SEVERITY_LEVEL := WARNING
43
 
44
    );
45
 
46
  PROCEDURE GenericValueCheckMessage (
47
    CONSTANT HeaderMsg      : IN STRING := " Attribute Syntax Error ";
48
    CONSTANT GenericName : IN STRING := "";
49
    CONSTANT EntityName : IN STRING := "";
50
    CONSTANT InstanceName : IN STRING := "";
51
    CONSTANT GenericValue : IN BOOLEAN;
52
    Constant Unit : IN STRING := "";
53
    Constant ExpectedValueMsg : IN STRING := "";
54
    Constant ExpectedGenericValue : IN STRING := "";
55
    CONSTANT TailMsg      : IN STRING;
56
 
57
    CONSTANT MsgSeverity    : IN SEVERITY_LEVEL := WARNING
58
 
59
    );
60
 
61
  PROCEDURE GenericValueCheckMessage (
62
    CONSTANT HeaderMsg      : IN STRING := " Attribute Syntax Error ";
63
    CONSTANT GenericName : IN STRING := "";
64
    CONSTANT EntityName : IN STRING := "";
65
    CONSTANT InstanceName : IN STRING := "";
66
    CONSTANT GenericValue : IN INTEGER;
67
    CONSTANT Unit : IN STRING := "";
68
    CONSTANT ExpectedValueMsg : IN STRING := "";
69
    CONSTANT ExpectedGenericValue : IN STRING := "";
70
    CONSTANT TailMsg      : IN STRING;
71
    CONSTANT MsgSeverity    : IN SEVERITY_LEVEL := WARNING
72
    );
73
 
74
  PROCEDURE GenericValueCheckMessage (
75
    CONSTANT HeaderMsg      : IN STRING := " Attribute Syntax Error ";
76
    CONSTANT GenericName : IN STRING := "";
77
    CONSTANT EntityName : IN STRING := "";
78
    CONSTANT InstanceName : IN STRING := "";
79
    CONSTANT GenericValue : IN REAL;
80
    CONSTANT Unit : IN STRING := "";
81
    CONSTANT ExpectedValueMsg : IN STRING := "";
82
    CONSTANT ExpectedGenericValue : IN STRING := "";
83
    CONSTANT TailMsg      : IN STRING;
84
 
85
    CONSTANT MsgSeverity    : IN SEVERITY_LEVEL := WARNING
86
 
87
    );
88
 
89
  procedure detect_resolution ( constant model_name : in string);
90
  function slv_to_int (slv : in std_logic_vector) return integer;
91
  function addr_is_valid (slv : in std_logic_vector) return boolean ;
92
  function DECODE_ADDR4 (
93
    ADDRESS : in std_logic_vector(3 downto 0)
94
    ) return integer;
95
 
96
  function DECODE_ADDR5 (
97
    ADDRESS : in std_logic_vector(4 downto 0)
98
    ) return integer;
99
 
100
  function SLV_TO_STR (
101
    SLV : in std_logic_vector
102
    ) return string;
103
 
104
end;
105
 
106
package body vpkg is
107
 
108
  function SLV_TO_STR (
109
    SLV : in std_logic_vector
110
    ) return string is
111
 
112
    variable j : integer := SLV'length;
113
    variable STR : string (SLV'length downto 1);
114
  begin
115
    for I in SLV'high downto SLV'low loop
116
      case SLV(I) is
117
        when '0' => STR(J) := '0';
118
        when '1' => STR(J) := '1';
119
        when 'X' => STR(J) := 'X';
120
        when 'U' => STR(J) := 'U';
121
        when others => STR(J) := 'X';
122
      end case;
123
      J := J - 1;
124
    end loop;
125
    return STR;
126
  end SLV_TO_STR;
127
 
128
  function DECODE_ADDR4 (
129
    ADDRESS : in std_logic_vector(3 downto 0)
130
    ) return integer is
131
 
132
    variable I : integer;
133
 
134
  begin
135
    case ADDRESS is
136
      when "0000"  =>  I := 0;
137
      when "0001"  =>  I := 1;
138
      when "0010"  =>  I := 2;
139
      when "0011"  =>  I := 3;
140
      when "0100"  =>  I := 4;
141
      when "0101"  =>  I := 5;
142
      when "0110"  =>  I := 6;
143
      when "0111"  =>  I := 7;
144
      when "1000"  =>  I := 8;
145
      when "1001"  =>  I := 9;
146
      when "1010"  =>  I := 10;
147
      when "1011"  =>  I := 11;
148
      when "1100"  =>  I := 12;
149
      when "1101"  =>  I := 13;
150
      when "1110"  =>  I := 14;
151
      when "1111"  =>  I := 15;
152
      when others  =>  I := 16;
153
    end case;
154
    return I;
155
  end DECODE_ADDR4;
156
 
157
  function ADDR_IS_VALID (
158
    SLV : in std_logic_vector
159
    ) return boolean is
160
 
161
    variable IS_VALID : boolean := TRUE;
162
 
163
  begin
164
    for I in SLV'high downto SLV'low loop
165
      if (SLV(I) /= '0' AND SLV(I) /= '1') then
166
        IS_VALID := FALSE;
167
      end if;
168
    end loop;
169
    return IS_VALID;
170
  end ADDR_IS_VALID;
171
 
172
  function SLV_TO_INT(SLV: in std_logic_vector
173
                      ) return integer is
174
 
175
    variable int : integer;
176
  begin
177
    int := 0;
178
    for i in SLV'high downto SLV'low loop
179
      int := int * 2;
180
      if SLV(i) = '1' then
181
        int := int + 1;
182
      end if;
183
    end loop;
184
    return int;
185
  end;
186
 
187
  procedure detect_resolution (
188
    constant model_name : in string
189
    ) IS
190
 
191
    variable test_value : time;
192
    variable Message : LINE;
193
  BEGIN
194
    test_value := 1 ps;
195
    if (test_value = 0 ps) then
196
      Write (Message, STRING'(" Simulator Resolution Error : "));
197
      Write (Message, STRING'(" Simulator resolution is set to a value greater than 1 ps. "));
198
      Write (Message, STRING'(" In order to simulate the "));
199
      Write (Message, model_name);
200
      Write (Message, STRING'(", the simulator resolution must be set to 1ps or smaller "));
201
      ASSERT FALSE REPORT Message.ALL SEVERITY ERROR;
202
      DEALLOCATE (Message);
203
    end if;
204
  END detect_resolution;
205
 
206
  PROCEDURE GenericValueCheckMessage (
207
    CONSTANT HeaderMsg      : IN STRING := " Attribute Syntax Error ";
208
    CONSTANT GenericName : IN STRING := "";
209
    CONSTANT EntityName : IN STRING := "";
210
    CONSTANT InstanceName : IN STRING := "";
211
    CONSTANT GenericValue : IN STRING := "";
212
    Constant Unit : IN STRING := "";
213
    Constant ExpectedValueMsg : IN STRING := "";
214
    Constant ExpectedGenericValue : IN STRING := "";
215
    CONSTANT TailMsg      : IN STRING;
216
 
217
    CONSTANT MsgSeverity    : IN SEVERITY_LEVEL := WARNING
218
 
219
    ) IS
220
    VARIABLE Message : LINE;
221
  BEGIN
222
 
223
    Write ( Message, HeaderMsg );
224
    Write ( Message, STRING'(" The attribute ") );
225
    Write ( Message, GenericName );
226
    Write ( Message, STRING'(" on ") );
227
    Write ( Message, EntityName );
228
    Write ( Message, STRING'(" instance ") );
229
    Write ( Message, InstanceName );
230
    Write ( Message, STRING'(" is set to  ") );
231
    Write ( Message, GenericValue );
232
    Write ( Message, Unit );
233
    Write ( Message, '.' & LF );
234
    Write ( Message, ExpectedValueMsg );
235
    Write ( Message, ExpectedGenericValue );
236
    Write ( Message, Unit );
237
    Write ( Message, TailMsg );
238
 
239
    ASSERT FALSE REPORT Message.ALL SEVERITY MsgSeverity;
240
 
241
    DEALLOCATE (Message);
242
  END GenericValueCheckMessage;
243
 
244
  PROCEDURE GenericValueCheckMessage (
245
    CONSTANT HeaderMsg      : IN STRING := " Attribute Syntax Error ";
246
    CONSTANT GenericName : IN STRING := "";
247
    CONSTANT EntityName : IN STRING := "";
248
    CONSTANT InstanceName : IN STRING := "";
249
    CONSTANT GenericValue : IN INTEGER;
250
    CONSTANT Unit : IN STRING := "";
251
    CONSTANT ExpectedValueMsg : IN STRING := "";
252
    CONSTANT ExpectedGenericValue : IN INTEGER;
253
    CONSTANT TailMsg      : IN STRING;
254
 
255
    CONSTANT MsgSeverity    : IN SEVERITY_LEVEL := WARNING
256
 
257
    ) IS
258
    VARIABLE Message : LINE;
259
  BEGIN
260
 
261
    Write ( Message, HeaderMsg );
262
    Write ( Message, STRING'(" The attribute ") );
263
    Write ( Message, GenericName );
264
    Write ( Message, STRING'(" on ") );
265
    Write ( Message, EntityName );
266
    Write ( Message, STRING'(" instance ") );
267
    Write ( Message, InstanceName );
268
    Write ( Message, STRING'(" is set to  ") );
269
    Write ( Message, GenericValue );
270
    Write ( Message, Unit );
271
    Write ( Message, '.' & LF );
272
    Write ( Message, ExpectedValueMsg );
273
    Write ( Message, ExpectedGenericValue );
274
    Write ( Message, Unit );
275
    Write ( Message, TailMsg );
276
 
277
    ASSERT FALSE REPORT Message.ALL SEVERITY MsgSeverity;
278
 
279
    DEALLOCATE (Message);
280
  END GenericValueCheckMessage;
281
 
282
  PROCEDURE GenericValueCheckMessage (
283
    CONSTANT HeaderMsg      : IN STRING := " Attribute Syntax Error ";
284
    CONSTANT GenericName : IN STRING := "";
285
    CONSTANT EntityName : IN STRING := "";
286
    CONSTANT InstanceName : IN STRING := "";
287
    CONSTANT GenericValue : IN BOOLEAN;
288
    Constant Unit : IN STRING := "";
289
    CONSTANT ExpectedValueMsg : IN STRING := "";
290
    CONSTANT ExpectedGenericValue : IN STRING := "";
291
    CONSTANT TailMsg      : IN STRING;
292
 
293
    CONSTANT MsgSeverity    : IN SEVERITY_LEVEL := WARNING
294
 
295
    ) IS
296
    VARIABLE Message : LINE;
297
  BEGIN
298
 
299
    Write ( Message, HeaderMsg );
300
    Write ( Message, STRING'(" The attribute ") );
301
    Write ( Message, GenericName );
302
    Write ( Message, STRING'(" on ") );
303
    Write ( Message, EntityName );
304
    Write ( Message, STRING'(" instance ") );
305
    Write ( Message, InstanceName );
306
    Write ( Message, STRING'(" is set to  ") );
307
    Write ( Message, GenericValue );
308
    Write ( Message, Unit );
309
    Write ( Message, '.' & LF );
310
    Write ( Message, ExpectedValueMsg );
311
    Write ( Message, ExpectedGenericValue );
312
    Write ( Message, Unit );
313
    Write ( Message, TailMsg );
314
 
315
    ASSERT FALSE REPORT Message.ALL SEVERITY MsgSeverity;
316
 
317
    DEALLOCATE (Message);
318
  END GenericValueCheckMessage;
319
 
320
  PROCEDURE GenericValueCheckMessage (
321
    CONSTANT HeaderMsg      : IN STRING := " Attribute Syntax Error ";
322
    CONSTANT GenericName : IN STRING := "";
323
    CONSTANT EntityName : IN STRING := "";
324
    CONSTANT InstanceName : IN STRING := "";
325
    CONSTANT GenericValue : IN INTEGER;
326
    CONSTANT Unit : IN STRING := "";
327
    CONSTANT ExpectedValueMsg : IN STRING := "";
328
    CONSTANT ExpectedGenericValue : IN STRING := "";
329
    CONSTANT TailMsg      : IN STRING;
330
 
331
    CONSTANT MsgSeverity    : IN SEVERITY_LEVEL := WARNING
332
 
333
    ) IS
334
    VARIABLE Message : LINE;
335
  BEGIN
336
 
337
    Write ( Message, HeaderMsg );
338
    Write ( Message, STRING'(" The attribute ") );
339
    Write ( Message, GenericName );
340
    Write ( Message, STRING'(" on ") );
341
    Write ( Message, EntityName );
342
    Write ( Message, STRING'(" instance ") );
343
    Write ( Message, InstanceName );
344
    Write ( Message, STRING'(" is set to  ") );
345
    Write ( Message, GenericValue );
346
    Write ( Message, Unit );
347
    Write ( Message, '.' & LF );
348
    Write ( Message, ExpectedValueMsg );
349
    Write ( Message, ExpectedGenericValue );
350
    Write ( Message, Unit );
351
    Write ( Message, TailMsg );
352
 
353
    ASSERT FALSE REPORT Message.ALL SEVERITY MsgSeverity;
354
 
355
    DEALLOCATE (Message);
356
  END GenericValueCheckMessage;
357
  PROCEDURE GenericValueCheckMessage (
358
    CONSTANT HeaderMsg      : IN STRING := " Attribute Syntax Error ";
359
    CONSTANT GenericName : IN STRING := "";
360
    CONSTANT EntityName : IN STRING := "";
361
    CONSTANT InstanceName : IN STRING := "";
362
    CONSTANT GenericValue : IN REAL;
363
    CONSTANT Unit : IN STRING := "";
364
    CONSTANT ExpectedValueMsg : IN STRING := "";
365
    CONSTANT ExpectedGenericValue : IN STRING := "";
366
    CONSTANT TailMsg      : IN STRING;
367
 
368
    CONSTANT MsgSeverity    : IN SEVERITY_LEVEL := WARNING
369
 
370
    ) IS
371
    VARIABLE Message : LINE;
372
  BEGIN
373
 
374
    Write ( Message, HeaderMsg );
375
    Write ( Message, STRING'(" The attribute ") );
376
    Write ( Message, GenericName );
377
    Write ( Message, STRING'(" on ") );
378
    Write ( Message, EntityName );
379
    Write ( Message, STRING'(" instance ") );
380
    Write ( Message, InstanceName );
381
    Write ( Message, STRING'(" is set to  ") );
382
    Write ( Message, GenericValue );
383
    Write ( Message, Unit );
384
    Write ( Message, '.' & LF );
385
    Write ( Message, ExpectedValueMsg );
386
    Write ( Message, ExpectedGenericValue );
387
    Write ( Message, Unit );
388
    Write ( Message, TailMsg );
389
 
390
    ASSERT FALSE REPORT Message.ALL SEVERITY MsgSeverity;
391
 
392
    DEALLOCATE (Message);
393
  END GenericValueCheckMessage;
394
 
395
  function DECODE_ADDR5 (
396
    ADDRESS : in std_logic_vector(4 downto 0)
397
    ) return integer is
398
 
399
    variable I : integer;
400
 
401
  begin
402
    case ADDRESS is
403
      when "00000"  =>  I := 0;
404
      when "00001"  =>  I := 1;
405
      when "00010"  =>  I := 2;
406
      when "00011"  =>  I := 3;
407
      when "00100"  =>  I := 4;
408
      when "00101"  =>  I := 5;
409
      when "00110"  =>  I := 6;
410
      when "00111"  =>  I := 7;
411
      when "01000"  =>  I := 8;
412
      when "01001"  =>  I := 9;
413
      when "01010"  =>  I := 10;
414
      when "01011"  =>  I := 11;
415
      when "01100"  =>  I := 12;
416
      when "01101"  =>  I := 13;
417
      when "01110"  =>  I := 14;
418
      when "01111"  =>  I := 15;
419
      when "10000"  =>  I := 16;
420
      when "10001"  =>  I := 17;
421
      when "10010"  =>  I := 18;
422
      when "10011"  =>  I := 19;
423
      when "10100"  =>  I := 20;
424
      when "10101"  =>  I := 21;
425
      when "10110"  =>  I := 22;
426
      when "10111"  =>  I := 23;
427
      when "11000"  =>  I := 24;
428
      when "11001"  =>  I := 25;
429
      when "11010"  =>  I := 26;
430
      when "11011"  =>  I := 27;
431
      when "11100"  =>  I := 28;
432
      when "11101"  =>  I := 29;
433
      when "11110"  =>  I := 30;
434
      when "11111"  =>  I := 31;
435
      when others   =>  I := 32;
436
    end case;
437
    return I;
438
  end DECODE_ADDR5;
439
 
440
end;
441
 
442
library ieee;
443
use ieee.std_logic_1164.all;
444
 
445
package simple_simprim is
446
 
447
  component ramb4_generic
448
  generic ( abits : integer := 10; dbits : integer := 8 );
449
  port (DI     : in std_logic_vector (dbits-1 downto 0);
450
        EN     : in std_ulogic;
451
        WE     : in std_ulogic;
452
        RST    : in std_ulogic;
453
        CLK    : in std_ulogic;
454
        ADDR   : in std_logic_vector (abits-1 downto 0);
455
        DO     : out std_logic_vector (dbits-1 downto 0)
456
       );
457
  end component;
458
 
459
  component ramb4_sx_sx
460
  generic (abits : integer := 10; dbits : integer := 8 );
461
  port (DIA    : in std_logic_vector (dbits-1 downto 0);
462
        DIB    : in std_logic_vector (dbits-1 downto 0);
463
        ENA    : in std_ulogic;
464
        ENB    : in std_ulogic;
465
        WEA    : in std_ulogic;
466
        WEB    : in std_ulogic;
467
        RSTA   : in std_ulogic;
468
        RSTB   : in std_ulogic;
469
        CLKA   : in std_ulogic;
470
        CLKB   : in std_ulogic;
471
        ADDRA  : in std_logic_vector (abits-1 downto 0);
472
        ADDRB  : in std_logic_vector (abits-1 downto 0);
473
        DOA    : out std_logic_vector (dbits-1 downto 0);
474
        DOB    : out std_logic_vector (dbits-1 downto 0)
475
       );
476
  end component;
477
 
478
  component ramb16_sx
479
  generic (abits : integer := 10; dbits : integer := 8 );
480
  port (
481
    DO : out std_logic_vector (dbits-1 downto 0);
482
    ADDR : in std_logic_vector (abits-1 downto 0);
483
    DI : in std_logic_vector (dbits-1 downto 0);
484
    EN : in std_ulogic;
485
    CLK : in std_ulogic;
486
    WE : in std_ulogic;
487
    SSR : in std_ulogic);
488
  end component;
489
 
490
 
491
  component ram16_sx_sx
492
  generic (abits : integer := 10; dbits : integer := 8 );
493
  port (
494
   DOA : out std_logic_vector (dbits-1 downto 0);
495
   DOB : out std_logic_vector (dbits-1 downto 0);
496
   ADDRA : in std_logic_vector (abits-1 downto 0);
497
   CLKA : in std_ulogic;
498
   DIA : in std_logic_vector (dbits-1 downto 0);
499
   ENA : in std_ulogic;
500
   WEA : in std_ulogic;
501
   ADDRB : in std_logic_vector (abits-1 downto 0);
502
   CLKB : in std_ulogic;
503
   DIB : in std_logic_vector (dbits-1 downto 0);
504
   ENB : in std_ulogic;
505
   WEB : in std_ulogic);
506
  end component;
507
 
508
end;
509
 
510
library ieee;
511
use ieee.std_logic_1164.all;
512
use ieee.numeric_std.all;
513
 
514
entity ramb4_generic is
515
  generic ( abits : integer := 10; dbits : integer := 8 );
516
  port (DI     : in std_logic_vector (dbits-1 downto 0);
517
        EN     : in std_ulogic;
518
        WE     : in std_ulogic;
519
        RST    : in std_ulogic;
520
        CLK    : in std_ulogic;
521
        ADDR   : in std_logic_vector (abits-1 downto 0);
522
        DO     : out std_logic_vector (dbits-1 downto 0)
523
       );
524
end;
525
 
526
architecture behavioral of ramb4_generic is
527
  type mem is array(0 to (2**abits -1))
528
        of std_logic_vector((dbits -1) downto 0);
529
begin
530
  main : process(clk)
531
  variable memarr : mem;
532
  begin
533
    if rising_edge(clk)then
534
      if (en = '1') and not (is_x(addr)) then
535
        do <= memarr(to_integer(unsigned(addr)));
536
      end if;
537
      if (we and en) = '1' then
538
        if not is_x(addr) then
539
          memarr(to_integer(unsigned(addr))) := di;
540
        end if;
541
      end if;
542
    end if;
543
  end process;
544
 
545
end;
546
 
547
library ieee;
548
use ieee.std_logic_1164.all;
549
use ieee.numeric_std.all;
550
 
551
entity ramb16_sx is
552
  generic ( abits : integer := 10; dbits : integer := 8 );
553
  port (
554
    DO : out std_logic_vector (dbits-1 downto 0);
555
    ADDR : in std_logic_vector (abits-1 downto 0);
556
    DI : in std_logic_vector (dbits-1 downto 0);
557
    EN : in std_ulogic;
558
    CLK : in std_ulogic;
559
    WE : in std_ulogic;
560
    SSR : in std_ulogic
561
  );
562
end;
563
architecture behav of ramb16_sx is
564
begin
565
  rp : process(clk)
566
  subtype dword is std_logic_vector(dbits-1 downto 0);
567
  type dregtype is array (0 to 2**abits -1) of DWord;
568
  variable rfd : dregtype := (others => (others => '0'));
569
  begin
570
    if rising_edge(clk) and not is_x (addr) then
571
      if en = '1' then
572
        do <= rfd(to_integer(unsigned(addr)));
573
        if we = '1' then rfd(to_integer(unsigned(addr))) := di; end if;
574
      end if;
575
    end if;
576
  end process;
577
end;
578
 
579
library ieee;
580
use ieee.std_logic_1164.all;
581
use ieee.numeric_std.all;
582
 
583
entity ram16_sx_sx is
584
  generic ( abits : integer := 10; dbits : integer := 8 );
585
  port (
586
   DOA : out std_logic_vector (dbits-1 downto 0);
587
   DOB : out std_logic_vector (dbits-1 downto 0);
588
   ADDRA : in std_logic_vector (abits-1 downto 0);
589
   CLKA : in std_ulogic;
590
   DIA : in std_logic_vector (dbits-1 downto 0);
591
   ENA : in std_ulogic;
592
   WEA : in std_ulogic;
593
   ADDRB : in std_logic_vector (abits-1 downto 0);
594
   CLKB : in std_ulogic;
595
   DIB : in std_logic_vector (dbits-1 downto 0);
596
   ENB : in std_ulogic;
597
   WEB : in std_ulogic
598
  );
599
end;
600
 
601
architecture behav of ram16_sx_sx is
602
    signal async : std_ulogic := '0';
603
begin
604
 
605
  ramproc : process(clka, clkb)
606
    subtype dword is std_logic_vector(dbits-1 downto 0);
607
    type dregtype is array (0 to 2**abits -1) of DWord;
608
    variable rfd : dregtype := (others => (others => '0'));
609
  begin
610
 
611
    if rising_edge(clka) and not is_x (addra) then
612
      if ena = '1' then
613
        if wea = '1' then
614
          rfd(to_integer(unsigned(addra))) := dia;
615
        end if;
616
          doa <= rfd(to_integer(unsigned(addra)));
617
      end if;
618
    end if;
619
 
620
    if rising_edge(clkb) and not is_x (addrb) then
621
      if enb = '1' then
622
        if web = '1' then
623
          rfd(to_integer(unsigned(addrb))) := dib;
624
        end if;
625
          dob <= rfd(to_integer(unsigned(addrb)));
626
        end if;
627
    end if;
628
 
629
  end process;
630
 
631
end;
632
 
633
library ieee;
634
use ieee.std_logic_1164.all;
635
 
636
entity BSCAN_VIRTEX is
637
  port (CAPTURE : out STD_ULOGIC;
638
        DRCK1 : out STD_ULOGIC;
639
        DRCK2 : out STD_ULOGIC;
640
        RESET : out STD_ULOGIC;
641
        SEL1 : out STD_ULOGIC;
642
        SEL2 : out STD_ULOGIC;
643
        SHIFT : out STD_ULOGIC;
644
        TDI : out STD_ULOGIC;
645
        UPDATE : out STD_ULOGIC;
646
        TDO1 : in STD_ULOGIC;
647
        TDO2 : in STD_ULOGIC);
648
end;
649
 
650
architecture behav of BSCAN_VIRTEX is
651
begin
652
  CAPTURE <= '0'; DRCK1 <= '0'; DRCK2 <= '0';
653
  RESET <= '0'; SEL1 <= '0'; SEL2 <= '0';
654
  SHIFT <= '0'; TDI  <= '0'; UPDATE <= '0';
655
end;
656
 
657
library ieee;
658
use ieee.std_logic_1164.all;
659
 
660
entity BSCAN_VIRTEX2 is
661
  port (CAPTURE : out STD_ULOGIC;
662
        DRCK1 : out STD_ULOGIC;
663
        DRCK2 : out STD_ULOGIC;
664
        RESET : out STD_ULOGIC;
665
        SEL1 : out STD_ULOGIC;
666
        SEL2 : out STD_ULOGIC;
667
        SHIFT : out STD_ULOGIC;
668
        TDI : out STD_ULOGIC;
669
        UPDATE : out STD_ULOGIC;
670
        TDO1 : in STD_ULOGIC;
671
        TDO2 : in STD_ULOGIC);
672
end;
673
 
674
architecture behav of BSCAN_VIRTEX2 is
675
begin
676
  CAPTURE <= '0'; DRCK1 <= '0'; DRCK2 <= '0';
677
  RESET <= '0'; SEL1 <= '0'; SEL2 <= '0';
678
  SHIFT <= '0'; TDI  <= '0'; UPDATE <= '0';
679
end;
680
 
681
library ieee;
682
use ieee.std_logic_1164.all;
683
 
684
entity BSCAN_VIRTEX4 is
685
  generic(
686
        JTAG_CHAIN : integer := 1
687
        );
688
 
689
  port(
690
    CAPTURE : out std_ulogic ;
691
    DRCK    : out std_ulogic ;
692
    RESET   : out std_ulogic ;
693
    SEL     : out std_ulogic ;
694
    SHIFT   : out std_ulogic ;
695
    TDI     : out std_ulogic ;
696
    UPDATE  : out std_ulogic ;
697
    TDO     : in std_ulogic
698
    );
699
 
700
end BSCAN_VIRTEX4;
701
 
702
architecture behav of BSCAN_VIRTEX4 is
703
begin
704
  CAPTURE <= '0'; DRCK <= '0';
705
  RESET <= '0'; SEL <= '0';
706
  SHIFT <= '0'; TDI  <= '0'; UPDATE <= '0';
707
end;
708
 
709
library ieee;
710
use ieee.std_logic_1164.all;
711
 
712
entity BSCAN_VIRTEX5 is
713
  generic(
714
        JTAG_CHAIN : integer := 1
715
        );
716
 
717
  port(
718
    CAPTURE : out std_ulogic ;
719
    DRCK    : out std_ulogic ;
720
    RESET   : out std_ulogic ;
721
    SEL     : out std_ulogic ;
722
    SHIFT   : out std_ulogic ;
723
    TDI     : out std_ulogic ;
724
    UPDATE  : out std_ulogic ;
725
    TDO     : in std_ulogic
726
    );
727
 
728
end BSCAN_VIRTEX5;
729
 
730
architecture behav of BSCAN_VIRTEX5 is
731
begin
732
  CAPTURE <= '0'; DRCK <= '0';
733
  RESET <= '0'; SEL <= '0';
734
  SHIFT <= '0'; TDI  <= '0'; UPDATE <= '0';
735
end;
736
 
737
library ieee;
738
use ieee.std_logic_1164.all;
739
 
740
entity BSCAN_SPARTAN3 is
741
  port (CAPTURE : out STD_ULOGIC;
742
        DRCK1 : out STD_ULOGIC;
743
        DRCK2 : out STD_ULOGIC;
744
        RESET : out STD_ULOGIC;
745
        SEL1 : out STD_ULOGIC;
746
        SEL2 : out STD_ULOGIC;
747
        SHIFT : out STD_ULOGIC;
748
        TDI : out STD_ULOGIC;
749
        UPDATE : out STD_ULOGIC;
750
        TDO1 : in STD_ULOGIC;
751
        TDO2 : in STD_ULOGIC);
752
end;
753
 
754
architecture behav of BSCAN_SPARTAN3 is
755
begin
756
  CAPTURE <= '0'; DRCK1 <= '0'; DRCK2 <= '0';
757
  RESET <= '0'; SEL1 <= '0'; SEL2 <= '0';
758
  SHIFT <= '0'; TDI  <= '0'; UPDATE <= '0';
759
end;
760
 
761
library ieee; use ieee.std_logic_1164.all;
762
entity BUFGMUX is port (O : out std_logic; I0, I1, S : in std_logic); end;
763
architecture beh of BUFGMUX is
764
begin o <= to_X01(I0) when to_X01(S) = '0' else I1; end;
765
 
766
library ieee; use ieee.std_logic_1164.all;
767
entity BUFG is port (O : out std_logic; I : in std_logic); end;
768
architecture beh of BUFG is begin o <= to_X01(i); end;
769
 
770
library ieee; use ieee.std_logic_1164.all;
771
entity BUFGP is port (O : out std_logic; I : in std_logic); end;
772
architecture beh of BUFGP is begin o <= to_X01(i); end;
773
 
774
library ieee; use ieee.std_logic_1164.all;
775
entity BUFGDLL is port (O : out std_logic; I : in std_logic); end;
776
architecture beh of BUFGDLL is begin o <= to_X01(i); end;
777
 
778
library ieee; use ieee.std_logic_1164.all;
779
entity IBUFG is generic (
780
    CAPACITANCE : string := "DONT_CARE"; IOSTANDARD : string := "LVCMOS25");
781
  port (O : out std_logic; I : in std_logic); end;
782
architecture beh of IBUFG is begin o <= to_X01(i) after 1 ns; end;
783
 
784
library ieee; use ieee.std_logic_1164.all;
785
entity IBUF is generic (
786
    CAPACITANCE : string := "DONT_CARE"; IOSTANDARD : string := "LVCMOS25");
787
  port (O : out std_logic; I : in std_logic); end;
788
architecture beh of IBUF is begin o <= to_X01(i) after 1 ns; end;
789
 
790
library ieee;
791
use ieee.std_logic_1164.all;
792
entity OBUF is generic (
793
    CAPACITANCE : string := "DONT_CARE"; DRIVE : integer := 12;
794
    IOSTANDARD  : string := "LVCMOS25"; SLEW : string := "SLOW");
795
  port (O : out std_ulogic; I : in std_ulogic); end;
796
architecture beh of OBUF is
797
begin o <= to_X01(i) after 2 ns when slew = "SLOW" else  to_X01(i) after 1 ns; end;
798
 
799
library ieee;
800
use ieee.std_logic_1164.all;
801
entity IOBUF is  generic (
802
    CAPACITANCE : string := "DONT_CARE"; DRIVE : integer := 12;
803
    IOSTANDARD  : string := "LVCMOS25"; SLEW : string := "SLOW");
804
  port ( O  : out std_ulogic; IO : inout std_logic; I, T : in std_ulogic);
805
end;
806
architecture beh of IOBUF is
807
begin
808
  io <= 'X' after 2 ns when to_X01(t) = 'X' else
809
        I after 2 ns  when (to_X01(t) = '0')  else
810
       'Z' after 2 ns  when to_X01(t) = '1';
811
  o <= to_X01(io) after 1 ns;
812
end;
813
 
814
library ieee;
815
use ieee.std_logic_1164.all;
816
entity IOBUFDS is  generic (
817
    CAPACITANCE : string := "DONT_CARE"; IBUF_DELAY_VALUE : string := "0";
818
    IOSTANDARD  : string := "DEFAULT"; IFD_DELAY_VALUE : string := "AUTO");
819
  port ( O  : out std_ulogic; IO, IOB : inout std_logic; I, T : in std_ulogic);
820
end;
821
architecture beh of IOBUFDS is
822
begin
823
  io <= 'X' after 2 ns when to_X01(t) = 'X' else
824
        I after 2 ns  when (to_X01(t) = '0')  else
825
       'Z' after 2 ns  when to_X01(t) = '1';
826
  iob <= 'X' after 2 ns when to_X01(t) = 'X' else
827
        not I after 2 ns  when (to_X01(t) = '0')  else
828
       'Z' after 2 ns  when to_X01(t) = '1';
829
  o <= to_X01(io) after 1 ns;
830
end;
831
 
832
library ieee;
833
use ieee.std_logic_1164.all;
834
entity OBUFT is  generic (
835
    CAPACITANCE : string := "DONT_CARE"; DRIVE : integer := 12;
836
    IOSTANDARD  : string := "LVCMOS25"; SLEW : string := "SLOW");
837
  port ( O  : out std_ulogic; I, T : in std_ulogic);
838
end;
839
architecture beh of OBUFT is
840
begin
841
  o <= I after 2 ns when to_X01(t) = '0' else
842
       'Z' after 2 ns  when to_X01(t) = '1' else
843
        'X' after 2 ns ;
844
end;
845
 
846
library ieee; use ieee.std_logic_1164.all;
847
entity IBUFDS is
848
  generic ( CAPACITANCE : string := "DONT_CARE";
849
        DIFF_TERM : boolean := FALSE; IBUF_DELAY_VALUE : string := "0";
850
        IFD_DELAY_VALUE : string := "AUTO"; IOSTANDARD : string := "DEFAULT");
851
  port (O : out std_logic; I, IB : in std_logic); end;
852
architecture beh of IBUFDS is
853
signal old : std_ulogic;
854
begin
855
 
856
  old <= '1' after 1 ns when (to_X01(I) = '1') and (to_X01(IB) = '0') else
857
       '0' after 1 ns when (to_X01(I) = '0') and (to_X01(IB) = '1') else old;
858
  o <= old;
859
end;
860
 
861
library ieee; use ieee.std_logic_1164.all;
862
entity IBUFDS_LVDS_25 is
863
  port (O : out std_logic; I, IB : in std_logic); end;
864
architecture beh of IBUFDS_LVDS_25 is
865
signal old : std_ulogic;
866
begin
867
 
868
  old <= '1' after 1 ns when (to_X01(I) = '1') and (to_X01(IB) = '0') else
869
       '0' after 1 ns when (to_X01(I) = '0') and (to_X01(IB) = '1') else old;
870
  o <= old;
871
end;
872
 
873
library ieee; use ieee.std_logic_1164.all;
874
entity IBUFDS_LVDS_33 is
875
  port (O : out std_logic; I, IB : in std_logic); end;
876
architecture beh of IBUFDS_LVDS_33 is
877
signal old : std_ulogic;
878
begin
879
 
880
  old <= '1' after 1 ns when (to_X01(I) = '1') and (to_X01(IB) = '0') else
881
       '0' after 1 ns when (to_X01(I) = '0') and (to_X01(IB) = '1') else old;
882
  o <= old;
883
end;
884
 
885
library ieee; use ieee.std_logic_1164.all;
886
entity IBUFGDS_LVDS_25 is
887
  port (O : out std_logic; I, IB : in std_logic); end;
888
architecture beh of IBUFGDS_LVDS_25 is
889
signal old : std_ulogic;
890
begin
891
 
892
  old <= '1' after 1 ns when (to_X01(I) = '1') and (to_X01(IB) = '0') else
893
       '0' after 1 ns when (to_X01(I) = '0') and (to_X01(IB) = '1') else old;
894
  o <= old;
895
end;
896
 
897
library ieee; use ieee.std_logic_1164.all;
898
entity IBUFGDS_LVDS_33 is
899
  port (O : out std_logic; I, IB : in std_logic); end;
900
architecture beh of IBUFGDS_LVDS_33 is
901
signal old : std_ulogic;
902
begin
903
 
904
  old <= '1' after 1 ns when (to_X01(I) = '1') and (to_X01(IB) = '0') else
905
       '0' after 1 ns when (to_X01(I) = '0') and (to_X01(IB) = '1') else old;
906
  o <= old;
907
end;
908
 
909
library ieee; use ieee.std_logic_1164.all;
910
entity IBUFGDS is
911
  generic( CAPACITANCE : string  := "DONT_CARE";
912
      DIFF_TERM   : boolean :=  FALSE; IBUF_DELAY_VALUE : string := "0";
913
      IOSTANDARD  : string  := "DEFAULT");
914
  port (O : out std_logic; I, IB : in std_logic); end;
915
architecture beh of IBUFGDS is
916
signal old : std_ulogic;
917
begin
918
 
919
  old <= '1' after 1 ns when (to_X01(I) = '1') and (to_X01(IB) = '0') else
920
       '0' after 1 ns when (to_X01(I) = '0') and (to_X01(IB) = '1') else old;
921
  o <= old;
922
end;
923
 
924
library ieee; use ieee.std_logic_1164.all;
925
entity OBUFDS is
926
  generic(IOSTANDARD  : string  := "DEFAULT");
927
  port (O, OB : out std_ulogic; I : in std_ulogic); end;
928
architecture beh of OBUFDS is
929
begin
930
  o <= to_X01(i) after 1 ns; ob <= not to_X01(i) after 1 ns;
931
end;
932
 
933
library ieee; use ieee.std_logic_1164.all;
934
entity OBUFDS_LVDS_25 is
935
  port (O, OB : out std_ulogic; I : in std_ulogic); end;
936
architecture beh of OBUFDS_LVDS_25 is
937
begin
938
  o <= to_X01(i) after 1 ns; ob <= not to_X01(i) after 1 ns;
939
end;
940
 
941
library ieee; use ieee.std_logic_1164.all;
942
entity OBUFDS_LVDS_33 is
943
  port (O, OB : out std_ulogic; I : in std_ulogic); end;
944
architecture beh of OBUFDS_LVDS_33 is
945
begin
946
  o <= to_X01(i) after 1 ns; ob <= not to_X01(i) after 1 ns;
947
end;
948
 
949
----- CELL BUFGCE -----
950
 
951
library IEEE;
952
use IEEE.STD_LOGIC_1164.all;
953
 
954
--library UNISIM;
955
--use UNISIM.VCOMPONENTS.all;
956
 
957
entity BUFGCE is
958
     port(
959
         O : out STD_ULOGIC;
960
 
961
         CE: in STD_ULOGIC;
962
         I : in STD_ULOGIC
963
         );
964
end BUFGCE;
965
 
966
architecture BUFGCE_V of BUFGCE is
967
 
968
    signal NCE : STD_ULOGIC := 'X';
969
    signal GND : STD_ULOGIC := '0';
970
 
971
component BUFGMUX port (O : out std_logic; I0, I1, S : in std_logic); end component;
972
 
973
begin
974
    B1 : BUFGMUX
975
        port map (
976
        I0 => I,
977
        I1 => GND,
978
        O =>O,
979
        s =>NCE);
980
 
981
--     I1 : INV
982
--      port map (
983
--      I => CE,
984
--      O => NCE);
985
    nCE <= not CE;
986
 
987
end BUFGCE_V;
988
 
989
----- CELL CLKDLL                     -----
990
----- x_clkdll_maximum_period_check     -----
991
library IEEE;
992
use IEEE.STD_LOGIC_1164.all;
993
 
994
library STD;
995
use STD.TEXTIO.all;
996
 
997
entity x_clkdll_maximum_period_check is
998
  generic (
999
    InstancePath : string := "*";
1000
 
1001
    clock_name : string := "";
1002
    maximum_period : time);
1003
  port(
1004
    clock : in std_ulogic
1005
    );
1006
end x_clkdll_maximum_period_check;
1007
 
1008
architecture x_clkdll_maximum_period_check_V of x_clkdll_maximum_period_check is
1009
begin
1010
 
1011
  MAX_PERIOD_CHECKER : process
1012
    variable clock_edge_previous : time := 0 ps;
1013
    variable clock_edge_current : time := 0 ps;
1014
    variable clock_period : time := 0 ps;
1015
    variable Message : line;
1016
  begin
1017
 
1018
    clock_edge_previous := clock_edge_current;
1019
    clock_edge_current := NOW;
1020
 
1021
    if (clock_edge_previous > 0 ps) then
1022
      clock_period := clock_edge_current - clock_edge_previous;
1023
    end if;
1024
 
1025
    if (clock_period > maximum_period) then
1026
      Write ( Message, string'(" Timing Violation Error : Input Clock Period of"));
1027
      Write ( Message, clock_period/1000.0 );
1028
      Write ( Message, string'(" on the ") );
1029
      Write ( Message, clock_name );
1030
      Write ( Message, string'(" port ") );
1031
      Write ( Message, string'(" of CLKDLL instance ") );
1032
      Write ( Message, InstancePath );
1033
      Write ( Message, string'(" exceeds allotted value of ") );
1034
      Write ( Message, maximum_period/1000.0 );
1035
      Write ( Message, string'(" at simulation time ") );
1036
      Write ( Message, clock_edge_current/1000.0 );
1037
      Write ( Message, '.' & LF );
1038
      assert false report Message.all severity warning;
1039
      DEALLOCATE (Message);
1040
    end if;
1041
    wait on clock;
1042
  end process MAX_PERIOD_CHECKER;
1043
end x_clkdll_maximum_period_check_V;
1044
 
1045
----- CLKDLL  -----
1046
library IEEE;
1047
use IEEE.std_logic_1164.all;
1048
 
1049
library STD;
1050
use STD.TEXTIO.all;
1051
 
1052
library IEEE;
1053
use Ieee.Vital_Primitives.all;
1054
use Ieee.Vital_Timing.all;
1055
library unisim;
1056
use unisim.vpkg.all;
1057
 
1058
entity CLKDLL is
1059
  generic (
1060
    TimingChecksOn : boolean := true;
1061
    InstancePath : string := "*";
1062
    Xon : boolean := true;
1063
    MsgOn : boolean := false;
1064
 
1065
    tipd_CLKFB : VitalDelayType01 := (0.000 ns, 0.000 ns);
1066
    tipd_CLKIN : VitalDelayType01 := (0.000 ns, 0.000 ns);
1067
    tipd_RST : VitalDelayType01 := (0.000 ns, 0.000 ns);
1068
 
1069
    tpd_CLKIN_LOCKED : VitalDelayType01 := (0.000 ns, 0.000 ns);
1070
 
1071
    tperiod_CLKIN_POSEDGE : VitalDelayType := 0.000 ns;
1072
 
1073
    tpw_CLKIN_negedge : VitalDelayType := 0.000 ns;
1074
    tpw_CLKIN_posedge : VitalDelayType := 0.000 ns;
1075
    tpw_RST_posedge : VitalDelayType := 0.000 ns;
1076
 
1077
    CLKDV_DIVIDE : real := 2.0;
1078
    DUTY_CYCLE_CORRECTION : boolean := true;
1079
    FACTORY_JF : bit_vector := X"C080";  --non-simulatable
1080
    MAXPERCLKIN : time := 40000 ps;  --simulation parameter
1081
    SIM_CLKIN_CYCLE_JITTER : time := 300 ps;  --simulation parameter
1082
    SIM_CLKIN_PERIOD_JITTER : time := 1000 ps;  --simulation parameter
1083
    STARTUP_WAIT : boolean := false  --non-simulatable
1084
    );
1085
 
1086
  port (
1087
    CLK0 : out std_ulogic := '0';
1088
    CLK180 : out std_ulogic := '0';
1089
    CLK270 : out std_ulogic := '0';
1090
    CLK2X : out std_ulogic := '0';
1091
    CLK90 : out std_ulogic := '0';
1092
    CLKDV : out std_ulogic := '0';
1093
    LOCKED : out std_ulogic := '0';
1094
 
1095
    CLKFB : in std_ulogic := '0';
1096
    CLKIN : in std_ulogic := '0';
1097
    RST : in std_ulogic := '0'
1098
    );
1099
 
1100
  attribute VITAL_LEVEL0 of CLKDLL : entity is true;
1101
 
1102
end CLKDLL;
1103
 
1104
architecture CLKDLL_V of CLKDLL is
1105
 
1106
  component x_clkdll_maximum_period_check
1107
    generic (
1108
      InstancePath : string := "*";
1109
 
1110
      clock_name : string := "";
1111
      maximum_period : time);
1112
    port(
1113
      clock : in std_ulogic
1114
      );
1115
  end component;
1116
 
1117
  signal CLKFB_ipd, CLKIN_ipd, RST_ipd : std_ulogic;
1118
  signal clk0_out : std_ulogic;
1119
  signal clk2x_out, clkdv_out, locked_out : std_ulogic := '0';
1120
 
1121
  signal clkfb_type : integer;
1122
  signal divide_type : integer;
1123
  signal clk1x_type : integer;
1124
 
1125
  signal lock_period, lock_delay, lock_clkin, lock_clkfb : std_ulogic := '0';
1126
  signal lock_out : std_logic_vector(1 downto 0) := "00";
1127
 
1128
  signal lock_fb : std_ulogic := '0';
1129
  signal fb_delay_found : std_ulogic := '0';
1130
 
1131
  signal clkin_ps : std_ulogic;
1132
  signal clkin_fb, clkin_fb0, clkin_fb1, clkin_fb2 : std_ulogic;
1133
 
1134
  signal clkin_period_real : VitalDelayArrayType(2 downto 0) := (0.000 ns, 0.000 ns, 0.000 ns);
1135
  signal period : time := 0 ps;
1136
  signal period_orig : time := 0 ps;
1137
  signal period_ps : time := 0 ps;
1138
  signal clkout_delay : time := 0 ps;
1139
  signal fb_delay : time := 0 ps;
1140
  signal period_dv_high, period_dv_low : time := 0 ps;
1141
  signal cycle_jitter, period_jitter : time := 0 ps;
1142
 
1143
  signal clkin_window, clkfb_window : std_ulogic := '0';
1144
  signal clkin_5050 : std_ulogic := '0';
1145
  signal rst_reg : std_logic_vector(2 downto 0) := "000";
1146
 
1147
  signal clkin_period_real0_temp : time := 0 ps;
1148
  signal ps_lock_temp : std_ulogic := '0';
1149
 
1150
  signal clk0_temp : std_ulogic := '0';
1151
  signal clk2x_temp : std_ulogic := '0';
1152
 
1153
  signal no_stop : boolean := false;
1154
 
1155
begin
1156
  INITPROC : process
1157
  begin
1158
    detect_resolution
1159
      (model_name => "CLKDLL"
1160
       );
1161
    if (CLKDV_DIVIDE = 1.5) then
1162
      divide_type <= 3;
1163
    elsif (CLKDV_DIVIDE = 2.0) then
1164
      divide_type <= 4;
1165
    elsif (CLKDV_DIVIDE = 2.5) then
1166
      divide_type <= 5;
1167
    elsif (CLKDV_DIVIDE = 3.0) then
1168
      divide_type <= 6;
1169
    elsif (CLKDV_DIVIDE = 4.0) then
1170
      divide_type <= 8;
1171
    elsif (CLKDV_DIVIDE = 5.0) then
1172
      divide_type <= 10;
1173
    elsif (CLKDV_DIVIDE = 8.0) then
1174
      divide_type <= 16;
1175
    elsif (CLKDV_DIVIDE = 16.0) then
1176
      divide_type <= 32;
1177
    else
1178
      GenericValueCheckMessage
1179
        (HeaderMsg => "Attribute Syntax Error",
1180
         GenericName => "CLKDV_DIVIDE",
1181
         EntityName => "CLKDLL",
1182
         InstanceName => InstancePath,
1183
         GenericValue => CLKDV_DIVIDE,
1184
         Unit => "",
1185
         ExpectedValueMsg => "Legal Values for this attribute are 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 8.0 or 16.0",
1186
         ExpectedGenericValue => "",
1187
         TailMsg => "",
1188
         MsgSeverity => error
1189
         );
1190
    end if;
1191
 
1192
    clkfb_type <= 2;
1193
 
1194
    period_jitter <= SIM_CLKIN_PERIOD_JITTER;
1195
    cycle_jitter <= SIM_CLKIN_CYCLE_JITTER;
1196
 
1197
    case DUTY_CYCLE_CORRECTION is
1198
      when false => clk1x_type <= 0;
1199
      when true => clk1x_type <= 1;
1200
      when others =>
1201
        GenericValueCheckMessage
1202
          (HeaderMsg => "Attribute Syntax Error",
1203
           GenericName => "DUTY_CYCLE_CORRECTION",
1204
           EntityName => "CLKDLL",
1205
           InstanceName => InstancePath,
1206
           GenericValue => DUTY_CYCLE_CORRECTION,
1207
           Unit => "",
1208
           ExpectedValueMsg => "Legal Values for this attribute are TRUE or FALSE",
1209
           ExpectedGenericValue => "",
1210
           TailMsg => "",
1211
           MsgSeverity => error
1212
           );
1213
    end case;
1214
 
1215
    case STARTUP_WAIT is
1216
      when false => null;
1217
      when true => null;
1218
      when others =>
1219
        GenericValueCheckMessage
1220
          (HeaderMsg => "Attribute Syntax Error",
1221
           GenericName => "STARTUP_WAIT",
1222
           EntityName => "CLKDLL",
1223
           InstanceName => InstancePath,
1224
           GenericValue => STARTUP_WAIT,
1225
           Unit => "",
1226
           ExpectedValueMsg => "Legal Values for this attribute are TRUE or FALSE",
1227
           ExpectedGenericValue => "",
1228
           TailMsg => "",
1229
           MsgSeverity => error
1230
           );
1231
    end case;
1232
    wait;
1233
  end process INITPROC;
1234
 
1235
--
1236
-- input wire delays
1237
--
1238
 
1239
  WireDelay : block
1240
  begin
1241
    VitalWireDelay (CLKIN_ipd, CLKIN, tipd_CLKIN);
1242
    VitalWireDelay (CLKFB_ipd, CLKFB, tipd_CLKFB);
1243
    VitalWireDelay (RST_ipd, RST, tipd_RST);
1244
  end block;
1245
 
1246
  i_max_clkin : x_clkdll_maximum_period_check
1247
    generic map (
1248
      clock_name => "CLKIN",
1249
      maximum_period => MAXPERCLKIN)
1250
 
1251
    port map (
1252
      clock => clkin_ipd);
1253
 
1254
  assign_clkin_ps : process
1255
  begin
1256
    if (rst_ipd = '0') then
1257
      clkin_ps <= clkin_ipd;
1258
    elsif (rst_ipd = '1') then
1259
      clkin_ps <= '0';
1260
      wait until (falling_edge(rst_reg(2)));
1261
    end if;
1262
    wait on clkin_ipd, rst_ipd;
1263
  end process assign_clkin_ps;
1264
 
1265
  clkin_fb0 <= transport (clkin_ps and lock_fb) after period_ps/4;
1266
  clkin_fb1 <= transport clkin_fb0 after period_ps/4;
1267
  clkin_fb2 <= transport clkin_fb1 after period_ps/4;
1268
  clkin_fb <= transport clkin_fb2 after period_ps/4;
1269
 
1270
  determine_period_ps : process
1271
    variable clkin_ps_edge_previous : time := 0 ps;
1272
    variable clkin_ps_edge_current : time := 0 ps;
1273
  begin
1274
    if (rst_ipd'event) then
1275
      clkin_ps_edge_previous := 0 ps;
1276
      clkin_ps_edge_current := 0 ps;
1277
      period_ps <= 0 ps;
1278
    else
1279
      if (rising_edge(clkin_ps)) then
1280
        clkin_ps_edge_previous := clkin_ps_edge_current;
1281
        clkin_ps_edge_current := NOW;
1282
        wait for 0 ps;
1283
        if ((clkin_ps_edge_current - clkin_ps_edge_previous) <= (1.5 * period_ps)) then
1284
          period_ps <= clkin_ps_edge_current - clkin_ps_edge_previous;
1285
        elsif ((period_ps = 0 ps) and (clkin_ps_edge_previous /= 0 ps)) then
1286
          period_ps <= clkin_ps_edge_current - clkin_ps_edge_previous;
1287
        end if;
1288
      end if;
1289
    end if;
1290
    wait on clkin_ps, rst_ipd;
1291
  end process determine_period_ps;
1292
 
1293
  assign_lock_fb : process
1294
  begin
1295
    if (rising_edge(clkin_ps)) then
1296
      lock_fb <= lock_period;
1297
    end if;
1298
    wait on clkin_ps;
1299
  end process assign_lock_fb;
1300
 
1301
  calculate_clkout_delay : process
1302
  begin
1303
    if (rst_ipd'event) then
1304
      clkout_delay <= 0 ps;
1305
    elsif (period'event or fb_delay'event) then
1306
      clkout_delay <= period - fb_delay;
1307
    end if;
1308
    wait on period, fb_delay, rst_ipd;
1309
  end process calculate_clkout_delay;
1310
 
1311
--
1312
--generate master reset signal
1313
--
1314
 
1315
  gen_master_rst : process
1316
  begin
1317
    if (rising_edge(clkin_ipd)) then
1318
      rst_reg(2) <= rst_reg(1) and rst_reg(0) and rst_ipd;
1319
      rst_reg(1) <= rst_reg(0) and rst_ipd;
1320
      rst_reg(0) <= rst_ipd;
1321
    end if;
1322
    wait on clkin_ipd;
1323
  end process gen_master_rst;
1324
 
1325
  check_rst_width : process
1326
    variable Message : line;
1327
  begin
1328
    if (falling_edge(rst_ipd)) then
1329
      if ((rst_reg(2) and rst_reg(1) and rst_reg(0)) = '0') then
1330
        Write ( Message, string'(" Timing Violation Error : RST on instance "));
1331
        Write ( Message, Instancepath );
1332
        Write ( Message, string'(" must be asserted for 3 CLKIN clock cycles. "));
1333
        assert false report Message.all severity error;
1334
        DEALLOCATE (Message);
1335
      end if;
1336
    end if;
1337
 
1338
    wait on rst_ipd;
1339
  end process check_rst_width;
1340
 
1341
--
1342
--determine clock period
1343
--
1344
  determine_clock_period : process
1345
    variable clkin_edge_previous : time := 0 ps;
1346
    variable clkin_edge_current : time := 0 ps;
1347
  begin
1348
    if (rst_ipd'event) then
1349
      clkin_period_real(0) <= 0 ps;
1350
      clkin_period_real(1) <= 0 ps;
1351
      clkin_period_real(2) <= 0 ps;
1352
    elsif (rising_edge(clkin_ps)) then
1353
      clkin_edge_previous := clkin_edge_current;
1354
      clkin_edge_current := NOW;
1355
      clkin_period_real(2) <= clkin_period_real(1);
1356
      clkin_period_real(1) <= clkin_period_real(0);
1357
      if (clkin_edge_previous /= 0 ps) then
1358
        clkin_period_real(0) <= clkin_edge_current - clkin_edge_previous;
1359
      end if;
1360
    end if;
1361
    if (no_stop'event) then
1362
      clkin_period_real(0) <= clkin_period_real0_temp;
1363
    end if;
1364
    wait on clkin_ps, no_stop, rst_ipd;
1365
  end process determine_clock_period;
1366
 
1367
  evaluate_clock_period : process
1368
    variable clock_stopped : std_ulogic := '1';
1369
    variable Message : line;
1370
  begin
1371
    if (rst_ipd'event) then
1372
      lock_period <= '0';
1373
      clock_stopped := '1';
1374
      clkin_period_real0_temp <= 0 ps;
1375
    else
1376
      if (falling_edge(clkin_ps)) then
1377
        if (lock_period = '0') then
1378
          if ((clkin_period_real(0) /= 0 ps ) and (clkin_period_real(0) - cycle_jitter <= clkin_period_real(1)) and (clkin_period_real(1) <= clkin_period_real(0) + cycle_jitter) and (clkin_period_real(1) - cycle_jitter <= clkin_period_real(2)) and (clkin_period_real(2) <= clkin_period_real(1) + cycle_jitter)) then
1379
            lock_period <= '1';
1380
            period_orig <= (clkin_period_real(0) + clkin_period_real(1) + clkin_period_real(2)) / 3;
1381
            period <= clkin_period_real(0);
1382
          end if;
1383
        elsif (lock_period = '1') then
1384
          if (100000000 ps < clkin_period_real(0)/1000) then
1385
            Write ( Message, string'(" Timing Violation Error : CLKIN stopped toggling on instance "));
1386
            Write ( Message, Instancepath );
1387
            Write ( Message, string'(" exceeds "));
1388
            Write ( Message, string'(" 10000 "));
1389
            Write ( Message, string'(" Current CLKIN Period = "));
1390
            Write ( Message, string'(" clkin_period(0) / 10000.0 "));
1391
            Write ( Message, string'(" ns "));
1392
            assert false report Message.all severity warning;
1393
            DEALLOCATE (Message);
1394
            lock_period <= '0';
1395
            wait until (falling_edge(rst_reg(2)));
1396
          elsif ((period_orig * 2 < clkin_period_real(0)) and (clock_stopped = '0')) then
1397
            clkin_period_real0_temp <= clkin_period_real(1);
1398
            no_stop <= not no_stop;
1399
            clock_stopped := '1';
1400
          elsif ((clkin_period_real(0) < period_orig - period_jitter) or (period_orig + period_jitter < clkin_period_real(0))) then
1401
            Write ( Message, string'(" Timing Violation Error : Input Clock Period Jitter on instance "));
1402
            Write ( Message, Instancepath );
1403
            Write ( Message, string'(" exceeds "));
1404
            Write ( Message, period_jitter / 1000.0 );
1405
            Write ( Message, string'(" Locked CLKIN Period = "));
1406
            Write ( Message, period_orig / 1000.0 );
1407
            Write ( Message, string'(" Current CLKIN Period = "));
1408
            Write ( Message, clkin_period_real(0) / 1000.0 );
1409
            assert false report Message.all severity warning;
1410
            DEALLOCATE (Message);
1411
            lock_period <= '0';
1412
            wait until (falling_edge(rst_reg(2)));
1413
          elsif ((clkin_period_real(0) < clkin_period_real(1) - cycle_jitter) or (clkin_period_real(1) + cycle_jitter < clkin_period_real(0))) then
1414
            Write ( Message, string'(" Timing Violation Error : Input Clock Cycle Jitter on on instance "));
1415
            Write ( Message, Instancepath );
1416
            Write ( Message, string'(" exceeds "));
1417
            Write ( Message, cycle_jitter / 1000.0 );
1418
            Write ( Message, string'(" Previous CLKIN Period = "));
1419
            Write ( Message, clkin_period_real(1) / 1000.0 );
1420
            Write ( Message, string'(" Current CLKIN Period = "));
1421
            Write ( Message, clkin_period_real(0) / 1000.0 );
1422
            assert false report Message.all severity warning;
1423
            DEALLOCATE (Message);
1424
            lock_period <= '0';
1425
            wait until (falling_edge(rst_reg(2)));
1426
          else
1427
            period <= clkin_period_real(0);
1428
            clock_stopped := '0';
1429
          end if;
1430
        end if;
1431
      end if;
1432
    end if;
1433
    wait on clkin_ps, rst_ipd;
1434
  end process evaluate_clock_period;
1435
 
1436
--
1437
--determine clock delay
1438
--
1439
 
1440
  determine_clock_delay : process
1441
    variable delay_edge : time := 0 ps;
1442
    variable temp1 : integer := 0;
1443
    variable temp2 : integer := 0;
1444
    variable temp : integer := 0;
1445
    variable delay_edge_current : time := 0 ps;
1446
  begin
1447
    if (rst_ipd'event) then
1448
      fb_delay <= 0 ps;
1449
      fb_delay_found <= '0';
1450
    else
1451
      if (rising_edge(lock_period)) then
1452
        if ((lock_period = '1') and (clkfb_type /= 0)) then
1453
          if (clkfb_type = 1) then
1454
            wait until ((rising_edge(clk0_temp)) or (rst_ipd'event));
1455
            delay_edge := NOW;
1456
          elsif (clkfb_type = 2) then
1457
            wait until ((rising_edge(clk2x_temp)) or (rst_ipd'event));
1458
            delay_edge := NOW;
1459
          end if;
1460
          wait until ((rising_edge(clkfb_ipd)) or (rst_ipd'event));
1461
          temp1 := ((NOW*1) - (delay_edge*1))/ (1 ps);
1462
          temp2 := (period_orig * 1)/ (1 ps);
1463
          temp := temp1 mod temp2;
1464
          fb_delay <= temp * 1 ps;
1465
        end if;
1466
      end if;
1467
      fb_delay_found <= '1';
1468
    end if;
1469
    wait on lock_period, rst_ipd;
1470
  end process determine_clock_delay;
1471
--
1472
-- determine feedback lock
1473
--
1474
  GEN_CLKFB_WINDOW : process
1475
  begin
1476
    if (rst_ipd'event) then
1477
      clkfb_window <= '0';
1478
    else
1479
      if (rising_edge(CLKFB_ipd)) then
1480
        wait for 0 ps;
1481
        clkfb_window <= '1';
1482
        wait for cycle_jitter;
1483
        clkfb_window <= '0';
1484
      end if;
1485
    end if;
1486
    wait on clkfb_ipd, rst_ipd;
1487
  end process GEN_CLKFB_WINDOW;
1488
 
1489
  GEN_CLKIN_WINDOW : process
1490
  begin
1491
    if (rst_ipd'event) then
1492
      clkin_window <= '0';
1493
    else
1494
      if (rising_edge(clkin_fb)) then
1495
        wait for 0 ps;
1496
        clkin_window <= '1';
1497
        wait for cycle_jitter;
1498
        clkin_window <= '0';
1499
      end if;
1500
    end if;
1501
    wait on clkin_fb, rst_ipd;
1502
  end process GEN_CLKIN_WINDOW;
1503
 
1504
  set_reset_lock_clkin : process
1505
  begin
1506
    if (rst_ipd'event) then
1507
      lock_clkin <= '0';
1508
    else
1509
      if (rising_edge(clkin_fb)) then
1510
        wait for 1 ps;
1511
        if ((clkfb_window = '1') and (fb_delay_found = '1')) then
1512
          lock_clkin <= '1';
1513
        else
1514
          lock_clkin <= '0';
1515
        end if;
1516
      end if;
1517
    end if;
1518
    wait on clkin_fb, rst_ipd;
1519
  end process set_reset_lock_clkin;
1520
 
1521
  set_reset_lock_clkfb : process
1522
  begin
1523
    if (rst_ipd'event) then
1524
      lock_clkfb <= '0';
1525
    else
1526
      if (rising_edge(clkfb_ipd)) then
1527
        wait for 1 ps;
1528
        if ((clkin_window = '1') and (fb_delay_found = '1')) then
1529
          lock_clkfb <= '1';
1530
        else
1531
          lock_clkfb <= '0';
1532
        end if;
1533
      end if;
1534
    end if;
1535
    wait on clkfb_ipd, rst_ipd;
1536
  end process set_reset_lock_clkfb;
1537
 
1538
  assign_lock_delay : process
1539
  begin
1540
    if (rst_ipd'event) then
1541
      lock_delay <= '0';
1542
    else
1543
      if (falling_edge(clkin_fb)) then
1544
        lock_delay <= lock_clkin or lock_clkfb;
1545
      end if;
1546
    end if;
1547
    wait on clkin_fb, rst_ipd;
1548
  end process;
1549
 
1550
--
1551
--generate lock signal
1552
--
1553
 
1554
  generate_lock : process
1555
  begin
1556
    if (rst_ipd'event) then
1557
      lock_out <= "00";
1558
      locked_out <= '0';
1559
    else
1560
      if (rising_edge(clkin_ps)) then
1561
        if (clkfb_type = 0) then
1562
          lock_out(0) <= lock_period;
1563
        else
1564
          lock_out(0) <= lock_period and lock_delay and lock_fb;
1565
        end if;
1566
        lock_out(1) <= lock_out(0);
1567
        locked_out <= lock_out(1);
1568
 
1569
      end if;
1570
    end if;
1571
    wait on clkin_ps, rst_ipd;
1572
  end process generate_lock;
1573
 
1574
--
1575
--generate the clk1x_out
1576
--
1577
 
1578
  gen_clk1x : process
1579
  begin
1580
    if (rst_ipd'event) then
1581
      clkin_5050 <= '0';
1582
    else
1583
      if (rising_edge(clkin_ps)) then
1584
        clkin_5050 <= '1';
1585
        wait for (period/2);
1586
        clkin_5050 <= '0';
1587
      end if;
1588
    end if;
1589
    wait on clkin_ps, rst_ipd;
1590
  end process gen_clk1x;
1591
 
1592
  clk0_out <= clkin_5050 when (clk1x_type = 1) else clkin_ps;
1593
 
1594
--
1595
--generate the clk2x_out
1596
--
1597
 
1598
  gen_clk2x : process
1599
  begin
1600
 
1601
    if (rising_edge(clkin_ps)) then
1602
      clk2x_out <= '1';
1603
      wait for (period / 4);
1604
      clk2x_out <= '0';
1605
      if (lock_out(0) = '1') then
1606
        wait for (period / 4);
1607
        clk2x_out <= '1';
1608
        wait for (period / 4);
1609
        clk2x_out <= '0';
1610
      else
1611
        wait for (period / 2);
1612
      end if;
1613
    end if;
1614
    wait on clkin_ps;
1615
  end process gen_clk2x;
1616
 
1617
--
1618
--generate the clkdv_out
1619
--
1620
 
1621
  determine_clkdv_period : process
1622
  begin
1623
    if (period'event) then
1624
      period_dv_high <= (period / 2) * (divide_type / 2);
1625
      period_dv_low <= (period / 2) * (divide_type / 2 + divide_type mod 2);
1626
    end if;
1627
    wait on period;
1628
  end process determine_clkdv_period;
1629
 
1630
 
1631
  gen_clkdv : process
1632
  begin
1633
    if (rising_edge(clkin_ps)) then
1634
      if (lock_out(0) = '1') then
1635
        clkdv_out <= '1';
1636
        wait for (period_dv_high);
1637
        clkdv_out <= '0';
1638
        wait for (period_dv_low);
1639
        clkdv_out <= '1';
1640
        wait for (period_dv_high);
1641
        clkdv_out <= '0';
1642
        wait for (period_dv_low - period/2);
1643
      end if;
1644
    end if;
1645
    wait on clkin_ps;
1646
  end process gen_clkdv;
1647
 
1648
 
1649
--
1650
--generate all output signal
1651
--
1652
  schedule_outputs : process
1653
    variable LOCKED_GlitchData : VitalGlitchDataType;
1654
  begin
1655
    if (CLK0_out'event) then
1656
      CLK0 <= transport CLK0_out after clkout_delay;
1657
      clk0_temp <= transport CLK0_out after clkout_delay;
1658
      CLK90 <= transport clk0_out after (clkout_delay + period / 4);
1659
      CLK180 <= transport clk0_out after (clkout_delay + period / 2);
1660
      CLK270 <= transport clk0_out after (clkout_delay + (3 * period) / 4);
1661
    end if;
1662
 
1663
    if (clk2x_out'event) then
1664
      CLK2X <= transport clk2x_out after clkout_delay;
1665
      clk2x_temp <= transport clk2x_out after clkout_delay;
1666
    end if;
1667
 
1668
    if (clkdv_out'event) then
1669
      CLKDV <= transport clkdv_out after clkout_delay;
1670
    end if;
1671
 
1672
    VitalPathDelay01 (
1673
      OutSignal => LOCKED,
1674
      GlitchData => LOCKED_GlitchData,
1675
      OutSignalName => "LOCKED",
1676
      OutTemp => locked_out,
1677
      Paths => (0 => (locked_out'last_event, tpd_CLKIN_LOCKED, true)),
1678
      Mode => OnEvent,
1679
      Xon => Xon,
1680
      MsgOn => MsgOn,
1681
      MsgSeverity => warning
1682
      );
1683
    wait on clk0_out, clk2x_out, clkdv_out, locked_out;
1684
  end process schedule_outputs;
1685
 
1686
  VitalTimingCheck : process
1687
    variable Tviol_PSINCDEC_PSCLK_posedge : std_ulogic := '0';
1688
    variable Tmkr_PSINCDEC_PSCLK_posedge : VitalTimingDataType := VitalTimingDataInit;
1689
    variable Tviol_PSEN_PSCLK_posedge : std_ulogic := '0';
1690
    variable Tmkr_PSEN_PSCLK_posedge : VitalTimingDataType := VitalTimingDataInit;
1691
    variable Pviol_CLKIN : std_ulogic := '0';
1692
    variable PInfo_CLKIN : VitalPeriodDataType := VitalPeriodDataInit;
1693
    variable Pviol_PSCLK : std_ulogic := '0';
1694
    variable PInfo_PSCLK : VitalPeriodDataType := VitalPeriodDataInit;
1695
    variable Pviol_RST : std_ulogic := '0';
1696
    variable PInfo_RST : VitalPeriodDataType := VitalPeriodDataInit;
1697
 
1698
  begin
1699
    if (TimingChecksOn) then
1700
      VitalPeriodPulseCheck (
1701
        Violation => Pviol_CLKIN,
1702
        PeriodData => PInfo_CLKIN,
1703
        TestSignal => CLKIN_ipd,
1704
        TestSignalName => "CLKIN",
1705
        TestDelay => 0 ns,
1706
        Period => tperiod_CLKIN_POSEDGE,
1707
        PulseWidthHigh => tpw_CLKIN_posedge,
1708
        PulseWidthLow => tpw_CLKIN_negedge,
1709
        CheckEnabled => TO_X01(not RST_ipd) /= '0',
1710
        HeaderMsg => InstancePath &"/CLKDLL",
1711
        Xon => Xon,
1712
        MsgOn => MsgOn,
1713
        MsgSeverity => warning);
1714
 
1715
      VitalPeriodPulseCheck (
1716
        Violation => Pviol_RST,
1717
        PeriodData => PInfo_RST,
1718
        TestSignal => RST_ipd,
1719
        TestSignalName => "RST",
1720
        TestDelay => 0 ns,
1721
        Period => 0 ns,
1722
        PulseWidthHigh => tpw_RST_posedge,
1723
        PulseWidthLow => 0 ns,
1724
        CheckEnabled => true,
1725
        HeaderMsg => InstancePath &"/CLKDLL",
1726
        Xon => Xon,
1727
        MsgOn => MsgOn,
1728
        MsgSeverity => warning);
1729
    end if;
1730
    wait on CLKIN_ipd, RST_ipd;
1731
  end process VITALTimingCheck;
1732
end CLKDLL_V;
1733
 
1734
 
1735
library IEEE;
1736
use IEEE.STD_LOGIC_1164.all;
1737
 
1738
library STD;
1739
use STD.TEXTIO.all;
1740
 
1741
 
1742
 
1743
entity clkdllhf_maximum_period_check is
1744
  generic (
1745
    InstancePath : string := "*";
1746
 
1747
    clock_name : string := "";
1748
    maximum_period : time);
1749
  port(
1750
    clock : in std_ulogic;
1751
    rst : in std_ulogic
1752
    );
1753
end clkdllhf_maximum_period_check;
1754
 
1755
architecture clkdllhf_maximum_period_check_V of clkdllhf_maximum_period_check is
1756
begin
1757
 
1758
  MAX_PERIOD_CHECKER : process
1759
    variable clock_edge_previous : time := 0 ps;
1760
    variable clock_edge_current : time := 0 ps;
1761
    variable clock_period : time := 0 ps;
1762
    variable Message : line;
1763
  begin
1764
    if (rising_edge(clock)) then
1765
      clock_edge_previous := clock_edge_current;
1766
      clock_edge_current := NOW;
1767
 
1768
      if (clock_edge_previous > 0 ps) then
1769
        clock_period := clock_edge_current - clock_edge_previous;
1770
      end if;
1771
 
1772
      if ((clock_period > maximum_period) and (rst = '0')) then
1773
        Write ( Message, string'(" Timing Violation Error : Input Clock Period of"));
1774
        Write ( Message, clock_period/1000.0 );
1775
        Write ( Message, string'(" on the ") );
1776
        Write ( Message, clock_name );
1777
        Write ( Message, string'(" port ") );
1778
        Write ( Message, string'(" of CLKDLLHF instance ") );
1779
        Write ( Message, InstancePath );
1780
        Write ( Message, string'(" exceeds allotted value of ") );
1781
        Write ( Message, maximum_period/1000.0 );
1782
        Write ( Message, string'(" at simulation time ") );
1783
        Write ( Message, clock_edge_current/1000.0 );
1784
        Write ( Message, '.' & LF );
1785
        assert false report Message.all severity warning;
1786
        DEALLOCATE (Message);
1787
      end if;
1788
    end if;
1789
    wait on clock;
1790
  end process MAX_PERIOD_CHECKER;
1791
end clkdllhf_maximum_period_check_V;
1792
 
1793
----- CELL CLKDLLHF -----
1794
library IEEE;
1795
use IEEE.std_logic_1164.all;
1796
use IEEE.VITAL_Timing.all;
1797
 
1798
library STD;
1799
use STD.TEXTIO.all;
1800
 
1801
library unisim;
1802
use unisim.VPKG.all;
1803
library unisim;
1804
use unisim.VCOMPONENTS.all;
1805
 
1806
entity CLKDLLHF is
1807
  generic (
1808
    TimingChecksOn : boolean := true;
1809
    InstancePath : string := "*";
1810
    Xon : boolean := true;
1811
    MsgOn : boolean := false;
1812
 
1813
    tipd_CLKFB : VitalDelayType01 := (0.000 ns, 0.000 ns);
1814
    tipd_CLKIN : VitalDelayType01 := (0.000 ns, 0.000 ns);
1815
    tipd_RST : VitalDelayType01 := (0.000 ns, 0.000 ns);
1816
 
1817
    tpd_CLKIN_LOCKED : VitalDelayType01 := (0.000 ns, 0.000 ns);
1818
 
1819
    tperiod_CLKIN_POSEDGE : VitalDelayType := 0.000 ns;
1820
 
1821
 
1822
    tpw_CLKIN_negedge : VitalDelayType := 0.000 ns;
1823
    tpw_CLKIN_posedge : VitalDelayType := 0.000 ns;
1824
    tpw_RST_posedge : VitalDelayType := 0.000 ns;
1825
 
1826
    CLKDV_DIVIDE : real := 2.0;
1827
    DUTY_CYCLE_CORRECTION : boolean := true;
1828
    FACTORY_JF : bit_vector := X"FFF0";  --non-simulatable
1829
    STARTUP_WAIT : boolean := false  --non-simulatable
1830
    );
1831
 
1832
  port (
1833
    CLK0 : out std_ulogic := '0';
1834
    CLK180 : out std_ulogic := '0';
1835
    CLKDV : out std_ulogic := '0';
1836
    LOCKED : out std_ulogic := '0';
1837
 
1838
    CLKFB : in std_ulogic := '0';
1839
    CLKIN : in std_ulogic := '0';
1840
    RST : in std_ulogic := '0'
1841
    );
1842
 
1843
  attribute VITAL_LEVEL0 of CLKDLLHF : entity is true;
1844
 
1845
end CLKDLLHF;
1846
 
1847
architecture CLKDLLHF_V of CLKDLLHF is
1848
 
1849
  component clkdllhf_maximum_period_check
1850
    generic (
1851
      InstancePath : string := "*";
1852
 
1853
      clock_name : string := "";
1854
      maximum_period : time);
1855
    port(
1856
      clock : in std_ulogic;
1857
      rst : in std_ulogic
1858
      );
1859
  end component;
1860
 
1861
  constant MAXPERCLKIN : time := 40000 ps;
1862
  constant SIM_CLKIN_CYCLE_JITTER : time := 300 ps;
1863
  constant SIM_CLKIN_PERIOD_JITTER : time := 1000 ps;
1864
 
1865
  signal CLKFB_ipd, CLKIN_ipd, RST_ipd : std_ulogic;
1866
  signal clk0_out : std_ulogic;
1867
  signal clkdv_out, locked_out : std_ulogic := '0';
1868
 
1869
  signal clkfb_type : integer;
1870
  signal divide_type : integer;
1871
  signal clk1x_type : integer;
1872
 
1873
  signal lock_period, lock_delay, lock_clkin, lock_clkfb : std_ulogic := '0';
1874
  signal lock_out : std_logic_vector(1 downto 0) := "00";
1875
 
1876
  signal lock_fb : std_ulogic := '0';
1877
  signal fb_delay_found : std_ulogic := '0';
1878
 
1879
  signal clkin_ps : std_ulogic;
1880
  signal clkin_fb, clkin_fb0, clkin_fb1, clkin_fb2 : std_ulogic;
1881
 
1882
  signal clkin_period_real : VitalDelayArrayType(2 downto 0) := (0.000 ns, 0.000 ns, 0.000 ns);
1883
  signal period : time := 0 ps;
1884
  signal period_orig : time := 0 ps;
1885
  signal period_ps : time := 0 ps;
1886
  signal clkout_delay : time := 0 ps;
1887
  signal fb_delay : time := 0 ps;
1888
  signal period_dv_high, period_dv_low : time := 0 ps;
1889
  signal cycle_jitter, period_jitter : time := 0 ps;
1890
 
1891
  signal clkin_window, clkfb_window : std_ulogic := '0';
1892
  signal clkin_5050 : std_ulogic := '0';
1893
  signal rst_reg : std_logic_vector(2 downto 0) := "000";
1894
 
1895
  signal clkin_period_real0_temp : time := 0 ps;
1896
  signal ps_lock_temp : std_ulogic := '0';
1897
 
1898
  signal clk0_temp : std_ulogic := '0';
1899
  signal clk2X_temp : std_ulogic := '0';
1900
 
1901
  signal no_stop : boolean := false;
1902
 
1903
begin
1904
  INITPROC : process
1905
  begin
1906
    detect_resolution
1907
      (model_name => "CLKDLLHF"
1908
       );
1909
 
1910
    if (CLKDV_DIVIDE = 1.5) then
1911
      divide_type <= 3;
1912
    elsif (CLKDV_DIVIDE = 2.0) then
1913
      divide_type <= 4;
1914
    elsif (CLKDV_DIVIDE = 2.5) then
1915
      divide_type <= 5;
1916
    elsif (CLKDV_DIVIDE = 3.0) then
1917
      divide_type <= 6;
1918
    elsif (CLKDV_DIVIDE = 4.0) then
1919
      divide_type <= 8;
1920
    elsif (CLKDV_DIVIDE = 5.0) then
1921
      divide_type <= 10;
1922
    elsif (CLKDV_DIVIDE = 8.0) then
1923
      divide_type <= 16;
1924
    elsif (CLKDV_DIVIDE = 16.0) then
1925
      divide_type <= 32;
1926
    else
1927
      GenericValueCheckMessage
1928
        (HeaderMsg => "Attribute Syntax Error",
1929
         GenericName => "CLKDV_DIVIDE",
1930
         EntityName => "CLKDLLHF",
1931
         InstanceName => InstancePath,
1932
         GenericValue => CLKDV_DIVIDE,
1933
         Unit => "",
1934
         ExpectedValueMsg => "Legal Values for this attribute are 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 8.0 or 16.0",
1935
         ExpectedGenericValue => "",
1936
         TailMsg => "",
1937
         MsgSeverity => error
1938
         );
1939
    end if;
1940
 
1941
    clkfb_type <= 1;
1942
 
1943
    period_jitter <= SIM_CLKIN_PERIOD_JITTER;
1944
    cycle_jitter <= SIM_CLKIN_CYCLE_JITTER;
1945
 
1946
    case DUTY_CYCLE_CORRECTION is
1947
      when false => clk1x_type <= 0;
1948
      when true => clk1x_type <= 1;
1949
      when others =>
1950
        GenericValueCheckMessage
1951
          (HeaderMsg => "Attribute Syntax Error",
1952
           GenericName => "DUTY_CYCLE_CORRECTION",
1953
           EntityName => "CLKDLLHF",
1954
           InstanceName => InstancePath,
1955
           GenericValue => DUTY_CYCLE_CORRECTION,
1956
           Unit => "",
1957
           ExpectedValueMsg => "Legal Values for this attribute are TRUE or FALSE",
1958
           ExpectedGenericValue => "",
1959
           TailMsg => "",
1960
           MsgSeverity => error
1961
           );
1962
    end case;
1963
 
1964
    case STARTUP_WAIT is
1965
      when false => null;
1966
      when true => null;
1967
      when others =>
1968
        GenericValueCheckMessage
1969
          (HeaderMsg => "Attribute Syntax Error",
1970
           GenericName => "STARTUP_WAIT",
1971
           EntityName => "CLKDLLHF",
1972
           InstanceName => InstancePath,
1973
           GenericValue => STARTUP_WAIT,
1974
           Unit => "",
1975
           ExpectedValueMsg => "Legal Values for this attribute are TRUE or FALSE",
1976
           ExpectedGenericValue => "",
1977
           TailMsg => "",
1978
           MsgSeverity => error
1979
           );
1980
    end case;
1981
    wait;
1982
  end process INITPROC;
1983
 
1984
--
1985
-- input wire delays
1986
--
1987
 
1988
  WireDelay : block
1989
  begin
1990
    VitalWireDelay (CLKIN_ipd, CLKIN, tipd_CLKIN);
1991
    VitalWireDelay (CLKFB_ipd, CLKFB, tipd_CLKFB);
1992
    VitalWireDelay (RST_ipd, RST, tipd_RST);
1993
  end block;
1994
 
1995
 
1996
  i_max_clkin : clkdllhf_maximum_period_check
1997
    generic map (
1998
      clock_name => "CLKIN",
1999
      maximum_period => MAXPERCLKIN)
2000
 
2001
    port map (
2002
      clock => clkin_ipd,
2003
      rst => rst_ipd);
2004
 
2005
  assign_clkin_ps : process
2006
  begin
2007
    if (rst_ipd = '0') then
2008
      clkin_ps <= clkin_ipd;
2009
    elsif (rst_ipd = '1') then
2010
      clkin_ps <= '0';
2011
      wait until (falling_edge(rst_reg(2)));
2012
    end if;
2013
    wait on clkin_ipd, rst_ipd;
2014
  end process assign_clkin_ps;
2015
 
2016
  clkin_fb0 <= transport (clkin_ps and lock_fb) after period_ps/4;
2017
  clkin_fb1 <= transport clkin_fb0 after period_ps/4;
2018
  clkin_fb2 <= transport clkin_fb1 after period_ps/4;
2019
  clkin_fb <= transport clkin_fb2 after period_ps/4;
2020
 
2021
  determine_period_ps : process
2022
    variable clkin_ps_edge_previous : time := 0 ps;
2023
    variable clkin_ps_edge_current : time := 0 ps;
2024
  begin
2025
    if (rst_ipd'event) then
2026
      clkin_ps_edge_previous := 0 ps;
2027
      clkin_ps_edge_current := 0 ps;
2028
      period_ps <= 0 ps;
2029
    else
2030
      if (rising_edge(clkin_ps)) then
2031
        clkin_ps_edge_previous := clkin_ps_edge_current;
2032
        clkin_ps_edge_current := NOW;
2033
        wait for 0 ps;
2034
        if ((clkin_ps_edge_current - clkin_ps_edge_previous) <= (1.5 * period_ps)) then
2035
          period_ps <= clkin_ps_edge_current - clkin_ps_edge_previous;
2036
        elsif ((period_ps = 0 ps) and (clkin_ps_edge_previous /= 0 ps)) then
2037
          period_ps <= clkin_ps_edge_current - clkin_ps_edge_previous;
2038
        end if;
2039
      end if;
2040
    end if;
2041
    wait on clkin_ps, rst_ipd;
2042
  end process determine_period_ps;
2043
 
2044
  assign_lock_fb : process
2045
  begin
2046
    if (rising_edge(clkin_ps)) then
2047
      lock_fb <= lock_period;
2048
    end if;
2049
    wait on clkin_ps;
2050
  end process assign_lock_fb;
2051
 
2052
  calculate_clkout_delay : process
2053
  begin
2054
    if (rst_ipd'event) then
2055
      clkout_delay <= 0 ps;
2056
    elsif (period'event or fb_delay'event) then
2057
      clkout_delay <= period - fb_delay;
2058
    end if;
2059
    wait on period, fb_delay, rst_ipd;
2060
  end process calculate_clkout_delay;
2061
 
2062
--
2063
--generate master reset signal
2064
--
2065
 
2066
  gen_master_rst : process
2067
  begin
2068
    if (rising_edge(clkin_ipd)) then
2069
      rst_reg(2) <= rst_reg(1) and rst_reg(0) and rst_ipd;
2070
      rst_reg(1) <= rst_reg(0) and rst_ipd;
2071
      rst_reg(0) <= rst_ipd;
2072
    end if;
2073
    wait on clkin_ipd;
2074
  end process gen_master_rst;
2075
 
2076
  check_rst_width : process
2077
    variable Message : line;
2078
    variable rst_tmp1, rst_tmp2 : time := 0 ps;
2079
  begin
2080
    if ((rising_edge(rst_ipd)) or (falling_edge(rst_ipd))) then
2081
      if (rst_ipd = '1') then
2082
        rst_tmp1 := NOW;
2083
      elsif (rst_ipd = '1') then
2084
        rst_tmp2 := NOW - rst_tmp1;
2085
      end if;
2086
      if ((rst_tmp2 < 2000 ps) and (rst_tmp2 /= 0 ps)) then
2087
        Write ( Message, string'(" Timing Violation Error : RST on instance "));
2088
        Write ( Message, Instancepath );
2089
        Write ( Message, string'(" must be asserted atleast for 2 ns. "));
2090
        assert false report Message.all severity error;
2091
        DEALLOCATE (Message);
2092
      end if;
2093
    end if;
2094
    wait on rst_ipd;
2095
  end process check_rst_width;
2096
 
2097
--
2098
--determine clock period
2099
--
2100
  determine_clock_period : process
2101
    variable clkin_edge_previous : time := 0 ps;
2102
    variable clkin_edge_current : time := 0 ps;
2103
  begin
2104
    if (rst_ipd'event) then
2105
      clkin_period_real(0) <= 0 ps;
2106
      clkin_period_real(1) <= 0 ps;
2107
      clkin_period_real(2) <= 0 ps;
2108
    elsif (rising_edge(clkin_ps)) then
2109
      clkin_edge_previous := clkin_edge_current;
2110
      clkin_edge_current := NOW;
2111
      clkin_period_real(2) <= clkin_period_real(1);
2112
      clkin_period_real(1) <= clkin_period_real(0);
2113
      if (clkin_edge_previous /= 0 ps) then
2114
        clkin_period_real(0) <= clkin_edge_current - clkin_edge_previous;
2115
      end if;
2116
    end if;
2117
    if (no_stop'event) then
2118
      clkin_period_real(0) <= clkin_period_real0_temp;
2119
    end if;
2120
    wait on clkin_ps, no_stop, rst_ipd;
2121
  end process determine_clock_period;
2122
 
2123
  evaluate_clock_period : process
2124
    variable clock_stopped : std_ulogic := '1';
2125
    variable Message : line;
2126
  begin
2127
    if (rst_ipd'event) then
2128
      lock_period <= '0';
2129
      clock_stopped := '1';
2130
      clkin_period_real0_temp <= 0 ps;
2131
    else
2132
      if (falling_edge(clkin_ps)) then
2133
        if (lock_period = '0') then
2134
          if ((clkin_period_real(0) /= 0 ps ) and (clkin_period_real(0) - cycle_jitter <= clkin_period_real(1)) and (clkin_period_real(1) <= clkin_period_real(0) + cycle_jitter) and (clkin_period_real(1) - cycle_jitter <= clkin_period_real(2)) and (clkin_period_real(2) <= clkin_period_real(1) + cycle_jitter)) then
2135
            lock_period <= '1';
2136
            period_orig <= (clkin_period_real(0) + clkin_period_real(1) + clkin_period_real(2)) / 3;
2137
            period <= clkin_period_real(0);
2138
          end if;
2139
        elsif (lock_period = '1') then
2140
          if (100000000 ps < clkin_period_real(0)/1000) then
2141
            Write ( Message, string'(" Timing Violation Error : CLKIN stopped toggling on instance "));
2142
            Write ( Message, Instancepath );
2143
            Write ( Message, string'(" exceeds "));
2144
            Write ( Message, string'(" 10000 "));
2145
            Write ( Message, string'(" Current CLKIN Period = "));
2146
            Write ( Message, string'(" clkin_period(0) / 10000.0 "));
2147
            Write ( Message, string'(" ns "));
2148
            assert false report Message.all severity warning;
2149
            DEALLOCATE (Message);
2150
            lock_period <= '0';
2151
            wait until (falling_edge(rst_reg(2)));
2152
          elsif ((period_orig * 2 < clkin_period_real(0)) and (clock_stopped = '0')) then
2153
            clkin_period_real0_temp <= clkin_period_real(1);
2154
            no_stop <= not no_stop;
2155
            clock_stopped := '1';
2156
          elsif ((clkin_period_real(0) < period_orig - period_jitter) or (period_orig + period_jitter < clkin_period_real(0))) then
2157
            Write ( Message, string'(" Timing Violation Error : Input Clock Period Jitter on instance "));
2158
            Write ( Message, Instancepath );
2159
            Write ( Message, string'(" exceeds "));
2160
            Write ( Message, period_jitter / 1000.0 );
2161
            Write ( Message, string'(" Locked CLKIN Period = "));
2162
            Write ( Message, period_orig / 1000.0 );
2163
            Write ( Message, string'(" Current CLKIN Period = "));
2164
            Write ( Message, clkin_period_real(0) / 1000.0 );
2165
            assert false report Message.all severity warning;
2166
            DEALLOCATE (Message);
2167
            lock_period <= '0';
2168
            wait until (falling_edge(rst_reg(2)));
2169
          elsif ((clkin_period_real(0) < clkin_period_real(1) - cycle_jitter) or (clkin_period_real(1) + cycle_jitter < clkin_period_real(0))) then
2170
            Write ( Message, string'(" Timing Violation Error : Input Clock Cycle Jitter on on instance "));
2171
            Write ( Message, Instancepath );
2172
            Write ( Message, string'(" exceeds "));
2173
            Write ( Message, cycle_jitter / 1000.0 );
2174
            Write ( Message, string'(" Previous CLKIN Period = "));
2175
            Write ( Message, clkin_period_real(1) / 1000.0 );
2176
            Write ( Message, string'(" Current CLKIN Period = "));
2177
            Write ( Message, clkin_period_real(0) / 1000.0 );
2178
            assert false report Message.all severity warning;
2179
            DEALLOCATE (Message);
2180
            lock_period <= '0';
2181
            wait until (falling_edge(rst_reg(2)));
2182
          end if;
2183
        else
2184
          period <= clkin_period_real(0);
2185
          clock_stopped := '0';
2186
        end if;
2187
      end if;
2188
    end if;
2189
    wait on clkin_ps, rst_ipd;
2190
  end process evaluate_clock_period;
2191
 
2192
  determine_clock_delay : process
2193
    variable delay_edge : time := 0 ps;
2194
    variable temp1 : integer := 0;
2195
    variable temp2 : integer := 0;
2196
    variable temp : integer := 0;
2197
    variable delay_edge_current : time := 0 ps;
2198
  begin
2199
    if (rst_ipd'event) then
2200
      fb_delay <= 0 ps;
2201
      fb_delay_found <= '0';
2202
    else
2203
      if (rising_edge(lock_period)) then
2204
        if ((lock_period = '1') and (clkfb_type /= 0)) then
2205
          if (clkfb_type = 1) then
2206
            wait until ((rising_edge(clk0_temp)) or (rst_ipd'event));
2207
            delay_edge := NOW;
2208
          elsif (clkfb_type = 2) then
2209
            wait until ((rising_edge(clk2x_temp)) or (rst_ipd'event));
2210
            delay_edge := NOW;
2211
          end if;
2212
          wait until ((rising_edge(clkfb_ipd)) or (rst_ipd'event));
2213
          temp1 := ((NOW*1) - (delay_edge*1))/ (1 ps);
2214
          temp2 := (period_orig * 1)/ (1 ps);
2215
          temp := temp1 mod temp2;
2216
          fb_delay <= temp * 1 ps;
2217
        end if;
2218
      end if;
2219
      fb_delay_found <= '1';
2220
    end if;
2221
    wait on lock_period, rst_ipd;
2222
  end process determine_clock_delay;
2223
--
2224
-- determine feedback lock
2225
--
2226
  GEN_CLKFB_WINDOW : process
2227
  begin
2228
    if (rst_ipd'event) then
2229
      clkfb_window <= '0';
2230
    else
2231
      if (rising_edge(CLKFB_ipd)) then
2232
        wait for 0 ps;
2233
        clkfb_window <= '1';
2234
        wait for cycle_jitter;
2235
        clkfb_window <= '0';
2236
      end if;
2237
    end if;
2238
    wait on clkfb_ipd, rst_ipd;
2239
  end process GEN_CLKFB_WINDOW;
2240
 
2241
  GEN_CLKIN_WINDOW : process
2242
  begin
2243
    if (rst_ipd'event) then
2244
      clkin_window <= '0';
2245
    else
2246
      if (rising_edge(clkin_fb)) then
2247
        wait for 0 ps;
2248
        clkin_window <= '1';
2249
        wait for cycle_jitter;
2250
        clkin_window <= '0';
2251
      end if;
2252
    end if;
2253
    wait on clkin_fb, rst_ipd;
2254
  end process GEN_CLKIN_WINDOW;
2255
 
2256
  set_reset_lock_clkin : process
2257
  begin
2258
    if (rst_ipd'event) then
2259
      lock_clkin <= '0';
2260
    else
2261
      if (rising_edge(clkin_fb)) then
2262
        wait for 1 ps;
2263
        if ((clkfb_window = '1') and (fb_delay_found = '1')) then
2264
          lock_clkin <= '1';
2265
        else
2266
          lock_clkin <= '0';
2267
        end if;
2268
      end if;
2269
    end if;
2270
    wait on clkin_fb, rst_ipd;
2271
  end process set_reset_lock_clkin;
2272
 
2273
  set_reset_lock_clkfb : process
2274
  begin
2275
    if (rst_ipd'event) then
2276
      lock_clkfb <= '0';
2277
    else
2278
      if (rising_edge(clkfb_ipd)) then
2279
        wait for 1 ps;
2280
        if ((clkin_window = '1') and (fb_delay_found = '1')) then
2281
          lock_clkfb <= '1';
2282
        else
2283
          lock_clkfb <= '0';
2284
        end if;
2285
      end if;
2286
    end if;
2287
    wait on clkfb_ipd, rst_ipd;
2288
  end process set_reset_lock_clkfb;
2289
 
2290
  assign_lock_delay : process
2291
  begin
2292
    if (rst_ipd'event) then
2293
      lock_delay <= '0';
2294
    else
2295
      if (falling_edge(clkin_fb)) then
2296
        lock_delay <= lock_clkin or lock_clkfb;
2297
      end if;
2298
    end if;
2299
    wait on clkin_fb, rst_ipd;
2300
  end process;
2301
 
2302
--
2303
--generate lock signal
2304
--
2305
 
2306
  generate_lock : process
2307
  begin
2308
    if (rst_ipd'event) then
2309
      lock_out <= "00";
2310
      locked_out <= '0';
2311
    else
2312
      if (rising_edge(clkin_ps)) then
2313
        if (clkfb_type = 0) then
2314
          lock_out(0) <= lock_period;
2315
        else
2316
          lock_out(0) <= lock_period and lock_delay and lock_fb;
2317
        end if;
2318
        lock_out(1) <= lock_out(0);
2319
        locked_out <= lock_out(1);
2320
 
2321
      end if;
2322
    end if;
2323
    wait on clkin_ps, rst_ipd;
2324
  end process generate_lock;
2325
 
2326
--
2327
--generate the clk1x_out
2328
--
2329
 
2330
  gen_clk1x : process
2331
  begin
2332
    if (rst_ipd'event) then
2333
      clkin_5050 <= '0';
2334
    else
2335
      if (rising_edge(clkin_ps)) then
2336
        clkin_5050 <= '1';
2337
        wait for (period/2);
2338
        clkin_5050 <= '0';
2339
      end if;
2340
    end if;
2341
    wait on clkin_ps, rst_ipd;
2342
  end process gen_clk1x;
2343
 
2344
  clk0_out <= clkin_5050 when (clk1x_type = 1) else clkin_ps;
2345
 
2346
--
2347
--generate the clkdv_out
2348
--
2349
 
2350
  determine_clkdv_period : process
2351
  begin
2352
    if (period'event) then
2353
      period_dv_high <= (period / 2) * (divide_type / 2);
2354
      period_dv_low <= (period / 2) * (divide_type / 2 + divide_type mod 2);
2355
    end if;
2356
    wait on period;
2357
  end process determine_clkdv_period;
2358
 
2359
 
2360
  gen_clkdv : process
2361
  begin
2362
    if (rising_edge(clkin_ps)) then
2363
      if (lock_out(0) = '1') then
2364
        clkdv_out <= '1';
2365
        wait for (period_dv_high);
2366
        clkdv_out <= '0';
2367
        wait for (period_dv_low);
2368
        clkdv_out <= '1';
2369
        wait for (period_dv_high);
2370
        clkdv_out <= '0';
2371
        wait for (period_dv_low - period/2);
2372
      end if;
2373
    end if;
2374
    wait on clkin_ps;
2375
  end process gen_clkdv;
2376
 
2377
 
2378
--
2379
--generate all output signal
2380
--
2381
  schedule_outputs : process
2382
    variable LOCKED_GlitchData : VitalGlitchDataType;
2383
  begin
2384
    if (CLK0_out'event) then
2385
      CLK0 <= transport CLK0_out after clkout_delay;
2386
      clk0_temp <= transport CLK0_out after clkout_delay;
2387
      CLK180 <= transport clk0_out after (clkout_delay + period / 2);
2388
    end if;
2389
 
2390
 
2391
    if (clkdv_out'event) then
2392
      CLKDV <= transport clkdv_out after clkout_delay;
2393
    end if;
2394
 
2395
    VitalPathDelay01 (
2396
      OutSignal => LOCKED,
2397
      GlitchData => LOCKED_GlitchData,
2398
      OutSignalName => "LOCKED",
2399
      OutTemp => locked_out,
2400
      Paths => (0 => (locked_out'last_event, tpd_CLKIN_LOCKED, true)),
2401
      Mode => OnEvent,
2402
      Xon => Xon,
2403
      MsgOn => MsgOn,
2404
      MsgSeverity => warning
2405
      );
2406
    wait on clk0_out, clkdv_out, locked_out;
2407
  end process schedule_outputs;
2408
 
2409
  VitalTimingCheck : process
2410
    variable Tviol_PSINCDEC_PSCLK_posedge : std_ulogic := '0';
2411
    variable Tmkr_PSINCDEC_PSCLK_posedge : VitalTimingDataType := VitalTimingDataInit;
2412
    variable Tviol_PSEN_PSCLK_posedge : std_ulogic := '0';
2413
    variable Tmkr_PSEN_PSCLK_posedge : VitalTimingDataType := VitalTimingDataInit;
2414
    variable Pviol_CLKIN : std_ulogic := '0';
2415
    variable PInfo_CLKIN : VitalPeriodDataType := VitalPeriodDataInit;
2416
    variable Pviol_PSCLK : std_ulogic := '0';
2417
    variable PInfo_PSCLK : VitalPeriodDataType := VitalPeriodDataInit;
2418
    variable Pviol_RST : std_ulogic := '0';
2419
    variable PInfo_RST : VitalPeriodDataType := VitalPeriodDataInit;
2420
 
2421
  begin
2422
    if (TimingChecksOn) then
2423
      VitalPeriodPulseCheck (
2424
        Violation => Pviol_CLKIN,
2425
        PeriodData => PInfo_CLKIN,
2426
        TestSignal => CLKIN_ipd,
2427
        TestSignalName => "CLKIN",
2428
        TestDelay => 0 ns,
2429
        Period => tperiod_CLKIN_POSEDGE,
2430
        PulseWidthHigh => tpw_CLKIN_posedge,
2431
        PulseWidthLow => tpw_CLKIN_negedge,
2432
        CheckEnabled => TO_X01(not RST_ipd) /= '0',
2433
        HeaderMsg => InstancePath &"/CLKDLLHF",
2434
        Xon => Xon,
2435
        MsgOn => MsgOn,
2436
        MsgSeverity => warning);
2437
 
2438
      VitalPeriodPulseCheck (
2439
        Violation => Pviol_RST,
2440
        PeriodData => PInfo_RST,
2441
        TestSignal => RST_ipd,
2442
        TestSignalName => "RST",
2443
        TestDelay => 0 ns,
2444
        Period => 0 ns,
2445
        PulseWidthHigh => tpw_RST_posedge,
2446
        PulseWidthLow => 0 ns,
2447
        CheckEnabled => true,
2448
        HeaderMsg => InstancePath &"/CLKDLLHF",
2449
        Xon => Xon,
2450
        MsgOn => MsgOn,
2451
        MsgSeverity => warning);
2452
    end if;
2453
    wait on CLKIN_ipd, RST_ipd;
2454
  end process VITALTimingCheck;
2455
end CLKDLLHF_V;
2456
 
2457
library IEEE;
2458
use IEEE.STD_LOGIC_1164.all;
2459
 
2460
library unisim;
2461
use unisim.vpkg.all;
2462
 
2463
entity IDDR is
2464
 
2465
  generic(
2466
 
2467
      DDR_CLK_EDGE : string := "OPPOSITE_EDGE";
2468
      INIT_Q1      : bit    := '0';
2469
      INIT_Q2      : bit    := '0';
2470
      SRTYPE       : string := "SYNC"
2471
      );
2472
 
2473
  port(
2474
      Q1          : out std_ulogic;
2475
      Q2          : out std_ulogic;
2476
 
2477
      C           : in  std_ulogic;
2478
      CE          : in  std_ulogic;
2479
      D           : in  std_ulogic;
2480
      R           : in  std_ulogic;
2481
      S           : in  std_ulogic
2482
    );
2483
 
2484
end IDDR;
2485
 
2486
architecture IDDR_V OF IDDR is
2487
 
2488
 
2489
  constant SYNC_PATH_DELAY : time := 100 ps;
2490
 
2491
  signal C_ipd          : std_ulogic := 'X';
2492
  signal CE_ipd         : std_ulogic := 'X';
2493
  signal D_ipd          : std_ulogic := 'X';
2494
  signal GSR            : std_ulogic := '0';
2495
  signal GSR_ipd        : std_ulogic := 'X';
2496
  signal R_ipd          : std_ulogic := 'X';
2497
  signal S_ipd          : std_ulogic := 'X';
2498
 
2499
  signal C_dly          : std_ulogic := 'X';
2500
  signal CE_dly         : std_ulogic := 'X';
2501
  signal D_dly          : std_ulogic := 'X';
2502
  signal GSR_dly        : std_ulogic := 'X';
2503
  signal R_dly          : std_ulogic := 'X';
2504
  signal S_dly          : std_ulogic := 'X';
2505
 
2506
  signal Q1_zd          : std_ulogic := 'X';
2507
  signal Q2_zd          : std_ulogic := 'X';
2508
 
2509
  signal Q1_viol        : std_ulogic := 'X';
2510
  signal Q2_viol        : std_ulogic := 'X';
2511
 
2512
  signal Q1_o_reg       : std_ulogic := 'X';
2513
  signal Q2_o_reg       : std_ulogic := 'X';
2514
  signal Q3_o_reg       : std_ulogic := 'X';
2515
  signal Q4_o_reg       : std_ulogic := 'X';
2516
 
2517
  signal ddr_clk_edge_type      : integer := -999;
2518
  signal sr_type                : integer := -999;
2519
begin
2520
 
2521
  ---------------------
2522
  --  INPUT PATH DELAYs
2523
  --------------------
2524
 
2525
  C_dly                  <= C                   after 0 ps;
2526
  CE_dly                 <= CE                  after 0 ps;
2527
  D_dly                  <= D                   after 0 ps;
2528
  GSR_dly                <= GSR                 after 0 ps;
2529
  R_dly                  <= R                   after 0 ps;
2530
  S_dly                  <= S                   after 0 ps;
2531
 
2532
  --------------------
2533
  --  BEHAVIOR SECTION
2534
  --------------------
2535
 
2536
--####################################################################
2537
--#####                     Initialize                           #####
2538
--####################################################################
2539
  prcs_init:process
2540
 
2541
  begin
2542
      if((DDR_CLK_EDGE = "OPPOSITE_EDGE") or (DDR_CLK_EDGE = "opposite_edge")) then
2543
         ddr_clk_edge_type <= 1;
2544
      elsif((DDR_CLK_EDGE = "SAME_EDGE") or (DDR_CLK_EDGE = "same_edge")) then
2545
         ddr_clk_edge_type <= 2;
2546
      elsif((DDR_CLK_EDGE = "SAME_EDGE_PIPELINED") or (DDR_CLK_EDGE = "same_edge_pipelined")) then
2547
         ddr_clk_edge_type <= 3;
2548
      else
2549
        GenericValueCheckMessage
2550
          (  HeaderMsg  => " Attribute Syntax Warning ",
2551
             GenericName => " DDR_CLK_EDGE ",
2552
             EntityName => "/IDDR",
2553
             GenericValue => DDR_CLK_EDGE,
2554
             Unit => "",
2555
             ExpectedValueMsg => " The Legal values for this attribute are ",
2556
             ExpectedGenericValue => " OPPOSITE_EDGE or SAME_EDGE or  SAME_EDGE_PIPELINED.",
2557
             TailMsg => "",
2558
             MsgSeverity => ERROR
2559
         );
2560
      end if;
2561
 
2562
      if((SRTYPE = "ASYNC") or (SRTYPE = "async")) then
2563
         sr_type <= 1;
2564
      elsif((SRTYPE = "SYNC") or (SRTYPE = "sync")) then
2565
         sr_type <= 2;
2566
      else
2567
        GenericValueCheckMessage
2568
          (  HeaderMsg  => " Attribute Syntax Warning ",
2569
             GenericName => " SRTYPE ",
2570
             EntityName => "/IDDR",
2571
             GenericValue => SRTYPE,
2572
             Unit => "",
2573
             ExpectedValueMsg => " The Legal values for this attribute are ",
2574
             ExpectedGenericValue => " ASYNC or SYNC. ",
2575
             TailMsg => "",
2576
             MsgSeverity => ERROR
2577
         );
2578
      end if;
2579
 
2580
     wait;
2581
  end process prcs_init;
2582
--####################################################################
2583
--#####                    q1_q2_q3_q4 reg                       #####
2584
--####################################################################
2585
  prcs_q1q2q3q4_reg:process(C_dly, D_dly, GSR_dly, R_dly, S_dly)
2586
  variable Q1_var : std_ulogic := TO_X01(INIT_Q1);
2587
  variable Q2_var : std_ulogic := TO_X01(INIT_Q2);
2588
  variable Q3_var : std_ulogic := TO_X01(INIT_Q1);
2589
  variable Q4_var : std_ulogic := TO_X01(INIT_Q2);
2590
  begin
2591
     if(GSR_dly = '1') then
2592
         Q1_var := TO_X01(INIT_Q1);
2593
         Q3_var := TO_X01(INIT_Q1);
2594
         Q2_var := TO_X01(INIT_Q2);
2595
         Q4_var := TO_X01(INIT_Q2);
2596
     elsif(GSR_dly = '0') then
2597
        case sr_type is
2598
           when 1 =>
2599
                   if(R_dly = '1') then
2600
                      Q1_var := '0';
2601
                      Q2_var := '0';
2602
                      Q3_var := '0';
2603
                      Q4_var := '0';
2604
                   elsif((R_dly = '0') and (S_dly = '1')) then
2605
                      Q1_var := '1';
2606
                      Q2_var := '1';
2607
                      Q3_var := '1';
2608
                      Q4_var := '1';
2609
                   elsif((R_dly = '0') and (S_dly = '0')) then
2610
                      if(CE_dly = '1') then
2611
                         if(rising_edge(C_dly)) then
2612
                            Q3_var := Q1_var;
2613
                            Q1_var := D_dly;
2614
                            Q4_var := Q2_var;
2615
                         end if;
2616
                         if(falling_edge(C_dly)) then
2617
                            Q2_var := D_dly;
2618
                         end if;
2619
                      end if;
2620
                   end if;
2621
 
2622
           when 2 =>
2623
                   if(rising_edge(C_dly)) then
2624
                      if(R_dly = '1') then
2625
                         Q1_var := '0';
2626
                         Q3_var := '0';
2627
                         Q4_var := '0';
2628
                      elsif((R_dly = '0') and (S_dly = '1')) then
2629
                         Q1_var := '1';
2630
                         Q3_var := '1';
2631
                         Q4_var := '1';
2632
                      elsif((R_dly = '0') and (S_dly = '0')) then
2633
                         if(CE_dly = '1') then
2634
                               Q3_var := Q1_var;
2635
                               Q1_var := D_dly;
2636
                               Q4_var := Q2_var;
2637
                         end if;
2638
                      end if;
2639
                   end if;
2640
 
2641
                   if(falling_edge(C_dly)) then
2642
                      if(R_dly = '1') then
2643
                         Q2_var := '0';
2644
                      elsif((R_dly = '0') and (S_dly = '1')) then
2645
                         Q2_var := '1';
2646
                      elsif((R_dly = '0') and (S_dly = '0')) then
2647
                         if(CE_dly = '1') then
2648
                               Q2_var := D_dly;
2649
                         end if;
2650
                      end if;
2651
                   end if;
2652
 
2653
           when others =>
2654
                   null;
2655
        end case;
2656
     end if;
2657
 
2658
     q1_o_reg <= Q1_var;
2659
     q2_o_reg <= Q2_var;
2660
     q3_o_reg <= Q3_var;
2661
     q4_o_reg <= Q4_var;
2662
 
2663
  end process prcs_q1q2q3q4_reg;
2664
--####################################################################
2665
--#####                        q1 & q2  mux                      #####
2666
--####################################################################
2667
  prcs_q1q2_mux:process(q1_o_reg, q2_o_reg, q3_o_reg, q4_o_reg)
2668
  begin
2669
     case ddr_clk_edge_type is
2670
        when 1 =>
2671
                 Q1_zd <= q1_o_reg;
2672
                 Q2_zd <= q2_o_reg;
2673
        when 2 =>
2674
                 Q1_zd <= q1_o_reg;
2675
                 Q2_zd <= q4_o_reg;
2676
       when 3 =>
2677
                 Q1_zd <= q3_o_reg;
2678
                 Q2_zd <= q4_o_reg;
2679
       when others =>
2680
                 null;
2681
     end case;
2682
  end process prcs_q1q2_mux;
2683
--####################################################################
2684
 
2685
--####################################################################
2686
--#####                         OUTPUT                           #####
2687
--####################################################################
2688
  prcs_output:process(Q1_zd, Q2_zd)
2689
  begin
2690
      Q1 <= Q1_zd after SYNC_PATH_DELAY;
2691
      Q2 <= Q2_zd after SYNC_PATH_DELAY;
2692
  end process prcs_output;
2693
--####################################################################
2694
 
2695
 
2696
end IDDR_V;
2697
 
2698
 
2699
library IEEE;
2700
use IEEE.STD_LOGIC_1164.all;
2701
 
2702
--use unisim.vpkg.all;
2703
 
2704
library unisim;
2705
use unisim.vpkg.all;
2706
 
2707
entity ODDR is
2708
 
2709
  generic(
2710
 
2711
      DDR_CLK_EDGE : string := "OPPOSITE_EDGE";
2712
      INIT         : bit    := '0';
2713
      SRTYPE       : string := "SYNC"
2714
      );
2715
 
2716
  port(
2717
      Q           : out std_ulogic;
2718
 
2719
      C           : in  std_ulogic;
2720
      CE          : in  std_ulogic;
2721
      D1          : in  std_ulogic;
2722
      D2          : in  std_ulogic;
2723
      R           : in  std_ulogic;
2724
      S           : in  std_ulogic
2725
    );
2726
 
2727
end ODDR;
2728
 
2729
architecture ODDR_V OF ODDR is
2730
 
2731
 
2732
  constant SYNC_PATH_DELAY : time := 100 ps;
2733
 
2734
  signal C_ipd          : std_ulogic := 'X';
2735
  signal CE_ipd         : std_ulogic := 'X';
2736
  signal D1_ipd         : std_ulogic := 'X';
2737
  signal D2_ipd         : std_ulogic := 'X';
2738
  signal GSR            : std_ulogic := '0';
2739
  signal GSR_ipd        : std_ulogic := 'X';
2740
  signal R_ipd          : std_ulogic := 'X';
2741
  signal S_ipd          : std_ulogic := 'X';
2742
 
2743
  signal C_dly          : std_ulogic := 'X';
2744
  signal CE_dly         : std_ulogic := 'X';
2745
  signal D1_dly         : std_ulogic := 'X';
2746
  signal D2_dly         : std_ulogic := 'X';
2747
  signal GSR_dly        : std_ulogic := 'X';
2748
  signal R_dly          : std_ulogic := 'X';
2749
  signal S_dly          : std_ulogic := 'X';
2750
 
2751
  signal Q_zd           : std_ulogic := 'X';
2752
 
2753
  signal Q_viol         : std_ulogic := 'X';
2754
 
2755
  signal ddr_clk_edge_type      : integer := -999;
2756
  signal sr_type                : integer := -999;
2757
 
2758
begin
2759
 
2760
  ---------------------
2761
  --  INPUT PATH DELAYs
2762
  --------------------
2763
 
2764
  C_dly                  <= C                   after 0 ps;
2765
  CE_dly                 <= CE                  after 0 ps;
2766
  D1_dly                 <= D1                  after 0 ps;
2767
  D2_dly                 <= D2                  after 0 ps;
2768
  GSR_dly                <= GSR                 after 0 ps;
2769
  R_dly                  <= R                   after 0 ps;
2770
  S_dly                  <= S                   after 0 ps;
2771
 
2772
  --------------------
2773
  --  BEHAVIOR SECTION
2774
  --------------------
2775
 
2776
--####################################################################
2777
--#####                     Initialize                           #####
2778
--####################################################################
2779
  prcs_init:process
2780
 
2781
  begin
2782
      if((DDR_CLK_EDGE = "OPPOSITE_EDGE") or (DDR_CLK_EDGE = "opposite_edge")) then
2783
         ddr_clk_edge_type <= 1;
2784
      elsif((DDR_CLK_EDGE = "SAME_EDGE") or (DDR_CLK_EDGE = "same_edge")) then
2785
         ddr_clk_edge_type <= 2;
2786
      else
2787
        GenericValueCheckMessage
2788
          (  HeaderMsg  => " Attribute Syntax Warning ",
2789
             GenericName => " DDR_CLK_EDGE ",
2790
             EntityName => "/ODDR",
2791
             GenericValue => DDR_CLK_EDGE,
2792
             Unit => "",
2793
             ExpectedValueMsg => " The Legal values for this attribute are ",
2794
             ExpectedGenericValue => " OPPOSITE_EDGE or SAME_EDGE.",
2795
             TailMsg => "",
2796
             MsgSeverity => ERROR
2797
         );
2798
      end if;
2799
 
2800
      if((SRTYPE = "ASYNC") or (SRTYPE = "async")) then
2801
         sr_type <= 1;
2802
      elsif((SRTYPE = "SYNC") or (SRTYPE = "sync")) then
2803
         sr_type <= 2;
2804
      else
2805
        GenericValueCheckMessage
2806
          (  HeaderMsg  => " Attribute Syntax Warning ",
2807
             GenericName => " SRTYPE ",
2808
             EntityName => "/ODDR",
2809
             GenericValue => SRTYPE,
2810
             Unit => "",
2811
             ExpectedValueMsg => " The Legal values for this attribute are ",
2812
             ExpectedGenericValue => " ASYNC or SYNC. ",
2813
             TailMsg => "",
2814
             MsgSeverity => ERROR
2815
         );
2816
      end if;
2817
 
2818
     wait;
2819
  end process prcs_init;
2820
--####################################################################
2821
--#####                       q1_q2_q3 reg                       #####
2822
--####################################################################
2823
  prcs_q1q2q3_reg:process(C_dly, GSR_dly, R_dly, S_dly)
2824
  variable Q1_var         : std_ulogic := TO_X01(INIT);
2825
  variable Q2_posedge_var : std_ulogic := TO_X01(INIT);
2826
  begin
2827
     if(GSR_dly = '1') then
2828
         Q1_var         := TO_X01(INIT);
2829
         Q2_posedge_var := TO_X01(INIT);
2830
     elsif(GSR_dly = '0') then
2831
        case sr_type is
2832
           when 1 =>
2833
                   if(R_dly = '1') then
2834
                      Q1_var := '0';
2835
                      Q2_posedge_var := '0';
2836
                   elsif((R_dly = '0') and (S_dly = '1')) then
2837
                      Q1_var := '1';
2838
                      Q2_posedge_var := '1';
2839
                   elsif((R_dly = '0') and (S_dly = '0')) then
2840
                      if(CE_dly = '1') then
2841
                         if(rising_edge(C_dly)) then
2842
                            Q1_var         := D1_dly;
2843
                            Q2_posedge_var := D2_dly;
2844
                         end if;
2845
                         if(falling_edge(C_dly)) then
2846
                             case ddr_clk_edge_type is
2847
                                when 1 =>
2848
                                       Q1_var :=  D2_dly;
2849
                                when 2 =>
2850
                                       Q1_var :=  Q2_posedge_var;
2851
                                when others =>
2852
                                          null;
2853
                              end case;
2854
                         end if;
2855
                      end if;
2856
                   end if;
2857
 
2858
           when 2 =>
2859
                   if(rising_edge(C_dly)) then
2860
                      if(R_dly = '1') then
2861
                         Q1_var := '0';
2862
                         Q2_posedge_var := '0';
2863
                      elsif((R_dly = '0') and (S_dly = '1')) then
2864
                         Q1_var := '1';
2865
                         Q2_posedge_var := '1';
2866
                      elsif((R_dly = '0') and (S_dly = '0')) then
2867
                         if(CE_dly = '1') then
2868
                            Q1_var         := D1_dly;
2869
                            Q2_posedge_var := D2_dly;
2870
                         end if;
2871
                      end if;
2872
                   end if;
2873
 
2874
                   if(falling_edge(C_dly)) then
2875
                      if(R_dly = '1') then
2876
                         Q1_var := '0';
2877
                      elsif((R_dly = '0') and (S_dly = '1')) then
2878
                         Q1_var := '1';
2879
                      elsif((R_dly = '0') and (S_dly = '0')) then
2880
                         if(CE_dly = '1') then
2881
                             case ddr_clk_edge_type is
2882
                                when 1 =>
2883
                                       Q1_var :=  D2_dly;
2884
                                when 2 =>
2885
                                       Q1_var :=  Q2_posedge_var;
2886
                                when others =>
2887
                                          null;
2888
                              end case;
2889
                         end if;
2890
                      end if;
2891
                   end if;
2892
 
2893
           when others =>
2894
                   null;
2895
        end case;
2896
     end if;
2897
 
2898
     Q_zd <= Q1_var;
2899
 
2900
  end process prcs_q1q2q3_reg;
2901
--####################################################################
2902
 
2903
--####################################################################
2904
--#####                         OUTPUT                           #####
2905
--####################################################################
2906
  prcs_output:process(Q_zd)
2907
  begin
2908
      Q <= Q_zd after SYNC_PATH_DELAY;
2909
  end process prcs_output;
2910
--####################################################################
2911
 
2912
 
2913
end ODDR_V;
2914
 
2915
 
2916
library IEEE;
2917
use IEEE.STD_LOGIC_1164.all;
2918
 
2919
entity FDDRRSE is
2920
  generic(
2921
    INIT : bit := '0'
2922
    );
2923
 
2924
  port(
2925
    Q : out std_ulogic;
2926
 
2927
    C0 : in std_ulogic;
2928
    C1 : in std_ulogic;
2929
    CE : in std_ulogic;
2930
    D0 : in std_ulogic;
2931
    D1 : in std_ulogic;
2932
    R  : in std_ulogic;
2933
    S  : in std_ulogic
2934
    );
2935
end FDDRRSE;
2936
 
2937
architecture FDDRRSE_V of FDDRRSE is
2938
begin
2939
 
2940
  VITALBehavior         : process(C0, C1)
2941
    variable FIRST_TIME : boolean := true;
2942
  begin
2943
 
2944
    if (FIRST_TIME) then
2945
      Q <= TO_X01(INIT);
2946
      FIRST_TIME := false ;
2947
    end if;
2948
 
2949
    if ( rising_edge(C0) = true) then
2950
      if (R = '1') then
2951
        Q <= '0' after 100 ps;
2952
      elsif (S = '1' ) then
2953
        Q <= '1' after 100 ps;
2954
      elsif (CE = '1' ) then
2955
        Q <= D0 after 100 ps;
2956
      end if;
2957
    elsif (rising_edge(C1) = true ) then
2958
      if (R = '1') then
2959
        Q <= '0' after 100 ps;
2960
      elsif (S = '1' ) then
2961
        Q <= '1' after 100 ps;
2962
      elsif (CE = '1') then
2963
        Q <= D1 after 100 ps;
2964
      end if;
2965
    end if;
2966
  end process VITALBehavior;
2967
end FDDRRSE_V;
2968
 
2969
 
2970
library IEEE;
2971
use IEEE.STD_LOGIC_1164.all;
2972
 
2973
library UNISIM;
2974
use UNISIM.VCOMPONENTS.all;
2975
 
2976
entity OFDDRRSE is
2977
  port(
2978
    Q : out std_ulogic;
2979
 
2980
    C0 : in std_ulogic;
2981
    C1 : in std_ulogic;
2982
    CE : in std_ulogic;
2983
    D0 : in std_ulogic;
2984
    D1 : in std_ulogic;
2985
    R  : in std_ulogic;
2986
    S  : in std_ulogic
2987
    );
2988
end OFDDRRSE;
2989
 
2990
architecture OFDDRRSE_V of OFDDRRSE is
2991
 
2992
  signal Q_out : std_ulogic := 'X';
2993
 
2994
begin
2995
  O1 : OBUF
2996
    port map (
2997
      I => Q_out,
2998
      O => Q
2999
      );
3000
 
3001
  F0 : FDDRRSE
3002
    generic map (INIT => '0'
3003
                 )
3004
 
3005
    port map (
3006
      C0 => C0,
3007
      C1 => C1,
3008
      CE => CE,
3009
      R  => R,
3010
      D0 => D0,
3011
      D1 => D1,
3012
      S  => S,
3013
      Q  => Q_out
3014
      );
3015
end OFDDRRSE_V;
3016
 
3017
 
3018
library IEEE;
3019
use IEEE.STD_LOGIC_1164.all;
3020
 
3021
entity FDRSE is
3022
  generic(
3023
    INIT : bit := '0'
3024
    );
3025
 
3026
  port(
3027
    Q : out std_ulogic;
3028
 
3029
    C  : in std_ulogic;
3030
    CE : in std_ulogic;
3031
    D  : in std_ulogic;
3032
    R  : in std_ulogic;
3033
    S  : in std_ulogic
3034
    );
3035
end FDRSE;
3036
 
3037
architecture FDRSE_V of FDRSE is
3038
begin
3039
  VITALBehavior         : process(C)
3040
    variable FIRST_TIME : boolean := true ;
3041
  begin
3042
 
3043
    if (FIRST_TIME = true) then
3044
      Q <= TO_X01(INIT);
3045
      FIRST_TIME := false;
3046
    end if;
3047
 
3048
    if (rising_edge(C)) then
3049
      if (R = '1') then
3050
        Q <= '0' after 100 ps;
3051
      elsif (S = '1') then
3052
        Q <= '1' after 100 ps;
3053
      elsif (CE = '1') then
3054
        Q <= D after 100 ps;
3055
      end if;
3056
    end if;
3057
  end process;
3058
end FDRSE_V;
3059
 
3060
library IEEE;
3061
use IEEE.STD_LOGIC_1164.all;
3062
 
3063
library UNISIM;
3064
use UNISIM.VCOMPONENTS.all;
3065
 
3066
entity IFDDRRSE is
3067
  port(
3068
    Q0 : out std_ulogic;
3069
    Q1 : out std_ulogic;
3070
 
3071
    C0 : in std_ulogic;
3072
    C1 : in std_ulogic;
3073
    CE : in std_ulogic;
3074
    D  : in std_ulogic;
3075
    R  : in std_ulogic;
3076
    S  : in std_ulogic
3077
    );
3078
end IFDDRRSE;
3079
 
3080
architecture IFDDRRSE_V of IFDDRRSE is
3081
  signal D_in : std_ulogic := 'X';
3082
begin
3083
  I1          : IBUF
3084
    port map (
3085
      I => D,
3086
      O => D_in
3087
      );
3088
 
3089
  F0 : FDRSE
3090
    generic map (
3091
      INIT => '0')
3092
    port map (
3093
      C    => C0,
3094
      CE   => CE,
3095
      R    => R,
3096
      D    => D_in,
3097
      S    => S,
3098
      Q    => Q0
3099
      );
3100
 
3101
  F1 : FDRSE
3102
    generic map (
3103
      INIT => '0')
3104
    port map (
3105
      C    => C1,
3106
      CE   => CE,
3107
      R    => R,
3108
      D    => D,
3109
      S    => S,
3110
      Q    => Q1
3111
      );
3112
end IFDDRRSE_V;
3113
 
3114
library IEEE;
3115
use IEEE.STD_LOGIC_1164.all;
3116
 
3117
entity FD is
3118
  generic(
3119
    INIT : bit := '0'
3120
    );
3121
 
3122
  port(
3123
    Q : out std_ulogic;
3124
 
3125
    C : in std_ulogic;
3126
    D : in std_ulogic
3127
    );
3128
end FD;
3129
 
3130
architecture FD_V of FD is
3131
begin
3132
 
3133
  VITALBehavior : process(C)
3134
    variable FIRST_TIME : boolean := true ;
3135
  begin
3136
    if (FIRST_TIME = true) then
3137
      Q <= TO_X01(INIT);
3138
      FIRST_TIME := false;
3139
    end if;
3140
 
3141
    if (rising_edge(C)) then
3142
      Q <= D after 100 ps;
3143
    end if;
3144
  end process;
3145
end FD_V;
3146
 
3147
library IEEE;
3148
use IEEE.STD_LOGIC_1164.all;
3149
 
3150
entity FDR is
3151
  generic(
3152
    INIT : bit := '0'
3153
    );
3154
 
3155
  port(
3156
    Q : out std_ulogic;
3157
 
3158
    C : in std_ulogic;
3159
    D : in std_ulogic;
3160
    R : in std_ulogic
3161
    );
3162
end FDR;
3163
 
3164
architecture FDR_V of FDR is
3165
begin
3166
  VITALBehavior         : process(C)
3167
    variable FIRST_TIME : boolean := true ;
3168
  begin
3169
 
3170
    if (FIRST_TIME = true) then
3171
      Q <= TO_X01(INIT);
3172
      FIRST_TIME := false;
3173
    end if;
3174
 
3175
    if (rising_edge(C)) then
3176
      if (R = '1') then
3177
        Q <= '0' after 100 ps;
3178
      else
3179
        Q <= D after 100 ps;
3180
      end if;
3181
    end if;
3182
  end process;
3183
end FDR_V;
3184
 
3185
library IEEE;
3186
use IEEE.STD_LOGIC_1164.all;
3187
 
3188
entity FDRE is
3189
  generic(
3190
    INIT : bit := '0'
3191
    );
3192
 
3193
  port(
3194
    Q : out std_ulogic;
3195
 
3196
    C  : in std_ulogic;
3197
    CE : in std_ulogic;
3198
    D  : in std_ulogic;
3199
    R  : in std_ulogic
3200
    );
3201
end FDRE;
3202
 
3203
architecture FDRE_V of FDRE is
3204
begin
3205
  VITALBehavior         : process(C)
3206
    variable FIRST_TIME : boolean := true ;
3207
  begin
3208
 
3209
    if (FIRST_TIME = true) then
3210
      Q <= TO_X01(INIT);
3211
      FIRST_TIME := false;
3212
    end if;
3213
 
3214
    if (rising_edge(C)) then
3215
      if (R = '1') then
3216
        Q <= '0' after 100 ps;
3217
      elsif (CE = '1') then
3218
        Q <= D after 100 ps;
3219
      end if;
3220
    end if;
3221
  end process;
3222
end FDRE_V;
3223
 
3224
library IEEE;
3225
use IEEE.STD_LOGIC_1164.all;
3226
 
3227
entity FDRS is
3228
  generic(
3229
    INIT : bit := '0'
3230
    );
3231
 
3232
  port(
3233
    Q : out std_ulogic;
3234
 
3235
    C : in std_ulogic;
3236
    D : in std_ulogic;
3237
    R : in std_ulogic;
3238
    S : in std_ulogic
3239
    );
3240
end FDRS;
3241
 
3242
architecture FDRS_V of FDRS is
3243
begin
3244
  VITALBehavior         : process(C)
3245
    variable FIRST_TIME : boolean := true ;
3246
  begin
3247
 
3248
    if (FIRST_TIME = true) then
3249
      Q <= TO_X01(INIT);
3250
      FIRST_TIME := false;
3251
    end if;
3252
 
3253
    if (rising_edge(C)) then
3254
      if (R = '1') then
3255
        Q <= '0' after 100 ps;
3256
      elsif (S = '1') then
3257
        Q <= '1' after 100 ps;
3258
      else
3259
        Q <= D after 100 ps;
3260
      end if;
3261
    end if;
3262
  end process;
3263
end FDRS_V;
3264
 
3265
library IEEE;
3266
use IEEE.STD_LOGIC_1164.all;
3267
 
3268
entity VCC is
3269
  port(
3270
    P : out std_ulogic := '1'
3271
    );
3272
end VCC;
3273
 
3274
architecture VCC_V of VCC is
3275
begin
3276
  P <= '1';
3277
end VCC_V;
3278
 
3279
library IEEE;
3280
use IEEE.STD_LOGIC_1164.all;
3281
 
3282
entity GND is
3283
  port(
3284
    G : out std_ulogic := '0'
3285
    );
3286
end GND;
3287
 
3288
architecture GND_V of GND is
3289
begin
3290
 
3291
  G <= '0';
3292
end GND_V;
3293
 
3294
library IEEE;
3295
use IEEE.STD_LOGIC_1164.all;
3296
 
3297
entity MUXF5 is
3298
  port(
3299
    O : out std_ulogic;
3300
 
3301
    I0 : in std_ulogic;
3302
    I1 : in std_ulogic;
3303
    S  : in std_ulogic
3304
    );
3305
end MUXF5;
3306
 
3307
architecture MUXF5_V of MUXF5 is
3308
begin
3309
  VITALBehavior   : process (I0, I1, S)
3310
  begin
3311
    if (S = '0') then
3312
      O <= I0;
3313
    elsif (S = '1') then
3314
      O <= I1;
3315
    end if;
3316
  end process;
3317
end MUXF5_V;
3318
 
3319
library IEEE;
3320
use IEEE.STD_LOGIC_1164.all;
3321
 
3322
entity FDE is
3323
  generic(
3324
    INIT : bit := '0'
3325
    );
3326
 
3327
  port(
3328
    Q : out std_ulogic;
3329
 
3330
    C  : in std_ulogic;
3331
    CE : in std_ulogic;
3332
    D  : in std_ulogic
3333
    );
3334
end FDE;
3335
 
3336
architecture FDE_V of FDE is
3337
begin
3338
  VITALBehavior         : process(C)
3339
    variable FIRST_TIME : boolean := true ;
3340
  begin
3341
 
3342
    if (FIRST_TIME = true) then
3343
      Q <= TO_X01(INIT);
3344
      FIRST_TIME := false;
3345
    end if;
3346
 
3347
    if (rising_edge(C)) then
3348
      if (CE = '1') then
3349
        Q <= D after 100 ps;
3350
      end if;
3351
    end if;
3352
  end process;
3353
end FDE_V;
3354
 
3355
library IEEE;
3356
use IEEE.STD_LOGIC_1164.all;
3357
 
3358
library unisim;
3359
use unisim.vpkg.all;
3360
 
3361
entity IDELAY is
3362
 
3363
  generic(
3364
 
3365
      IOBDELAY_TYPE  : string := "DEFAULT";
3366
      IOBDELAY_VALUE : integer := 0
3367
      );
3368
 
3369
  port(
3370
      O      : out std_ulogic;
3371
 
3372
      C      : in  std_ulogic;
3373
      CE     : in  std_ulogic;
3374
      I      : in  std_ulogic;
3375
      INC    : in  std_ulogic;
3376
      RST    : in  std_ulogic
3377
      );
3378
 
3379
end IDELAY;
3380
 
3381
architecture IDELAY_V OF IDELAY is
3382
 
3383
  constant SIM_TAPDELAY_VALUE : integer := 75;
3384
 
3385
  ---------------------------------------------------------
3386
  -- Function  str_2_int converts string to integer
3387
  ---------------------------------------------------------
3388
  function str_2_int(str: in string ) return integer is
3389
  variable int : integer;
3390
  variable val : integer := 0;
3391
  variable neg_flg   : boolean := false;
3392
  variable is_it_int : boolean := true;
3393
  begin
3394
    int := 0;
3395
    val := 0;
3396
    is_it_int := true;
3397
    neg_flg   := false;
3398
 
3399
    for i in  1 to str'length loop
3400
      case str(i) is
3401
         when  '-'
3402
           =>
3403
             if(i = 1) then
3404
                neg_flg := true;
3405
                val := -1;
3406
             end if;
3407
         when  '1'
3408
           =>  val := 1;
3409
         when  '2'
3410
           =>   val := 2;
3411
         when  '3'
3412
           =>   val := 3;
3413
         when  '4'
3414
           =>   val := 4;
3415
         when  '5'
3416
           =>   val := 5;
3417
         when  '6'
3418
           =>   val := 6;
3419
         when  '7'
3420
           =>   val := 7;
3421
         when  '8'
3422
           =>   val := 8;
3423
         when  '9'
3424
           =>   val := 9;
3425
         when  '0'
3426
           =>   val := 0;
3427
         when others
3428
           => is_it_int := false;
3429
        end case;
3430
        if(val /= -1) then
3431
          int := int *10  + val;
3432
        end if;
3433
        val := 0;
3434
    end loop;
3435
    if(neg_flg) then
3436
      int := int * (-1);
3437
    end if;
3438
 
3439
    if(NOT is_it_int) then
3440
      int := -9999;
3441
    end if;
3442
    return int;
3443
  end;
3444
-----------------------------------------------------------
3445
 
3446
  constant      SYNC_PATH_DELAY : time := 100 ps;
3447
 
3448
  constant      MIN_TAP_COUNT   : integer := 0;
3449
  constant      MAX_TAP_COUNT   : integer := 63;
3450
 
3451
  signal        C_ipd           : std_ulogic := 'X';
3452
  signal        CE_ipd          : std_ulogic := 'X';
3453
  signal GSR            : std_ulogic := '0';
3454
  signal        GSR_ipd         : std_ulogic := 'X';
3455
  signal        I_ipd           : std_ulogic := 'X';
3456
  signal        INC_ipd         : std_ulogic := 'X';
3457
  signal        RST_ipd         : std_ulogic := 'X';
3458
 
3459
  signal        C_dly           : std_ulogic := 'X';
3460
  signal        CE_dly          : std_ulogic := 'X';
3461
  signal        GSR_dly         : std_ulogic := 'X';
3462
  signal        I_dly           : std_ulogic := 'X';
3463
  signal        INC_dly         : std_ulogic := 'X';
3464
  signal        RST_dly         : std_ulogic := 'X';
3465
 
3466
  signal        O_zd            : std_ulogic := 'X';
3467
  signal        O_viol          : std_ulogic := 'X';
3468
 
3469
  signal        TapCount        : integer := 0;
3470
  signal        IsTapDelay      : boolean := true;
3471
  signal        IsTapFixed      : boolean := false;
3472
  signal        IsTapDefault    : boolean := false;
3473
  signal        Delay           : time := 0 ps;
3474
 
3475
begin
3476
 
3477
  ---------------------
3478
  --  INPUT PATH DELAYs
3479
  --------------------
3480
 
3481
  C_dly                  <= C                   after 0 ps;
3482
  CE_dly                 <= CE                  after 0 ps;
3483
  GSR_dly                <= GSR                 after 0 ps;
3484
  I_dly                  <= I                   after 0 ps;
3485
  INC_dly                <= INC                 after 0 ps;
3486
  RST_dly                <= RST                 after 0 ps;
3487
 
3488
  --------------------
3489
  --  BEHAVIOR SECTION
3490
  --------------------
3491
 
3492
--####################################################################
3493
--#####                     Initialize                           #####
3494
--####################################################################
3495
  prcs_init:process
3496
  variable TapCount_var   : integer := 0;
3497
  variable IsTapDelay_var : boolean := true;
3498
  variable IsTapFixed_var : boolean := false;
3499
  variable IsTapDefault_var : boolean := false;
3500
  begin
3501
--     if((IOBDELAY_VALUE = "OFF") or (IOBDELAY_VALUE = "off")) then
3502
--        IsTapDelay_var := false;
3503
--     elsif((IOBDELAY_VALUE = "ON") or (IOBDELAY_VALUE = "on")) then
3504
--        IsTapDelay_var := false;
3505
--     else
3506
--       TapCount_var := str_2_int(IOBDELAY_VALUE);
3507
       TapCount_var := IOBDELAY_VALUE;
3508
       If((TapCount_var >= 0) and (TapCount_var <= 63)) then
3509
         IsTapDelay_var := true;
3510
 
3511
       else
3512
          GenericValueCheckMessage
3513
          (  HeaderMsg  => " Attribute Syntax Warning ",
3514
             GenericName => " IOBDELAY_VALUE ",
3515
             EntityName => "/IOBDELAY_VALUE",
3516
             GenericValue => IOBDELAY_VALUE,
3517
             Unit => "",
3518
             ExpectedValueMsg => " The Legal values for this attribute are ",
3519
             ExpectedGenericValue => " OFF, 1, 2, ..., 62, 63 ",
3520
             TailMsg => "",
3521
             MsgSeverity => failure
3522
          );
3523
        end if;
3524
--     end if;
3525
 
3526
     if(IsTapDelay_var) then
3527
        if((IOBDELAY_TYPE = "FIXED") or (IOBDELAY_TYPE = "fixed")) then
3528
           IsTapFixed_var := true;
3529
        elsif((IOBDELAY_TYPE = "VARIABLE") or (IOBDELAY_TYPE = "variable")) then
3530
           IsTapFixed_var := false;
3531
        elsif((IOBDELAY_TYPE = "DEFAULT") or (IOBDELAY_TYPE = "default")) then
3532
           IsTapDefault_var := true;
3533
        else
3534
          GenericValueCheckMessage
3535
          (  HeaderMsg  => " Attribute Syntax Warning ",
3536
             GenericName => " IOBDELAY_TYPE ",
3537
             EntityName => "/IOBDELAY_TYPE",
3538
             GenericValue => IOBDELAY_TYPE,
3539
             Unit => "",
3540
             ExpectedValueMsg => " The Legal values for this attribute are ",
3541
             ExpectedGenericValue => " FIXED or VARIABLE ",
3542
             TailMsg => "",
3543
             MsgSeverity => failure
3544
          );
3545
        end if;
3546
     end if;
3547
 
3548
     IsTapDelay   <= IsTapDelay_var;
3549
     IsTapFixed   <= IsTapFixed_var;
3550
     IsTapDefault <= IsTapDefault_var;
3551
     TapCount     <= TapCount_var;
3552
 
3553
     wait;
3554
  end process prcs_init;
3555
--####################################################################
3556
--#####                  CALCULATE DELAY                         #####
3557
--####################################################################
3558
  prcs_refclk:process(C_dly, GSR_dly, RST_dly)
3559
  variable TapCount_var : integer :=0;
3560
  variable FIRST_TIME   : boolean :=true;
3561
  variable BaseTime_var : time    := 1 ps ;
3562
  variable delay_var    : time    := 0 ps ;
3563
  begin
3564
     if(IsTapDelay) then
3565
       if((GSR_dly = '1') or (FIRST_TIME))then
3566
          TapCount_var := TapCount;
3567
          Delay        <= TapCount_var * SIM_TAPDELAY_VALUE * BaseTime_var;
3568
          FIRST_TIME   := false;
3569
       elsif(GSR_dly = '0') then
3570
          if(rising_edge(C_dly)) then
3571
             if(RST_dly = '1') then
3572
               TapCount_var := TapCount;
3573
             elsif((RST_dly = '0') and (CE_dly = '1')) then
3574
-- CR fix CR 213995
3575
                  if(INC_dly = '1') then
3576
                     if (TapCount_var < MAX_TAP_COUNT) then
3577
                        TapCount_var := TapCount_var + 1;
3578
                     else
3579
                        TapCount_var := MIN_TAP_COUNT;
3580
                     end if;
3581
                  elsif(INC_dly = '0') then
3582
                     if (TapCount_var > MIN_TAP_COUNT) then
3583
                         TapCount_var := TapCount_var - 1;
3584
                     else
3585
                         TapCount_var := MAX_TAP_COUNT;
3586
                     end if;
3587
 
3588
                  end if; -- INC_dly
3589
             end if; -- RST_dly
3590
             Delay <= TapCount_var *  SIM_TAPDELAY_VALUE * BaseTime_var;
3591
          end if; -- C_dly
3592
       end if; -- GSR_dly
3593
 
3594
     end if; -- IsTapDelay
3595
  end process prcs_refclk;
3596
 
3597
--####################################################################
3598
--#####                      DELAY INPUT                         #####
3599
--####################################################################
3600
  prcs_i:process(I_dly)
3601
  begin
3602
     if(IsTapFixed) then
3603
       O_zd <= transport I_dly after (TapCount *SIM_TAPDELAY_VALUE * 1 ps);
3604
     else
3605
        O_zd <= transport I_dly after delay;
3606
     end if;
3607
  end process prcs_i;
3608
 
3609
 
3610
--####################################################################
3611
--#####                         OUTPUT                           #####
3612
--####################################################################
3613
  prcs_output:process(O_zd)
3614
  begin
3615
      O <= O_zd after SYNC_PATH_DELAY;
3616
  end process prcs_output;
3617
--####################################################################
3618
 
3619
 
3620
end IDELAY_V;
3621
 
3622
library IEEE;
3623
use IEEE.STD_LOGIC_1164.all;
3624
 
3625
 
3626
library unisim;
3627
use unisim.vpkg.all;
3628
 
3629
entity IDELAYCTRL is
3630
 
3631
  port(
3632
      RDY       : out std_ulogic;
3633
 
3634
      REFCLK    : in  std_ulogic;
3635
      RST       : in  std_ulogic
3636
  );
3637
 
3638
end IDELAYCTRL;
3639
 
3640
architecture IDELAYCTRL_V OF IDELAYCTRL is
3641
 
3642
 
3643
  constant SYNC_PATH_DELAY : time := 100 ps;
3644
 
3645
  signal REFCLK_ipd     : std_ulogic := 'X';
3646
  signal RST_ipd        : std_ulogic := 'X';
3647
 
3648
  signal GSR_dly        : std_ulogic := '0';
3649
  signal REFCLK_dly     : std_ulogic := 'X';
3650
  signal RST_dly        : std_ulogic := 'X';
3651
 
3652
  signal RDY_zd         : std_ulogic := '0';
3653
  signal RDY_viol       : std_ulogic := 'X';
3654
 
3655
-- taken from DCM_adv
3656
  signal period : time := 0 ps;
3657
  signal lost   : std_ulogic := '0';
3658
  signal lost_r : std_ulogic := '0';
3659
  signal lost_f : std_ulogic := '0';
3660
  signal clock_negedge, clock_posedge, clock : std_ulogic;
3661
  signal temp1 : boolean := false;
3662
  signal temp2 : boolean := false;
3663
  signal clock_low, clock_high : std_ulogic := '0';
3664
 
3665
 
3666
begin
3667
 
3668
  ---------------------
3669
  --  INPUT PATH DELAYs
3670
  --------------------
3671
 
3672
  REFCLK_dly             <= REFCLK              after 0 ps;
3673
  RST_dly                <= RST                 after 0 ps;
3674
 
3675
  --------------------
3676
  --  BEHAVIOR SECTION
3677
  --------------------
3678
 
3679
--####################################################################
3680
--#####                             RDY                          #####
3681
--####################################################################
3682
   prcs_rdy:process(RST_dly, lost)
3683
   begin
3684
      if((RST_dly = '1') or (lost = '1')) then
3685
         RDY_zd <= '0';
3686
      elsif((RST_dly = '0') and (lost = '0')) then
3687
         RDY_zd <= '1';
3688
      end if;
3689
   end process prcs_rdy;
3690
--####################################################################
3691
--#####                prcs_determine_period                     #####
3692
--####################################################################
3693
  prcs_determine_period : process
3694
    variable clock_edge_previous : time := 0 ps;
3695
    variable clock_edge_current  : time := 0 ps;
3696
  begin
3697
    if (rising_edge(REFCLK_dly)) then
3698
      clock_edge_previous := clock_edge_current;
3699
      clock_edge_current := NOW;
3700
      if (period /= 0 ps and ((clock_edge_current - clock_edge_previous) <= (1.5 * period))) then
3701
        period <= NOW - clock_edge_previous;
3702
      elsif (period /= 0 ps and ((NOW - clock_edge_previous) > (1.5 * period))) then
3703
        period <= 0 ps;
3704
      elsif ((period = 0 ps) and (clock_edge_previous /= 0 ps)) then
3705
        period <= NOW - clock_edge_previous;
3706
      end if;
3707
    end if;
3708
    wait on REFCLK_dly;
3709
  end process prcs_determine_period;
3710
 
3711
--####################################################################
3712
--#####                prcs_clock_lost_checker                   #####
3713
--####################################################################
3714
  prcs_clock_lost_checker : process
3715
    variable clock_low, clock_high : std_ulogic := '0';
3716
 
3717
  begin
3718
    if (rising_edge(clock)) then
3719
      clock_low := '0';
3720
      clock_high := '1';
3721
      clock_posedge <= '0';
3722
      clock_negedge <= '1';
3723
    end if;
3724
 
3725
    if (falling_edge(clock)) then
3726
      clock_high := '0';
3727
      clock_low := '1';
3728
      clock_posedge <= '1';
3729
      clock_negedge <= '0';
3730
    end if;
3731
    wait on clock;
3732
  end process prcs_clock_lost_checker;
3733
 
3734
--####################################################################
3735
--#####                prcs_set_reset_lost_r                     #####
3736
--####################################################################
3737
  prcs_set_reset_lost_r : process
3738
    begin
3739
    if (rising_edge(clock)) then
3740
      if (period /= 0 ps) then
3741
        lost_r <= '0';
3742
      end if;
3743
      wait for (period * 9.1)/10;
3744
      if ((clock_low /= '1') and (clock_posedge /= '1')) then
3745
        lost_r <= '1';
3746
      end if;
3747
    end if;
3748
    wait on clock;
3749
  end process prcs_set_reset_lost_r;
3750
 
3751
--####################################################################
3752
--#####                     prcs_assign_lost                     #####
3753
--####################################################################
3754
  prcs_assign_lost : process
3755
    begin
3756
      if (lost_r'event) then
3757
        lost <= lost_r;
3758
      end if;
3759
      if (lost_f'event) then
3760
        lost <= lost_f;
3761
      end if;
3762
      wait on lost_r, lost_f;
3763
    end process prcs_assign_lost;
3764
 
3765
--####################################################################
3766
--#####                         OUTPUT                           #####
3767
--####################################################################
3768
  prcs_output:process(RDY_zd)
3769
  begin
3770
      RDY <= RDY_zd after SYNC_PATH_DELAY;
3771
  end process prcs_output;
3772
--####################################################################
3773
 
3774
 
3775
end IDELAYCTRL_V;
3776
 
3777
library IEEE;
3778
use IEEE.STD_LOGIC_1164.all;
3779
 
3780
entity BUFIO is
3781
  port(
3782
    O : out std_ulogic;
3783
 
3784
    I : in std_ulogic
3785
    );
3786
 
3787
end BUFIO;
3788
 
3789
architecture BUFIO_V of BUFIO is
3790
begin
3791
  O <= I after 0 ps;
3792
end BUFIO_V;
3793
 
3794
library IEEE;
3795
use IEEE.STD_LOGIC_1164.all;
3796
 
3797
 
3798
library unisim;
3799
use unisim.vpkg.all;
3800
 
3801
entity BUFR is
3802
 
3803
  generic(
3804
 
3805
      BUFR_DIVIDE   : string := "BYPASS";
3806
      SIM_DEVICE    : string := "VIRTEX4"
3807
      );
3808
 
3809
  port(
3810
      O           : out std_ulogic;
3811
 
3812
      CE          : in  std_ulogic;
3813
      CLR         : in  std_ulogic;
3814
      I           : in  std_ulogic
3815
      );
3816
 
3817
end BUFR;
3818
 
3819
architecture BUFR_V OF BUFR is
3820
 
3821
 
3822
--    06/30/2005 - CR # 211199 --
3823
--  constant SYNC_PATH_DELAY : time := 100 ps;
3824
 
3825
  signal CE_ipd         : std_ulogic := 'X';
3826
  signal GSR            : std_ulogic := '0';
3827
  signal GSR_ipd        : std_ulogic := '0';
3828
  signal I_ipd          : std_ulogic := 'X';
3829
  signal CLR_ipd        : std_ulogic := 'X';
3830
 
3831
  signal CE_dly         : std_ulogic := 'X';
3832
  signal GSR_dly        : std_ulogic := '0';
3833
  signal I_dly          : std_ulogic := 'X';
3834
  signal CLR_dly        : std_ulogic := 'X';
3835
 
3836
  signal O_zd           : std_ulogic := 'X';
3837
  signal O_viol         : std_ulogic := 'X';
3838
 
3839
  signal q4_sig         : std_ulogic := 'X';
3840
  signal ce_en          : std_ulogic;
3841
 
3842
  signal divide         : boolean    := false;
3843
  signal divide_by      : integer    := -1;
3844
  signal FIRST_TOGGLE_COUNT     : integer    := -1;
3845
  signal SECOND_TOGGLE_COUNT    : integer    := -1;
3846
 
3847
begin
3848
 
3849
  ---------------------
3850
  --  INPUT PATH DELAYs
3851
  --------------------
3852
 
3853
  CE_dly                 <= CE                  after 0 ps;
3854
  CLR_dly                <= CLR                 after 0 ps;
3855
  GSR_dly                <= GSR                 after 0 ps;
3856
  I_dly                  <= I                   after 0 ps;
3857
 
3858
  --------------------
3859
  --  BEHAVIOR SECTION
3860
  --------------------
3861
 
3862
--####################################################################
3863
--#####                     Initialize                           #####
3864
--####################################################################
3865
  prcs_init:process
3866
  variable FIRST_TOGGLE_COUNT_var  : integer    := -1;
3867
  variable SECOND_TOGGLE_COUNT_var : integer    := -1;
3868
  variable ODD                     : integer    := -1;
3869
  variable divide_var      : boolean    := false;
3870
  variable divide_by_var           :  integer    := -1;
3871
 
3872
  begin
3873
      if(BUFR_DIVIDE = "BYPASS") then
3874
         divide_var := false;
3875
      elsif(BUFR_DIVIDE = "1") then
3876
         divide_var    := true;
3877
         divide_by_var := 1;
3878
         FIRST_TOGGLE_COUNT_var  := 1;
3879
         SECOND_TOGGLE_COUNT_var := 1;
3880
      elsif(BUFR_DIVIDE = "2") then
3881
         divide_var    := true;
3882
         divide_by_var := 2;
3883
         FIRST_TOGGLE_COUNT_var  := 2;
3884
         SECOND_TOGGLE_COUNT_var := 2;
3885
      elsif(BUFR_DIVIDE = "3") then
3886
         divide_var    := true;
3887
         divide_by_var := 3;
3888
         FIRST_TOGGLE_COUNT_var  := 2;
3889
         SECOND_TOGGLE_COUNT_var := 4;
3890
      elsif(BUFR_DIVIDE = "4") then
3891
         divide_var    := true;
3892
         divide_by_var := 4;
3893
         FIRST_TOGGLE_COUNT_var  := 4;
3894
         SECOND_TOGGLE_COUNT_var := 4;
3895
      elsif(BUFR_DIVIDE = "5") then
3896
         divide_var    := true;
3897
         divide_by_var := 5;
3898
         FIRST_TOGGLE_COUNT_var  := 4;
3899
         SECOND_TOGGLE_COUNT_var := 6;
3900
      elsif(BUFR_DIVIDE = "6") then
3901
         divide_var    := true;
3902
         divide_by_var := 6;
3903
         FIRST_TOGGLE_COUNT_var  := 6;
3904
         SECOND_TOGGLE_COUNT_var := 6;
3905
      elsif(BUFR_DIVIDE = "7") then
3906
         divide_var    := true;
3907
         divide_by_var := 7;
3908
         FIRST_TOGGLE_COUNT_var  := 6;
3909
         SECOND_TOGGLE_COUNT_var := 8;
3910
      elsif(BUFR_DIVIDE = "8") then
3911
         divide_var    := true;
3912
         divide_by_var := 8;
3913
         FIRST_TOGGLE_COUNT_var  := 8;
3914
         SECOND_TOGGLE_COUNT_var := 8;
3915
      else
3916
        GenericValueCheckMessage
3917
          (  HeaderMsg  => " Attribute Syntax Warning ",
3918
             GenericName => " BUFR_DIVIDE ",
3919
             EntityName => "/BUFR",
3920
             GenericValue => BUFR_DIVIDE,
3921
             Unit => "",
3922
             ExpectedValueMsg => " The Legal values for this attribute are ",
3923
             ExpectedGenericValue => " BYPASS, 1, 2, 3, 4, 5, 6, 7 or 8 ",
3924
             TailMsg => "",
3925
             MsgSeverity => ERROR
3926
         );
3927
      end if;
3928
 
3929
     if (SIM_DEVICE /= "VIRTEX4" and SIM_DEVICE /= "VIRTEX5") then
3930
        GenericValueCheckMessage
3931
          (  HeaderMsg  => " Attribute Syntax Warning ",
3932
             GenericName => " SIM_DEVICE ",
3933
             EntityName => "/BUFR",
3934
             GenericValue => SIM_DEVICE,
3935
             Unit => "",
3936
             ExpectedValueMsg => " The Legal values for this attribute are ",
3937
             ExpectedGenericValue => " VIRTEX4 or VIRTEX5 ",
3938
             TailMsg => "",
3939
             MsgSeverity => ERROR
3940
         );
3941
      end if;
3942
 
3943
      FIRST_TOGGLE_COUNT  <= FIRST_TOGGLE_COUNT_var;
3944
      SECOND_TOGGLE_COUNT <= SECOND_TOGGLE_COUNT_var;
3945
 
3946
      divide    <= divide_var;
3947
      divide_by <= divide_by_var;
3948
 
3949
     wait;
3950
  end process prcs_init;
3951
--####################################################################
3952
--#####                      CLOCK_ENABLE                        #####
3953
--####################################################################
3954
   prcs_ce:process(I_Dly, GSR_dly)
3955
   variable fall_i_count : integer    := 0;
3956
   variable q4_var       : std_ulogic := '0';
3957
   variable q3_var       : std_ulogic := '0';
3958
   variable q2_var       : std_ulogic := '0';
3959
   variable q1_var       : std_ulogic := '0';
3960
   begin
3961
--    06/30/2005 - CR # 211199 -- removed CLR_dly dependency
3962
      if(GSR_dly = '1')  then
3963
         q4_var := '0';
3964
         q3_var := '0';
3965
         q2_var := '0';
3966
         q1_var := '0';
3967
      elsif(GSR_dly = '0') then
3968
         if(falling_edge(I_dly)) then
3969
            q4_var := q3_var;
3970
            q3_var := q2_var;
3971
            q2_var := q1_var;
3972
            q1_var := CE_dly;
3973
         end if;
3974
 
3975
         q4_sig  <= q4_var;
3976
      end if;
3977
   end process prcs_ce;
3978
 
3979
   ce_en <= CE_dly when (SIM_DEVICE = "VIRTEX5") else q4_sig;
3980
 
3981
--####################################################################
3982
--#####                       CLK-I                              #####
3983
--####################################################################
3984
  prcs_I:process(I_dly, GSR_dly, CLR_dly, ce_en)
3985
  variable clk_count      : integer := 0;
3986
  variable toggle_count   : integer := 0;
3987
  variable first          : boolean := true;
3988
  variable FIRST_TIME     : boolean := true;
3989
  begin
3990
       if(divide) then
3991
          if((GSR_dly = '1') or (CLR_dly = '1')) then
3992
            O_zd       <= '0';
3993
            clk_count  := 0;
3994
            FIRST_TIME := true;
3995
          elsif((GSR_dly = '0') and (CLR_dly = '0')) then
3996
             if(ce_en = '1') then
3997
                if((I_dly='1') and (FIRST_TIME)) then
3998
                    O_zd <= '1';
3999
                    first        := true;
4000
                    toggle_count := FIRST_TOGGLE_COUNT;
4001
                    FIRST_TIME := false;
4002
                elsif ((I_dly'event) and ( FIRST_TIME = false)) then
4003
                    if(clk_count = toggle_count) then
4004
                       O_zd <= not O_zd;
4005
                       clk_count := 0;
4006
                       first := not first;
4007
                       if(first = true) then
4008
                         toggle_count := FIRST_TOGGLE_COUNT;
4009
                       else
4010
                         toggle_count := SECOND_TOGGLE_COUNT;
4011
                       end if;
4012
                    end if;
4013
                 end if;
4014
 
4015
                 if (FIRST_TIME = false) then
4016
                       clk_count := clk_count + 1;
4017
                end if;
4018
             else
4019
                 clk_count := 0;
4020
                 FIRST_TIME := true;
4021
             end if;
4022
          end if;
4023
       else
4024
          O_zd <= I_dly;
4025
       end if;
4026
  end process prcs_I;
4027
 
4028
--####################################################################
4029
--#####                         OUTPUT                           #####
4030
--####################################################################
4031
  prcs_output:process(O_zd)
4032
  begin
4033
--    06/30/2005 - CR # 211199 --
4034
--    O <= O_zd after SYNC_PATH_DELAY;
4035
      O <= O_zd;
4036
  end process prcs_output;
4037
--####################################################################
4038
 
4039
 
4040
end BUFR_V;
4041
 
4042
library IEEE;
4043
use IEEE.STD_LOGIC_1164.all;
4044
 
4045
 
4046
library unisim;
4047
use unisim.vpkg.all;
4048
 
4049
entity ODDR2 is
4050
 
4051
  generic(
4052
 
4053
      DDR_ALIGNMENT : string := "NONE";
4054
      INIT          : bit    := '0';
4055
      SRTYPE        : string := "SYNC"
4056
      );
4057
 
4058
  port(
4059
      Q           : out std_ulogic;
4060
 
4061
      C0          : in  std_ulogic;
4062
      C1          : in  std_ulogic;
4063
      CE          : in  std_ulogic;
4064
      D0          : in  std_ulogic;
4065
      D1          : in  std_ulogic;
4066
      R           : in  std_ulogic;
4067
      S           : in  std_ulogic
4068
    );
4069
 
4070
end ODDR2;
4071
 
4072
architecture ODDR2_V OF ODDR2 is
4073
 
4074
 
4075
  constant SYNC_PATH_DELAY : time := 100 ps;
4076
 
4077
  signal C0_ipd         : std_ulogic := 'X';
4078
  signal C1_ipd         : std_ulogic := 'X';
4079
  signal CE_ipd         : std_ulogic := 'X';
4080
  signal D0_ipd         : std_ulogic := 'X';
4081
  signal D1_ipd         : std_ulogic := 'X';
4082
  signal GSR            : std_ulogic := '0';
4083
  signal GSR_ipd        : std_ulogic := 'X';
4084
  signal R_ipd          : std_ulogic := 'X';
4085
  signal S_ipd          : std_ulogic := 'X';
4086
 
4087
  signal C0_dly         : std_ulogic := 'X';
4088
  signal C1_dly         : std_ulogic := 'X';
4089
  signal CE_dly         : std_ulogic := 'X';
4090
  signal D0_dly         : std_ulogic := 'X';
4091
  signal D1_dly         : std_ulogic := 'X';
4092
  signal GSR_dly        : std_ulogic := 'X';
4093
  signal R_dly          : std_ulogic := 'X';
4094
  signal S_dly          : std_ulogic := 'X';
4095
 
4096
  signal Q_zd           : std_ulogic := 'X';
4097
 
4098
  signal Q_viol         : std_ulogic := 'X';
4099
 
4100
  signal ddr_alignment_type     : integer := -999;
4101
  signal sr_type                : integer := -999;
4102
 
4103
begin
4104
 
4105
  ---------------------
4106
  --  INPUT PATH DELAYs
4107
  --------------------
4108
 
4109
  C0_dly                 <= C0                  after 0 ps;
4110
  C1_dly                 <= C1                  after 0 ps;
4111
  CE_dly                 <= CE                  after 0 ps;
4112
  D0_dly                 <= D0                  after 0 ps;
4113
  D1_dly                 <= D1                  after 0 ps;
4114
  GSR_dly                <= GSR                 after 0 ps;
4115
  R_dly                  <= R                   after 0 ps;
4116
  S_dly                  <= S                   after 0 ps;
4117
 
4118
  --------------------
4119
  --  BEHAVIOR SECTION
4120
  --------------------
4121
 
4122
--####################################################################
4123
--#####                     Initialize                           #####
4124
--####################################################################
4125
  prcs_init:process
4126
 
4127
  begin
4128
      if((DDR_ALIGNMENT = "NONE") or (DDR_ALIGNMENT = "none")) then
4129
         ddr_alignment_type <= 1;
4130
      elsif((DDR_ALIGNMENT = "C0") or (DDR_ALIGNMENT = "c0")) then
4131
         ddr_alignment_type <= 2;
4132
      elsif((DDR_ALIGNMENT = "C1") or (DDR_ALIGNMENT = "c1")) then
4133
         ddr_alignment_type <= 3;
4134
      else
4135
        GenericValueCheckMessage
4136
          (  HeaderMsg  => " Attribute Syntax Error :",
4137
             GenericName => " DDR_ALIGNMENT ",
4138
             EntityName => "/ODDR2",
4139
             GenericValue => DDR_ALIGNMENT,
4140
             Unit => "",
4141
             ExpectedValueMsg => " The Legal values for this attribute are ",
4142
             ExpectedGenericValue => " NONE, C0 or C1.",
4143
             TailMsg => "",
4144
             MsgSeverity => failure
4145
         );
4146
      end if;
4147
 
4148
      if((SRTYPE = "ASYNC") or (SRTYPE = "async")) then
4149
         sr_type <= 1;
4150
      elsif((SRTYPE = "SYNC") or (SRTYPE = "sync")) then
4151
         sr_type <= 2;
4152
      else
4153
        GenericValueCheckMessage
4154
          (  HeaderMsg  => " Attribute Syntax Error :",
4155
             GenericName => " SRTYPE ",
4156
             EntityName => "/ODDR2",
4157
             GenericValue => SRTYPE,
4158
             Unit => "",
4159
             ExpectedValueMsg => " The Legal values for this attribute are ",
4160
             ExpectedGenericValue => " ASYNC or SYNC. ",
4161
             TailMsg => "",
4162
             MsgSeverity => failure
4163
         );
4164
      end if;
4165
 
4166
     wait;
4167
  end process prcs_init;
4168
--####################################################################
4169
--#####                      functionality                       #####
4170
--####################################################################
4171
  prcs_func_reg:process(C0_dly, C1_dly, GSR_dly, R_dly, S_dly)
4172
    variable FIRST_TIME : boolean := true;
4173
    variable q_var         : std_ulogic := TO_X01(INIT);
4174
    variable q_d0_c1_out_var : std_ulogic := TO_X01(INIT);
4175
    variable q_d1_c0_out_var : std_ulogic := TO_X01(INIT);
4176
  begin
4177
     if((GSR_dly = '1') or (FIRST_TIME)) then
4178
         q_var         := TO_X01(INIT);
4179
         q_d0_c1_out_var := TO_X01(INIT);
4180
         q_d1_c0_out_var := TO_X01(INIT);
4181
         FIRST_TIME := false;
4182
     else
4183
        case sr_type is
4184
           when 1 =>
4185
                   if(R_dly = '1') then
4186
                      q_var := '0';
4187
                      q_d0_c1_out_var := '0';
4188
                      q_d1_c0_out_var := '0';
4189
                   elsif((R_dly = '0') and (S_dly = '1')) then
4190
                      q_var := '1';
4191
                      q_d0_c1_out_var := '1';
4192
                      q_d1_c0_out_var := '1';
4193
                   elsif((R_dly = '0') and (S_dly = '0')) then
4194
                      if(CE_dly = '1') then
4195
                         if(rising_edge(C0_dly)) then
4196
                           if(ddr_alignment_type = 3) then
4197
                             q_var := q_d0_c1_out_var;
4198
                           else
4199
                             q_var := D0_dly;
4200
                             if(ddr_alignment_type = 2) then
4201
                               q_d1_c0_out_var := D1_dly;
4202
                             end if;
4203
                           end if;
4204
                         end if;
4205
                         if(rising_edge(C1_dly)) then
4206
                           if(ddr_alignment_type = 2) then
4207
                             q_var := q_d1_c0_out_var;
4208
                           else
4209
                             q_var := D1_dly;
4210
                             if(ddr_alignment_type = 3) then
4211
                               q_d0_c1_out_var := D0_dly;
4212
                             end if;
4213
                           end if;
4214
                         end if;
4215
                      end if;
4216
                   end if;
4217
 
4218
           when 2 =>
4219
                   if(rising_edge(C0_dly)) then
4220
                      if(R_dly = '1') then
4221
                         q_var := '0';
4222
                         q_d1_c0_out_var := '0';
4223
                      elsif((R_dly = '0') and (S_dly = '1')) then
4224
                         q_var := '1';
4225
                         q_d1_c0_out_var := '1';
4226
                      elsif((R_dly = '0') and (S_dly = '0')) then
4227
                         if(CE_dly = '1') then
4228
                           if(ddr_alignment_type = 3) then
4229
                             q_var := q_d0_c1_out_var;
4230
                           else
4231
                             q_var := D0_dly;
4232
                             if(ddr_alignment_type = 2) then
4233
                               q_d1_c0_out_var := D1_dly;
4234
                             end if;
4235
                           end if;
4236
                         end if;
4237
                      end if;
4238
                   end if;
4239
 
4240
                   if(rising_edge(C1_dly)) then
4241
                      if(R_dly = '1') then
4242
                         q_var := '0';
4243
                         q_d0_c1_out_var := '0';
4244
                      elsif((R_dly = '0') and (S_dly = '1')) then
4245
                         q_var := '1';
4246
                         q_d0_c1_out_var := '1';
4247
                      elsif((R_dly = '0') and (S_dly = '0')) then
4248
                         if(CE_dly = '1') then
4249
                           if(ddr_alignment_type = 2) then
4250
                             q_var := q_d1_c0_out_var;
4251
                           else
4252
                             q_var := D1_dly;
4253
                             if(ddr_alignment_type = 3) then
4254
                               q_d0_c1_out_var := D0_dly;
4255
                             end if;
4256
                           end if;
4257
                         end if;
4258
                      end if;
4259
                   end if;
4260
 
4261
           when others =>
4262
                   null;
4263
        end case;
4264
     end if;
4265
 
4266
     Q_zd <= q_var;
4267
 
4268
  end process prcs_func_reg;
4269
--####################################################################
4270
 
4271
--####################################################################
4272
--#####                         OUTPUT                           #####
4273
--####################################################################
4274
  prcs_output:process(Q_zd)
4275
  begin
4276
      Q <= Q_zd after SYNC_PATH_DELAY;
4277
  end process prcs_output;
4278
--####################################################################
4279
 
4280
 
4281
end ODDR2_V;
4282
 
4283
library IEEE;
4284
use IEEE.STD_LOGIC_1164.all;
4285
 
4286
 
4287
library unisim;
4288
use unisim.vpkg.all;
4289
 
4290
entity IDDR2 is
4291
 
4292
  generic(
4293
 
4294
      DDR_ALIGNMENT : string := "NONE";
4295
      INIT_Q0       : bit    := '0';
4296
      INIT_Q1       : bit    := '0';
4297
      SRTYPE        : string := "SYNC"
4298
      );
4299
 
4300
  port(
4301
      Q0          : out std_ulogic;
4302
      Q1          : out std_ulogic;
4303
 
4304
      C0          : in  std_ulogic;
4305
      C1          : in  std_ulogic;
4306
      CE          : in  std_ulogic;
4307
      D           : in  std_ulogic;
4308
      R           : in  std_ulogic;
4309
      S           : in  std_ulogic
4310
    );
4311
 
4312
end IDDR2;
4313
 
4314
architecture IDDR2_V OF IDDR2 is
4315
 
4316
 
4317
  constant SYNC_PATH_DELAY : time := 100 ps;
4318
 
4319
  signal C0_ipd         : std_ulogic := 'X';
4320
  signal C1_ipd         : std_ulogic := 'X';
4321
  signal CE_ipd         : std_ulogic := 'X';
4322
  signal D_ipd          : std_ulogic := 'X';
4323
  signal GSR            : std_ulogic := '0';
4324
  signal GSR_ipd        : std_ulogic := 'X';
4325
  signal R_ipd          : std_ulogic := 'X';
4326
  signal S_ipd          : std_ulogic := 'X';
4327
 
4328
  signal C0_dly         : std_ulogic := 'X';
4329
  signal C1_dly         : std_ulogic := 'X';
4330
  signal CE_dly         : std_ulogic := 'X';
4331
  signal D_dly          : std_ulogic := 'X';
4332
  signal GSR_dly        : std_ulogic := 'X';
4333
  signal R_dly          : std_ulogic := 'X';
4334
  signal S_dly          : std_ulogic := 'X';
4335
 
4336
  signal Q0_zd          : std_ulogic := 'X';
4337
  signal Q1_zd          : std_ulogic := 'X';
4338
 
4339
  signal Q0_viol        : std_ulogic := 'X';
4340
  signal Q1_viol        : std_ulogic := 'X';
4341
 
4342
  signal q0_o_reg       : std_ulogic := 'X';
4343
  signal q0_c1_o_reg    : std_ulogic := 'X';
4344
  signal q1_o_reg       : std_ulogic := 'X';
4345
  signal q1_c0_o_reg    : std_ulogic := 'X';
4346
 
4347
  signal ddr_alignment_type     : integer := -999;
4348
  signal sr_type                : integer := -999;
4349
 
4350
begin
4351
 
4352
  ---------------------
4353
  --  INPUT PATH DELAYs
4354
  --------------------
4355
 
4356
  C0_dly                 <= C0                  after 0 ps;
4357
  C1_dly                 <= C1                  after 0 ps;
4358
  CE_dly                 <= CE                  after 0 ps;
4359
  D_dly                  <= D                   after 0 ps;
4360
  GSR_dly                <= GSR                 after 0 ps;
4361
  R_dly                  <= R                   after 0 ps;
4362
  S_dly                  <= S                   after 0 ps;
4363
 
4364
  --------------------
4365
  --  BEHAVIOR SECTION
4366
  --------------------
4367
 
4368
--####################################################################
4369
--#####                     Initialize                           #####
4370
--####################################################################
4371
  prcs_init:process
4372
 
4373
  begin
4374
      if((DDR_ALIGNMENT = "NONE") or (DDR_ALIGNMENT = "none")) then
4375
         ddr_alignment_type <= 1;
4376
      elsif((DDR_ALIGNMENT = "C0") or (DDR_ALIGNMENT = "c0")) then
4377
         ddr_alignment_type <= 2;
4378
      elsif((DDR_ALIGNMENT = "C1") or (DDR_ALIGNMENT = "c1")) then
4379
         ddr_alignment_type <= 3;
4380
      else
4381
        GenericValueCheckMessage
4382
          (  HeaderMsg  => " Attribute Syntax Error ",
4383
             GenericName => " DDR_ALIGNMENT ",
4384
             EntityName => "/IDDR2",
4385
             GenericValue => DDR_ALIGNMENT,
4386
             Unit => "",
4387
             ExpectedValueMsg => " The Legal values for this attribute are ",
4388
             ExpectedGenericValue => " NONE or C0 or C1.",
4389
             TailMsg => "",
4390
             MsgSeverity => ERROR
4391
         );
4392
      end if;
4393
 
4394
      if((SRTYPE = "ASYNC") or (SRTYPE = "async")) then
4395
         sr_type <= 1;
4396
      elsif((SRTYPE = "SYNC") or (SRTYPE = "sync")) then
4397
         sr_type <= 2;
4398
      else
4399
        GenericValueCheckMessage
4400
          (  HeaderMsg  => " Attribute Syntax Error ",
4401
             GenericName => " SRTYPE ",
4402
             EntityName => "/IDDR2",
4403
             GenericValue => SRTYPE,
4404
             Unit => "",
4405
             ExpectedValueMsg => " The Legal values for this attribute are ",
4406
             ExpectedGenericValue => " ASYNC or SYNC. ",
4407
             TailMsg => "",
4408
             MsgSeverity => ERROR
4409
         );
4410
      end if;
4411
 
4412
     wait;
4413
  end process prcs_init;
4414
--####################################################################
4415
--#####                    functionality                         #####
4416
--####################################################################
4417
  prcs_func_reg:process(C0_dly, C1_dly, D_dly, GSR_dly, R_dly, S_dly)
4418
  variable FIRST_TIME : boolean := true;
4419
  variable q0_out_var : std_ulogic := TO_X01(INIT_Q0);
4420
  variable q1_out_var : std_ulogic := TO_X01(INIT_Q1);
4421
  variable q0_c1_out_var : std_ulogic := TO_X01(INIT_Q0);
4422
  variable q1_c0_out_var : std_ulogic := TO_X01(INIT_Q1);
4423
  begin
4424
     if((GSR_dly = '1') or (FIRST_TIME)) then
4425
       q0_out_var := TO_X01(INIT_Q0);
4426
       q1_out_var := TO_X01(INIT_Q1);
4427
       q0_c1_out_var := TO_X01(INIT_Q0);
4428
       q1_c0_out_var := TO_X01(INIT_Q1);
4429
       FIRST_TIME := false;
4430
     else
4431
        case sr_type is
4432
           when 1 =>
4433
                   if(R_dly = '1') then
4434
                     q0_out_var := '0';
4435
                     q1_out_var := '0';
4436
                     q1_c0_out_var := '0';
4437
                     q0_c1_out_var := '0';
4438
                   elsif((R_dly = '0') and (S_dly = '1')) then
4439
                     q0_out_var := '1';
4440
                     q1_out_var := '1';
4441
                     q1_c0_out_var := '1';
4442
                     q0_c1_out_var := '1';
4443
                   elsif((R_dly = '0') and (S_dly = '0')) then
4444
                      if(CE_dly = '1') then
4445
                         if(rising_edge(C0_dly)) then
4446
                           q0_out_var := D_dly;
4447
                           q1_c0_out_var := q1_out_var;
4448
                         end if;
4449
                         if(rising_edge(C1_dly)) then
4450
                           q1_out_var := D_dly;
4451
                           q0_c1_out_var := q0_out_var;
4452
                         end if;
4453
                      end if;
4454
                   end if;
4455
 
4456
           when 2 =>
4457
                   if(rising_edge(C0_dly)) then
4458
                      if(R_dly = '1') then
4459
                        q0_out_var := '0';
4460
                        q1_c0_out_var := '0';
4461
                      elsif((R_dly = '0') and (S_dly = '1')) then
4462
                        q0_out_var := '1';
4463
                        q1_c0_out_var := '1';
4464
                      elsif((R_dly = '0') and (S_dly = '0')) then
4465
                         if(CE_dly = '1') then
4466
                           q0_out_var := D_dly;
4467
                           q1_c0_out_var := q1_out_var;
4468
                         end if;
4469
                      end if;
4470
                   end if;
4471
 
4472
                   if(rising_edge(C1_dly)) then
4473
                      if(R_dly = '1') then
4474
                        q1_out_var := '0';
4475
                        q0_c1_out_var := '0';
4476
                      elsif((R_dly = '0') and (S_dly = '1')) then
4477
                        q1_out_var := '1';
4478
                        q0_c1_out_var := '1';
4479
                      elsif((R_dly = '0') and (S_dly = '0')) then
4480
                         if(CE_dly = '1') then
4481
                           q1_out_var := D_dly;
4482
                           q0_c1_out_var := q0_out_var;
4483
                         end if;
4484
                      end if;
4485
                   end if;
4486
 
4487
           when others =>
4488
                   null;
4489
        end case;
4490
     end if;
4491
 
4492
     q0_o_reg <= q0_out_var;
4493
     q1_o_reg <= q1_out_var;
4494
     q0_c1_o_reg <= q0_c1_out_var;
4495
     q1_c0_o_reg <= q1_c0_out_var;
4496
 
4497
  end process prcs_func_reg;
4498
--####################################################################
4499
--#####                        output mux                        #####
4500
--####################################################################
4501
  prcs_output_mux:process(q0_o_reg, q1_o_reg, q0_c1_o_reg, q1_c0_o_reg)
4502
  begin
4503
     case ddr_alignment_type is
4504
       when 1 =>
4505
                 Q0_zd <= q0_o_reg;
4506
                 Q1_zd <= q1_o_reg;
4507
       when 2 =>
4508
                 Q0_zd <= q0_o_reg;
4509
                 Q1_zd <= q1_c0_o_reg;
4510
       when 3 =>
4511
                 Q0_zd <= q0_c1_o_reg;
4512
                 Q1_zd <= q1_o_reg;
4513
       when others =>
4514
                 null;
4515
     end case;
4516
  end process prcs_output_mux;
4517
--####################################################################
4518
 
4519
--####################################################################
4520
--#####                         OUTPUT                           #####
4521
--####################################################################
4522
  prcs_output:process(Q0_zd, Q1_zd)
4523
  begin
4524
      Q0 <= Q0_zd after SYNC_PATH_DELAY;
4525
      Q1 <= Q1_zd after SYNC_PATH_DELAY;
4526
  end process prcs_output;
4527
--####################################################################
4528
 
4529
 
4530
end IDDR2_V;
4531
 
4532
-------------------------------------------------------------------------------
4533
-- Copyright (c) 1995/2004 Xilinx, Inc.
4534
-- All Right Reserved.
4535
-------------------------------------------------------------------------------
4536
--   ____  ____
4537
--  /   /\/   /
4538
-- /___/  \  /    Vendor : Xilinx
4539
-- \   \   \/     Version : 9.1i
4540
--  \   \         Description : Xilinx Timing Simulation Library Component
4541
--  /   /                  Digital Clock Manager
4542
-- /___/   /\     Filename : X_DCM.vhd
4543
-- \   \  /  \    Timestamp : Fri Jun 18 10:57:08 PDT 2004
4544
--  \___\/\___\
4545
--
4546
-- Revision:
4547
--    03/23/04 - Initial version.
4548
--    05/11/05 - Add clkin alignment check control to remove the glitch when
4549
--               clkin stopped. (CR207409).
4550
--    05/25/05 - Seperate clock_second_pos and neg to another process due to
4551
--               wait caused unreset. Set fb_delay_found after fb_delay computed.
4552
--               Enable clkfb_div after lock_fb high (CR 208771)
4553
--    06/03/05 - Use after instead wait for clk0_out(CR209283).
4554
--               Update error message (CR 209076).
4555
--    07/06/05 - Add lock_fb_dly to alignment check. (CR210755).
4556
--               Use counter to generate clkdv_out to align with clk0_out. (CR211465).
4557
--    07/25/05 - Set CLKIN_PERIOD default to 10.0ns to (CR 213190).
4558
--    08/30/05 - Change reset for CLK270, CLK180 (CR 213641).
4559
--    09/08/05 - Add positive edge trig to dcm_maximum_period_check_v. (CR 216828).
4560
--    12/22/05 - LOCKED = x when RST less than 3 clock cycles (CR 222795)
4561
--    02/28/06 - Remove 1 ps in clkfx_out block to support fs resolution (CR222390)
4562
--    09/22/06 - Add lock_period and lock_fb to clkfb_div block (CR418722).
4563
--    12/19/06 - Add clkfb_div_en for clkfb2x divider (CR431210).
4564
--    04/06/07 - Enable the clock out in clock low time after reset in model 
4565
--               clock_divide_by_2  (CR 437471).
4566
-- End Revision
4567
 
4568
 
4569
----- x_dcm_clock_divide_by_2 -----
4570
library IEEE;
4571
use IEEE.STD_LOGIC_1164.all;
4572
 
4573
entity x_dcm_clock_divide_by_2 is
4574
  port(
4575
    clock_out : out std_ulogic := '0';
4576
 
4577
    clock : in std_ulogic;
4578
    clock_type : in integer;
4579
    rst : in std_ulogic
4580
    );
4581
end x_dcm_clock_divide_by_2;
4582
 
4583
architecture x_dcm_clock_divide_by_2_V of x_dcm_clock_divide_by_2 is
4584
  signal clock_div2 : std_ulogic := '0';
4585
  signal rst_reg : std_logic_vector(2 downto 0);
4586
  signal clk_src : std_ulogic;
4587
begin
4588
 
4589
  CLKIN_DIVIDER : process
4590
  begin
4591
    if (rising_edge(clock)) then
4592
      clock_div2 <= not clock_div2;
4593
    end if;
4594
    wait on clock;
4595
  end process CLKIN_DIVIDER;
4596
 
4597
  gen_reset : process
4598
  begin
4599
    if (rising_edge(clock)) then
4600
      rst_reg(0) <= rst;
4601
      rst_reg(1) <= rst_reg(0) and rst;
4602
      rst_reg(2) <= rst_reg(1) and rst_reg(0) and rst;
4603
    end if;
4604
    wait on clock;
4605
  end process gen_reset;
4606
 
4607
  clk_src <= clock_div2 when (clock_type = 1) else clock;
4608
 
4609
  assign_clkout : process
4610
  begin
4611
    if (rst = '0') then
4612
      clock_out <= clk_src;
4613
    elsif (rst = '1') then
4614
      clock_out <= '0';
4615
      wait until falling_edge(rst_reg(2));
4616
      if (clk_src = '1') then
4617
         wait until falling_edge(clk_src);
4618
      end if;
4619
    end if;
4620
    wait on clk_src, rst, rst_reg;
4621
  end process assign_clkout;
4622
end x_dcm_clock_divide_by_2_V;
4623
 
4624
----- x_dcm_maximum_period_check  -----
4625
library IEEE;
4626
use IEEE.STD_LOGIC_1164.all;
4627
 
4628
library STD;
4629
use STD.TEXTIO.all;
4630
 
4631
entity x_dcm_maximum_period_check is
4632
  generic (
4633
    InstancePath : string := "*";
4634
 
4635
    clock_name : string := "";
4636
    maximum_period : time);
4637
  port(
4638
    clock : in std_ulogic;
4639
    rst : in std_ulogic
4640
    );
4641
end x_dcm_maximum_period_check;
4642
 
4643
architecture x_dcm_maximum_period_check_V of x_dcm_maximum_period_check is
4644
begin
4645
 
4646
  MAX_PERIOD_CHECKER : process
4647
    variable clock_edge_previous : time := 0 ps;
4648
    variable clock_edge_current : time := 0 ps;
4649
    variable clock_period : time := 0 ps;
4650
    variable Message : line;
4651
  begin
4652
 
4653
   if (rising_edge(clock)) then
4654
    clock_edge_previous := clock_edge_current;
4655
    clock_edge_current := NOW;
4656
 
4657
    if (clock_edge_previous > 0 ps) then
4658
      clock_period := clock_edge_current - clock_edge_previous;
4659
    end if;
4660
 
4661
    if (clock_period > maximum_period and  rst = '0') then
4662
      Write ( Message, string'(" Warning : Input Clock Period of "));
4663
      Write ( Message, clock_period );
4664
      Write ( Message, string'(" on the ") );
4665
      Write ( Message, clock_name );
4666
      Write ( Message, string'(" port ") );
4667
      Write ( Message, string'(" of X_DCM instance ") );
4668
      Write ( Message, string'(" exceeds allowed value of ") );
4669
      Write ( Message, maximum_period );
4670
      Write ( Message, string'(" at simulation time ") );
4671
      Write ( Message, clock_edge_current );
4672
      Write ( Message, '.' & LF );
4673
      assert false report Message.all severity warning;
4674
      DEALLOCATE (Message);
4675
    end if;
4676
   end if;
4677
    wait on clock;
4678
  end process MAX_PERIOD_CHECKER;
4679
end x_dcm_maximum_period_check_V;
4680
 
4681
----- x_dcm_clock_lost  -----
4682
library IEEE;
4683
use IEEE.STD_LOGIC_1164.all;
4684
 
4685
entity x_dcm_clock_lost is
4686
  port(
4687
    lost : out std_ulogic := '0';
4688
 
4689
    clock : in std_ulogic;
4690
    enable : in boolean := false;
4691
    rst :  in std_ulogic
4692
    );
4693
end x_dcm_clock_lost;
4694
 
4695
architecture x_dcm_clock_lost_V of x_dcm_clock_lost is
4696
  signal period : time := 0 ps;
4697
  signal lost_r : std_ulogic := '0';
4698
  signal lost_f : std_ulogic := '0';
4699
  signal lost_sig : std_ulogic := '0';
4700
  signal clock_negedge, clock_posedge : std_ulogic;
4701
  signal clock_low, clock_high : std_ulogic := '0';
4702
  signal clock_second_pos, clock_second_neg : std_ulogic := '0';
4703
begin
4704
  determine_period : process
4705
    variable clock_edge_previous : time := 0 ps;
4706
    variable clock_edge_current : time := 0 ps;
4707
  begin
4708
      if (rst = '1') then
4709
        period <= 0 ps;
4710
      elsif (rising_edge(clock)) then
4711
        clock_edge_previous := clock_edge_current;
4712
        clock_edge_current := NOW;
4713
        if (period /= 0 ps and ((clock_edge_current - clock_edge_previous) <= (1.5 * period))) then
4714
          period <= NOW - clock_edge_previous;
4715
        elsif (period /= 0 ps and ((NOW - clock_edge_previous) > (1.5 * period))) then
4716
          period <= 0 ps;
4717
        elsif ((period = 0 ps) and (clock_edge_previous /= 0 ps) and (clock_second_pos = '1')) then
4718
          period <= NOW - clock_edge_previous;
4719
        end if;
4720
      end if;
4721
    wait on clock, rst;
4722
  end process determine_period;
4723
 
4724
  CLOCK_LOST_CHECKER : process
4725
 
4726
  begin
4727
      if (rst = '1') then
4728
        clock_low <= '0';
4729
        clock_high <= '0';
4730
        clock_posedge <= '0';
4731
        clock_negedge <= '0';
4732
      else
4733
        if (rising_edge(clock)) then
4734
          clock_low <= '0';
4735
          clock_high <= '1';
4736
          clock_posedge <= '0';
4737
          clock_negedge <= '1';
4738
        end if;
4739
 
4740
        if (falling_edge(clock)) then
4741
          clock_high <= '0';
4742
          clock_low <= '1';
4743
          clock_posedge <= '1';
4744
          clock_negedge <= '0';
4745
        end if;
4746
      end if;
4747
 
4748
    wait on clock, rst;
4749
  end process CLOCK_LOST_CHECKER;
4750
 
4751
  CLOCK_SECOND_P : process
4752
    begin
4753
      if (rst = '1') then
4754
        clock_second_pos <= '0';
4755
        clock_second_neg <= '0';
4756
    else
4757
      if (rising_edge(clock)) then
4758
        clock_second_pos <= '1';
4759
      end if;
4760
      if (falling_edge(clock)) then
4761
          clock_second_neg <= '1';
4762
      end if;
4763
    end if;
4764
    wait on clock, rst;
4765
  end process CLOCK_SECOND_P;
4766
 
4767
  SET_RESET_LOST_R : process
4768
    begin
4769
    if (rst = '1') then
4770
      lost_r <= '0';
4771
    else
4772
      if ((enable = true) and (clock_second_pos = '1'))then
4773
        if (rising_edge(clock)) then
4774
          wait for 1 ps;
4775
          if (period /= 0 ps) then
4776
            lost_r <= '0';
4777
          end if;
4778
          wait for (period * (9.1/10.0));
4779
          if ((clock_low /= '1') and (clock_posedge /= '1') and (rst = '0')) then
4780
            lost_r <= '1';
4781
          end if;
4782
        end if;
4783
      end if;
4784
    end if;
4785
    wait on clock, rst;
4786
  end process SET_RESET_LOST_R;
4787
 
4788
  SET_RESET_LOST_F : process
4789
    begin
4790
      if (rst = '1') then
4791
        lost_f <= '0';
4792
      else
4793
        if ((enable = true) and (clock_second_neg = '1'))then
4794
          if (falling_edge(clock)) then
4795
            if (period /= 0 ps) then
4796
              lost_f <= '0';
4797
            end if;
4798
            wait for (period * (9.1/10.0));
4799
            if ((clock_high /= '1') and (clock_negedge /= '1') and (rst = '0')) then
4800
              lost_f <= '1';
4801
            end if;
4802
          end if;
4803
        end if;
4804
      end if;
4805
    wait on clock, rst;
4806
  end process SET_RESET_LOST_F;
4807
 
4808
  assign_lost : process
4809
    begin
4810
      if (enable = true) then
4811
        if (lost_r'event) then
4812
          lost <= lost_r;
4813
        end if;
4814
        if (lost_f'event) then
4815
          lost <= lost_f;
4816
        end if;
4817
      end if;
4818
      wait on lost_r, lost_f;
4819
    end process assign_lost;
4820
end x_dcm_clock_lost_V;
4821
 
4822
 
4823
----- CELL X_DCM  -----
4824
library IEEE;
4825
use IEEE.std_logic_1164.all;
4826
 
4827
library IEEE;
4828
use IEEE.VITAL_Timing.all;
4829
use IEEE.VITAL_Primitives.all;
4830
 
4831
library STD;
4832
use STD.TEXTIO.all;
4833
 
4834
library unisim;
4835
use unisim.vpkg.all;
4836
 
4837
entity X_DCM is
4838
  generic (
4839
    TimingChecksOn : boolean := true;
4840
    InstancePath : string := "*";
4841
    Xon : boolean := true;
4842
    MsgOn : boolean := false;
4843
    LOC   : string  := "UNPLACED";
4844
 
4845
    thold_PSEN_PSCLK_negedge_posedge : VitalDelayType := 0.000 ns;
4846
    thold_PSEN_PSCLK_posedge_posedge : VitalDelayType := 0.000 ns;
4847
    thold_PSINCDEC_PSCLK_negedge_posedge : VitalDelayType := 0.000 ns;
4848
    thold_PSINCDEC_PSCLK_posedge_posedge : VitalDelayType := 0.000 ns;
4849
 
4850
    ticd_PSCLK :  VitalDelayType := 0.000 ns;
4851
 
4852
    tipd_CLKFB : VitalDelayType01 := (0.000 ns, 0.000 ns);
4853
    tipd_CLKIN : VitalDelayType01 := (0.000 ns, 0.000 ns);
4854
    tipd_DSSEN : VitalDelayType01 := (0.000 ns, 0.000 ns);
4855
    tipd_PSCLK : VitalDelayType01 := (0.000 ns, 0.000 ns);
4856
    tipd_PSEN : VitalDelayType01 := (0.000 ns, 0.000 ns);
4857
    tipd_PSINCDEC : VitalDelayType01 := (0.000 ns, 0.000 ns);
4858
    tipd_RST : VitalDelayType01 := (0.000 ns, 0.000 ns);
4859
 
4860
    tisd_PSINCDEC_PSCLK :  VitalDelayType := 0.000 ns;
4861
    tisd_PSEN_PSCLK :  VitalDelayType := 0.000 ns;
4862
 
4863
    tpd_CLKIN_LOCKED : VitalDelayType01 := (0.100 ns, 0.100 ns);
4864
    tpd_PSCLK_PSDONE : VitalDelayType01 := (0.100 ns, 0.100 ns);
4865
 
4866
    tperiod_CLKIN_POSEDGE : VitalDelayType := 0.000 ns;
4867
    tperiod_PSCLK_POSEDGE : VitalDelayType := 0.000 ns;
4868
 
4869
    tpw_CLKIN_negedge : VitalDelayType := 0.000 ns;
4870
    tpw_CLKIN_posedge : VitalDelayType := 0.000 ns;
4871
    tpw_PSCLK_negedge : VitalDelayType := 0.000 ns;
4872
    tpw_PSCLK_posedge : VitalDelayType := 0.000 ns;
4873
    tpw_RST_posedge : VitalDelayType := 0.000 ns;
4874
 
4875
    tsetup_PSEN_PSCLK_negedge_posedge : VitalDelayType := 0.000 ns;
4876
    tsetup_PSEN_PSCLK_posedge_posedge : VitalDelayType := 0.000 ns;
4877
    tsetup_PSINCDEC_PSCLK_negedge_posedge : VitalDelayType := 0.000 ns;
4878
    tsetup_PSINCDEC_PSCLK_posedge_posedge : VitalDelayType := 0.000 ns;
4879
 
4880
    CLKDV_DIVIDE : real := 2.0;
4881
    CLKFX_DIVIDE : integer := 1;
4882
    CLKFX_MULTIPLY : integer := 4;
4883
    CLKIN_DIVIDE_BY_2 : boolean := false;
4884
    CLKIN_PERIOD : real := 10.0;                         --non-simulatable
4885
    CLKOUT_PHASE_SHIFT : string := "NONE";
4886
    CLK_FEEDBACK : string := "1X";
4887
    DESKEW_ADJUST : string := "SYSTEM_SYNCHRONOUS";     --non-simulatable
4888
    DFS_FREQUENCY_MODE : string := "LOW";
4889
    DLL_FREQUENCY_MODE : string := "LOW";
4890
    DSS_MODE : string := "NONE";                        --non-simulatable
4891
    DUTY_CYCLE_CORRECTION : boolean := true;
4892
    FACTORY_JF : bit_vector := X"C080";                 --non-simulatable
4893
    MAXPERCLKIN : time := 1000000 ps;                   --non-modifiable simulation parameter
4894
    MAXPERPSCLK : time := 100000000 ps;                 --non-modifiable simulation parameter
4895
    PHASE_SHIFT : integer := 0;
4896
    SIM_CLKIN_CYCLE_JITTER : time := 300 ps;            --non-modifiable simulation parameter
4897
    SIM_CLKIN_PERIOD_JITTER : time := 1000 ps;          --non-modifiable simulation parameter
4898
    STARTUP_WAIT : boolean := false                     --non-simulatable
4899
    );
4900
 
4901
  port (
4902
    CLK0 : out std_ulogic := '0';
4903
    CLK180 : out std_ulogic := '0';
4904
    CLK270 : out std_ulogic := '0';
4905
    CLK2X : out std_ulogic := '0';
4906
    CLK2X180 : out std_ulogic := '0';
4907
    CLK90 : out std_ulogic := '0';
4908
    CLKDV : out std_ulogic := '0';
4909
    CLKFX : out std_ulogic := '0';
4910
    CLKFX180 : out std_ulogic := '0';
4911
    LOCKED : out std_ulogic := '0';
4912
    PSDONE : out std_ulogic := '0';
4913
    STATUS : out std_logic_vector(7 downto 0) := "00000000";
4914
 
4915
    CLKFB : in std_ulogic := '0';
4916
    CLKIN : in std_ulogic := '0';
4917
    DSSEN : in std_ulogic := '0';
4918
    PSCLK : in std_ulogic := '0';
4919
    PSEN : in std_ulogic := '0';
4920
    PSINCDEC : in std_ulogic := '0';
4921
    RST : in std_ulogic := '0'
4922
    );
4923
 
4924
  attribute VITAL_LEVEL0 of X_DCM : entity is true;
4925
 
4926
end X_DCM;
4927
 
4928
architecture X_DCM_V of X_DCM is
4929
 
4930
 
4931
  component x_dcm_clock_divide_by_2
4932
    port(
4933
      clock_out : out std_ulogic;
4934
 
4935
      clock : in std_ulogic;
4936
      clock_type : in integer;
4937
      rst : in std_ulogic
4938
      );
4939
  end component;
4940
 
4941
  component x_dcm_maximum_period_check
4942
    generic (
4943
      InstancePath : string := "*";
4944
 
4945
      clock_name : string := "";
4946
      maximum_period : time);
4947
    port(
4948
      clock : in std_ulogic;
4949
      rst : in std_ulogic
4950
      );
4951
  end component;
4952
 
4953
  component x_dcm_clock_lost
4954
    port(
4955
      lost : out std_ulogic;
4956
 
4957
      clock : in std_ulogic;
4958
      enable : in boolean := false;
4959
      rst :  in std_ulogic
4960
      );
4961
  end component;
4962
 
4963
 
4964
 
4965
 
4966
 
4967
 
4968
  signal CLKFB_ipd, CLKIN_ipd, DSSEN_ipd : std_ulogic;
4969
  signal PSCLK_ipd, PSEN_ipd, PSINCDEC_ipd, RST_ipd : std_ulogic;
4970
  signal PSCLK_dly ,PSEN_dly, PSINCDEC_dly : std_ulogic := '0';
4971
 
4972
  signal clk0_out : std_ulogic;
4973
  signal clk2x_out, clkdv_out : std_ulogic := '0';
4974
  signal clkfx_out, locked_out, psdone_out, ps_overflow_out, ps_lock : std_ulogic := '0';
4975
  signal locked_out_out : std_ulogic := '0';
4976
  signal LOCKED_sig : std_ulogic := '0';
4977
 
4978
  signal clkdv_cnt : integer := 0;
4979
  signal clkfb_type : integer;
4980
  signal divide_type : integer;
4981
  signal clkin_type : integer;
4982
  signal ps_type : integer;
4983
  signal deskew_adjust_mode : integer;
4984
  signal dfs_mode_type : integer;
4985
  signal dll_mode_type : integer;
4986
  signal clk1x_type : integer;
4987
 
4988
 
4989
  signal lock_period, lock_delay, lock_clkin, lock_clkfb : std_ulogic := '0';
4990
  signal lock_out : std_logic_vector(1 downto 0) := "00";
4991
  signal lock_out1_neg : std_ulogic := '0';
4992
 
4993
  signal lock_fb : std_ulogic := '0';
4994
  signal lock_fb_dly : std_ulogic := '0';
4995
  signal lock_fb_dly_tmp : std_ulogic := '0';
4996
  signal fb_delay_found : std_ulogic := '0';
4997
 
4998
  signal clkin_div : std_ulogic;
4999
  signal clkin_ps : std_ulogic;
5000
  signal clkin_fb : std_ulogic;
5001
 
5002
 
5003
  signal ps_delay : time := 0 ps;
5004
  signal clkin_period_real : VitalDelayArrayType(2 downto 0) := (0.000 ns, 0.000 ns, 0.000 ns);
5005
 
5006
 
5007
  signal period : time := 0 ps;
5008
  signal period_div : time := 0 ps;
5009
  signal period_orig : time := 0 ps;
5010
  signal period_ps : time := 0 ps;
5011
  signal clkout_delay : time := 0 ps;
5012
  signal fb_delay : time := 0 ps;
5013
  signal period_fx, remain_fx : time := 0 ps;
5014
  signal period_dv_high, period_dv_low : time := 0 ps;
5015
  signal cycle_jitter, period_jitter : time := 0 ps;
5016
 
5017
  signal clkin_window, clkfb_window : std_ulogic := '0';
5018
  signal rst_reg : std_logic_vector(2 downto 0) := "000";
5019
  signal rst_flag : std_ulogic := '0';
5020
  signal numerator, denominator, gcd : integer := 1;
5021
 
5022
  signal clkin_lost_out : std_ulogic := '0';
5023
  signal clkfx_lost_out : std_ulogic := '0';
5024
 
5025
  signal remain_fx_temp : integer := 0;
5026
 
5027
  signal clkin_period_real0_temp : time := 0 ps;
5028
  signal ps_lock_reg : std_ulogic := '0';
5029
 
5030
  signal clk0_sig : std_ulogic := '0';
5031
  signal clk2x_sig : std_ulogic := '0';
5032
 
5033
  signal no_stop : boolean := false;
5034
 
5035
  signal clkfx180_en : std_ulogic := '0';
5036
 
5037
  signal status_out  : std_logic_vector(7 downto 0) := "00000000";
5038
 
5039
  signal first_time_locked : boolean := false;
5040
 
5041
  signal en_status : boolean := false;
5042
 
5043
  signal ps_overflow_out_ext : std_ulogic := '0';
5044
  signal clkin_lost_out_ext : std_ulogic := '0';
5045
  signal clkfx_lost_out_ext : std_ulogic := '0';
5046
 
5047
  signal clkfb_div : std_ulogic := '0';
5048
  signal clkfb_div_en : std_ulogic := '0';
5049
  signal clkfb_chk : std_ulogic := '0';
5050
 
5051
  signal lock_period_dly : std_ulogic := '0';
5052
  signal lock_period_pulse : std_ulogic := '0';
5053
 
5054
  signal clock_stopped : std_ulogic := '1';
5055
 
5056
  signal clkin_chkin, clkfb_chkin : std_ulogic := '0';
5057
  signal chk_enable, chk_rst : std_ulogic := '0';
5058
 
5059
  signal lock_ps : std_ulogic := '0';
5060
  signal lock_ps_dly : std_ulogic := '0';
5061
 
5062
begin
5063
  INITPROC : process
5064
  begin
5065
    detect_resolution
5066
      (model_name => "X_DCM"
5067
       );
5068
    if (CLKDV_DIVIDE = 1.5) then
5069
      divide_type <= 3;
5070
    elsif (CLKDV_DIVIDE = 2.0) then
5071
      divide_type <= 4;
5072
    elsif (CLKDV_DIVIDE = 2.5) then
5073
      divide_type <= 5;
5074
    elsif (CLKDV_DIVIDE = 3.0) then
5075
      divide_type <= 6;
5076
    elsif (CLKDV_DIVIDE = 3.5) then
5077
      divide_type <= 7;
5078
    elsif (CLKDV_DIVIDE = 4.0) then
5079
      divide_type <= 8;
5080
    elsif (CLKDV_DIVIDE = 4.5) then
5081
      divide_type <= 9;
5082
    elsif (CLKDV_DIVIDE = 5.0) then
5083
      divide_type <= 10;
5084
    elsif (CLKDV_DIVIDE = 5.5) then
5085
      divide_type <= 11;
5086
    elsif (CLKDV_DIVIDE = 6.0) then
5087
      divide_type <= 12;
5088
    elsif (CLKDV_DIVIDE = 6.5) then
5089
      divide_type <= 13;
5090
    elsif (CLKDV_DIVIDE = 7.0) then
5091
      divide_type <= 14;
5092
    elsif (CLKDV_DIVIDE = 7.5) then
5093
      divide_type <= 15;
5094
    elsif (CLKDV_DIVIDE = 8.0) then
5095
      divide_type <= 16;
5096
    elsif (CLKDV_DIVIDE = 9.0) then
5097
      divide_type <= 18;
5098
    elsif (CLKDV_DIVIDE = 10.0) then
5099
      divide_type <= 20;
5100
    elsif (CLKDV_DIVIDE = 11.0) then
5101
      divide_type <= 22;
5102
    elsif (CLKDV_DIVIDE = 12.0) then
5103
      divide_type <= 24;
5104
    elsif (CLKDV_DIVIDE = 13.0) then
5105
      divide_type <= 26;
5106
    elsif (CLKDV_DIVIDE = 14.0) then
5107
      divide_type <= 28;
5108
    elsif (CLKDV_DIVIDE = 15.0) then
5109
      divide_type <= 30;
5110
    elsif (CLKDV_DIVIDE = 16.0) then
5111
      divide_type <= 32;
5112
    else
5113
      GenericValueCheckMessage
5114
        (HeaderMsg => "Attribute Syntax Error",
5115
         GenericName => "CLKDV_DIVIDE",
5116
         EntityName => "X_DCM",
5117
         InstanceName => InstancePath,
5118
         GenericValue => CLKDV_DIVIDE,
5119
         Unit => "",
5120
         ExpectedValueMsg => "Legal Values for this attribute are 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, or 16.0",
5121
         ExpectedGenericValue => "",
5122
         TailMsg => "",
5123
         MsgSeverity => error
5124
         );
5125
    end if;
5126
 
5127
    if ((CLKFX_DIVIDE <= 0) or (32 < CLKFX_DIVIDE)) then
5128
      GenericValueCheckMessage
5129
        (HeaderMsg => "Attribute Syntax Error",
5130
         GenericName => "CLKFX_DIVIDE",
5131
         EntityName => "X_DCM",
5132
         InstanceName => InstancePath,
5133
         GenericValue => CLKFX_DIVIDE,
5134
         Unit => "",
5135
         ExpectedValueMsg => "Legal Values for this attribute are 1....32",
5136
         ExpectedGenericValue => "",
5137
         TailMsg => "",
5138
         MsgSeverity => error
5139
         );
5140
    end if;
5141
    if ((CLKFX_MULTIPLY <= 1) or (32 < CLKFX_MULTIPLY)) then
5142
      GenericValueCheckMessage
5143
        (HeaderMsg => "Attribute Syntax Error",
5144
         GenericName => "CLKFX_MULTIPLY",
5145
         EntityName => "X_DCM",
5146
         InstanceName => InstancePath,
5147
         GenericValue => CLKFX_MULTIPLY,
5148
         Unit => "",
5149
         ExpectedValueMsg => "Legal Values for this attribute are 2....32",
5150
         ExpectedGenericValue => "",
5151
         TailMsg => "",
5152
         MsgSeverity => error
5153
         );
5154
    end if;
5155
    case CLKIN_DIVIDE_BY_2 is
5156
      when false => clkin_type <= 0;
5157
      when true => clkin_type <= 1;
5158
      when others =>
5159
        GenericValueCheckMessage
5160
          (HeaderMsg => "Attribute Syntax Error",
5161
           GenericName => "CLKIN_DIVIDE_BY_2",
5162
           EntityName => "X_DCM",
5163
           InstanceName => InstancePath,
5164
           GenericValue => CLKIN_DIVIDE_BY_2,
5165
           Unit => "",
5166
           ExpectedValueMsg => "Legal Values for this attribute are TRUE or FALSE",
5167
           ExpectedGenericValue => "",
5168
           TailMsg => "",
5169
           MsgSeverity => error
5170
           );
5171
    end case;
5172
 
5173
 
5174
    if ((CLKOUT_PHASE_SHIFT = "none") or (CLKOUT_PHASE_SHIFT = "NONE")) then
5175
      ps_type <= 0;
5176
    elsif ((CLKOUT_PHASE_SHIFT = "fixed") or (CLKOUT_PHASE_SHIFT = "FIXED")) then
5177
      ps_type <= 1;
5178
    elsif ((CLKOUT_PHASE_SHIFT = "variable") or (CLKOUT_PHASE_SHIFT = "VARIABLE")) then
5179
      ps_type <= 2;
5180
    else
5181
      GenericValueCheckMessage
5182
        (HeaderMsg => "Attribute Syntax Error",
5183
         GenericName => "CLKOUT_PHASE_SHIFT",
5184
         EntityName => "X_DCM",
5185
         InstanceName => InstancePath,
5186
         GenericValue => CLKOUT_PHASE_SHIFT,
5187
         Unit => "",
5188
         ExpectedValueMsg => "Legal Values for this attribute are NONE, FIXED or VARIABLE",
5189
         ExpectedGenericValue => "",
5190
         TailMsg => "",
5191
         MsgSeverity => error
5192
         );
5193
    end if;
5194
 
5195
    if ((CLK_FEEDBACK = "none") or (CLK_FEEDBACK = "NONE")) then
5196
      clkfb_type <= 0;
5197
    elsif ((CLK_FEEDBACK = "1x") or (CLK_FEEDBACK = "1X")) then
5198
      clkfb_type <= 1;
5199
    elsif ((CLK_FEEDBACK = "2x") or (CLK_FEEDBACK = "2X")) then
5200
      clkfb_type <= 2;
5201
    else
5202
      GenericValueCheckMessage
5203
        (HeaderMsg => "Attribute Syntax Error",
5204
         GenericName => "CLK_FEEDBACK",
5205
         EntityName => "X_DCM",
5206
         InstanceName => InstancePath,
5207
         GenericValue => CLK_FEEDBACK,
5208
         Unit => "",
5209
         ExpectedValueMsg => "Legal Values for this attribute are NONE, 1X or 2X",
5210
         ExpectedGenericValue => "",
5211
         TailMsg => "",
5212
         MsgSeverity => error
5213
         );
5214
    end if;
5215
 
5216
 
5217
 
5218
    if ((DESKEW_ADJUST = "source_synchronous") or (DESKEW_ADJUST = "SOURCE_SYNCHRONOUS")) then
5219
      DESKEW_ADJUST_mode <= 8;
5220
    elsif ((DESKEW_ADJUST = "system_synchronous") or (DESKEW_ADJUST = "SYSTEM_SYNCHRONOUS")) then
5221
      DESKEW_ADJUST_mode <= 11;
5222
    elsif ((DESKEW_ADJUST = "0")) then
5223
      DESKEW_ADJUST_mode <= 0;
5224
    elsif ((DESKEW_ADJUST = "1")) then
5225
      DESKEW_ADJUST_mode <= 1;
5226
    elsif ((DESKEW_ADJUST = "2")) then
5227
      DESKEW_ADJUST_mode <= 2;
5228
    elsif ((DESKEW_ADJUST = "3")) then
5229
      DESKEW_ADJUST_mode <= 3;
5230
    elsif ((DESKEW_ADJUST = "4")) then
5231
      DESKEW_ADJUST_mode <= 4;
5232
    elsif ((DESKEW_ADJUST = "5")) then
5233
      DESKEW_ADJUST_mode <= 5;
5234
    elsif ((DESKEW_ADJUST = "6")) then
5235
      DESKEW_ADJUST_mode <= 6;
5236
    elsif ((DESKEW_ADJUST = "7")) then
5237
      DESKEW_ADJUST_mode <= 7;
5238
    elsif ((DESKEW_ADJUST = "8")) then
5239
      DESKEW_ADJUST_mode <= 8;
5240
    elsif ((DESKEW_ADJUST = "9")) then
5241
      DESKEW_ADJUST_mode <= 9;
5242
    elsif ((DESKEW_ADJUST = "10")) then
5243
      DESKEW_ADJUST_mode <= 10;
5244
    elsif ((DESKEW_ADJUST = "11")) then
5245
      DESKEW_ADJUST_mode <= 11;
5246
    elsif ((DESKEW_ADJUST = "12")) then
5247
      DESKEW_ADJUST_mode <= 12;
5248
    elsif ((DESKEW_ADJUST = "13")) then
5249
      DESKEW_ADJUST_mode <= 13;
5250
    elsif ((DESKEW_ADJUST = "14")) then
5251
      DESKEW_ADJUST_mode <= 14;
5252
    elsif ((DESKEW_ADJUST = "15")) then
5253
      DESKEW_ADJUST_mode <= 15;
5254
    else
5255
      GenericValueCheckMessage
5256
        (HeaderMsg => "Attribute Syntax Error",
5257
         GenericName => "DESKEW_ADJUST_MODE",
5258
         EntityName => "X_DCM",
5259
         InstanceName => InstancePath,
5260
         GenericValue => DESKEW_ADJUST_MODE,
5261
         Unit => "",
5262
         ExpectedValueMsg => "Legal Values for this attribute are SOURCE_SYNCHRONOUS, SYSTEM_SYNCHRONOUS or 1....15",
5263
         ExpectedGenericValue => "",
5264
         TailMsg => "",
5265
         MsgSeverity => error
5266
         );
5267
    end if;
5268
 
5269
    if ((DFS_FREQUENCY_MODE = "high") or (DFS_FREQUENCY_MODE = "HIGH")) then
5270
      dfs_mode_type <= 1;
5271
    elsif ((DFS_FREQUENCY_MODE = "low") or (DFS_FREQUENCY_MODE = "LOW")) then
5272
      dfs_mode_type <= 0;
5273
    else
5274
      GenericValueCheckMessage
5275
        (HeaderMsg => "Attribute Syntax Error",
5276
         GenericName => "DFS_FREQUENCY_MODE",
5277
         EntityName => "X_DCM",
5278
         InstanceName => InstancePath,
5279
         GenericValue => DFS_FREQUENCY_MODE,
5280
         Unit => "",
5281
         ExpectedValueMsg => "Legal Values for this attribute are HIGH or LOW",
5282
         ExpectedGenericValue => "",
5283
         TailMsg => "",
5284
         MsgSeverity => error
5285
         );
5286
    end if;
5287
 
5288
    if ((DLL_FREQUENCY_MODE = "high") or (DLL_FREQUENCY_MODE = "HIGH")) then
5289
      dll_mode_type <= 1;
5290
    elsif ((DLL_FREQUENCY_MODE = "low") or (DLL_FREQUENCY_MODE = "LOW")) then
5291
      dll_mode_type <= 0;
5292
    else
5293
      GenericValueCheckMessage
5294
        (HeaderMsg => "Attribute Syntax Error",
5295
         GenericName => "DLL_FREQUENCY_MODE",
5296
         EntityName => "X_DCM",
5297
         InstanceName => InstancePath,
5298
         GenericValue => DLL_FREQUENCY_MODE,
5299
         Unit => "",
5300
         ExpectedValueMsg => "Legal Values for this attribute are HIGH or LOW",
5301
         ExpectedGenericValue => "",
5302
         TailMsg => "",
5303
         MsgSeverity => error
5304
         );
5305
    end if;
5306
 
5307
    if ((DSS_MODE = "none") or (DSS_MODE = "NONE")) then
5308
    else
5309
      GenericValueCheckMessage
5310
        (HeaderMsg => "Attribute Syntax Error",
5311
         GenericName => "DSS_MODE",
5312
         EntityName => "X_DCM",
5313
         InstanceName => InstancePath,
5314
         GenericValue => DSS_MODE,
5315
         Unit => "",
5316
         ExpectedValueMsg => "Legal Values for this attribute are NONE",
5317
         ExpectedGenericValue => "",
5318
         TailMsg => "",
5319
         MsgSeverity => error
5320
         );
5321
    end if;
5322
 
5323
    case DUTY_CYCLE_CORRECTION is
5324
      when false => clk1x_type <= 0;
5325
      when true => clk1x_type <= 1;
5326
      when others =>
5327
        GenericValueCheckMessage
5328
          (HeaderMsg => "Attribute Syntax Error",
5329
           GenericName => "DUTY_CYCLE_CORRECTION",
5330
           EntityName => "X_DCM",
5331
           InstanceName => InstancePath,
5332
           GenericValue => DUTY_CYCLE_CORRECTION,
5333
           Unit => "",
5334
           ExpectedValueMsg => "Legal Values for this attribute are TRUE or FALSE",
5335
           ExpectedGenericValue => "",
5336
           TailMsg => "",
5337
           MsgSeverity => error
5338
           );
5339
    end case;
5340
 
5341
    if ((PHASE_SHIFT < -255) or (PHASE_SHIFT > 255)) then
5342
      GenericValueCheckMessage
5343
        (HeaderMsg => "Attribute Syntax Error",
5344
         GenericName => "PHASE_SHIFT",
5345
         EntityName => "X_DCM",
5346
         InstanceName => InstancePath,
5347
         GenericValue => PHASE_SHIFT,
5348
         Unit => "",
5349
         ExpectedValueMsg => "Legal Values for this attribute are -255 ... 255",
5350
         ExpectedGenericValue => "",
5351
         TailMsg => "",
5352
         MsgSeverity => error
5353
         );
5354
    end if;
5355
 
5356
    period_jitter <= SIM_CLKIN_PERIOD_JITTER;
5357
    cycle_jitter <= SIM_CLKIN_CYCLE_JITTER;
5358
 
5359
    case STARTUP_WAIT is
5360
      when false => null;
5361
      when true => null;
5362
      when others =>
5363
        GenericValueCheckMessage
5364
          (HeaderMsg => "Attribute Syntax Error",
5365
           GenericName => "STARTUP_WAIT",
5366
           EntityName => "X_DCM",
5367
           InstanceName => InstancePath,
5368
           GenericValue => STARTUP_WAIT,
5369
           Unit => "",
5370
           ExpectedValueMsg => "Legal Values for this attribute are TRUE or FALSE",
5371
           ExpectedGenericValue => "",
5372
           TailMsg => "",
5373
           MsgSeverity => error
5374
           );
5375
    end case;
5376
 
5377
--
5378
-- fx parameters
5379
--    
5380
    gcd <= 1;
5381
    for i in 2 to CLKFX_MULTIPLY loop
5382
      if (((CLKFX_MULTIPLY mod i) = 0) and ((CLKFX_DIVIDE mod i) = 0)) then
5383
        gcd <= i;
5384
      end if;
5385
    end loop;
5386
    numerator <= CLKFX_MULTIPLY / gcd;
5387
    denominator <= CLKFX_DIVIDE / gcd;
5388
    wait;
5389
  end process INITPROC;
5390
 
5391
--
5392
-- input wire delays
5393
--  
5394
 
5395
 
5396
  WireDelay : block
5397
  begin
5398
    VitalWireDelay (CLKIN_ipd, CLKIN, tipd_CLKIN);
5399
    VitalWireDelay (CLKFB_ipd, CLKFB, tipd_CLKFB);
5400
    VitalWireDelay (DSSEN_ipd, DSSEN, tipd_DSSEN);
5401
    VitalWireDelay (PSCLK_ipd, PSCLK, tipd_PSCLK);
5402
    VitalWireDelay (PSEN_ipd, PSEN, tipd_PSEN);
5403
    VitalWireDelay (PSINCDEC_ipd, PSINCDEC, tipd_PSINCDEC);
5404
    VitalWireDelay (RST_ipd, RST, tipd_RST);
5405
  end block;
5406
 
5407
  SignalDelay : block
5408
  begin
5409
    VitalSignalDelay (PSCLK_dly, PSCLK_ipd, ticd_PSCLK);
5410
    VitalSignalDelay (PSEN_dly, PSEN_ipd, tisd_PSEN_PSCLK);
5411
    VitalSignalDelay (PSINCDEC_dly, PSINCDEC_ipd, tisd_PSINCDEC_PSCLK);
5412
  end block;
5413
 
5414
  i_clock_divide_by_2 : x_dcm_clock_divide_by_2
5415
    port map (
5416
      clock => clkin_ipd,
5417
      clock_type => clkin_type,
5418
      rst => rst_ipd,
5419
      clock_out => clkin_div);
5420
 
5421
  i_max_clkin : x_dcm_maximum_period_check
5422
    generic map (
5423
      clock_name => "CLKIN",
5424
      maximum_period => MAXPERCLKIN)
5425
 
5426
    port map (
5427
      clock => clkin_ipd,
5428
      rst => rst_ipd);
5429
 
5430
  i_max_psclk : x_dcm_maximum_period_check
5431
    generic map (
5432
      clock_name => "PSCLK",
5433
      maximum_period => MAXPERPSCLK)
5434
 
5435
    port map (
5436
      clock => psclk_dly,
5437
      rst => rst_ipd);
5438
 
5439
  i_clkin_lost : x_dcm_clock_lost
5440
    port map (
5441
      lost  => clkin_lost_out,
5442
      clock => clkin_ipd,
5443
      enable => first_time_locked,
5444
      rst => rst_ipd
5445
      );
5446
 
5447
  i_clkfx_lost : x_dcm_clock_lost
5448
    port map (
5449
      lost  => clkfx_lost_out,
5450
      clock => clkfx_out,
5451
      enable => first_time_locked,
5452
      rst => rst_ipd
5453
      );
5454
 
5455
  clkin_ps <= transport clkin_div after ps_delay;
5456
 
5457
  clkin_fb <= transport (clkin_ps and lock_fb);
5458
 
5459
  detect_first_time_locked : process
5460
    begin
5461
      if (first_time_locked = false) then
5462
        if (rising_edge(locked_out)) then
5463
          first_time_locked <= true;
5464
        end if;
5465
      end if;
5466
      wait on locked_out;
5467
  end process detect_first_time_locked;
5468
 
5469
  set_reset_en_status : process
5470
  begin
5471
    if (rst_ipd = '1') then
5472
      en_status <= false;
5473
    elsif (rising_edge(Locked_sig)) then
5474
      en_status <= true;
5475
    end if;
5476
    wait on rst_ipd, Locked_sig;
5477
  end process set_reset_en_status;
5478
 
5479
  gen_clkfb_div_en: process
5480
  begin
5481
    if (rst_ipd = '1') then
5482
      clkfb_div_en <= '0';
5483
    elsif (falling_edge(clkfb_ipd)) then
5484
      if (lock_fb_dly='1' and lock_period='1' and lock_fb = '1' and clkin_ps = '0') then
5485
        clkfb_div_en <= '1';
5486
      end if;
5487
    end if;
5488
    wait on clkfb_ipd, rst_ipd;
5489
  end process  gen_clkfb_div_en;
5490
 
5491
   gen_clkfb_div: process
5492
  begin
5493
    if (rst_ipd = '1') then
5494
      clkfb_div <= '0';
5495
    elsif (rising_edge(clkfb_ipd)) then
5496
      if (clkfb_div_en='1') then
5497
        clkfb_div <= not clkfb_div;
5498
      end if;
5499
    end if;
5500
    wait on clkfb_ipd, rst_ipd;
5501
  end process  gen_clkfb_div;
5502
 
5503
  determine_clkfb_chk: process
5504
  begin
5505
    if (clkfb_type = 2) then
5506
      clkfb_chk <= clkfb_div;
5507
    else
5508
      clkfb_chk <= clkfb_ipd and lock_fb_dly;
5509
    end if;
5510
    wait on clkfb_ipd, clkfb_div;
5511
  end process  determine_clkfb_chk;
5512
 
5513
  set_reset_clkin_chkin : process
5514
  begin
5515
    if ((rising_edge(clkin_fb)) or (rising_edge(chk_rst))) then
5516
      if (chk_rst = '1') then
5517
        clkin_chkin <= '0';
5518
      else
5519
        clkin_chkin <= '1';
5520
      end if;
5521
    end if;
5522
    wait on clkin_fb, chk_rst;
5523
  end process set_reset_clkin_chkin;
5524
 
5525
  set_reset_clkfb_chkin : process
5526
  begin
5527
    if ((rising_edge(clkfb_chk)) or (rising_edge(chk_rst))) then
5528
      if (chk_rst = '1') then
5529
        clkfb_chkin <= '0';
5530
      else
5531
        clkfb_chkin <= '1';
5532
      end if;
5533
    end if;
5534
    wait on clkfb_chk, chk_rst;
5535
  end process set_reset_clkfb_chkin;
5536
 
5537
 
5538
--   assign_chk_rst: process
5539
--   begin
5540
--     if ((rst_ipd = '1') or (clock_stopped = '1')) then
5541
--       chk_rst <= '1';
5542
--     else
5543
--       chk_rst <= '0';  
5544
--     end if;
5545
--     wait on rst_ipd, clock_stopped;
5546
--   end process assign_chk_rst;
5547
 
5548
  chk_rst <= '1' when ((rst_ipd = '1') or (clock_stopped = '1')) else '0';
5549
 
5550
--   assign_chk_enable: process
5551
--   begin
5552
--     if ((clkin_chkin = '1') and (clkfb_chkin = '1')) then
5553
--       chk_enable <= '1';
5554
--     else
5555
--       chk_enable <= '0';  
5556
--     end if;
5557
--   wait on clkin_chkin, clkfb_chkin;  
5558
--   end process  assign_chk_enable;
5559
 
5560
  chk_enable <= '1' when ((clkin_chkin = '1') and (clkfb_chkin = '1') and (lock_ps = '1') and (lock_fb_dly = '1') and (lock_fb = '1')) else '0';
5561
 
5562
 
5563
 
5564
 
5565
  control_status_bits: process
5566
  begin
5567
    if ((rst_ipd = '1') or (en_status = false)) then
5568
      ps_overflow_out_ext <= '0';
5569
      clkin_lost_out_ext <= '0';
5570
      clkfx_lost_out_ext <= '0';
5571
    else
5572
      ps_overflow_out_ext <= ps_overflow_out;
5573
      clkin_lost_out_ext <= clkin_lost_out;
5574
      clkfx_lost_out_ext <= clkfx_lost_out;
5575
    end if;
5576
    wait on clkfx_lost_out, clkin_lost_out, en_status, ps_overflow_out, rst_ipd;
5577
  end process  control_status_bits;
5578
 
5579
  determine_period_div : process
5580
    variable clkin_div_edge_previous : time := 0 ps;
5581
    variable clkin_div_edge_current : time := 0 ps;
5582
  begin
5583
    if ((rising_edge(rst_ipd)) or (rst_ipd = '1')) then
5584
      clkin_div_edge_previous := 0 ps;
5585
      clkin_div_edge_current := 0 ps;
5586
      period_div <= 0 ps;
5587
    else
5588
      if (rising_edge(clkin_div)) then
5589
        clkin_div_edge_previous := clkin_div_edge_current;
5590
        clkin_div_edge_current := NOW;
5591
        if ((clkin_div_edge_current - clkin_div_edge_previous) <= (1.5 * period_div)) then
5592
          period_div <= clkin_div_edge_current - clkin_div_edge_previous;
5593
        elsif ((period_div = 0 ps) and (clkin_div_edge_previous /= 0 ps)) then
5594
          period_div <= clkin_div_edge_current - clkin_div_edge_previous;
5595
        end if;
5596
      end if;
5597
    end if;
5598
    wait on clkin_div, rst_ipd;
5599
  end process determine_period_div;
5600
 
5601
  determine_period_ps : process
5602
    variable clkin_ps_edge_previous : time := 0 ps;
5603
    variable clkin_ps_edge_current : time := 0 ps;
5604
  begin
5605
    if ((rising_edge(rst_ipd)) or (rst_ipd = '1')) then
5606
      clkin_ps_edge_previous := 0 ps;
5607
      clkin_ps_edge_current := 0 ps;
5608
      period_ps <= 0 ps;
5609
    else
5610
      if (rising_edge(clkin_ps)) then
5611
        clkin_ps_edge_previous := clkin_ps_edge_current;
5612
        clkin_ps_edge_current := NOW;
5613
        wait for 0 ps;
5614
        if ((clkin_ps_edge_current - clkin_ps_edge_previous) <= (1.5 * period_ps)) then
5615
          period_ps <= clkin_ps_edge_current - clkin_ps_edge_previous;
5616
        elsif ((period_ps = 0 ps) and (clkin_ps_edge_previous /= 0 ps)) then
5617
          period_ps <= clkin_ps_edge_current - clkin_ps_edge_previous;
5618
        end if;
5619
      end if;
5620
    end if;
5621
    wait on clkin_ps, rst_ipd;
5622
  end process determine_period_ps;
5623
 
5624
  assign_lock_ps_fb : process
5625
 
5626
  begin
5627
    if ((rising_edge(rst_ipd)) or (rst_ipd = '1')) then
5628
      lock_fb <= '0';
5629
      lock_ps <= '0';
5630
      lock_ps_dly <= '0';
5631
      lock_fb_dly <= '0';
5632
      lock_fb_dly_tmp <= '0';
5633
    else
5634
      if (rising_edge(clkin_ps)) then
5635
        lock_ps <= lock_period;
5636
        lock_ps_dly <= lock_ps;
5637
        lock_fb <= lock_ps_dly;
5638
        lock_fb_dly_tmp <= lock_fb;
5639
      end if;
5640
      if (falling_edge(clkin_ps)) then
5641
         lock_fb_dly <= lock_fb_dly_tmp after (period/4);
5642
      end if;
5643
    end if;
5644
    wait on clkin_ps, rst_ipd;
5645
  end process assign_lock_ps_fb;
5646
 
5647
  calculate_clkout_delay : process
5648
  begin
5649
    if ((rising_edge(rst_ipd)) or (rst_ipd = '1')) then
5650
      clkout_delay <= 0 ps;
5651
    elsif (fb_delay = 0 ps) then
5652
      clkout_delay <= 0 ps;
5653
    elsif (period'event or fb_delay'event) then
5654
      clkout_delay <= period - fb_delay;
5655
    end if;
5656
    wait on period, fb_delay, rst_ipd;
5657
  end process calculate_clkout_delay;
5658
 
5659
--
5660
--generate master reset signal
5661
--  
5662
 
5663
  gen_master_rst : process
5664
  begin
5665
    if (rising_edge(clkin_ipd)) then
5666
      rst_reg(2) <= rst_reg(1) and rst_reg(0) and rst_ipd;
5667
      rst_reg(1) <= rst_reg(0) and rst_ipd;
5668
      rst_reg(0) <= rst_ipd;
5669
    end if;
5670
    wait on clkin_ipd;
5671
  end process gen_master_rst;
5672
 
5673
  check_rst_width : process
5674
    variable Message : line;
5675
    begin
5676
      if (rst_ipd ='1') then
5677
          rst_flag <= '0';
5678
      end if;
5679
      if (falling_edge(rst_ipd)) then
5680
        if ((rst_reg(2) and rst_reg(1) and rst_reg(0)) = '0') then
5681
          rst_flag <= '1';
5682
          Write ( Message, string'(" Input Error : RST on X_DCM "));
5683
          Write ( Message, string'(" must be asserted for 3 CLKIN clock cycles. "));
5684
          assert false report Message.all severity error;
5685
          DEALLOCATE (Message);
5686
        end if;
5687
      end if;
5688
 
5689
      wait on rst_ipd;
5690
    end process check_rst_width;
5691
 
5692
--
5693
--phase shift parameters
5694
--  
5695
 
5696
  determine_phase_shift : process
5697
    variable Message : line;
5698
    variable  FINE_SHIFT_RANGE : time;
5699
    variable first_time : boolean := true;
5700
    variable ps_in : integer;
5701
  begin
5702
    if (first_time = true) then
5703
      if ((CLKOUT_PHASE_SHIFT = "none") or (CLKOUT_PHASE_SHIFT = "NONE")) then
5704
        ps_in := 256;
5705
      elsif ((CLKOUT_PHASE_SHIFT = "fixed") or (CLKOUT_PHASE_SHIFT = "FIXED")) then
5706
        ps_in := 256 + PHASE_SHIFT;
5707
      elsif ((CLKOUT_PHASE_SHIFT = "variable") or (CLKOUT_PHASE_SHIFT = "VARIABLE")) then
5708
        ps_in := 256 + PHASE_SHIFT;
5709
      end if;
5710
      first_time := false;
5711
    end if;
5712
    if ((rising_edge(rst_ipd)) or (rst_ipd = '1')) then
5713
      if ((CLKOUT_PHASE_SHIFT = "none") or (CLKOUT_PHASE_SHIFT = "NONE")) then
5714
        ps_in := 256;
5715
      elsif ((CLKOUT_PHASE_SHIFT = "fixed") or (CLKOUT_PHASE_SHIFT = "FIXED")) then
5716
        ps_in := 256 + PHASE_SHIFT;
5717
      elsif ((CLKOUT_PHASE_SHIFT = "variable") or (CLKOUT_PHASE_SHIFT = "VARIABLE")) then
5718
        ps_in := 256 + PHASE_SHIFT;
5719
      else
5720
      end if;
5721
      ps_lock <= '0';
5722
      ps_overflow_out <= '0';
5723
      ps_delay <= 0 ps;
5724
    else
5725
      if (rising_edge (lock_period)) then
5726
        if (ps_type = 1) then
5727
          FINE_SHIFT_RANGE := 10000 ps;
5728
        elsif (ps_type = 2) then
5729
          FINE_SHIFT_RANGE := 5000 ps;
5730
        end if;
5731
        if (PHASE_SHIFT > 0) then
5732
          if (((ps_in * period_orig) / 256) > (period_orig + FINE_SHIFT_RANGE)) then
5733
            Write ( Message, string'(" Function Error : Instance "));
5734
            Write ( Message, Instancepath );
5735
            Write ( Message, string'(" Requested Phase Shift = "));
5736
 
5737
            Write ( Message, string'(" PHASE_SHIFT * PERIOD/256 = "));
5738
            Write ( Message, PHASE_SHIFT);
5739
            Write ( Message, string'(" * "));
5740
            Write ( Message, period_orig / 256);
5741
            Write ( Message, string'(" = "));
5742
            Write ( Message, (PHASE_SHIFT) * period_orig / 256 );
5743
            Write ( Message, string'(" This exceeds the FINE_SHIFT_RANGE of "));
5744
            Write ( Message, FINE_SHIFT_RANGE);
5745
            assert false report Message.all severity error;
5746
            DEALLOCATE (Message);
5747
          end if;
5748
        elsif (PHASE_SHIFT < 0) then
5749
          if ((period_orig > FINE_SHIFT_RANGE) and ((ps_in * period_orig / 256) < period_orig - FINE_SHIFT_RANGE)) then
5750
            Write ( Message, string'(" Function Error : Instance "));
5751
            Write ( Message, Instancepath );
5752
            Write ( Message, string'(" Requested Phase Shift = "));
5753
 
5754
            Write ( Message, string'(" PHASE_SHIFT * PERIOD/256 = "));
5755
            Write ( Message, PHASE_SHIFT);
5756
            Write ( Message, string'(" * "));
5757
            Write ( Message, period_orig / 256);
5758
            Write ( Message, string'(" = "));
5759
            Write ( Message, (-PHASE_SHIFT) * period_orig / 256 );
5760
            Write ( Message, string'(" This exceeds the FINE_SHIFT_RANGE of "));
5761
            Write ( Message, FINE_SHIFT_RANGE);
5762
 
5763
            assert false report Message.all severity error;
5764
            DEALLOCATE (Message);
5765
          end if;
5766
        end if;
5767
      end if;
5768
      if (rising_edge(lock_period_pulse)) then
5769
        ps_delay <= (ps_in * period_div / 256);
5770
      end if;
5771
      if (rising_edge(PSCLK_dly)) then
5772
        if (ps_type = 2) then
5773
          if (psen_dly = '1') then
5774
            if (ps_lock = '1') then
5775
              Write ( Message, string'(" Warning : Please wait for PSDONE signal before adjusting the Phase Shift. "));
5776
              assert false report Message.all severity warning;
5777
              DEALLOCATE (Message);
5778
            else
5779
              if (psincdec_dly = '1') then
5780
                if (ps_in = 511) then
5781
                  ps_overflow_out <= '1';
5782
                elsif (((ps_in + 1) * period_orig / 256) > period_orig + FINE_SHIFT_RANGE) then
5783
                  ps_overflow_out <= '1';
5784
                else
5785
                  ps_in := ps_in + 1;
5786
                  ps_delay <= (ps_in * period_div / 256);
5787
                  ps_overflow_out <= '0';
5788
                end if;
5789
                ps_lock <= '1';
5790
              elsif (psincdec_dly = '0') then
5791
                if (ps_in = 1) then
5792
                  ps_overflow_out <= '1';
5793
                elsif ((period_orig > FINE_SHIFT_RANGE) and (((ps_in - 1) * period_orig / 256) < period_orig - FINE_SHIFT_RANGE)) then
5794
                  ps_overflow_out <= '1';
5795
                else
5796
                  ps_in := ps_in - 1;
5797
                  ps_delay <= (ps_in * period_div / 256);
5798
                  ps_overflow_out <= '0';
5799
                end if;
5800
                ps_lock <= '1';
5801
              end if;
5802
            end if;
5803
          end if;
5804
        end if;
5805
      end if;
5806
    end if;
5807
    if (ps_lock_reg'event) then
5808
      ps_lock <= ps_lock_reg;
5809
    end if;
5810
    wait on lock_period, lock_period_pulse, psclk_dly, ps_lock_reg, rst_ipd;
5811
  end process determine_phase_shift;
5812
 
5813
  determine_psdone_out : process
5814
  begin
5815
    if (rising_edge(ps_lock)) then
5816
      ps_lock_reg <= '1';
5817
      wait until (rising_edge(clkin_ps));
5818
      wait until (rising_edge(psclk_dly));
5819
      wait until (rising_edge(psclk_dly));
5820
      wait until (rising_edge(psclk_dly));
5821
      psdone_out <= '1';
5822
      wait until (rising_edge(psclk_dly));
5823
      psdone_out <= '0';
5824
      ps_lock_reg <= '0';
5825
    end if;
5826
    wait on ps_lock;
5827
  end process determine_psdone_out;
5828
 
5829
--
5830
--determine clock period
5831
--    
5832
  determine_clock_period : process
5833
    variable clkin_edge_previous : time := 0 ps;
5834
    variable clkin_edge_current : time := 0 ps;
5835
  begin
5836
    if ((rising_edge(rst_ipd)) or (rst_ipd = '1')) then
5837
      clkin_period_real(0) <= 0 ps;
5838
      clkin_period_real(1) <= 0 ps;
5839
      clkin_period_real(2) <= 0 ps;
5840
      clkin_edge_previous := 0 ps;
5841
      clkin_edge_current := 0 ps;
5842
    elsif (rising_edge(clkin_div)) then
5843
      clkin_edge_previous := clkin_edge_current;
5844
      clkin_edge_current := NOW;
5845
      clkin_period_real(2) <= clkin_period_real(1);
5846
      clkin_period_real(1) <= clkin_period_real(0);
5847
      if (clkin_edge_previous /= 0 ps) then
5848
        clkin_period_real(0) <= clkin_edge_current - clkin_edge_previous;
5849
      end if;
5850
    end if;
5851
    if (no_stop'event) then
5852
      clkin_period_real(0) <= clkin_period_real0_temp;
5853
    end if;
5854
    wait on clkin_div, no_stop, rst_ipd;
5855
  end process determine_clock_period;
5856
 
5857
  evaluate_clock_period : process
5858
    variable Message : line;
5859
  begin
5860
    if ((rising_edge(rst_ipd)) or (rst_ipd = '1')) then
5861
      lock_period <= '0';
5862
      clock_stopped <= '1';
5863
      clkin_period_real0_temp <= 0 ps;
5864
    else
5865
      if (falling_edge(clkin_div)) then
5866
        if (lock_period = '0') then
5867
          if ((clkin_period_real(0) /= 0 ps ) and (clkin_period_real(0) - cycle_jitter <= clkin_period_real(1)) and (clkin_period_real(1) <= clkin_period_real(0) + cycle_jitter) and (clkin_period_real(1) - cycle_jitter <= clkin_period_real(2)) and (clkin_period_real(2) <= clkin_period_real(1) + cycle_jitter)) then
5868
            lock_period <= '1';
5869
            period_orig <= (clkin_period_real(0) + clkin_period_real(1) + clkin_period_real(2)) / 3;
5870
            period <= clkin_period_real(0);
5871
          end if;
5872
        elsif (lock_period = '1') then
5873
          if (100000000 ns < clkin_period_real(0)) then
5874
            Write ( Message, string'(" Warning : CLKIN stopped toggling on instance "));
5875
            Write ( Message, Instancepath );
5876
            Write ( Message, string'(" exceeds "));
5877
            Write ( Message, string'(" 100 ms "));
5878
            Write ( Message, string'(" Current CLKIN Period = "));
5879
            Write ( Message, clkin_period_real(0));
5880
            assert false report Message.all severity warning;
5881
            DEALLOCATE (Message);
5882
            lock_period <= '0';
5883
            wait until (falling_edge(rst_reg(2)));
5884
          elsif ((period_orig * 2 < clkin_period_real(0)) and (clock_stopped = '0')) then
5885
              clkin_period_real0_temp <= clkin_period_real(1);
5886
              no_stop <= not no_stop;
5887
              clock_stopped <= '1';
5888
          elsif ((clkin_period_real(0) < period_orig - period_jitter) or (period_orig + period_jitter < clkin_period_real(0))) then
5889
            Write ( Message, string'(" Warning : Input Clock Period Jitter on instance "));
5890
            Write ( Message, Instancepath );
5891
            Write ( Message, string'(" exceeds "));
5892
            Write ( Message, period_jitter );
5893
            Write ( Message, string'(" Locked CLKIN Period =  "));
5894
            Write ( Message, period_orig );
5895
            Write ( Message, string'(" Current CLKIN Period =  "));
5896
            Write ( Message, clkin_period_real(0) );
5897
            assert false report Message.all severity warning;
5898
            DEALLOCATE (Message);
5899
            lock_period <= '0';
5900
            wait until (falling_edge(rst_reg(2)));
5901
          elsif ((clkin_period_real(0) < clkin_period_real(1) - cycle_jitter) or (clkin_period_real(1) + cycle_jitter < clkin_period_real(0))) then
5902
            Write ( Message, string'(" Warning : Input Clock Cycle Jitter on on instance "));
5903
            Write ( Message, Instancepath );
5904
            Write ( Message, string'(" exceeds "));
5905
            Write ( Message, cycle_jitter );
5906
            Write ( Message, string'(" Previous CLKIN Period =  "));
5907
            Write ( Message, clkin_period_real(1) );
5908
            Write ( Message, string'(" Current CLKIN Period =  "));
5909
            Write ( Message, clkin_period_real(0) );
5910
            assert false report Message.all severity warning;
5911
            DEALLOCATE (Message);
5912
            lock_period <= '0';
5913
            wait until (falling_edge(rst_reg(2)));
5914
          else
5915
            period <= clkin_period_real(0);
5916
            clock_stopped <= '0';
5917
          end if;
5918
        end if;
5919
      end if;
5920
    end if;
5921
    wait on clkin_div, rst_ipd;
5922
  end process evaluate_clock_period;
5923
 
5924
  lock_period_dly <= transport lock_period after period/2;
5925
 
5926
--   determine_lock_period_pulse: process
5927
--   begin
5928
--     if ((lock_period = '1') and (lock_period_dly = '0')) then
5929
--       lock_period_pulse <= '1';
5930
--     else
5931
--       lock_period_pulse <= '0';      
5932
--     end if;
5933
--     wait on lock_period, lock_period_dly;
5934
--   end process determine_lock_period_pulse;
5935
 
5936
  lock_period_pulse <= '1' when ((lock_period = '1') and (lock_period_dly = '0')) else '0';
5937
 
5938
--
5939
--determine clock delay
5940
--  
5941
 
5942
  determine_clock_delay : process
5943
    variable delay_edge : time := 0 ps;
5944
    variable temp1 : integer := 0;
5945
    variable temp2 : integer := 0;
5946
    variable temp : integer := 0;
5947
    variable delay_edge_current : time := 0 ps;
5948
  begin
5949
    if ((rising_edge(rst_ipd)) or (rst_ipd = '1')) then
5950
      fb_delay <= 0 ps;
5951
      fb_delay_found <= '0';
5952
    else
5953
      if (rising_edge(lock_ps_dly)) then
5954
        if  ((lock_period = '1') and (clkfb_type /= 0)) then
5955
          if (clkfb_type = 1) then
5956
            wait until ((rising_edge(clk0_sig)) or (rst_ipd'event));
5957
            delay_edge := NOW;
5958
          elsif (clkfb_type = 2) then
5959
            wait until ((rising_edge(clk2x_sig)) or (rst_ipd'event));
5960
            delay_edge := NOW;
5961
          end if;
5962
          wait until ((rising_edge(clkfb_ipd)) or (rst_ipd'event));
5963
          temp1 := ((NOW*1) - (delay_edge*1))/ (1 ps);
5964
          temp2 := (period_orig * 1)/ (1 ps);
5965
          temp := temp1 mod temp2;
5966
          fb_delay <= temp * 1 ps;
5967
          fb_delay_found <= '1';
5968
        end if;
5969
      end if;
5970
    end if;
5971
    wait on lock_ps_dly, rst_ipd;
5972
  end process determine_clock_delay;
5973
--
5974
--  determine feedback lock
5975
--  
5976
  GEN_CLKFB_WINDOW : process
5977
  begin
5978
    if ((rising_edge(rst_ipd)) or (rst_ipd = '1')) then
5979
      clkfb_window <= '0';
5980
    else
5981
      if (rising_edge(clkfb_chk)) then
5982
        wait for 0 ps;
5983
        clkfb_window <= '1';
5984
        wait for cycle_jitter;
5985
        clkfb_window <= '0';
5986
      end if;
5987
    end if;
5988
    wait on clkfb_chk, rst_ipd;
5989
  end process GEN_CLKFB_WINDOW;
5990
 
5991
  GEN_CLKIN_WINDOW : process
5992
  begin
5993
    if ((rising_edge(rst_ipd)) or (rst_ipd = '1')) then
5994
      clkin_window <= '0';
5995
    else
5996
      if (rising_edge(clkin_fb)) then
5997
        wait for 0 ps;
5998
        clkin_window <= '1';
5999
        wait for cycle_jitter;
6000
        clkin_window <= '0';
6001
      end if;
6002
    end if;
6003
    wait on clkin_fb, rst_ipd;
6004
  end process GEN_CLKIN_WINDOW;
6005
 
6006
  set_reset_lock_clkin : process
6007
  begin
6008
    if ((rising_edge(rst_ipd)) or (rst_ipd = '1')) then
6009
      lock_clkin <= '0';
6010
    else
6011
      if (rising_edge(clkin_fb)) then
6012
        wait for 1 ps;
6013
        if (((clkfb_window = '1') and (fb_delay_found = '1')) or ((clkin_lost_out = '1') and (lock_out(0) = '1'))) then
6014
          lock_clkin <= '1';
6015
        else
6016
          if (chk_enable = '1') then
6017
            lock_clkin <= '0';
6018
          end if;
6019
        end if;
6020
      end if;
6021
    end if;
6022
    wait on clkin_fb, rst_ipd;
6023
  end process set_reset_lock_clkin;
6024
 
6025
  set_reset_lock_clkfb : process
6026
  begin
6027
    if ((rising_edge(rst_ipd)) or (rst_ipd = '1')) then
6028
      lock_clkfb <= '0';
6029
    else
6030
      if (rising_edge(clkfb_chk)) then
6031
        wait for 1 ps;
6032
        if (((clkin_window = '1') and (fb_delay_found = '1')) or ((clkin_lost_out = '1') and (lock_out(0) = '1')))then
6033
          lock_clkfb <= '1';
6034
        else
6035
          if (chk_enable = '1') then
6036
            lock_clkfb <= '0';
6037
          end if;
6038
        end if;
6039
      end if;
6040
    end if;
6041
    wait on clkfb_chk, rst_ipd;
6042
  end process set_reset_lock_clkfb;
6043
 
6044
  assign_lock_delay : process
6045
  begin
6046
    if ((rising_edge(rst_ipd)) or (rst_ipd = '1')) then
6047
      lock_delay <= '0';
6048
    else
6049
      if (falling_edge(clkin_fb)) then
6050
        lock_delay <= lock_clkin or lock_clkfb;
6051
      end if;
6052
    end if;
6053
    wait on clkin_fb, rst_ipd;
6054
  end process;
6055
 
6056
--
6057
--generate lock signal
6058
--  
6059
 
6060
  generate_lock : process(clkin_ps, rst_ipd)
6061
  begin
6062
    if (rst_ipd='1') then
6063
      lock_out <= "00";
6064
      locked_out <= '0';
6065
      lock_out1_neg <= '0';
6066
    elsif (rising_edge(clkin_ps)) then
6067
        if (clkfb_type = 0) then
6068
          lock_out(0) <= lock_period;
6069
        else
6070
          lock_out(0) <= lock_period and lock_delay and lock_fb;
6071
        end if;
6072
        lock_out(1) <= lock_out(0);
6073
        locked_out <= lock_out(1);
6074
    elsif (falling_edge(clkin_ps)) then
6075
        lock_out1_neg <= lock_out(1);
6076
    end if;
6077
  end process generate_lock;
6078
 
6079
--
6080
--generate the clk1x_out
6081
--  
6082
 
6083
  gen_clk1x : process( clkin_ps, rst_ipd)
6084
  begin
6085
    if ((rising_edge(rst_ipd)) or (rst_ipd = '1')) then
6086
      clk0_out <= '0';
6087
    elsif (clkin_ps'event) then
6088
      if (clkin_ps = '1' ) then
6089
        if ((clk1x_type = 1) and (lock_out(0) = '1')) then
6090
          clk0_out <= '1', '0' after period/2;
6091
        else
6092
          clk0_out <= '1';
6093
        end if;
6094
      else
6095
        if ((clkin_ps = '0') and ((((clk1x_type = 1) and (lock_out(0) = '1')) = false) or ((lock_out(0) = '1') and (lock_out(1) = '0')))) then
6096
          clk0_out <= '0';
6097
        end if;
6098
      end if;
6099
    end if;
6100
  end process gen_clk1x;
6101
 
6102
 
6103
 
6104
 
6105
 
6106
--
6107
--generate the clk2x_out
6108
--    
6109
 
6110
  gen_clk2x : process
6111
  begin
6112
    if (rising_edge(rst_ipd) or (rst_ipd = '1')) then
6113
      clk2x_out <= '0';
6114
    else
6115
      if (rising_edge(clkin_ps)) then
6116
        clk2x_out <= '1';
6117
        wait for (period / 4);
6118
        clk2x_out <= '0';
6119
        wait for (period / 4);
6120
        clk2x_out <= '1';
6121
        wait for (period / 4);
6122
        clk2x_out <= '0';
6123
      end if;
6124
    end if;
6125
    wait on clkin_ps, rst_ipd;
6126
  end process gen_clk2x;
6127
 
6128
-- 
6129
--generate the clkdv_out
6130
-- 
6131
 
6132
  gen_clkdv : process (clkin_ps, rst_ipd)
6133
  begin
6134
    if (rst_ipd='1') then
6135
       clkdv_out <= '0';
6136
       clkdv_cnt <= 0;
6137
    elsif ((rising_edge(clkin_ps)) or (falling_edge(clkin_ps))) then
6138
      if (lock_out1_neg = '1') then
6139
         if (clkdv_cnt >= divide_type -1) then
6140
           clkdv_cnt <= 0;
6141
         else
6142
           clkdv_cnt <= clkdv_cnt + 1;
6143
         end if;
6144
 
6145
         if (clkdv_cnt < divide_type /2) then
6146
            clkdv_out <= '1';
6147
         else
6148
           if ( ((divide_type rem (2)) > 0) and (dll_mode_type = 0)) then
6149
             clkdv_out <= '0' after (period/4);
6150
           else
6151
            clkdv_out <= '0';
6152
           end if;
6153
         end if;
6154
      end if;
6155
    end if;
6156
  end process;
6157
 
6158
--
6159
-- generate fx output signal
6160
--
6161
 
6162
  calculate_period_fx : process
6163
  begin
6164
    if (lock_period = '1') then
6165
      period_fx <= (period * denominator) / (numerator * 2);
6166
      remain_fx <= (((period/1 ps) * denominator) mod (numerator * 2)) * 1 ps;
6167
    end if;
6168
    wait on lock_period, period, denominator, numerator;
6169
  end process calculate_period_fx;
6170
 
6171
  generate_clkfx : process
6172
    variable temp : integer;
6173
  begin
6174
    if (rst_ipd = '1') then
6175
      clkfx_out <= '0';
6176
    elsif (clkin_lost_out_ext = '1') then
6177
       wait until (rising_edge(rst_ipd));
6178
       clkfx_out <= '0';
6179
      wait until (falling_edge(rst_reg(2)));
6180
    elsif (rising_edge(clkin_ps)) then
6181
      if (lock_out(1) = '1') then
6182
        clkfx_out <= '1';
6183
        temp := numerator * 2 - 1 - 1;
6184
        for p in 0 to temp loop
6185
          wait for (period_fx);
6186
          clkfx_out <= not clkfx_out;
6187
        end loop;
6188
        if (period_fx > (period / 2)) then
6189
          wait for (period_fx - (period / 2));
6190
        end if;
6191
      end if;
6192
      if (clkin_lost_out_ext = '1') then
6193
        wait until (rising_edge(rst_ipd));
6194
        clkfx_out <= '0';
6195
        wait until (falling_edge(rst_reg(2)));
6196
      end if;
6197
    end if;
6198
    wait on clkin_lost_out_ext, clkin_ps, rst_ipd, rst_reg(2);
6199
  end process generate_clkfx;
6200
 
6201
 
6202
--
6203
--generate all output signal
6204
--
6205
 
6206
  schedule_p1_outputs : process
6207
  begin
6208
    if (CLK0_out'event) then
6209
      if (clkfb_type /= 0) then
6210
        CLK0 <= transport CLK0_out after clkout_delay;
6211
        clk0_sig <= transport CLK0_out after clkout_delay;
6212
      end if;
6213
      if ((dll_mode_type = 0) and (clkfb_type /= 0)) then
6214
        CLK90 <= transport clk0_out after (clkout_delay + period / 4);
6215
      end if;
6216
    end if;
6217
 
6218
    if (CLK0_out'event or rst_ipd'event)then
6219
      if (rst_ipd = '1') then
6220
        CLK180 <= '0';
6221
        CLK270 <= '0';
6222
      elsif (CLK0_out'event) then
6223
        if (clkfb_type /= 0) then
6224
          CLK180 <= transport (not clk0_out) after clkout_delay;
6225
        end if;
6226
        if ((dll_mode_type = 0) and (clkfb_type /= 0)) then
6227
          CLK270 <= transport (not clk0_out) after (clkout_delay + period/4);
6228
        end if;
6229
      end if;
6230
    end if;
6231
 
6232
    if (clk2x_out'event) then
6233
      if ((dll_mode_type = 0) and (clkfb_type /= 0)) then
6234
        CLK2X <= transport clk2x_out after clkout_delay;
6235
        clk2x_sig <= transport clk2x_out after clkout_delay;
6236
      end if;
6237
    end if;
6238
 
6239
    if (CLK2X_out'event or rst_ipd'event) then
6240
      if (rst_ipd = '1') then
6241
        CLK2X180 <= '0';
6242
      elsif (CLK2X_out'event) then
6243
        if ((dll_mode_type = 0) and (clkfb_type /= 0)) then
6244
          CLK2X180 <= transport (not CLK2X_out) after clkout_delay;
6245
        end if;
6246
      end if;
6247
    end if;
6248
 
6249
 
6250
    if (clkdv_out'event) then
6251
      if (clkfb_type /= 0) then
6252
        CLKDV <= transport clkdv_out after clkout_delay;
6253
      end if;
6254
    end if;
6255
 
6256
    if (clkfx_out'event or rst_ipd'event) then
6257
      if (rst_ipd = '1') then
6258
        CLKFX <= '0';
6259
      elsif (clkfx_out'event) then
6260
        CLKFX <= transport clkfx_out after clkout_delay;
6261
      end if;
6262
    end if;
6263
 
6264
    if (clkfx_out'event or (rising_edge(rst_ipd)) or first_time_locked'event or locked_out'event) then
6265
      if ((rst_ipd = '1') or (not first_time_locked)) then
6266
        CLKFX180 <= '0';
6267
      else
6268
        CLKFX180 <= transport (not clkfx_out) after clkout_delay;
6269
      end if;
6270
    end if;
6271
 
6272
    if (status_out(0)'event) then
6273
      status(0) <= status_out(0);
6274
    end if;
6275
 
6276
    if (status_out(1)'event) then
6277
      status(1) <= status_out(1);
6278
    end if;
6279
 
6280
    if (status_out(2)'event) then
6281
      status(2) <= status_out(2);
6282
    end if;
6283
 
6284
   wait on clk0_out, clk2x_out, clkdv_out, clkfx_out, first_time_locked, locked_out, rst_ipd, status_out;
6285
   end process;
6286
 
6287
  assign_status_out : process
6288
    begin
6289
      if (rst_ipd = '1') then
6290
        status_out(0) <= '0';
6291
        status_out(1) <= '0';
6292
        status_out(2) <= '0';
6293
      elsif (ps_overflow_out_ext'event) then
6294
        status_out(0) <= ps_overflow_out_ext;
6295
      elsif (clkin_lost_out_ext'event) then
6296
        status_out(1) <= clkin_lost_out_ext;
6297
      elsif (clkfx_lost_out_ext'event) then
6298
        status_out(2) <= clkfx_lost_out_ext;
6299
      end if;
6300
      wait on clkin_lost_out_ext, clkfx_lost_out_ext, ps_overflow_out_ext, rst_ipd;
6301
    end process assign_status_out;
6302
 
6303
   locked_out_out <= 'X' when rst_flag = '1' else locked_out;
6304
 
6305
-- LOCKED <= locked_out_out;
6306
-- PSDONE <= psdone_out;
6307
-- LOCKED_sig <= locked_out_out;    
6308
 
6309
  schedule_outputs : process
6310
    variable PSDONE_GlitchData : VitalGlitchDataType;
6311
    variable LOCKED_GlitchData : VitalGlitchDataType;
6312
  begin
6313
    VitalPathDelay01 (
6314
      OutSignal  => PSDONE,
6315
      GlitchData => PSDONE_GlitchData,
6316
      OutSignalName => "PSDONE",
6317
      OutTemp => psdone_out,
6318
      Paths => (0 => (psdone_out'last_event, tpd_PSCLK_PSDONE, true)),
6319
      Mode => OnEvent,
6320
      Xon => Xon,
6321
      MsgOn => MsgOn,
6322
      MsgSeverity => warning
6323
      );
6324
    LOCKED_sig <= locked_out_out after tpd_CLKIN_LOCKED(tr01);
6325
    VitalPathDelay01 (
6326
      OutSignal  => LOCKED,
6327
      GlitchData => LOCKED_GlitchData,
6328
      OutSignalName => "LOCKED",
6329
      OutTemp => locked_out_out,
6330
      Paths => (0 => (locked_out_out'last_event, tpd_CLKIN_LOCKED, true)),
6331
      Mode => OnEvent,
6332
      Xon => Xon,
6333
      MsgOn => MsgOn,
6334
      MsgSeverity => warning
6335
      );
6336
    wait on  locked_out_out, psdone_out;
6337
  end process schedule_outputs;
6338
 
6339
  VitalTimingCheck : process
6340
    variable Tviol_PSINCDEC_PSCLK_posedge : std_ulogic := '0';
6341
    variable Tmkr_PSINCDEC_PSCLK_posedge  : VitalTimingDataType := VitalTimingDataInit;
6342
    variable Tviol_PSEN_PSCLK_posedge        : std_ulogic := '0';
6343
    variable Tmkr_PSEN_PSCLK_posedge : VitalTimingDataType := VitalTimingDataInit;
6344
    variable Pviol_CLKIN   : std_ulogic := '0';
6345
    variable PInfo_CLKIN   : VitalPeriodDataType := VitalPeriodDataInit;
6346
    variable Pviol_PSCLK   : std_ulogic := '0';
6347
    variable PInfo_PSCLK   : VitalPeriodDataType := VitalPeriodDataInit;
6348
    variable Pviol_RST   : std_ulogic := '0';
6349
    variable PInfo_RST   : VitalPeriodDataType := VitalPeriodDataInit;
6350
 
6351
  begin
6352
    if (TimingChecksOn) then
6353
      VitalSetupHoldCheck (
6354
        Violation               => Tviol_PSINCDEC_PSCLK_posedge,
6355
        TimingData              => Tmkr_PSINCDEC_PSCLK_posedge,
6356
        TestSignal              => PSINCDEC_dly,
6357
        TestSignalName          => "PSINCDEC",
6358
        TestDelay               => tisd_PSINCDEC_PSCLK,
6359
        RefSignal               => PSCLK_dly,
6360
        RefSignalName          => "PSCLK",
6361
        RefDelay                => ticd_PSCLK,
6362
        SetupHigh               => tsetup_PSINCDEC_PSCLK_posedge_posedge,
6363
        SetupLow                => tsetup_PSINCDEC_PSCLK_negedge_posedge,
6364
        HoldLow                => thold_PSINCDEC_PSCLK_posedge_posedge,
6365
        HoldHigh                 => thold_PSINCDEC_PSCLK_negedge_posedge,
6366
        CheckEnabled            => (TO_X01(((NOT RST_ipd)) AND (PSEN_dly)) /= '0'),
6367
        RefTransition           => 'R',
6368
        HeaderMsg               => InstancePath & "/X_DCM",
6369
        Xon                     => Xon,
6370
        MsgOn                   => MsgOn,
6371
        MsgSeverity             => warning);
6372
 
6373
      VitalSetupHoldCheck (
6374
        Violation               => Tviol_PSEN_PSCLK_posedge,
6375
        TimingData              => Tmkr_PSEN_PSCLK_posedge,
6376
        TestSignal              => PSEN_dly,
6377
        TestSignalName          => "PSEN",
6378
        TestDelay               => tisd_PSEN_PSCLK,
6379
        RefSignal               => PSCLK_dly,
6380
        RefSignalName          => "PSCLK",
6381
        RefDelay                => ticd_PSCLK,
6382
        SetupHigh               => tsetup_PSEN_PSCLK_posedge_posedge,
6383
        SetupLow                => tsetup_PSEN_PSCLK_negedge_posedge,
6384
        HoldLow                => thold_PSEN_PSCLK_posedge_posedge,
6385
        HoldHigh                 => thold_PSEN_PSCLK_negedge_posedge,
6386
        CheckEnabled            => TO_X01(NOT RST_ipd)  /= '0',
6387
        RefTransition           => 'R',
6388
        HeaderMsg               => InstancePath & "/X_DCM",
6389
        Xon                     => Xon,
6390
        MsgOn                   => MsgOn,
6391
        MsgSeverity             => warning);
6392
 
6393
      VitalPeriodPulseCheck (
6394
        Violation               => Pviol_PSCLK,
6395
        PeriodData              => PInfo_PSCLK,
6396
        TestSignal              => PSCLK_dly,
6397
        TestSignalName          => "PSCLK",
6398
        TestDelay               => 0 ns,
6399
        Period                  => tperiod_PSCLK_POSEDGE,
6400
        PulseWidthHigh          => tpw_PSCLK_posedge,
6401
        PulseWidthLow           => tpw_PSCLK_negedge,
6402
        CheckEnabled            => true,
6403
        HeaderMsg               => InstancePath &"/X_DCM",
6404
        Xon                     => Xon,
6405
        MsgOn                   => MsgOn,
6406
        MsgSeverity             => warning);
6407
 
6408
      VitalPeriodPulseCheck (
6409
        Violation               => Pviol_CLKIN,
6410
        PeriodData              => PInfo_CLKIN,
6411
        TestSignal              => CLKIN_ipd,
6412
        TestSignalName          => "CLKIN",
6413
        TestDelay               => 0 ns,
6414
        Period                  => tperiod_CLKIN_POSEDGE,
6415
        PulseWidthHigh          => tpw_CLKIN_posedge,
6416
        PulseWidthLow           => tpw_CLKIN_negedge,
6417
        CheckEnabled            => TO_X01(NOT RST_ipd)  /= '0',
6418
        HeaderMsg               => InstancePath &"/X_DCM",
6419
        Xon                     => Xon,
6420
        MsgOn                   => MsgOn,
6421
        MsgSeverity             => warning);
6422
 
6423
      VitalPeriodPulseCheck (
6424
        Violation               => Pviol_RST,
6425
        PeriodData              => PInfo_RST,
6426
        TestSignal              => RST_ipd,
6427
        TestSignalName          => "RST",
6428
        TestDelay               => 0 ns,
6429
        Period                  => 0 ns,
6430
        PulseWidthHigh          => tpw_RST_posedge,
6431
        PulseWidthLow           => 0 ns,
6432
        CheckEnabled            => true,
6433
        HeaderMsg               => InstancePath &"/X_DCM",
6434
        Xon                     => Xon,
6435
        MsgOn                   => MsgOn,
6436
        MsgSeverity             => warning);
6437
    end if;
6438
    wait on CLKIN_ipd, PSCLK_dly, PSEN_dly, PSINCDEC_dly, RST_ipd;
6439
  end process VITALTimingCheck;
6440
end X_DCM_V;
6441
-------------------------------------------------------------------------------
6442
-- Copyright (c) 1995/2004 Xilinx, Inc.
6443
-- All Right Reserved.
6444
-------------------------------------------------------------------------------
6445
--   ____  ____
6446
--  /   /\/   /
6447
-- /___/  \  /    Vendor : Xilinx
6448
-- \   \   \/     Version : 9.1i
6449
--  \   \         Description : Xilinx Timing Simulation Library Component
6450
--  /   /                  Digital Clock Manager
6451
-- /___/   /\     Filename : X_DCM_SP.vhd
6452
-- \   \  /  \    Timestamp : Fri Jun 18 10:57:08 PDT 2004
6453
--  \___\/\___\
6454
--
6455
-- Revision:
6456
--    03/06/06 - Initial version.
6457
--    05/09/06 - Add clkin_ps_mkup and clkin_ps_mkup_win for phase shifting (CR 229789).
6458
--    06/14/06 - Add period_int2 and period_int3 for multiple cycle phase shifting (CR 233283).
6459
--        07/21/06 - Change range of variable phase shifting to +/- integer of 20*(Period-3ns).
6460
--               Give warning not support initial phase shifting for variable phase shifting.
6461
--               (CR 235216).
6462
--    09/22/06 - Add lock_period and lock_fb to clkfb_div block (CR 418722).
6463
--    12/19/06 - Add clkfb_div_en for clkfb2x divider (CR431210).
6464
--    04/06/07 - Enable the clock out in clock low time after reset in model
6465
--               clock_divide_by_2  (CR 437471).
6466
-- End Revision
6467
 
6468
 
6469
----- x_dcm_sp_clock_divide_by_2 -----
6470
library IEEE;
6471
use IEEE.STD_LOGIC_1164.all;
6472
 
6473
entity x_dcm_sp_clock_divide_by_2 is
6474
  port(
6475
    clock_out : out std_ulogic := '0';
6476
 
6477
    clock : in std_ulogic;
6478
    clock_type : in integer;
6479
    rst : in std_ulogic
6480
    );
6481
end x_dcm_sp_clock_divide_by_2;
6482
 
6483
architecture x_dcm_sp_clock_divide_by_2_V of x_dcm_sp_clock_divide_by_2 is
6484
  signal clock_div2 : std_ulogic := '0';
6485
  signal rst_reg : std_logic_vector(2 downto 0);
6486
  signal clk_src : std_ulogic;
6487
begin
6488
 
6489
  CLKIN_DIVIDER : process
6490
  begin
6491
    if (rising_edge(clock)) then
6492
      clock_div2 <= not clock_div2;
6493
    end if;
6494
    wait on clock;
6495
  end process CLKIN_DIVIDER;
6496
 
6497
  gen_reset : process
6498
  begin
6499
    if (rising_edge(clock)) then
6500
      rst_reg(0) <= rst;
6501
      rst_reg(1) <= rst_reg(0) and rst;
6502
      rst_reg(2) <= rst_reg(1) and rst_reg(0) and rst;
6503
    end if;
6504
    wait on clock;
6505
  end process gen_reset;
6506
 
6507
  clk_src <= clock_div2 when (clock_type = 1) else clock;
6508
 
6509
  assign_clkout : process
6510
  begin
6511
    if (rst = '0') then
6512
      clock_out <= clk_src;
6513
    elsif (rst = '1') then
6514
      clock_out <= '0';
6515
      wait until falling_edge(rst_reg(2));
6516
      if (clk_src = '1') then
6517
         wait until falling_edge(clk_src);
6518
      end if;
6519
    end if;
6520
    wait on clk_src, rst, rst_reg;
6521
  end process assign_clkout;
6522
end x_dcm_sp_clock_divide_by_2_V;
6523
 
6524
----- x_dcm_sp_maximum_period_check  -----
6525
library IEEE;
6526
use IEEE.STD_LOGIC_1164.all;
6527
 
6528
library STD;
6529
use STD.TEXTIO.all;
6530
 
6531
entity x_dcm_sp_maximum_period_check is
6532
  generic (
6533
    InstancePath : string := "*";
6534
 
6535
    clock_name : string := "";
6536
    maximum_period : time);
6537
  port(
6538
    clock : in std_ulogic;
6539
    rst : in std_ulogic
6540
    );
6541
end x_dcm_sp_maximum_period_check;
6542
 
6543
architecture x_dcm_sp_maximum_period_check_V of x_dcm_sp_maximum_period_check is
6544
begin
6545
 
6546
  MAX_PERIOD_CHECKER : process
6547
    variable clock_edge_previous : time := 0 ps;
6548
    variable clock_edge_current : time := 0 ps;
6549
    variable clock_period : time := 0 ps;
6550
    variable Message : line;
6551
  begin
6552
 
6553
   if (rising_edge(clock)) then
6554
    clock_edge_previous := clock_edge_current;
6555
    clock_edge_current := NOW;
6556
 
6557
    if (clock_edge_previous > 0 ps) then
6558
      clock_period := clock_edge_current - clock_edge_previous;
6559
    end if;
6560
 
6561
    if (clock_period > maximum_period and  rst = '0') then
6562
      Write ( Message, string'(" Warning : Input Clock Period of "));
6563
      Write ( Message, clock_period );
6564
      Write ( Message, string'(" on the ") );
6565
      Write ( Message, clock_name );
6566
      Write ( Message, string'(" port ") );
6567
      Write ( Message, string'(" of X_DCM_SP instance ") );
6568
      Write ( Message, string'(" exceeds allowed value of ") );
6569
      Write ( Message, maximum_period );
6570
      Write ( Message, string'(" at simulation time ") );
6571
      Write ( Message, clock_edge_current );
6572
      Write ( Message, '.' & LF );
6573
      assert false report Message.all severity warning;
6574
      DEALLOCATE (Message);
6575
    end if;
6576
   end if;
6577
    wait on clock;
6578
  end process MAX_PERIOD_CHECKER;
6579
end x_dcm_sp_maximum_period_check_V;
6580
 
6581
----- x_dcm_sp_clock_lost  -----
6582
library IEEE;
6583
use IEEE.STD_LOGIC_1164.all;
6584
 
6585
entity x_dcm_sp_clock_lost is
6586
  port(
6587
    lost : out std_ulogic := '0';
6588
 
6589
    clock : in std_ulogic;
6590
    enable : in boolean := false;
6591
    rst :  in std_ulogic
6592
    );
6593
end x_dcm_sp_clock_lost;
6594
 
6595
architecture x_dcm_sp_clock_lost_V of x_dcm_sp_clock_lost is
6596
  signal period : time := 0 ps;
6597
  signal lost_r : std_ulogic := '0';
6598
  signal lost_f : std_ulogic := '0';
6599
  signal lost_sig : std_ulogic := '0';
6600
  signal clock_negedge, clock_posedge : std_ulogic;
6601
  signal clock_low, clock_high : std_ulogic := '0';
6602
  signal clock_second_pos, clock_second_neg : std_ulogic := '0';
6603
begin
6604
  determine_period : process
6605
    variable clock_edge_previous : time := 0 ps;
6606
    variable clock_edge_current : time := 0 ps;
6607
  begin
6608
      if (rst = '1') then
6609
        period <= 0 ps;
6610
      elsif (rising_edge(clock)) then
6611
        clock_edge_previous := clock_edge_current;
6612
        clock_edge_current := NOW;
6613
        if (period /= 0 ps and ((clock_edge_current - clock_edge_previous) <= (1.5 * period))) then
6614
          period <= NOW - clock_edge_previous;
6615
        elsif (period /= 0 ps and ((NOW - clock_edge_previous) > (1.5 * period))) then
6616
          period <= 0 ps;
6617
        elsif ((period = 0 ps) and (clock_edge_previous /= 0 ps) and (clock_second_pos = '1')) then
6618
          period <= NOW - clock_edge_previous;
6619
        end if;
6620
      end if;
6621
    wait on clock, rst;
6622
  end process determine_period;
6623
 
6624
  CLOCK_LOST_CHECKER : process
6625
 
6626
  begin
6627
      if (rst = '1') then
6628
        clock_low <= '0';
6629
        clock_high <= '0';
6630
        clock_posedge <= '0';
6631
        clock_negedge <= '0';
6632
      else
6633
        if (rising_edge(clock)) then
6634
          clock_low <= '0';
6635
          clock_high <= '1';
6636
          clock_posedge <= '0';
6637
          clock_negedge <= '1';
6638
        end if;
6639
 
6640
        if (falling_edge(clock)) then
6641
          clock_high <= '0';
6642
          clock_low <= '1';
6643
          clock_posedge <= '1';
6644
          clock_negedge <= '0';
6645
        end if;
6646
      end if;
6647
 
6648
    wait on clock, rst;
6649
  end process CLOCK_LOST_CHECKER;
6650
 
6651
  CLOCK_SECOND_P : process
6652
    begin
6653
      if (rst = '1') then
6654
        clock_second_pos <= '0';
6655
        clock_second_neg <= '0';
6656
    else
6657
      if (rising_edge(clock)) then
6658
        clock_second_pos <= '1';
6659
      end if;
6660
      if (falling_edge(clock)) then
6661
          clock_second_neg <= '1';
6662
      end if;
6663
    end if;
6664
    wait on clock, rst;
6665
  end process CLOCK_SECOND_P;
6666
 
6667
  SET_RESET_LOST_R : process
6668
    begin
6669
    if (rst = '1') then
6670
      lost_r <= '0';
6671
    else
6672
      if ((enable = true) and (clock_second_pos = '1'))then
6673
        if (rising_edge(clock)) then
6674
          wait for 1 ps;
6675
          if (period /= 0 ps) then
6676
            lost_r <= '0';
6677
          end if;
6678
          wait for (period * (9.1/10.0));
6679
          if ((clock_low /= '1') and (clock_posedge /= '1') and (rst = '0')) then
6680
            lost_r <= '1';
6681
          end if;
6682
        end if;
6683
      end if;
6684
    end if;
6685
    wait on clock, rst;
6686
  end process SET_RESET_LOST_R;
6687
 
6688
  SET_RESET_LOST_F : process
6689
    begin
6690
      if (rst = '1') then
6691
        lost_f <= '0';
6692
      else
6693
        if ((enable = true) and (clock_second_neg = '1'))then
6694
          if (falling_edge(clock)) then
6695
            if (period /= 0 ps) then
6696
              lost_f <= '0';
6697
            end if;
6698
            wait for (period * (9.1/10.0));
6699
            if ((clock_high /= '1') and (clock_negedge /= '1') and (rst = '0')) then
6700
              lost_f <= '1';
6701
            end if;
6702
          end if;
6703
        end if;
6704
      end if;
6705
    wait on clock, rst;
6706
  end process SET_RESET_LOST_F;
6707
 
6708
  assign_lost : process
6709
    begin
6710
      if (enable = true) then
6711
        if (lost_r'event) then
6712
          lost <= lost_r;
6713
        end if;
6714
        if (lost_f'event) then
6715
          lost <= lost_f;
6716
        end if;
6717
      end if;
6718
      wait on lost_r, lost_f;
6719
    end process assign_lost;
6720
end x_dcm_sp_clock_lost_V;
6721
 
6722
 
6723
----- CELL X_DCM_SP  -----
6724
library IEEE;
6725
use IEEE.std_logic_1164.all;
6726
 
6727
library IEEE;
6728
use IEEE.VITAL_Timing.all;
6729
use IEEE.VITAL_Primitives.all;
6730
 
6731
library STD;
6732
use STD.TEXTIO.all;
6733
 
6734
library unisim;
6735
use unisim.vpkg.all;
6736
 
6737
entity X_DCM_SP is
6738
  generic (
6739
    TimingChecksOn : boolean := true;
6740
    InstancePath : string := "*";
6741
    Xon : boolean := true;
6742
    MsgOn : boolean := false;
6743
    LOC   : string  := "UNPLACED";
6744
 
6745
    thold_PSEN_PSCLK_negedge_posedge : VitalDelayType := 0.000 ns;
6746
    thold_PSEN_PSCLK_posedge_posedge : VitalDelayType := 0.000 ns;
6747
    thold_PSINCDEC_PSCLK_negedge_posedge : VitalDelayType := 0.000 ns;
6748
    thold_PSINCDEC_PSCLK_posedge_posedge : VitalDelayType := 0.000 ns;
6749
 
6750
    ticd_PSCLK :  VitalDelayType := 0.000 ns;
6751
 
6752
    tipd_CLKFB : VitalDelayType01 := (0.000 ns, 0.000 ns);
6753
    tipd_CLKIN : VitalDelayType01 := (0.000 ns, 0.000 ns);
6754
    tipd_DSSEN : VitalDelayType01 := (0.000 ns, 0.000 ns);
6755
    tipd_PSCLK : VitalDelayType01 := (0.000 ns, 0.000 ns);
6756
    tipd_PSEN : VitalDelayType01 := (0.000 ns, 0.000 ns);
6757
    tipd_PSINCDEC : VitalDelayType01 := (0.000 ns, 0.000 ns);
6758
    tipd_RST : VitalDelayType01 := (0.000 ns, 0.000 ns);
6759
 
6760
    tisd_PSINCDEC_PSCLK :  VitalDelayType := 0.000 ns;
6761
    tisd_PSEN_PSCLK :  VitalDelayType := 0.000 ns;
6762
 
6763
    tpd_CLKIN_LOCKED : VitalDelayType01 := (0.100 ns, 0.100 ns);
6764
    tpd_PSCLK_PSDONE : VitalDelayType01 := (0.100 ns, 0.100 ns);
6765
 
6766
    tperiod_CLKIN_POSEDGE : VitalDelayType := 0.000 ns;
6767
    tperiod_PSCLK_POSEDGE : VitalDelayType := 0.000 ns;
6768
 
6769
    tpw_CLKIN_negedge : VitalDelayType := 0.000 ns;
6770
    tpw_CLKIN_posedge : VitalDelayType := 0.000 ns;
6771
    tpw_PSCLK_negedge : VitalDelayType := 0.000 ns;
6772
    tpw_PSCLK_posedge : VitalDelayType := 0.000 ns;
6773
    tpw_RST_posedge : VitalDelayType := 0.000 ns;
6774
 
6775
    tsetup_PSEN_PSCLK_negedge_posedge : VitalDelayType := 0.000 ns;
6776
    tsetup_PSEN_PSCLK_posedge_posedge : VitalDelayType := 0.000 ns;
6777
    tsetup_PSINCDEC_PSCLK_negedge_posedge : VitalDelayType := 0.000 ns;
6778
    tsetup_PSINCDEC_PSCLK_posedge_posedge : VitalDelayType := 0.000 ns;
6779
 
6780
    CLKDV_DIVIDE : real := 2.0;
6781
    CLKFX_DIVIDE : integer := 1;
6782
    CLKFX_MULTIPLY : integer := 4;
6783
    CLKIN_DIVIDE_BY_2 : boolean := false;
6784
    CLKIN_PERIOD : real := 10.0;                         --non-simulatable
6785
    CLKOUT_PHASE_SHIFT : string := "NONE";
6786
    CLK_FEEDBACK : string := "1X";
6787
    DESKEW_ADJUST : string := "SYSTEM_SYNCHRONOUS";     --non-simulatable
6788
    DFS_FREQUENCY_MODE : string := "LOW";
6789
    DLL_FREQUENCY_MODE : string := "LOW";
6790
    DSS_MODE : string := "NONE";                        --non-simulatable
6791
    DUTY_CYCLE_CORRECTION : boolean := true;
6792
    FACTORY_JF : bit_vector := X"C080";                 --non-simulatable
6793
    MAXPERCLKIN : time := 1000000 ps;                   --non-modifiable simulation parameter
6794
    MAXPERPSCLK : time := 100000000 ps;                 --non-modifiable simulation parameter
6795
    PHASE_SHIFT : integer := 0;
6796
    SIM_CLKIN_CYCLE_JITTER : time := 300 ps;            --non-modifiable simulation parameter
6797
    SIM_CLKIN_PERIOD_JITTER : time := 1000 ps;          --non-modifiable simulation parameter
6798
    STARTUP_WAIT : boolean := false                     --non-simulatable
6799
    );
6800
 
6801
  port (
6802
    CLK0 : out std_ulogic := '0';
6803
    CLK180 : out std_ulogic := '0';
6804
    CLK270 : out std_ulogic := '0';
6805
    CLK2X : out std_ulogic := '0';
6806
    CLK2X180 : out std_ulogic := '0';
6807
    CLK90 : out std_ulogic := '0';
6808
    CLKDV : out std_ulogic := '0';
6809
    CLKFX : out std_ulogic := '0';
6810
    CLKFX180 : out std_ulogic := '0';
6811
    LOCKED : out std_ulogic := '0';
6812
    PSDONE : out std_ulogic := '0';
6813
    STATUS : out std_logic_vector(7 downto 0) := "00000000";
6814
 
6815
    CLKFB : in std_ulogic := '0';
6816
    CLKIN : in std_ulogic := '0';
6817
    DSSEN : in std_ulogic := '0';
6818
    PSCLK : in std_ulogic := '0';
6819
    PSEN : in std_ulogic := '0';
6820
    PSINCDEC : in std_ulogic := '0';
6821
    RST : in std_ulogic := '0'
6822
    );
6823
 
6824
  attribute VITAL_LEVEL0 of X_DCM_SP : entity is true;
6825
 
6826
end X_DCM_SP;
6827
 
6828
architecture X_DCM_SP_V of X_DCM_SP is
6829
 
6830
 
6831
  component x_dcm_sp_clock_divide_by_2
6832
    port(
6833
      clock_out : out std_ulogic;
6834
 
6835
      clock : in std_ulogic;
6836
      clock_type : in integer;
6837
      rst : in std_ulogic
6838
      );
6839
  end component;
6840
 
6841
  component x_dcm_sp_maximum_period_check
6842
    generic (
6843
      InstancePath : string := "*";
6844
 
6845
      clock_name : string := "";
6846
      maximum_period : time);
6847
    port(
6848
      clock : in std_ulogic;
6849
      rst : in std_ulogic
6850
      );
6851
  end component;
6852
 
6853
  component x_dcm_sp_clock_lost
6854
    port(
6855
      lost : out std_ulogic;
6856
 
6857
      clock : in std_ulogic;
6858
      enable : in boolean := false;
6859
      rst :  in std_ulogic
6860
      );
6861
  end component;
6862
 
6863
 
6864
 
6865
 
6866
 
6867
 
6868
  signal CLKFB_ipd, CLKIN_ipd, DSSEN_ipd : std_ulogic;
6869
  signal PSCLK_ipd, PSEN_ipd, PSINCDEC_ipd, RST_ipd : std_ulogic;
6870
  signal PSCLK_dly ,PSEN_dly, PSINCDEC_dly : std_ulogic := '0';
6871
 
6872
  signal clk0_out : std_ulogic;
6873
  signal clk2x_out, clkdv_out : std_ulogic := '0';
6874
  signal clkfx_out, locked_out, psdone_out, ps_overflow_out, ps_lock : std_ulogic := '0';
6875
  signal locked_out_out : std_ulogic := '0';
6876
  signal LOCKED_sig : std_ulogic := '0';
6877
 
6878
  signal clkdv_cnt : integer := 0;
6879
  signal clkfb_type : integer;
6880
  signal divide_type : integer;
6881
  signal clkin_type : integer;
6882
  signal ps_type : integer;
6883
  signal deskew_adjust_mode : integer;
6884
  signal dfs_mode_type : integer;
6885
  signal dll_mode_type : integer;
6886
  signal clk1x_type : integer;
6887
 
6888
 
6889
  signal lock_period, lock_delay, lock_clkin, lock_clkfb : std_ulogic := '0';
6890
  signal lock_out : std_logic_vector(1 downto 0) := "00";
6891
  signal lock_out1_neg : std_ulogic := '0';
6892
 
6893
  signal lock_fb : std_ulogic := '0';
6894
  signal lock_fb_dly : std_ulogic := '0';
6895
  signal lock_fb_dly_tmp : std_ulogic := '0';
6896
  signal fb_delay_found : std_ulogic := '0';
6897
 
6898
  signal clkin_div : std_ulogic;
6899
  signal clkin_ps : std_ulogic;
6900
  signal clkin_ps_tmp : std_ulogic;
6901
  signal clkin_ps_mkup : std_ulogic := '0';
6902
  signal clkin_ps_mkup_win : std_ulogic := '0';
6903
 
6904
  signal clkin_fb : std_ulogic;
6905
 
6906
 
6907
  signal ps_delay : time := 0 ps;
6908
  signal ps_delay_init : time := 0 ps;
6909
  signal ps_delay_md : time := 0 ps;
6910
  signal ps_delay_all : time := 0 ps;
6911
  signal ps_max_range : integer := 0;
6912
  signal ps_acc : integer := 0;
6913
  signal period_int : integer := 0;
6914
 
6915
  signal clkin_period_real : VitalDelayArrayType(2 downto 0) := (0.000 ns, 0.000 ns, 0.000 ns);
6916
 
6917
 
6918
  signal period : time := 0 ps;
6919
  signal period_div : time := 0 ps;
6920
  signal period_orig : time := 0 ps;
6921
  signal period_ps : time := 0 ps;
6922
  signal clkout_delay : time := 0 ps;
6923
  signal fb_delay : time := 0 ps;
6924
  signal period_fx, remain_fx : time := 0 ps;
6925
  signal period_dv_high, period_dv_low : time := 0 ps;
6926
  signal cycle_jitter, period_jitter : time := 0 ps;
6927
 
6928
  signal clkin_window, clkfb_window : std_ulogic := '0';
6929
  signal rst_reg : std_logic_vector(2 downto 0) := "000";
6930
  signal rst_flag : std_ulogic := '0';
6931
  signal numerator, denominator, gcd : integer := 1;
6932
 
6933
  signal clkin_lost_out : std_ulogic := '0';
6934
  signal clkfx_lost_out : std_ulogic := '0';
6935
 
6936
  signal remain_fx_temp : integer := 0;
6937
 
6938
  signal clkin_period_real0_temp : time := 0 ps;
6939
  signal ps_lock_reg : std_ulogic := '0';
6940
 
6941
  signal clk0_sig : std_ulogic := '0';
6942
  signal clk2x_sig : std_ulogic := '0';
6943
 
6944
  signal no_stop : boolean := false;
6945
 
6946
  signal clkfx180_en : std_ulogic := '0';
6947
 
6948
  signal status_out  : std_logic_vector(7 downto 0) := "00000000";
6949
 
6950
  signal first_time_locked : boolean := false;
6951
 
6952
  signal en_status : boolean := false;
6953
 
6954
  signal ps_overflow_out_ext : std_ulogic := '0';
6955
  signal clkin_lost_out_ext : std_ulogic := '0';
6956
  signal clkfx_lost_out_ext : std_ulogic := '0';
6957
 
6958
  signal clkfb_div : std_ulogic := '0';
6959
  signal clkfb_div_en : std_ulogic := '0';
6960
  signal clkfb_chk : std_ulogic := '0';
6961
 
6962
  signal lock_period_dly : std_ulogic := '0';
6963
  signal lock_period_dly1 : std_ulogic := '0';
6964
  signal lock_period_pulse : std_ulogic := '0';
6965
 
6966
  signal clock_stopped : std_ulogic := '1';
6967
 
6968
  signal clkin_chkin, clkfb_chkin : std_ulogic := '0';
6969
  signal chk_enable, chk_rst : std_ulogic := '0';
6970
 
6971
  signal lock_ps : std_ulogic := '0';
6972
  signal lock_ps_dly : std_ulogic := '0';
6973
 
6974
  constant PS_STEP : time := 25 ps;
6975
 
6976
begin
6977
  INITPROC : process
6978
  begin
6979
    detect_resolution
6980
      (model_name => "X_DCM_SP"
6981
       );
6982
    if (CLKDV_DIVIDE = 1.5) then
6983
      divide_type <= 3;
6984
    elsif (CLKDV_DIVIDE = 2.0) then
6985
      divide_type <= 4;
6986
    elsif (CLKDV_DIVIDE = 2.5) then
6987
      divide_type <= 5;
6988
    elsif (CLKDV_DIVIDE = 3.0) then
6989
      divide_type <= 6;
6990
    elsif (CLKDV_DIVIDE = 3.5) then
6991
      divide_type <= 7;
6992
    elsif (CLKDV_DIVIDE = 4.0) then
6993
      divide_type <= 8;
6994
    elsif (CLKDV_DIVIDE = 4.5) then
6995
      divide_type <= 9;
6996
    elsif (CLKDV_DIVIDE = 5.0) then
6997
      divide_type <= 10;
6998
    elsif (CLKDV_DIVIDE = 5.5) then
6999
      divide_type <= 11;
7000
    elsif (CLKDV_DIVIDE = 6.0) then
7001
      divide_type <= 12;
7002
    elsif (CLKDV_DIVIDE = 6.5) then
7003
      divide_type <= 13;
7004
    elsif (CLKDV_DIVIDE = 7.0) then
7005
      divide_type <= 14;
7006
    elsif (CLKDV_DIVIDE = 7.5) then
7007
      divide_type <= 15;
7008
    elsif (CLKDV_DIVIDE = 8.0) then
7009
      divide_type <= 16;
7010
    elsif (CLKDV_DIVIDE = 9.0) then
7011
      divide_type <= 18;
7012
    elsif (CLKDV_DIVIDE = 10.0) then
7013
      divide_type <= 20;
7014
    elsif (CLKDV_DIVIDE = 11.0) then
7015
      divide_type <= 22;
7016
    elsif (CLKDV_DIVIDE = 12.0) then
7017
      divide_type <= 24;
7018
    elsif (CLKDV_DIVIDE = 13.0) then
7019
      divide_type <= 26;
7020
    elsif (CLKDV_DIVIDE = 14.0) then
7021
      divide_type <= 28;
7022
    elsif (CLKDV_DIVIDE = 15.0) then
7023
      divide_type <= 30;
7024
    elsif (CLKDV_DIVIDE = 16.0) then
7025
      divide_type <= 32;
7026
    else
7027
      GenericValueCheckMessage
7028
        (HeaderMsg => "Attribute Syntax Error",
7029
         GenericName => "CLKDV_DIVIDE",
7030
         EntityName => "X_DCM_SP",
7031
         InstanceName => InstancePath,
7032
         GenericValue => CLKDV_DIVIDE,
7033
         Unit => "",
7034
         ExpectedValueMsg => "Legal Values for this attribute are 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, or 16.0",
7035
         ExpectedGenericValue => "",
7036
         TailMsg => "",
7037
         MsgSeverity => error
7038
         );
7039
    end if;
7040
 
7041
    if ((CLKFX_DIVIDE <= 0) or (32 < CLKFX_DIVIDE)) then
7042
      GenericValueCheckMessage
7043
        (HeaderMsg => "Attribute Syntax Error",
7044
         GenericName => "CLKFX_DIVIDE",
7045
         EntityName => "X_DCM_SP",
7046
         InstanceName => InstancePath,
7047
         GenericValue => CLKFX_DIVIDE,
7048
         Unit => "",
7049
         ExpectedValueMsg => "Legal Values for this attribute are 1....32",
7050
         ExpectedGenericValue => "",
7051
         TailMsg => "",
7052
         MsgSeverity => error
7053
         );
7054
    end if;
7055
    if ((CLKFX_MULTIPLY <= 1) or (32 < CLKFX_MULTIPLY)) then
7056
      GenericValueCheckMessage
7057
        (HeaderMsg => "Attribute Syntax Error",
7058
         GenericName => "CLKFX_MULTIPLY",
7059
         EntityName => "X_DCM_SP",
7060
         InstanceName => InstancePath,
7061
         GenericValue => CLKFX_MULTIPLY,
7062
         Unit => "",
7063
         ExpectedValueMsg => "Legal Values for this attribute are 2....32",
7064
         ExpectedGenericValue => "",
7065
         TailMsg => "",
7066
         MsgSeverity => error
7067
         );
7068
    end if;
7069
    case CLKIN_DIVIDE_BY_2 is
7070
      when false => clkin_type <= 0;
7071
      when true => clkin_type <= 1;
7072
      when others =>
7073
        GenericValueCheckMessage
7074
          (HeaderMsg => "Attribute Syntax Error",
7075
           GenericName => "CLKIN_DIVIDE_BY_2",
7076
           EntityName => "X_DCM_SP",
7077
           InstanceName => InstancePath,
7078
           GenericValue => CLKIN_DIVIDE_BY_2,
7079
           Unit => "",
7080
           ExpectedValueMsg => "Legal Values for this attribute are TRUE or FALSE",
7081
           ExpectedGenericValue => "",
7082
           TailMsg => "",
7083
           MsgSeverity => error
7084
           );
7085
    end case;
7086
 
7087
 
7088
    if ((CLKOUT_PHASE_SHIFT = "none") or (CLKOUT_PHASE_SHIFT = "NONE")) then
7089
      ps_type <= 0;
7090
    elsif ((CLKOUT_PHASE_SHIFT = "fixed") or (CLKOUT_PHASE_SHIFT = "FIXED")) then
7091
      ps_type <= 1;
7092
    elsif ((CLKOUT_PHASE_SHIFT = "variable") or (CLKOUT_PHASE_SHIFT = "VARIABLE")) then
7093
      ps_type <= 2;
7094
      if (PHASE_SHIFT /= 0) then
7095
       GenericValueCheckMessage
7096
        (HeaderMsg => "Attribute Syntax Warning",
7097
         GenericName => "PHASE_SHIFT",
7098
         EntityName => "X_DCM_SP",
7099
         InstanceName => InstancePath,
7100
         GenericValue => PHASE_SHIFT,
7101
         Unit => "",
7102
         ExpectedValueMsg => "The maximum variable phase shift range is only valid when initial phase shift PHASE_SHIFT is zero",
7103
         ExpectedGenericValue => "",
7104
         TailMsg => "",
7105
         MsgSeverity => warning
7106
         );
7107
      end if;
7108
    else
7109
      GenericValueCheckMessage
7110
        (HeaderMsg => "Attribute Syntax Error",
7111
         GenericName => "CLKOUT_PHASE_SHIFT",
7112
         EntityName => "X_DCM_SP",
7113
         InstanceName => InstancePath,
7114
         GenericValue => CLKOUT_PHASE_SHIFT,
7115
         Unit => "",
7116
         ExpectedValueMsg => "Legal Values for this attribute are NONE, FIXED or VARIABLE",
7117
         ExpectedGenericValue => "",
7118
         TailMsg => "",
7119
         MsgSeverity => error
7120
         );
7121
    end if;
7122
 
7123
    if ((CLK_FEEDBACK = "none") or (CLK_FEEDBACK = "NONE")) then
7124
      clkfb_type <= 0;
7125
    elsif ((CLK_FEEDBACK = "1x") or (CLK_FEEDBACK = "1X")) then
7126
      clkfb_type <= 1;
7127
    elsif ((CLK_FEEDBACK = "2x") or (CLK_FEEDBACK = "2X")) then
7128
      clkfb_type <= 2;
7129
    else
7130
      GenericValueCheckMessage
7131
        (HeaderMsg => "Attribute Syntax Error",
7132
         GenericName => "CLK_FEEDBACK",
7133
         EntityName => "X_DCM_SP",
7134
         InstanceName => InstancePath,
7135
         GenericValue => CLK_FEEDBACK,
7136
         Unit => "",
7137
         ExpectedValueMsg => "Legal Values for this attribute are NONE, 1X or 2X",
7138
         ExpectedGenericValue => "",
7139
         TailMsg => "",
7140
         MsgSeverity => error
7141
         );
7142
    end if;
7143
 
7144
 
7145
 
7146
    if ((DESKEW_ADJUST = "source_synchronous") or (DESKEW_ADJUST = "SOURCE_SYNCHRONOUS")) then
7147
      DESKEW_ADJUST_mode <= 8;
7148
    elsif ((DESKEW_ADJUST = "system_synchronous") or (DESKEW_ADJUST = "SYSTEM_SYNCHRONOUS")) then
7149
      DESKEW_ADJUST_mode <= 11;
7150
    elsif ((DESKEW_ADJUST = "0")) then
7151
      DESKEW_ADJUST_mode <= 0;
7152
    elsif ((DESKEW_ADJUST = "1")) then
7153
      DESKEW_ADJUST_mode <= 1;
7154
    elsif ((DESKEW_ADJUST = "2")) then
7155
      DESKEW_ADJUST_mode <= 2;
7156
    elsif ((DESKEW_ADJUST = "3")) then
7157
      DESKEW_ADJUST_mode <= 3;
7158
    elsif ((DESKEW_ADJUST = "4")) then
7159
      DESKEW_ADJUST_mode <= 4;
7160
    elsif ((DESKEW_ADJUST = "5")) then
7161
      DESKEW_ADJUST_mode <= 5;
7162
    elsif ((DESKEW_ADJUST = "6")) then
7163
      DESKEW_ADJUST_mode <= 6;
7164
    elsif ((DESKEW_ADJUST = "7")) then
7165
      DESKEW_ADJUST_mode <= 7;
7166
    elsif ((DESKEW_ADJUST = "8")) then
7167
      DESKEW_ADJUST_mode <= 8;
7168
    elsif ((DESKEW_ADJUST = "9")) then
7169
      DESKEW_ADJUST_mode <= 9;
7170
    elsif ((DESKEW_ADJUST = "10")) then
7171
      DESKEW_ADJUST_mode <= 10;
7172
    elsif ((DESKEW_ADJUST = "11")) then
7173
      DESKEW_ADJUST_mode <= 11;
7174
    elsif ((DESKEW_ADJUST = "12")) then
7175
      DESKEW_ADJUST_mode <= 12;
7176
    elsif ((DESKEW_ADJUST = "13")) then
7177
      DESKEW_ADJUST_mode <= 13;
7178
    elsif ((DESKEW_ADJUST = "14")) then
7179
      DESKEW_ADJUST_mode <= 14;
7180
    elsif ((DESKEW_ADJUST = "15")) then
7181
      DESKEW_ADJUST_mode <= 15;
7182
    else
7183
      GenericValueCheckMessage
7184
        (HeaderMsg => "Attribute Syntax Error",
7185
         GenericName => "DESKEW_ADJUST_MODE",
7186
         EntityName => "X_DCM_SP",
7187
         InstanceName => InstancePath,
7188
         GenericValue => DESKEW_ADJUST_MODE,
7189
         Unit => "",
7190
         ExpectedValueMsg => "Legal Values for this attribute are SOURCE_SYNCHRONOUS, SYSTEM_SYNCHRONOUS or 1....15",
7191
         ExpectedGenericValue => "",
7192
         TailMsg => "",
7193
         MsgSeverity => error
7194
         );
7195
    end if;
7196
 
7197
    if ((DFS_FREQUENCY_MODE = "high") or (DFS_FREQUENCY_MODE = "HIGH")) then
7198
      dfs_mode_type <= 1;
7199
    elsif ((DFS_FREQUENCY_MODE = "low") or (DFS_FREQUENCY_MODE = "LOW")) then
7200
      dfs_mode_type <= 0;
7201
    else
7202
      GenericValueCheckMessage
7203
        (HeaderMsg => "Attribute Syntax Error",
7204
         GenericName => "DFS_FREQUENCY_MODE",
7205
         EntityName => "X_DCM_SP",
7206
         InstanceName => InstancePath,
7207
         GenericValue => DFS_FREQUENCY_MODE,
7208
         Unit => "",
7209
         ExpectedValueMsg => "Legal Values for this attribute are HIGH or LOW",
7210
         ExpectedGenericValue => "",
7211
         TailMsg => "",
7212
         MsgSeverity => error
7213
         );
7214
    end if;
7215
 
7216
    if ((DLL_FREQUENCY_MODE = "high") or (DLL_FREQUENCY_MODE = "HIGH")) then
7217
      dll_mode_type <= 1;
7218
    elsif ((DLL_FREQUENCY_MODE = "low") or (DLL_FREQUENCY_MODE = "LOW")) then
7219
      dll_mode_type <= 0;
7220
    else
7221
      GenericValueCheckMessage
7222
        (HeaderMsg => "Attribute Syntax Error",
7223
         GenericName => "DLL_FREQUENCY_MODE",
7224
         EntityName => "X_DCM_SP",
7225
         InstanceName => InstancePath,
7226
         GenericValue => DLL_FREQUENCY_MODE,
7227
         Unit => "",
7228
         ExpectedValueMsg => "Legal Values for this attribute are HIGH or LOW",
7229
         ExpectedGenericValue => "",
7230
         TailMsg => "",
7231
         MsgSeverity => error
7232
         );
7233
    end if;
7234
 
7235
    if ((DSS_MODE = "none") or (DSS_MODE = "NONE")) then
7236
    else
7237
      GenericValueCheckMessage
7238
        (HeaderMsg => "Attribute Syntax Error",
7239
         GenericName => "DSS_MODE",
7240
         EntityName => "X_DCM_SP",
7241
         InstanceName => InstancePath,
7242
         GenericValue => DSS_MODE,
7243
         Unit => "",
7244
         ExpectedValueMsg => "Legal Values for this attribute are NONE",
7245
         ExpectedGenericValue => "",
7246
         TailMsg => "",
7247
         MsgSeverity => error
7248
         );
7249
    end if;
7250
 
7251
    case DUTY_CYCLE_CORRECTION is
7252
      when false => clk1x_type <= 0;
7253
      when true => clk1x_type <= 1;
7254
      when others =>
7255
        GenericValueCheckMessage
7256
          (HeaderMsg => "Attribute Syntax Error",
7257
           GenericName => "DUTY_CYCLE_CORRECTION",
7258
           EntityName => "X_DCM_SP",
7259
           InstanceName => InstancePath,
7260
           GenericValue => DUTY_CYCLE_CORRECTION,
7261
           Unit => "",
7262
           ExpectedValueMsg => "Legal Values for this attribute are TRUE or FALSE",
7263
           ExpectedGenericValue => "",
7264
           TailMsg => "",
7265
           MsgSeverity => error
7266
           );
7267
    end case;
7268
 
7269
    if ((PHASE_SHIFT < -255) or (PHASE_SHIFT > 255)) then
7270
      GenericValueCheckMessage
7271
        (HeaderMsg => "Attribute Syntax Error",
7272
         GenericName => "PHASE_SHIFT",
7273
         EntityName => "X_DCM_SP",
7274
         InstanceName => InstancePath,
7275
         GenericValue => PHASE_SHIFT,
7276
         Unit => "",
7277
         ExpectedValueMsg => "Legal Values for this attribute are -255 ... 255",
7278
         ExpectedGenericValue => "",
7279
         TailMsg => "",
7280
         MsgSeverity => error
7281
         );
7282
    end if;
7283
 
7284
    period_jitter <= SIM_CLKIN_PERIOD_JITTER;
7285
    cycle_jitter <= SIM_CLKIN_CYCLE_JITTER;
7286
 
7287
    case STARTUP_WAIT is
7288
      when false => null;
7289
      when true => null;
7290
      when others =>
7291
        GenericValueCheckMessage
7292
          (HeaderMsg => "Attribute Syntax Error",
7293
           GenericName => "STARTUP_WAIT",
7294
           EntityName => "X_DCM_SP",
7295
           InstanceName => InstancePath,
7296
           GenericValue => STARTUP_WAIT,
7297
           Unit => "",
7298
           ExpectedValueMsg => "Legal Values for this attribute are TRUE or FALSE",
7299
           ExpectedGenericValue => "",
7300
           TailMsg => "",
7301
           MsgSeverity => error
7302
           );
7303
    end case;
7304
 
7305
--
7306
-- fx parameters
7307
--    
7308
    gcd <= 1;
7309
    for i in 2 to CLKFX_MULTIPLY loop
7310
      if (((CLKFX_MULTIPLY mod i) = 0) and ((CLKFX_DIVIDE mod i) = 0)) then
7311
        gcd <= i;
7312
      end if;
7313
    end loop;
7314
    numerator <= CLKFX_MULTIPLY / gcd;
7315
    denominator <= CLKFX_DIVIDE / gcd;
7316
    wait;
7317
  end process INITPROC;
7318
 
7319
--
7320
-- input wire delays
7321
--  
7322
 
7323
 
7324
  WireDelay : block
7325
  begin
7326
    VitalWireDelay (CLKIN_ipd, CLKIN, tipd_CLKIN);
7327
    VitalWireDelay (CLKFB_ipd, CLKFB, tipd_CLKFB);
7328
    VitalWireDelay (DSSEN_ipd, DSSEN, tipd_DSSEN);
7329
    VitalWireDelay (PSCLK_ipd, PSCLK, tipd_PSCLK);
7330
    VitalWireDelay (PSEN_ipd, PSEN, tipd_PSEN);
7331
    VitalWireDelay (PSINCDEC_ipd, PSINCDEC, tipd_PSINCDEC);
7332
    VitalWireDelay (RST_ipd, RST, tipd_RST);
7333
  end block;
7334
 
7335
  SignalDelay : block
7336
  begin
7337
    VitalSignalDelay (PSCLK_dly, PSCLK_ipd, ticd_PSCLK);
7338
    VitalSignalDelay (PSEN_dly, PSEN_ipd, tisd_PSEN_PSCLK);
7339
    VitalSignalDelay (PSINCDEC_dly, PSINCDEC_ipd, tisd_PSINCDEC_PSCLK);
7340
  end block;
7341
 
7342
  i_clock_divide_by_2 : x_dcm_sp_clock_divide_by_2
7343
    port map (
7344
      clock => clkin_ipd,
7345
      clock_type => clkin_type,
7346
      rst => rst_ipd,
7347
      clock_out => clkin_div);
7348
 
7349
  i_max_clkin : x_dcm_sp_maximum_period_check
7350
    generic map (
7351
      clock_name => "CLKIN",
7352
      maximum_period => MAXPERCLKIN)
7353
 
7354
    port map (
7355
      clock => clkin_ipd,
7356
      rst => rst_ipd);
7357
 
7358
  i_max_psclk : x_dcm_sp_maximum_period_check
7359
    generic map (
7360
      clock_name => "PSCLK",
7361
      maximum_period => MAXPERPSCLK)
7362
 
7363
    port map (
7364
      clock => psclk_dly,
7365
      rst => rst_ipd);
7366
 
7367
  i_clkin_lost : x_dcm_sp_clock_lost
7368
    port map (
7369
      lost  => clkin_lost_out,
7370
      clock => clkin_ipd,
7371
      enable => first_time_locked,
7372
      rst => rst_ipd
7373
      );
7374
 
7375
  i_clkfx_lost : x_dcm_sp_clock_lost
7376
    port map (
7377
      lost  => clkfx_lost_out,
7378
      clock => clkfx_out,
7379
      enable => first_time_locked,
7380
      rst => rst_ipd
7381
      );
7382
 
7383
  clkin_ps_tmp <= transport clkin_div after ps_delay_md;
7384
 
7385
  clkin_ps <= clkin_ps_mkup when clkin_ps_mkup_win = '1' else clkin_ps_tmp;
7386
 
7387
  clkin_fb <= transport (clkin_ps and lock_fb);
7388
 
7389
 
7390
  clkin_ps_tmp_p: process
7391
     variable  ps_delay_last : integer := 0;
7392
     variable  ps_delay_int : integer;
7393
     variable  period_int2  : integer := 0;
7394
     variable  period_int3  : integer := 0;
7395
  begin
7396
   if (ps_type = 2) then
7397
      ps_delay_int := (ps_delay /1 ps ) * 1;
7398
      period_int2 := 2 * period_int;
7399
      period_int3 := 3 * period_int;
7400
 
7401
     if (rising_edge(clkin_div)) then
7402
       if ((ps_delay_last > 0  and ps_delay_int <= 0 ) or
7403
        (ps_delay_last >= period_int  and ps_delay_int < period_int) or
7404
        (ps_delay_last >= period_int2 and ps_delay_int < period_int2) or
7405
        (ps_delay_last >= period_int3  and ps_delay_int < period_int3)) then
7406
        clkin_ps_mkup_win <= '1';
7407
        clkin_ps_mkup <= '1';
7408
        wait until falling_edge(clkin_div);
7409
           clkin_ps_mkup_win <= '1';
7410
           clkin_ps_mkup <= '0';
7411
       else
7412
           clkin_ps_mkup_win <= '0';
7413
           clkin_ps_mkup <= '0';
7414
       end if;
7415
     end if;
7416
 
7417
     if (falling_edge(clkin_div)) then
7418
        if ((ps_delay_last > 0  and ps_delay_int <= 0 ) or
7419
        (ps_delay_last >= period_int  and ps_delay_int < period_int) or
7420
        (ps_delay_last >= period_int2 and ps_delay_int < period_int2) or
7421
        (ps_delay_last >= period_int3  and ps_delay_int < period_int3)) then
7422
          clkin_ps_mkup <= '0';
7423
          clkin_ps_mkup_win <= '0';
7424
        wait until rising_edge(clkin_div);
7425
           clkin_ps_mkup <= '1';
7426
           clkin_ps_mkup_win <= '1';
7427
         wait until falling_edge(clkin_div);
7428
           clkin_ps_mkup <= '0';
7429
           clkin_ps_mkup_win <= '1';
7430
        else
7431
           clkin_ps_mkup <= '0';
7432
           clkin_ps_mkup_win <= '0';
7433
        end if;
7434
     end if;
7435
        ps_delay_last := ps_delay_int;
7436
   end if;
7437
    wait on clkin_div;
7438
  end process;
7439
 
7440
  detect_first_time_locked : process
7441
    begin
7442
      if (first_time_locked = false) then
7443
        if (rising_edge(locked_out)) then
7444
          first_time_locked <= true;
7445
        end if;
7446
      end if;
7447
      wait on locked_out;
7448
  end process detect_first_time_locked;
7449
 
7450
  set_reset_en_status : process
7451
  begin
7452
    if (rst_ipd = '1') then
7453
      en_status <= false;
7454
    elsif (rising_edge(Locked_sig)) then
7455
      en_status <= true;
7456
    end if;
7457
    wait on rst_ipd, Locked_sig;
7458
  end process set_reset_en_status;
7459
 
7460
  gen_clkfb_div_en: process
7461
  begin
7462
    if (rst_ipd = '1') then
7463
      clkfb_div_en <= '0';
7464
    elsif (falling_edge(clkfb_ipd)) then
7465
      if (lock_fb_dly='1' and lock_period='1' and lock_fb = '1' and clkin_ps = '0') then
7466
        clkfb_div_en <= '1';
7467
      end if;
7468
    end if;
7469
    wait on clkfb_ipd, rst_ipd;
7470
  end process  gen_clkfb_div_en;
7471
 
7472
   gen_clkfb_div: process
7473
  begin
7474
    if (rst_ipd = '1') then
7475
      clkfb_div <= '0';
7476
    elsif (rising_edge(clkfb_ipd)) then
7477
      if (clkfb_div_en = '1') then
7478
        clkfb_div <= not clkfb_div;
7479
      end if;
7480
    end if;
7481
    wait on clkfb_ipd, rst_ipd;
7482
  end process  gen_clkfb_div;
7483
 
7484
  determine_clkfb_chk: process
7485
  begin
7486
    if (clkfb_type = 2) then
7487
      clkfb_chk <= clkfb_div;
7488
    else
7489
      clkfb_chk <= clkfb_ipd and lock_fb_dly;
7490
    end if;
7491
    wait on clkfb_ipd, clkfb_div;
7492
  end process  determine_clkfb_chk;
7493
 
7494
  set_reset_clkin_chkin : process
7495
  begin
7496
    if ((rising_edge(clkin_fb)) or (rising_edge(chk_rst))) then
7497
      if (chk_rst = '1') then
7498
        clkin_chkin <= '0';
7499
      else
7500
        clkin_chkin <= '1';
7501
      end if;
7502
    end if;
7503
    wait on clkin_fb, chk_rst;
7504
  end process set_reset_clkin_chkin;
7505
 
7506
  set_reset_clkfb_chkin : process
7507
  begin
7508
    if ((rising_edge(clkfb_chk)) or (rising_edge(chk_rst))) then
7509
      if (chk_rst = '1') then
7510
        clkfb_chkin <= '0';
7511
      else
7512
        clkfb_chkin <= '1';
7513
      end if;
7514
    end if;
7515
    wait on clkfb_chk, chk_rst;
7516
  end process set_reset_clkfb_chkin;
7517
 
7518
 
7519
--   assign_chk_rst: process
7520
--   begin
7521
--     if ((rst_ipd = '1') or (clock_stopped = '1')) then
7522
--       chk_rst <= '1';
7523
--     else
7524
--       chk_rst <= '0';  
7525
--     end if;
7526
--     wait on rst_ipd, clock_stopped;
7527
--   end process assign_chk_rst;
7528
 
7529
  chk_rst <= '1' when ((rst_ipd = '1') or (clock_stopped = '1')) else '0';
7530
 
7531
--   assign_chk_enable: process
7532
--   begin
7533
--     if ((clkin_chkin = '1') and (clkfb_chkin = '1')) then
7534
--       chk_enable <= '1';
7535
--     else
7536
--       chk_enable <= '0';  
7537
--     end if;
7538
--   wait on clkin_chkin, clkfb_chkin;  
7539
--   end process  assign_chk_enable;
7540
 
7541
  chk_enable <= '1' when ((clkin_chkin = '1') and (clkfb_chkin = '1') and (lock_ps = '1') and (lock_fb_dly = '1') and (lock_fb = '1')) else '0';
7542
 
7543
 
7544
 
7545
 
7546
  control_status_bits: process
7547
  begin
7548
    if ((rst_ipd = '1') or (en_status = false)) then
7549
      ps_overflow_out_ext <= '0';
7550
      clkin_lost_out_ext <= '0';
7551
      clkfx_lost_out_ext <= '0';
7552
    else
7553
      ps_overflow_out_ext <= ps_overflow_out;
7554
      clkin_lost_out_ext <= clkin_lost_out;
7555
      clkfx_lost_out_ext <= clkfx_lost_out;
7556
    end if;
7557
    wait on clkfx_lost_out, clkin_lost_out, en_status, ps_overflow_out, rst_ipd;
7558
  end process  control_status_bits;
7559
 
7560
  determine_period_div : process
7561
    variable clkin_div_edge_previous : time := 0 ps;
7562
    variable clkin_div_edge_current : time := 0 ps;
7563
  begin
7564
    if ((rising_edge(rst_ipd)) or (rst_ipd = '1')) then
7565
      clkin_div_edge_previous := 0 ps;
7566
      clkin_div_edge_current := 0 ps;
7567
      period_div <= 0 ps;
7568
    else
7569
      if (rising_edge(clkin_div)) then
7570
        clkin_div_edge_previous := clkin_div_edge_current;
7571
        clkin_div_edge_current := NOW;
7572
        if ((clkin_div_edge_current - clkin_div_edge_previous) <= (1.5 * period_div)) then
7573
          period_div <= clkin_div_edge_current - clkin_div_edge_previous;
7574
        elsif ((period_div = 0 ps) and (clkin_div_edge_previous /= 0 ps)) then
7575
          period_div <= clkin_div_edge_current - clkin_div_edge_previous;
7576
        end if;
7577
      end if;
7578
    end if;
7579
    wait on clkin_div, rst_ipd;
7580
  end process determine_period_div;
7581
 
7582
  determine_period_ps : process
7583
    variable clkin_ps_edge_previous : time := 0 ps;
7584
    variable clkin_ps_edge_current : time := 0 ps;
7585
  begin
7586
    if ((rising_edge(rst_ipd)) or (rst_ipd = '1')) then
7587
      clkin_ps_edge_previous := 0 ps;
7588
      clkin_ps_edge_current := 0 ps;
7589
      period_ps <= 0 ps;
7590
    else
7591
      if (rising_edge(clkin_ps)) then
7592
        clkin_ps_edge_previous := clkin_ps_edge_current;
7593
        clkin_ps_edge_current := NOW;
7594
        wait for 0 ps;
7595
        if ((clkin_ps_edge_current - clkin_ps_edge_previous) <= (1.5 * period_ps)) then
7596
          period_ps <= clkin_ps_edge_current - clkin_ps_edge_previous;
7597
        elsif ((period_ps = 0 ps) and (clkin_ps_edge_previous /= 0 ps)) then
7598
          period_ps <= clkin_ps_edge_current - clkin_ps_edge_previous;
7599
        end if;
7600
      end if;
7601
    end if;
7602
    wait on clkin_ps, rst_ipd;
7603
  end process determine_period_ps;
7604
 
7605
  assign_lock_ps_fb : process
7606
 
7607
  begin
7608
    if ((rising_edge(rst_ipd)) or (rst_ipd = '1')) then
7609
      lock_fb <= '0';
7610
      lock_ps <= '0';
7611
      lock_ps_dly <= '0';
7612
      lock_fb_dly <= '0';
7613
      lock_fb_dly_tmp <= '0';
7614
    else
7615
      if (rising_edge(clkin_ps)) then
7616
        lock_ps <= lock_period;
7617
        lock_ps_dly <= lock_ps;
7618
        lock_fb <= lock_ps_dly;
7619
        lock_fb_dly_tmp <= lock_fb;
7620
      end if;
7621
      if (falling_edge(clkin_ps)) then
7622
         lock_fb_dly <= lock_fb_dly_tmp after (period/4);
7623
      end if;
7624
    end if;
7625
    wait on clkin_ps, rst_ipd;
7626
  end process assign_lock_ps_fb;
7627
 
7628
  calculate_clkout_delay : process
7629
  begin
7630
    if ((rising_edge(rst_ipd)) or (rst_ipd = '1')) then
7631
      clkout_delay <= 0 ps;
7632
    elsif (fb_delay = 0 ps) then
7633
      clkout_delay <= 0 ps;
7634
    elsif (period'event or fb_delay'event) then
7635
      clkout_delay <= period - fb_delay;
7636
    end if;
7637
    wait on period, fb_delay, rst_ipd;
7638
  end process calculate_clkout_delay;
7639
 
7640
--
7641
--generate master reset signal
7642
--  
7643
 
7644
  gen_master_rst : process
7645
  begin
7646
    if (rising_edge(clkin_ipd)) then
7647
      rst_reg(2) <= rst_reg(1) and rst_reg(0) and rst_ipd;
7648
      rst_reg(1) <= rst_reg(0) and rst_ipd;
7649
      rst_reg(0) <= rst_ipd;
7650
    end if;
7651
    wait on clkin_ipd;
7652
  end process gen_master_rst;
7653
 
7654
  check_rst_width : process
7655
    variable Message : line;
7656
    begin
7657
      if (rst_ipd ='1') then
7658
          rst_flag <= '0';
7659
      end if;
7660
      if (falling_edge(rst_ipd)) then
7661
        if ((rst_reg(2) and rst_reg(1) and rst_reg(0)) = '0') then
7662
          rst_flag <= '1';
7663
          Write ( Message, string'(" Input Error : RST on X_DCM_SP "));
7664
          Write ( Message, string'(" must be asserted for 3 CLKIN clock cycles. "));
7665
          assert false report Message.all severity error;
7666
          DEALLOCATE (Message);
7667
        end if;
7668
      end if;
7669
 
7670
      wait on rst_ipd;
7671
    end process check_rst_width;
7672
 
7673
--
7674
--phase shift parameters
7675
--  
7676
 
7677
  ps_max_range_p : process (period)
7678
    variable period_ps_tmp : integer := 0;
7679
  begin
7680
    period_int <= (period/ 1 ps ) * 1;
7681
    if (clkin_type = 1) then
7682
       period_ps_tmp := 2 * (period/ 1 ns );
7683
    else
7684
       period_ps_tmp := (period/ 1 ns ) * 1;
7685
    end if;
7686
   if (period_ps_tmp > 3) then
7687
     ps_max_range <= 20 * (period_ps_tmp - 3);
7688
   else
7689
     ps_max_range <= 0;
7690
  end if;
7691
  end process;
7692
 
7693
  ps_delay_md_p : process (period, ps_delay, lock_period, rst_ipd)
7694
      variable tmp_value : integer;
7695
      variable tmp_value1 : integer;
7696
      variable tmp_value2 : integer;
7697
  begin
7698
      if (rst_ipd = '1') then
7699
           ps_delay_md <= 0 ps;
7700
      elsif (lock_period = '1') then
7701
          tmp_value := (ps_delay / 1 ps ) * 1;
7702
          tmp_value1 := (period / 1 ps) * 1;
7703
          tmp_value2 := tmp_value mod tmp_value1;
7704
          ps_delay_md <= period + tmp_value2 * 1 ps;
7705
      end if;
7706
  end process;
7707
 
7708
 
7709
  determine_phase_shift : process
7710
    variable Message : line;
7711
    variable first_time : boolean := true;
7712
    variable ps_in : integer;
7713
    variable ps_acc : integer := 0;
7714
    variable ps_step_int : integer := 0;
7715
  begin
7716
    if (first_time = true) then
7717
      if ((CLKOUT_PHASE_SHIFT = "none") or (CLKOUT_PHASE_SHIFT = "NONE")) then
7718
        ps_in := 256;
7719
      elsif ((CLKOUT_PHASE_SHIFT = "fixed") or (CLKOUT_PHASE_SHIFT = "FIXED")) then
7720
        ps_in := 256 + PHASE_SHIFT;
7721
      elsif ((CLKOUT_PHASE_SHIFT = "variable") or (CLKOUT_PHASE_SHIFT = "VARIABLE")) then
7722
        ps_in := 256 + PHASE_SHIFT;
7723
      end if;
7724
      ps_step_int := (PS_STEP / 1 ps ) * 1;
7725
      first_time := false;
7726
    end if;
7727
 
7728
    if ((rising_edge(rst_ipd)) or (rst_ipd = '1')) then
7729
      if ((CLKOUT_PHASE_SHIFT = "none") or (CLKOUT_PHASE_SHIFT = "NONE")) then
7730
        ps_in := 256;
7731
      elsif ((CLKOUT_PHASE_SHIFT = "fixed") or (CLKOUT_PHASE_SHIFT = "FIXED")) then
7732
        ps_in := 256 + PHASE_SHIFT;
7733
      elsif ((CLKOUT_PHASE_SHIFT = "variable") or (CLKOUT_PHASE_SHIFT = "VARIABLE")) then
7734
        ps_in := 256 + PHASE_SHIFT;
7735
      else
7736
      end if;
7737
      ps_lock <= '0';
7738
      ps_overflow_out <= '0';
7739
      ps_delay <= 0 ps;
7740
      ps_acc := 0;
7741
    elsif (rising_edge(lock_period_pulse)) then
7742
        ps_delay <= (ps_in * period_div / 256);
7743
    elsif (rising_edge(PSCLK_dly)) then
7744
        if (ps_type = 2) then
7745
          if (psen_dly = '1') then
7746
            if (ps_lock = '1') then
7747
              Write ( Message, string'(" Warning : Please wait for PSDONE signal before adjusting the Phase Shift. "));
7748
              assert false report Message.all severity warning;
7749
              DEALLOCATE (Message);
7750
            else if (lock_ps = '1') then
7751
              if (psincdec_dly = '1') then
7752
                if (ps_acc > ps_max_range) then
7753
                  ps_overflow_out <= '1';
7754
                else
7755
                  ps_delay <= ps_delay  + PS_STEP;
7756
                  ps_acc := ps_acc + 1;
7757
                  ps_overflow_out <= '0';
7758
                end if;
7759
                ps_lock <= '1';
7760
              elsif (psincdec_dly = '0') then
7761
                if (ps_acc < -ps_max_range) then
7762
                  ps_overflow_out <= '1';
7763
                else
7764
                  ps_delay <= ps_delay - PS_STEP;
7765
                  ps_acc := ps_acc - 1;
7766
                  ps_overflow_out <= '0';
7767
                end if;
7768
                ps_lock <= '1';
7769
              end if;
7770
            end if;
7771
          end if;
7772
         end if;
7773
        end if;
7774
      end if;
7775
    if (ps_lock_reg'event) then
7776
      ps_lock <= ps_lock_reg;
7777
    end if;
7778
    wait on lock_period_pulse, psclk_dly, ps_lock_reg, rst_ipd;
7779
  end process determine_phase_shift;
7780
 
7781
  determine_psdone_out : process
7782
  begin
7783
    if (rising_edge(ps_lock)) then
7784
      ps_lock_reg <= '1';
7785
      wait until (rising_edge(clkin_ps));
7786
      wait until (rising_edge(psclk_dly));
7787
      wait until (rising_edge(psclk_dly));
7788
      wait until (rising_edge(psclk_dly));
7789
      psdone_out <= '1';
7790
      wait until (rising_edge(psclk_dly));
7791
      psdone_out <= '0';
7792
      ps_lock_reg <= '0';
7793
    end if;
7794
    wait on ps_lock;
7795
  end process determine_psdone_out;
7796
 
7797
--
7798
--determine clock period
7799
--    
7800
  determine_clock_period : process
7801
    variable clkin_edge_previous : time := 0 ps;
7802
    variable clkin_edge_current : time := 0 ps;
7803
  begin
7804
    if ((rising_edge(rst_ipd)) or (rst_ipd = '1')) then
7805
      clkin_period_real(0) <= 0 ps;
7806
      clkin_period_real(1) <= 0 ps;
7807
      clkin_period_real(2) <= 0 ps;
7808
      clkin_edge_previous := 0 ps;
7809
      clkin_edge_current := 0 ps;
7810
    elsif (rising_edge(clkin_div)) then
7811
      clkin_edge_previous := clkin_edge_current;
7812
      clkin_edge_current := NOW;
7813
      clkin_period_real(2) <= clkin_period_real(1);
7814
      clkin_period_real(1) <= clkin_period_real(0);
7815
      if (clkin_edge_previous /= 0 ps) then
7816
        clkin_period_real(0) <= clkin_edge_current - clkin_edge_previous;
7817
      end if;
7818
    end if;
7819
    if (no_stop'event) then
7820
      clkin_period_real(0) <= clkin_period_real0_temp;
7821
    end if;
7822
    wait on clkin_div, no_stop, rst_ipd;
7823
  end process determine_clock_period;
7824
 
7825
  evaluate_clock_period : process
7826
    variable Message : line;
7827
  begin
7828
    if ((rising_edge(rst_ipd)) or (rst_ipd = '1')) then
7829
      lock_period <= '0';
7830
      clock_stopped <= '1';
7831
      clkin_period_real0_temp <= 0 ps;
7832
    else
7833
      if (falling_edge(clkin_div)) then
7834
        if (lock_period = '0') then
7835
          if ((clkin_period_real(0) /= 0 ps ) and (clkin_period_real(0) - cycle_jitter <= clkin_period_real(1)) and (clkin_period_real(1) <= clkin_period_real(0) + cycle_jitter) and (clkin_period_real(1) - cycle_jitter <= clkin_period_real(2)) and (clkin_period_real(2) <= clkin_period_real(1) + cycle_jitter)) then
7836
            lock_period <= '1';
7837
            period_orig <= (clkin_period_real(0) + clkin_period_real(1) + clkin_period_real(2)) / 3;
7838
            period <= clkin_period_real(0);
7839
          end if;
7840
        elsif (lock_period = '1') then
7841
          if (100000000 ns < clkin_period_real(0)) then
7842
            Write ( Message, string'(" Warning : CLKIN stopped toggling on instance "));
7843
            Write ( Message, Instancepath );
7844
            Write ( Message, string'(" exceeds "));
7845
            Write ( Message, string'(" 100 ms "));
7846
            Write ( Message, string'(" Current CLKIN Period = "));
7847
            Write ( Message, clkin_period_real(0));
7848
            assert false report Message.all severity warning;
7849
            DEALLOCATE (Message);
7850
            lock_period <= '0';
7851
            wait until (falling_edge(rst_reg(2)));
7852
          elsif ((period_orig * 2 < clkin_period_real(0)) and (clock_stopped = '0')) then
7853
              clkin_period_real0_temp <= clkin_period_real(1);
7854
              no_stop <= not no_stop;
7855
              clock_stopped <= '1';
7856
          elsif ((clkin_period_real(0) < period_orig - period_jitter) or (period_orig + period_jitter < clkin_period_real(0))) then
7857
            Write ( Message, string'(" Warning : Input Clock Period Jitter on instance "));
7858
            Write ( Message, Instancepath );
7859
            Write ( Message, string'(" exceeds "));
7860
            Write ( Message, period_jitter );
7861
            Write ( Message, string'(" Locked CLKIN Period =  "));
7862
            Write ( Message, period_orig );
7863
            Write ( Message, string'(" Current CLKIN Period =  "));
7864
            Write ( Message, clkin_period_real(0) );
7865
            assert false report Message.all severity warning;
7866
            DEALLOCATE (Message);
7867
            lock_period <= '0';
7868
            wait until (falling_edge(rst_reg(2)));
7869
          elsif ((clkin_period_real(0) < clkin_period_real(1) - cycle_jitter) or (clkin_period_real(1) + cycle_jitter < clkin_period_real(0))) then
7870
            Write ( Message, string'(" Warning : Input Clock Cycle Jitter on on instance "));
7871
            Write ( Message, Instancepath );
7872
            Write ( Message, string'(" exceeds "));
7873
            Write ( Message, cycle_jitter );
7874
            Write ( Message, string'(" Previous CLKIN Period =  "));
7875
            Write ( Message, clkin_period_real(1) );
7876
            Write ( Message, string'(" Current CLKIN Period =  "));
7877
            Write ( Message, clkin_period_real(0) );
7878
            assert false report Message.all severity warning;
7879
            DEALLOCATE (Message);
7880
            lock_period <= '0';
7881
            wait until (falling_edge(rst_reg(2)));
7882
          else
7883
            period <= clkin_period_real(0);
7884
            clock_stopped <= '0';
7885
          end if;
7886
        end if;
7887
      end if;
7888
    end if;
7889
    wait on clkin_div, rst_ipd;
7890
  end process evaluate_clock_period;
7891
 
7892
  lock_period_dly1 <= transport lock_period after 1 ps;
7893
  lock_period_dly <= transport lock_period_dly1 after period/2;
7894
 
7895
  lock_period_pulse <= '1' when ((lock_period = '1') and (lock_period_dly = '0')) else '0';
7896
 
7897
--
7898
--determine clock delay
7899
--  
7900
 
7901
  determine_clock_delay : process
7902
    variable delay_edge : time := 0 ps;
7903
    variable temp1 : integer := 0;
7904
    variable temp2 : integer := 0;
7905
    variable temp : integer := 0;
7906
    variable delay_edge_current : time := 0 ps;
7907
  begin
7908
    if ((rising_edge(rst_ipd)) or (rst_ipd = '1')) then
7909
      fb_delay <= 0 ps;
7910
      fb_delay_found <= '0';
7911
    else
7912
      if (rising_edge(lock_ps_dly)) then
7913
        if  ((lock_period = '1') and (clkfb_type /= 0)) then
7914
          if (clkfb_type = 1) then
7915
            wait until ((rising_edge(clk0_sig)) or (rst_ipd'event));
7916
            delay_edge := NOW;
7917
          elsif (clkfb_type = 2) then
7918
            wait until ((rising_edge(clk2x_sig)) or (rst_ipd'event));
7919
            delay_edge := NOW;
7920
          end if;
7921
          wait until ((rising_edge(clkfb_ipd)) or (rst_ipd'event));
7922
          temp1 := ((NOW*1) - (delay_edge*1))/ (1 ps);
7923
          temp2 := (period_orig * 1)/ (1 ps);
7924
          temp := temp1 mod temp2;
7925
          fb_delay <= temp * 1 ps;
7926
          fb_delay_found <= '1';
7927
        end if;
7928
      end if;
7929
    end if;
7930
    wait on lock_ps_dly, rst_ipd;
7931
  end process determine_clock_delay;
7932
--
7933
--  determine feedback lock
7934
--  
7935
  GEN_CLKFB_WINDOW : process
7936
  begin
7937
    if ((rising_edge(rst_ipd)) or (rst_ipd = '1')) then
7938
      clkfb_window <= '0';
7939
    else
7940
      if (rising_edge(clkfb_chk)) then
7941
        wait for 0 ps;
7942
        clkfb_window <= '1';
7943
        wait for cycle_jitter;
7944
        clkfb_window <= '0';
7945
      end if;
7946
    end if;
7947
    wait on clkfb_chk, rst_ipd;
7948
  end process GEN_CLKFB_WINDOW;
7949
 
7950
  GEN_CLKIN_WINDOW : process
7951
  begin
7952
    if ((rising_edge(rst_ipd)) or (rst_ipd = '1')) then
7953
      clkin_window <= '0';
7954
    else
7955
      if (rising_edge(clkin_fb)) then
7956
        wait for 0 ps;
7957
        clkin_window <= '1';
7958
        wait for cycle_jitter;
7959
        clkin_window <= '0';
7960
      end if;
7961
    end if;
7962
    wait on clkin_fb, rst_ipd;
7963
  end process GEN_CLKIN_WINDOW;
7964
 
7965
  set_reset_lock_clkin : process
7966
  begin
7967
    if ((rising_edge(rst_ipd)) or (rst_ipd = '1')) then
7968
      lock_clkin <= '0';
7969
    else
7970
      if (rising_edge(clkin_fb)) then
7971
        wait for 1 ps;
7972
        if (((clkfb_window = '1') and (fb_delay_found = '1')) or ((clkin_lost_out = '1') and (lock_out(0) = '1'))) then
7973
          lock_clkin <= '1';
7974
        else
7975
          if (chk_enable = '1') then
7976
            lock_clkin <= '0';
7977
          end if;
7978
        end if;
7979
      end if;
7980
    end if;
7981
    wait on clkin_fb, rst_ipd;
7982
  end process set_reset_lock_clkin;
7983
 
7984
  set_reset_lock_clkfb : process
7985
  begin
7986
    if ((rising_edge(rst_ipd)) or (rst_ipd = '1')) then
7987
      lock_clkfb <= '0';
7988
    else
7989
      if (rising_edge(clkfb_chk)) then
7990
        wait for 1 ps;
7991
        if (((clkin_window = '1') and (fb_delay_found = '1')) or ((clkin_lost_out = '1') and (lock_out(0) = '1')))then
7992
          lock_clkfb <= '1';
7993
        else
7994
          if (chk_enable = '1') then
7995
            lock_clkfb <= '0';
7996
          end if;
7997
        end if;
7998
      end if;
7999
    end if;
8000
    wait on clkfb_chk, rst_ipd;
8001
  end process set_reset_lock_clkfb;
8002
 
8003
  assign_lock_delay : process
8004
  begin
8005
    if ((rising_edge(rst_ipd)) or (rst_ipd = '1')) then
8006
      lock_delay <= '0';
8007
    else
8008
      if (falling_edge(clkin_fb)) then
8009
        lock_delay <= lock_clkin or lock_clkfb;
8010
      end if;
8011
    end if;
8012
    wait on clkin_fb, rst_ipd;
8013
  end process;
8014
 
8015
--
8016
--generate lock signal
8017
--  
8018
 
8019
  generate_lock : process(clkin_ps, rst_ipd)
8020
  begin
8021
    if (rst_ipd='1') then
8022
      lock_out <= "00";
8023
      locked_out <= '0';
8024
      lock_out1_neg <= '0';
8025
    elsif (rising_edge(clkin_ps)) then
8026
        if (clkfb_type = 0) then
8027
          lock_out(0) <= lock_period;
8028
        else
8029
          lock_out(0) <= lock_period and lock_delay and lock_fb;
8030
        end if;
8031
        lock_out(1) <= lock_out(0);
8032
        locked_out <= lock_out(1);
8033
    elsif (falling_edge(clkin_ps)) then
8034
        lock_out1_neg <= lock_out(1);
8035
    end if;
8036
  end process generate_lock;
8037
 
8038
--
8039
--generate the clk1x_out
8040
--  
8041
 
8042
  gen_clk1x : process( clkin_ps, rst_ipd)
8043
  begin
8044
    if ((rising_edge(rst_ipd)) or (rst_ipd = '1')) then
8045
      clk0_out <= '0';
8046
    elsif (clkin_ps'event) then
8047
      if (clkin_ps = '1' ) then
8048
        if ((clk1x_type = 1) and (lock_out(0) = '1')) then
8049
          clk0_out <= '1', '0' after period/2;
8050
        else
8051
          clk0_out <= '1';
8052
        end if;
8053
      else
8054
        if ((clkin_ps = '0') and ((((clk1x_type = 1) and (lock_out(0) = '1')) = false) or ((lock_out(0) = '1') and (lock_out(1) = '0')))) then
8055
          clk0_out <= '0';
8056
        end if;
8057
      end if;
8058
    end if;
8059
  end process gen_clk1x;
8060
 
8061
 
8062
 
8063
 
8064
 
8065
--
8066
--generate the clk2x_out
8067
--    
8068
 
8069
  gen_clk2x : process
8070
  begin
8071
    if (rising_edge(rst_ipd) or (rst_ipd = '1')) then
8072
      clk2x_out <= '0';
8073
    else
8074
      if (rising_edge(clkin_ps)) then
8075
        clk2x_out <= '1';
8076
        wait for (period / 4);
8077
        clk2x_out <= '0';
8078
        wait for (period / 4);
8079
        clk2x_out <= '1';
8080
        wait for (period / 4);
8081
        clk2x_out <= '0';
8082
      end if;
8083
    end if;
8084
    wait on clkin_ps, rst_ipd;
8085
  end process gen_clk2x;
8086
 
8087
-- 
8088
--generate the clkdv_out
8089
-- 
8090
 
8091
  gen_clkdv : process (clkin_ps, rst_ipd)
8092
  begin
8093
    if (rst_ipd='1') then
8094
       clkdv_out <= '0';
8095
       clkdv_cnt <= 0;
8096
    elsif ((rising_edge(clkin_ps)) or (falling_edge(clkin_ps))) then
8097
      if (lock_out1_neg = '1') then
8098
         if (clkdv_cnt >= divide_type -1) then
8099
           clkdv_cnt <= 0;
8100
         else
8101
           clkdv_cnt <= clkdv_cnt + 1;
8102
         end if;
8103
 
8104
         if (clkdv_cnt < divide_type /2) then
8105
            clkdv_out <= '1';
8106
         else
8107
           if ( ((divide_type rem (2)) > 0) and (dll_mode_type = 0)) then
8108
             clkdv_out <= '0' after (period/4);
8109
           else
8110
            clkdv_out <= '0';
8111
           end if;
8112
         end if;
8113
      end if;
8114
    end if;
8115
  end process;
8116
 
8117
--
8118
-- generate fx output signal
8119
--
8120
 
8121
  calculate_period_fx : process
8122
  begin
8123
    if (lock_period = '1') then
8124
      period_fx <= (period * denominator) / (numerator * 2);
8125
      remain_fx <= (((period/1 ps) * denominator) mod (numerator * 2)) * 1 ps;
8126
    end if;
8127
    wait on lock_period, period, denominator, numerator;
8128
  end process calculate_period_fx;
8129
 
8130
  generate_clkfx : process
8131
    variable temp : integer;
8132
  begin
8133
    if (rst_ipd = '1') then
8134
      clkfx_out <= '0';
8135
    elsif (clkin_lost_out_ext = '1') then
8136
       wait until (rising_edge(rst_ipd));
8137
       clkfx_out <= '0';
8138
      wait until (falling_edge(rst_reg(2)));
8139
    elsif (rising_edge(clkin_ps)) then
8140
      if (lock_out(1) = '1') then
8141
        clkfx_out <= '1';
8142
        temp := numerator * 2 - 1 - 1;
8143
        for p in 0 to temp loop
8144
          wait for (period_fx);
8145
          clkfx_out <= not clkfx_out;
8146
        end loop;
8147
        if (period_fx > (period / 2)) then
8148
          wait for (period_fx - (period / 2));
8149
        end if;
8150
      end if;
8151
      if (clkin_lost_out_ext = '1') then
8152
        wait until (rising_edge(rst_ipd));
8153
        clkfx_out <= '0';
8154
        wait until (falling_edge(rst_reg(2)));
8155
      end if;
8156
    end if;
8157
    wait on clkin_lost_out_ext, clkin_ps, rst_ipd, rst_reg(2);
8158
  end process generate_clkfx;
8159
 
8160
 
8161
--
8162
--generate all output signal
8163
--
8164
 
8165
  schedule_p1_outputs : process
8166
  begin
8167
    if (CLK0_out'event) then
8168
      if (clkfb_type /= 0) then
8169
        CLK0 <= transport CLK0_out after clkout_delay;
8170
        clk0_sig <= transport CLK0_out after clkout_delay;
8171
      end if;
8172
      if ((dll_mode_type = 0) and (clkfb_type /= 0)) then
8173
        CLK90 <= transport clk0_out after (clkout_delay + period / 4);
8174
      end if;
8175
    end if;
8176
 
8177
    if (CLK0_out'event or rst_ipd'event)then
8178
      if (rst_ipd = '1') then
8179
        CLK180 <= '0';
8180
        CLK270 <= '0';
8181
      elsif (CLK0_out'event) then
8182
        if (clkfb_type /= 0) then
8183
          CLK180 <= transport (not clk0_out) after clkout_delay;
8184
        end if;
8185
        if ((dll_mode_type = 0) and (clkfb_type /= 0)) then
8186
          CLK270 <= transport (not clk0_out) after (clkout_delay + period/4);
8187
        end if;
8188
      end if;
8189
    end if;
8190
 
8191
    if (clk2x_out'event) then
8192
      if ((dll_mode_type = 0) and (clkfb_type /= 0)) then
8193
        CLK2X <= transport clk2x_out after clkout_delay;
8194
        clk2x_sig <= transport clk2x_out after clkout_delay;
8195
      end if;
8196
    end if;
8197
 
8198
    if (CLK2X_out'event or rst_ipd'event) then
8199
      if (rst_ipd = '1') then
8200
        CLK2X180 <= '0';
8201
      elsif (CLK2X_out'event) then
8202
        if ((dll_mode_type = 0) and (clkfb_type /= 0)) then
8203
          CLK2X180 <= transport (not CLK2X_out) after clkout_delay;
8204
        end if;
8205
      end if;
8206
    end if;
8207
 
8208
 
8209
    if (clkdv_out'event) then
8210
      if (clkfb_type /= 0) then
8211
        CLKDV <= transport clkdv_out after clkout_delay;
8212
      end if;
8213
    end if;
8214
 
8215
    if (clkfx_out'event or rst_ipd'event) then
8216
      if (rst_ipd = '1') then
8217
        CLKFX <= '0';
8218
      elsif (clkfx_out'event) then
8219
        CLKFX <= transport clkfx_out after clkout_delay;
8220
      end if;
8221
    end if;
8222
 
8223
    if (clkfx_out'event or (rising_edge(rst_ipd)) or first_time_locked'event or locked_out'event) then
8224
      if ((rst_ipd = '1') or (not first_time_locked)) then
8225
        CLKFX180 <= '0';
8226
      else
8227
        CLKFX180 <= transport (not clkfx_out) after clkout_delay;
8228
      end if;
8229
    end if;
8230
 
8231
    if (status_out(0)'event) then
8232
      status(0) <= status_out(0);
8233
    end if;
8234
 
8235
    if (status_out(1)'event) then
8236
      status(1) <= status_out(1);
8237
    end if;
8238
 
8239
    if (status_out(2)'event) then
8240
      status(2) <= status_out(2);
8241
    end if;
8242
 
8243
   wait on clk0_out, clk2x_out, clkdv_out, clkfx_out, first_time_locked, locked_out, rst_ipd, status_out;
8244
   end process;
8245
 
8246
  assign_status_out : process
8247
    begin
8248
      if (rst_ipd = '1') then
8249
        status_out(0) <= '0';
8250
        status_out(1) <= '0';
8251
        status_out(2) <= '0';
8252
      elsif (ps_overflow_out_ext'event) then
8253
        status_out(0) <= ps_overflow_out_ext;
8254
      elsif (clkin_lost_out_ext'event) then
8255
        status_out(1) <= clkin_lost_out_ext;
8256
      elsif (clkfx_lost_out_ext'event) then
8257
        status_out(2) <= clkfx_lost_out_ext;
8258
      end if;
8259
      wait on clkin_lost_out_ext, clkfx_lost_out_ext, ps_overflow_out_ext, rst_ipd;
8260
    end process assign_status_out;
8261
 
8262
   locked_out_out <= 'X' when rst_flag = '1' else locked_out;
8263
 
8264
-- LOCKED <= locked_out_out;
8265
-- PSDONE <= psdone_out;
8266
-- LOCKED_sig <= locked_out_out;    
8267
 
8268
  schedule_outputs : process
8269
    variable PSDONE_GlitchData : VitalGlitchDataType;
8270
    variable LOCKED_GlitchData : VitalGlitchDataType;
8271
  begin
8272
    VitalPathDelay01 (
8273
      OutSignal  => PSDONE,
8274
      GlitchData => PSDONE_GlitchData,
8275
      OutSignalName => "PSDONE",
8276
      OutTemp => psdone_out,
8277
      Paths => (0 => (psdone_out'last_event, tpd_PSCLK_PSDONE, true)),
8278
      Mode => OnEvent,
8279
      Xon => Xon,
8280
      MsgOn => MsgOn,
8281
      MsgSeverity => warning
8282
      );
8283
    LOCKED_sig <= locked_out_out after tpd_CLKIN_LOCKED(tr01);
8284
    VitalPathDelay01 (
8285
      OutSignal  => LOCKED,
8286
      GlitchData => LOCKED_GlitchData,
8287
      OutSignalName => "LOCKED",
8288
      OutTemp => locked_out_out,
8289
      Paths => (0 => (locked_out_out'last_event, tpd_CLKIN_LOCKED, true)),
8290
      Mode => OnEvent,
8291
      Xon => Xon,
8292
      MsgOn => MsgOn,
8293
      MsgSeverity => warning
8294
      );
8295
    wait on  locked_out_out, psdone_out;
8296
  end process schedule_outputs;
8297
 
8298
  VitalTimingCheck : process
8299
    variable Tviol_PSINCDEC_PSCLK_posedge : std_ulogic := '0';
8300
    variable Tmkr_PSINCDEC_PSCLK_posedge  : VitalTimingDataType := VitalTimingDataInit;
8301
    variable Tviol_PSEN_PSCLK_posedge        : std_ulogic := '0';
8302
    variable Tmkr_PSEN_PSCLK_posedge : VitalTimingDataType := VitalTimingDataInit;
8303
    variable Pviol_CLKIN   : std_ulogic := '0';
8304
    variable PInfo_CLKIN   : VitalPeriodDataType := VitalPeriodDataInit;
8305
    variable Pviol_PSCLK   : std_ulogic := '0';
8306
    variable PInfo_PSCLK   : VitalPeriodDataType := VitalPeriodDataInit;
8307
    variable Pviol_RST   : std_ulogic := '0';
8308
    variable PInfo_RST   : VitalPeriodDataType := VitalPeriodDataInit;
8309
 
8310
  begin
8311
    if (TimingChecksOn) then
8312
      VitalSetupHoldCheck (
8313
        Violation               => Tviol_PSINCDEC_PSCLK_posedge,
8314
        TimingData              => Tmkr_PSINCDEC_PSCLK_posedge,
8315
        TestSignal              => PSINCDEC_dly,
8316
        TestSignalName          => "PSINCDEC",
8317
        TestDelay               => tisd_PSINCDEC_PSCLK,
8318
        RefSignal               => PSCLK_dly,
8319
        RefSignalName          => "PSCLK",
8320
        RefDelay                => ticd_PSCLK,
8321
        SetupHigh               => tsetup_PSINCDEC_PSCLK_posedge_posedge,
8322
        SetupLow                => tsetup_PSINCDEC_PSCLK_negedge_posedge,
8323
        HoldLow                => thold_PSINCDEC_PSCLK_posedge_posedge,
8324
        HoldHigh                 => thold_PSINCDEC_PSCLK_negedge_posedge,
8325
        CheckEnabled            => (TO_X01(((NOT RST_ipd)) AND (PSEN_dly)) /= '0'),
8326
        RefTransition           => 'R',
8327
        HeaderMsg               => InstancePath & "/X_DCM_SP",
8328
        Xon                     => Xon,
8329
        MsgOn                   => MsgOn,
8330
        MsgSeverity             => warning);
8331
 
8332
      VitalSetupHoldCheck (
8333
        Violation               => Tviol_PSEN_PSCLK_posedge,
8334
        TimingData              => Tmkr_PSEN_PSCLK_posedge,
8335
        TestSignal              => PSEN_dly,
8336
        TestSignalName          => "PSEN",
8337
        TestDelay               => tisd_PSEN_PSCLK,
8338
        RefSignal               => PSCLK_dly,
8339
        RefSignalName          => "PSCLK",
8340
        RefDelay                => ticd_PSCLK,
8341
        SetupHigh               => tsetup_PSEN_PSCLK_posedge_posedge,
8342
        SetupLow                => tsetup_PSEN_PSCLK_negedge_posedge,
8343
        HoldLow                => thold_PSEN_PSCLK_posedge_posedge,
8344
        HoldHigh                 => thold_PSEN_PSCLK_negedge_posedge,
8345
        CheckEnabled            => TO_X01(NOT RST_ipd)  /= '0',
8346
        RefTransition           => 'R',
8347
        HeaderMsg               => InstancePath & "/X_DCM_SP",
8348
        Xon                     => Xon,
8349
        MsgOn                   => MsgOn,
8350
        MsgSeverity             => warning);
8351
 
8352
      VitalPeriodPulseCheck (
8353
        Violation               => Pviol_PSCLK,
8354
        PeriodData              => PInfo_PSCLK,
8355
        TestSignal              => PSCLK_dly,
8356
        TestSignalName          => "PSCLK",
8357
        TestDelay               => 0 ns,
8358
        Period                  => tperiod_PSCLK_POSEDGE,
8359
        PulseWidthHigh          => tpw_PSCLK_posedge,
8360
        PulseWidthLow           => tpw_PSCLK_negedge,
8361
        CheckEnabled            => true,
8362
        HeaderMsg               => InstancePath &"/X_DCM_SP",
8363
        Xon                     => Xon,
8364
        MsgOn                   => MsgOn,
8365
        MsgSeverity             => warning);
8366
 
8367
      VitalPeriodPulseCheck (
8368
        Violation               => Pviol_CLKIN,
8369
        PeriodData              => PInfo_CLKIN,
8370
        TestSignal              => CLKIN_ipd,
8371
        TestSignalName          => "CLKIN",
8372
        TestDelay               => 0 ns,
8373
        Period                  => tperiod_CLKIN_POSEDGE,
8374
        PulseWidthHigh          => tpw_CLKIN_posedge,
8375
        PulseWidthLow           => tpw_CLKIN_negedge,
8376
        CheckEnabled            => TO_X01(NOT RST_ipd)  /= '0',
8377
        HeaderMsg               => InstancePath &"/X_DCM_SP",
8378
        Xon                     => Xon,
8379
        MsgOn                   => MsgOn,
8380
        MsgSeverity             => warning);
8381
 
8382
      VitalPeriodPulseCheck (
8383
        Violation               => Pviol_RST,
8384
        PeriodData              => PInfo_RST,
8385
        TestSignal              => RST_ipd,
8386
        TestSignalName          => "RST",
8387
        TestDelay               => 0 ns,
8388
        Period                  => 0 ns,
8389
        PulseWidthHigh          => tpw_RST_posedge,
8390
        PulseWidthLow           => 0 ns,
8391
        CheckEnabled            => true,
8392
        HeaderMsg               => InstancePath &"/X_DCM_SP",
8393
        Xon                     => Xon,
8394
        MsgOn                   => MsgOn,
8395
        MsgSeverity             => warning);
8396
    end if;
8397
    wait on CLKIN_ipd, PSCLK_dly, PSEN_dly, PSINCDEC_dly, RST_ipd;
8398
  end process VITALTimingCheck;
8399
end X_DCM_SP_V;
8400
 
8401
library IEEE;
8402
use IEEE.STD_LOGIC_1164.all;
8403
library unisim;
8404
 
8405
  entity DCM is
8406
    generic (
8407
      CLKDV_DIVIDE : real := 2.0;
8408
      CLKFX_DIVIDE : integer := 1;
8409
      CLKFX_MULTIPLY : integer := 4;
8410
      CLKIN_DIVIDE_BY_2 : boolean := false;
8411
      CLKIN_PERIOD : real := 10.0;
8412
      CLKOUT_PHASE_SHIFT : string := "NONE";
8413
      CLK_FEEDBACK : string := "1X";
8414
      DESKEW_ADJUST : string := "SYSTEM_SYNCHRONOUS";
8415
      DFS_FREQUENCY_MODE : string := "LOW";
8416
      DLL_FREQUENCY_MODE : string := "LOW";
8417
      DSS_MODE : string := "NONE";
8418
      DUTY_CYCLE_CORRECTION : boolean := true;
8419
      FACTORY_JF : bit_vector := X"C080";
8420
      PHASE_SHIFT : integer := 0;
8421
      STARTUP_WAIT : boolean := false
8422
    );
8423
    port (
8424
      CLKFB    : in  std_logic;
8425
      CLKIN    : in  std_logic;
8426
      DSSEN    : in  std_logic;
8427
      PSCLK    : in  std_logic;
8428
      PSEN     : in  std_logic;
8429
      PSINCDEC : in  std_logic;
8430
      RST      : in  std_logic;
8431
      CLK0     : out std_logic;
8432
      CLK90    : out std_logic;
8433
      CLK180   : out std_logic;
8434
      CLK270   : out std_logic;
8435
      CLK2X    : out std_logic;
8436
      CLK2X180 : out std_logic;
8437
      CLKDV    : out std_logic;
8438
      CLKFX    : out std_logic;
8439
      CLKFX180 : out std_logic;
8440
      LOCKED   : out std_logic;
8441
      PSDONE   : out std_logic;
8442
      STATUS   : out std_logic_vector (7 downto 0));
8443
  end ;
8444
 
8445
  architecture sim of DCM is
8446
  begin
8447
    x0 : entity unisim.X_DCM
8448
    generic map (
8449
      CLKDV_DIVIDE => CLKDV_DIVIDE, CLKFX_DIVIDE => CLKFX_DIVIDE,
8450
      CLKFX_MULTIPLY => CLKFX_MULTIPLY, CLKIN_DIVIDE_BY_2 => CLKIN_DIVIDE_BY_2,
8451
      CLKIN_PERIOD => CLKIN_PERIOD, CLKOUT_PHASE_SHIFT => CLKOUT_PHASE_SHIFT,
8452
      CLK_FEEDBACK => CLK_FEEDBACK, DESKEW_ADJUST => DESKEW_ADJUST,
8453
      DFS_FREQUENCY_MODE => DFS_FREQUENCY_MODE, DLL_FREQUENCY_MODE => DLL_FREQUENCY_MODE,
8454
      DSS_MODE => DSS_MODE, DUTY_CYCLE_CORRECTION => DUTY_CYCLE_CORRECTION,
8455
      FACTORY_JF => FACTORY_JF, PHASE_SHIFT => PHASE_SHIFT,
8456
      STARTUP_WAIT => STARTUP_WAIT
8457
    )
8458
    port map (
8459
      CLKFB => CLKFB, CLKIN => CLKIN, DSSEN => DSSEN, PSCLK => PSCLK,
8460
      PSEN => PSEN, PSINCDEC => PSINCDEC, RST => RST, CLK0 => CLK0,
8461
      CLK90 => CLK90, CLK180 => CLK180, CLK270 => CLK270, CLK2X => CLK2X,
8462
      CLK2X180 => CLK2X180, CLKDV => CLKDV,  CLKFX => CLKFX,
8463
      CLKFX180 => CLKFX180, LOCKED => LOCKED, PSDONE => PSDONE,
8464
      STATUS => STATUS);
8465
  end;
8466
 
8467
library IEEE;
8468
use IEEE.STD_LOGIC_1164.all;
8469
 
8470
library grlib;
8471
use IEEE.NUMERIC_STD.all;
8472
 
8473
library STD;
8474
use STD.TEXTIO.all;
8475
 
8476
library unisim;
8477
--use unisim.vpkg.all;
8478
use unisim.vpkg.all;
8479
 
8480
entity SYSMON is
8481
 
8482
generic (
8483
 
8484
 
8485
                INIT_40 : bit_vector := X"0000";
8486
                INIT_41 : bit_vector := X"0000";
8487
                INIT_42 : bit_vector := X"0800";
8488
                INIT_43 : bit_vector := X"0000";
8489
                INIT_44 : bit_vector := X"0000";
8490
                INIT_45 : bit_vector := X"0000";
8491
                INIT_46 : bit_vector := X"0000";
8492
                INIT_47 : bit_vector := X"0000";
8493
                INIT_48 : bit_vector := X"0000";
8494
                INIT_49 : bit_vector := X"0000";
8495
                INIT_4A : bit_vector := X"0000";
8496
                INIT_4B : bit_vector := X"0000";
8497
                INIT_4C : bit_vector := X"0000";
8498
                INIT_4D : bit_vector := X"0000";
8499
                INIT_4E : bit_vector := X"0000";
8500
                INIT_4F : bit_vector := X"0000";
8501
                INIT_50 : bit_vector := X"0000";
8502
                INIT_51 : bit_vector := X"0000";
8503
                INIT_52 : bit_vector := X"0000";
8504
                INIT_53 : bit_vector := X"0000";
8505
                INIT_54 : bit_vector := X"0000";
8506
                INIT_55 : bit_vector := X"0000";
8507
                INIT_56 : bit_vector := X"0000";
8508
                INIT_57 : bit_vector := X"0000";
8509
                SIM_MONITOR_FILE : string := "design.txt"
8510
  );
8511
 
8512
port (
8513
                ALM : out std_logic_vector(2 downto 0);
8514
                BUSY : out std_ulogic;
8515
                CHANNEL : out std_logic_vector(4 downto 0);
8516
                DO : out std_logic_vector(15 downto 0);
8517
                DRDY : out std_ulogic;
8518
                EOC : out std_ulogic;
8519
                EOS : out std_ulogic;
8520
                JTAGBUSY : out std_ulogic;
8521
                JTAGLOCKED : out std_ulogic;
8522
                JTAGMODIFIED : out std_ulogic;
8523
                OT : out std_ulogic;
8524
 
8525
                CONVST : in std_ulogic;
8526
                CONVSTCLK : in std_ulogic;
8527
                DADDR : in std_logic_vector(6 downto 0);
8528
                DCLK : in std_ulogic;
8529
                DEN : in std_ulogic;
8530
                DI : in std_logic_vector(15 downto 0);
8531
                DWE : in std_ulogic;
8532
                RESET : in std_ulogic;
8533
                VAUXN : in std_logic_vector(15 downto 0);
8534
                VAUXP : in std_logic_vector(15 downto 0);
8535
                VN : in std_ulogic;
8536
                VP : in std_ulogic
8537
     );
8538
 
8539
 
8540
 
8541
end SYSMON;
8542
 
8543
 
8544
architecture SYSMON_V of SYSMON is
8545
 
8546
  ---------------------------------------------------------------------------
8547
  -- Function SLV_TO_INT converts a std_logic_vector TO INTEGER
8548
  ---------------------------------------------------------------------------
8549
  function SLV_TO_INT(SLV: in std_logic_vector
8550
                      ) return integer is
8551
 
8552
    variable int : integer;
8553
  begin
8554
    int := 0;
8555
    for i in SLV'high downto SLV'low loop
8556
      int := int * 2;
8557
      if SLV(i) = '1' then
8558
        int := int + 1;
8559
      end if;
8560
    end loop;
8561
    return int;
8562
  end;
8563
 
8564
 
8565
  ---------------------------------------------------------------------------
8566
  -- Function ADDR_IS_VALID checks for the validity of the argument. A FALSE
8567
  -- is returned if any argument bit is other than a '0' or '1'.
8568
  ---------------------------------------------------------------------------
8569
  function ADDR_IS_VALID (
8570
    SLV : in std_logic_vector
8571
    ) return boolean is
8572
 
8573
    variable IS_VALID : boolean := TRUE;
8574
 
8575
  begin
8576
    for I in SLV'high downto SLV'low loop
8577
      if (SLV(I) /= '0' AND SLV(I) /= '1') then
8578
        IS_VALID := FALSE;
8579
      end if;
8580
    end loop;
8581
    return IS_VALID;
8582
  end ADDR_IS_VALID;
8583
 
8584
  function int2real( int_in : in integer) return real is
8585
    variable conline1 : line;
8586
    variable rl_value : real;
8587
    variable tmpv1 : real;
8588
    variable tmpv2 : real := 1.0;
8589
    variable tmpi : integer;
8590
  begin
8591
    tmpi := int_in;
8592
    write (conline1, tmpi);
8593
    write (conline1, string'(".0 "));
8594
    write (conline1, tmpv2);
8595
    read (conline1, tmpv1);
8596
    rl_value := tmpv1;
8597
    return rl_value;
8598
    DEALLOCATE(conline1);
8599
  end int2real;
8600
 
8601
 
8602
  function real2int( real_in : in real) return integer is
8603
    variable int_value : integer;
8604
    variable tmpt : time;
8605
    variable tmpt1 : time;
8606
    variable tmpa : real;
8607
    variable tmpr : real;
8608
    variable int_out : integer;
8609
  begin
8610
    tmpa := abs(real_in);
8611
    tmpt := tmpa * 1 ps;
8612
    int_value := (tmpt / 1 ps ) * 1;
8613
    tmpt1 := int_value * 1 ps;
8614
      tmpr := int2real(int_value);
8615
 
8616
    if ( real_in < 0.0000) then
8617
       if (tmpr > tmpa) then
8618
           int_out := 1 - int_value;
8619
       else
8620
           int_out := -int_value;
8621
       end if;
8622
    else
8623
      if (tmpr > tmpa) then
8624
           int_out := int_value - 1;
8625
      else
8626
           int_out := int_value;
8627
      end if;
8628
    end if;
8629
    return int_out;
8630
  end real2int;
8631
 
8632
 
8633
    FUNCTION  To_Upper  ( CONSTANT  val    : IN String
8634
                         ) RETURN STRING IS
8635
        VARIABLE result   : string (1 TO val'LENGTH) := val;
8636
        VARIABLE ch       : character;
8637
    BEGIN
8638
        FOR i IN 1 TO val'LENGTH LOOP
8639
            ch := result(i);
8640
            EXIT WHEN ((ch = NUL) OR (ch = nul));
8641
            IF ( ch >= 'a' and ch <= 'z') THEN
8642
                  result(i) := CHARACTER'VAL( CHARACTER'POS(ch)
8643
                                       - CHARACTER'POS('a')
8644
                                       + CHARACTER'POS('A') );
8645
            END IF;
8646
        END LOOP;
8647
        RETURN result;
8648
    END To_Upper;
8649
 
8650
    procedure get_token(buf : inout LINE; token : out string;
8651
                            token_len : out integer)
8652
    is
8653
       variable index : integer := buf'low;
8654
       variable tk_index : integer := 0;
8655
       variable old_buf : LINE := buf;
8656
    BEGIN
8657
         while ((index <= buf' high) and ((buf(index) = ' ') or
8658
                                         (buf(index) = HT))) loop
8659
              index := index + 1;
8660
         end loop;
8661
 
8662
         while((index <= buf'high) and ((buf(index) /= ' ') and
8663
                                    (buf(index) /= HT))) loop
8664
              tk_index := tk_index + 1;
8665
              token(tk_index) := buf(index);
8666
              index := index + 1;
8667
         end loop;
8668
 
8669
         token_len := tk_index;
8670
 
8671
         buf := new string'(old_buf(index to old_buf'high));
8672
           old_buf := NULL;
8673
    END;
8674
 
8675
    procedure skip_blanks(buf : inout LINE)
8676
    is
8677
         variable index : integer := buf'low;
8678
         variable old_buf : LINE := buf;
8679
    BEGIN
8680
         while ((index <= buf' high) and ((buf(index) = ' ') or
8681
                                       (buf(index) = HT))) loop
8682
              index := index + 1;
8683
         end loop;
8684
         buf := new string'(old_buf(index to old_buf'high));
8685
           old_buf := NULL;
8686
    END;
8687
 
8688
    procedure infile_format
8689
    is
8690
         variable message_line : line;
8691
    begin
8692
 
8693
    write(message_line, string'("***** SYSMON Simulation Analog Data File Format ******"));
8694
    writeline(output, message_line);
8695
    write(message_line, string'("NAME: design.txt or user file name passed with generic sim_monitor_file"));
8696
    writeline(output, message_line);
8697
    write(message_line, string'("FORMAT: First line is header line. Valid column name are: TIME TEMP VCCINT VCCAUX VP VN VAUXP[0] VAUXN[0] ...."));
8698
    writeline(output, message_line);
8699
    write(message_line, string'("TIME must be in first column."));
8700
    writeline(output, message_line);
8701
    write(message_line, string'("Time value need to be integer in ns scale"));
8702
    writeline(output, message_line);
8703
    write(message_line, string'("Analog  value need to be real and contain a decimal  point '.', zero should be 0.0, 3 should be 3.0"));
8704
    writeline(output, message_line);
8705
    write(message_line, string'("Each line including header line can not have extra space after the last character/digit."));
8706
    writeline(output, message_line);
8707
    write(message_line, string'("Each data line must have same number of columns as the header line."));
8708
    writeline(output, message_line);
8709
    write(message_line, string'("Comment line start with -- or //"));
8710
    writeline(output, message_line);
8711
    write(message_line, string'("Example:"));
8712
    writeline(output, message_line);
8713
    write(message_line, string'("TIME TEMP VCCINT  VP VN VAUXP[0] VAUXN[0]"));
8714
    writeline(output, message_line);
8715
    write(message_line, string'("000  125.6  1.0  0.7  0.4  0.3  0.6"));
8716
    writeline(output, message_line);
8717
    write(message_line, string'("200  25.6   0.8  0.5  0.3  0.8  0.2"));
8718
    writeline(output, message_line);
8719
 
8720
    end infile_format;
8721
 
8722
    type     REG_FILE   is  array (integer range <>) of
8723
                            std_logic_vector(15 downto 0);
8724
    signal   dr_sram     :  REG_FILE(16#40# to 16#57#) :=
8725
               (
8726
                  16#40# => TO_STDLOGICVECTOR(INIT_40),
8727
                  16#41# => TO_STDLOGICVECTOR(INIT_41),
8728
                  16#42# => TO_STDLOGICVECTOR(INIT_42),
8729
                  16#43# => TO_STDLOGICVECTOR(INIT_43),
8730
                  16#44# => TO_STDLOGICVECTOR(INIT_44),
8731
                  16#45# => TO_STDLOGICVECTOR(INIT_45),
8732
                  16#46# => TO_STDLOGICVECTOR(INIT_46),
8733
                  16#47# => TO_STDLOGICVECTOR(INIT_47),
8734
                  16#48# => TO_STDLOGICVECTOR(INIT_48),
8735
                  16#49# => TO_STDLOGICVECTOR(INIT_49),
8736
                  16#4A# => TO_STDLOGICVECTOR(INIT_4A),
8737
                  16#4B# => TO_STDLOGICVECTOR(INIT_4B),
8738
                  16#4C# => TO_STDLOGICVECTOR(INIT_4C),
8739
                  16#4D# => TO_STDLOGICVECTOR(INIT_4D),
8740
                  16#4E# => TO_STDLOGICVECTOR(INIT_4E),
8741
                  16#4F# => TO_STDLOGICVECTOR(INIT_4F),
8742
                  16#50# => TO_STDLOGICVECTOR(INIT_50),
8743
                  16#51# => TO_STDLOGICVECTOR(INIT_51),
8744
                  16#52# => TO_STDLOGICVECTOR(INIT_52),
8745
                  16#53# => TO_STDLOGICVECTOR(INIT_53),
8746
                  16#54# => TO_STDLOGICVECTOR(INIT_54),
8747
                  16#55# => TO_STDLOGICVECTOR(INIT_55),
8748
                  16#56# => TO_STDLOGICVECTOR(INIT_56),
8749
                  16#57# => TO_STDLOGICVECTOR(INIT_57)
8750
               );
8751
 
8752
       signal ot_sf_limit_low_reg : unsigned(15 downto 0) := "1010111001000000";  --X"AE40";
8753
       type     adc_statetype    is (INIT_STATE, ACQ_STATE, CONV_STATE,
8754
                                   ADC_PRE_END, END_STATE, SINGLE_SEQ_STATE);
8755
       type     ANALOG_DATA    is array (0 to 31) of real;
8756
       type     DR_data_reg    is array (0 to 63) of
8757
                                  std_logic_vector(15 downto 0);
8758
       type     ACC_ARRAY      is array (0 to 31) of integer;
8759
       type     int_array      is array(0 to 31) of integer;
8760
       type     seq_array      is array(32 downto 0 ) of integer;
8761
 
8762
       signal   ot_limit_reg     : UNSIGNED(15 downto 0) := "1100011110000000";
8763
       signal   adc_state         : adc_statetype := CONV_STATE;
8764
       signal   next_state        : adc_statetype;
8765
       signal   cfg_reg0         : std_logic_vector(15 downto 0) := "0000000000000000";
8766
       signal   cfg_reg0_adc     : std_logic_vector(15 downto 0) := "0000000000000000";
8767
       signal   cfg_reg0_seq     : std_logic_vector(15 downto 0) := "0000000000000000";
8768
       signal   cfg_reg1         : std_logic_vector(15 downto 0) := "0000000000000000";
8769
       signal   cfg_reg1_init    : std_logic_vector(15 downto 0) := "0000000000000000";
8770
       signal   cfg_reg2         : std_logic_vector(15 downto 0) := "0000000000000000";
8771
       signal   seq1_0           : std_logic_vector(1 downto 0) := "00";
8772
       signal   curr_seq1_0      : std_logic_vector(1 downto 0) := "00";
8773
       signal   curr_seq1_0_lat  : std_logic_vector(1 downto 0) := "00";
8774
       signal   busy_r           : std_ulogic := '0';
8775
       signal   busy_r_rst       : std_ulogic := '0';
8776
       signal   busy_rst         : std_ulogic := '0';
8777
       signal   busy_conv        : std_ulogic := '0';
8778
       signal   busy_out_tmp     : std_ulogic := '0';
8779
       signal   busy_out_dly     : std_ulogic := '0';
8780
       signal   busy_out_sync    : std_ulogic := '0';
8781
       signal   busy_out_low_edge : std_ulogic := '0';
8782
       signal   shorten_acq      : integer := 1;
8783
       signal   busy_seq_rst     : std_ulogic := '0';
8784
       signal   busy_sync1       : std_ulogic := '0';
8785
       signal   busy_sync2       : std_ulogic := '0';
8786
       signal   busy_sync_fall   : std_ulogic := '0';
8787
       signal   busy_sync_rise   : std_ulogic := '0';
8788
       signal   cal_chan_update  : std_ulogic := '0';
8789
       signal   first_cal_chan   : std_ulogic := '0';
8790
       signal   seq_reset_flag   : std_ulogic := '0';
8791
       signal   seq_reset_flag_dly   : std_ulogic := '0';
8792
       signal   seq_reset_dly   : std_ulogic := '0';
8793
       signal   seq_reset_busy_out  : std_ulogic := '0';
8794
       signal   rst_in_not_seq   : std_ulogic := '0';
8795
       signal   rst_in_out       : std_ulogic := '0';
8796
       signal   rst_lock_early   : std_ulogic := '0';
8797
       signal   conv_count       : integer := 0;
8798
       signal   acq_count       : integer := 1;
8799
       signal   do_out_rdtmp     : std_logic_vector(15 downto 0);
8800
       signal   rst_in1          : std_ulogic := '0';
8801
       signal   rst_in2          : std_ulogic := '0';
8802
       signal   int_rst          : std_ulogic := '1';
8803
       signal   rst_input_t      : std_ulogic := '0';
8804
       signal   rst_in           : std_ulogic := '0';
8805
       signal   ot_en            : std_logic := '1';
8806
       signal   curr_clkdiv_sel  : std_logic_vector(7 downto 0)
8807
                                                  := "00000000";
8808
       signal   curr_clkdiv_sel_int : integer := 0;
8809
       signal   adcclk           : std_ulogic := '0';
8810
       signal   adcclk_div1      : std_ulogic := '0';
8811
       signal   sysclk           : std_ulogic := '0';
8812
       signal   curr_adc_resl    : std_logic_vector(2 downto 0) := "010";
8813
       signal   nx_seq           : std_logic_vector(15 downto 0) := "0000000000000000";
8814
       signal   curr_seq         : std_logic_vector(15 downto 0) := "0000000000000000";
8815
       signal   acq_cnt          : integer := 0;
8816
       signal   acq_chan         : std_logic_vector(4 downto 0) := "00000";
8817
       signal   acq_chan_index   : integer := 0;
8818
       signal   acq_chan_lat     : std_logic_vector(4 downto 0) := "00000";
8819
       signal   curr_chan        : std_logic_vector(4 downto 0) := "00000";
8820
       signal   curr_chan_dly    : std_logic_vector(4 downto 0) := "00000";
8821
       signal   curr_chan_lat    : std_logic_vector(4 downto 0) := "00000";
8822
       signal   curr_avg_set     : std_logic_vector(1 downto 0) := "00";
8823
       signal   acq_avg          : std_logic_vector(1 downto 0) := "00";
8824
       signal   curr_e_c         : std_logic:= '0';
8825
       signal   acq_e_c          : std_logic:= '0';
8826
       signal   acq_b_u          : std_logic:= '0';
8827
       signal   curr_b_u         : std_logic:= '0';
8828
       signal   acq_acqsel       : std_logic:= '0';
8829
       signal   curr_acq         : std_logic:= '0';
8830
       signal   seq_cnt          : integer := 0;
8831
       signal   busy_rst_cnt     : integer := 0;
8832
       signal   adc_s1_flag      : std_ulogic := '0';
8833
       signal   adc_convst       : std_ulogic := '0';
8834
       signal   conv_start       : std_ulogic := '0';
8835
       signal   conv_end         : std_ulogic := '0';
8836
       signal   eos_en           : std_ulogic := '0';
8837
       signal   eos_tmp_en       : std_ulogic := '0';
8838
       signal   seq_cnt_en       : std_ulogic := '0';
8839
       signal   eoc_en           : std_ulogic := '0';
8840
       signal   eoc_en_delay       : std_ulogic := '0';
8841
       signal   eoc_out_tmp     : std_ulogic := '0';
8842
       signal   eos_out_tmp     : std_ulogic := '0';
8843
       signal   eoc_out_tmp1     : std_ulogic := '0';
8844
       signal   eos_out_tmp1     : std_ulogic := '0';
8845
       signal   eoc_up_data      : std_ulogic := '0';
8846
       signal   eoc_up_alarm    : std_ulogic := '0';
8847
       signal   conv_time        : integer := 17;
8848
       signal   conv_time_cal_1  : integer := 69;
8849
       signal   conv_time_cal    : integer := 69;
8850
       signal   conv_result      : std_logic_vector(15 downto 0) := "0000000000000000";
8851
       signal   conv_result_reg  : std_logic_vector(15 downto 0) := "0000000000000000";
8852
       signal   data_written     : std_logic_vector(15 downto 0) := "0000000000000000";
8853
       signal   conv_result_int  : integer := 0;
8854
       signal   conv_result_int_resl  : integer := 0;
8855
       signal   analog_in_uni    : ANALOG_DATA :=(others=>0.0);
8856
       signal   analog_in_diff   : ANALOG_DATA :=(others=>0.0);
8857
       signal   analog_in        : ANALOG_DATA :=(others=>0.0);
8858
       signal   analog_in_comm   : ANALOG_DATA :=(others=>0.0);
8859
       signal   chan_val_tmp   : ANALOG_DATA :=(others=>0.0);
8860
       signal   chan_valn_tmp   : ANALOG_DATA :=(others=>0.0);
8861
       signal   data_reg         : DR_data_reg
8862
                                  :=( 36 to 39 => "1111111111111111",
8863
                                     others=>"0000000000000000");
8864
       signal   tmp_data_reg_out : std_logic_vector(15 downto 0) := "0000000000000000";
8865
       signal   tmp_dr_sram_out  : std_logic_vector(15 downto 0) := "0000000000000000";
8866
       signal   seq_chan_reg1    : std_logic_vector(15 downto 0) := "0000000000000000";
8867
       signal   seq_chan_reg2    : std_logic_vector(15 downto 0) := "0000000000000000";
8868
       signal   seq_acq_reg1     : std_logic_vector(15 downto 0) := "0000000000000000";
8869
       signal   seq_acq_reg2     : std_logic_vector(15 downto 0) := "0000000000000000";
8870
       signal   seq_avg_reg1     : std_logic_vector(15 downto 0) := "0000000000000000";
8871
       signal   seq_avg_reg2     : std_logic_vector(15 downto 0) := "0000000000000000";
8872
       signal   seq_du_reg1      : std_logic_vector(15 downto 0) := "0000000000000000";
8873
       signal   seq_du_reg2      : std_logic_vector(15 downto 0) := "0000000000000000";
8874
       signal   seq_count        : integer := 1;
8875
       signal   seq_count_en     : std_ulogic := '0';
8876
       signal   conv_acc         : ACC_ARRAY :=(others=>0);
8877
       signal   conv_avg_count   : ACC_ARRAY :=(others=>0);
8878
       signal   conv_acc_vec     : std_logic_vector (20 downto 1);
8879
       signal   conv_acc_result  : std_logic_vector(15 downto 0);
8880
       signal   seq_status_avg   : integer := 0;
8881
       signal   curr_chan_index       : integer := 0;
8882
       signal   curr_chan_index_lat   : integer := 0;
8883
       signal   conv_avg_cnt     : int_array :=(others=>0);
8884
       signal   analog_mux_in    : real := 0.0;
8885
       signal   adc_temp_result  : real := 0.0;
8886
       signal   adc_intpwr_result : real := 0.0;
8887
       signal   adc_ext_result    : real := 0.0;
8888
       signal   seq_reset        : std_ulogic := '0';
8889
       signal   seq_en           : std_ulogic := '0';
8890
       signal   seq_en_drp       : std_ulogic := '0';
8891
       signal   seq_en_init      : std_ulogic := '0';
8892
       signal   seq_en_dly       : std_ulogic := '0';
8893
       signal   seq_num          : integer := 0;
8894
       signal   seq_mem          : seq_array :=(others=>0);
8895
       signal   adc_seq_reset       : std_ulogic := '0';
8896
       signal   adc_seq_en          : std_ulogic := '0';
8897
       signal   adc_seq_reset_dly   : std_ulogic := '0';
8898
       signal   adc_seq_en_dly      : std_ulogic := '0';
8899
       signal   adc_seq_reset_hold  : std_ulogic := '0';
8900
       signal   adc_seq_en_hold     : std_ulogic := '0';
8901
       signal   rst_lock            : std_ulogic := '1';
8902
       signal   sim_file_flag       : std_ulogic := '0';
8903
       signal   gsr_in              : std_ulogic := '0';
8904
       signal   convstclk_in       : std_ulogic := '0';
8905
       signal   convst_raw_in      : std_ulogic := '0';
8906
       signal   convst_in          : std_ulogic := '0';
8907
       signal   dclk_in            : std_ulogic := '0';
8908
       signal   den_in             : std_ulogic := '0';
8909
       signal   rst_input          : std_ulogic := '0';
8910
       signal   dwe_in             : std_ulogic := '0';
8911
       signal   di_in              : std_logic_vector(15 downto 0) := "0000000000000000";
8912
       signal   daddr_in           : std_logic_vector(6 downto 0) := "0000000";
8913
       signal   daddr_in_lat       : std_logic_vector(6 downto 0) := "0000000";
8914
       signal   daddr_in_lat_int   : integer := 0;
8915
       signal   drdy_out_tmp1      : std_ulogic := '0';
8916
       signal   drdy_out_tmp2      : std_ulogic := '0';
8917
       signal   drdy_out_tmp3      : std_ulogic := '0';
8918
       signal   drp_update         : std_ulogic := '0';
8919
       signal   alarm_en           : std_logic_vector(2 downto 0) := "111";
8920
       signal   alarm_update       : std_ulogic := '0';
8921
       signal   adcclk_tmp         : std_ulogic := '0';
8922
       signal   ot_out_reg         : std_ulogic := '0';
8923
       signal   alarm_out_reg      : std_logic_vector(2 downto 0) := "000";
8924
       signal   conv_end_reg_read  :  std_logic_vector(3 downto 0) := "0000";
8925
       signal   busy_reg_read      : std_ulogic := '0';
8926
       signal   single_chan_conv_end : std_ulogic := '0';
8927
       signal   first_acq          : std_ulogic := '1';
8928
       signal   conv_start_cont    : std_ulogic := '0';
8929
       signal   conv_start_sel     : std_ulogic := '0';
8930
       signal   reset_conv_start   : std_ulogic := '0';
8931
       signal   reset_conv_start_tmp   : std_ulogic := '0';
8932
       signal   busy_r_rst_done    : std_ulogic := '0';
8933
       signal   op_count           : integer := 15;
8934
 
8935
 
8936
-- Input/Output Pin signals
8937
 
8938
        signal   DI_ipd  :  std_logic_vector(15 downto 0);
8939
        signal   DADDR_ipd  :  std_logic_vector(6 downto 0);
8940
        signal   DEN_ipd  :  std_ulogic;
8941
        signal   DWE_ipd  :  std_ulogic;
8942
        signal   DCLK_ipd  :  std_ulogic;
8943
        signal   CONVSTCLK_ipd  :  std_ulogic;
8944
        signal   RESET_ipd  :  std_ulogic;
8945
        signal   CONVST_ipd  :  std_ulogic;
8946
 
8947
        signal   do_out  :  std_logic_vector(15 downto 0) := "0000000000000000";
8948
        signal   drdy_out  :  std_ulogic := '0';
8949
        signal   ot_out  :  std_ulogic := '0';
8950
        signal   alarm_out  :  std_logic_vector(2 downto 0) := "000";
8951
        signal   channel_out  :  std_logic_vector(4 downto 0) := "00000";
8952
        signal   eoc_out  :  std_ulogic := '0';
8953
        signal   eos_out  :  std_ulogic := '0';
8954
        signal   busy_out  :  std_ulogic := '0';
8955
 
8956
        signal   DI_dly  :  std_logic_vector(15 downto 0);
8957
        signal   DADDR_dly  :  std_logic_vector(6 downto 0);
8958
        signal   DEN_dly  :  std_ulogic;
8959
        signal   DWE_dly  :  std_ulogic;
8960
        signal   DCLK_dly  :  std_ulogic;
8961
        signal   CONVSTCLK_dly  :  std_ulogic;
8962
        signal   RESET_dly  :  std_ulogic;
8963
        signal   CONVST_dly  :  std_ulogic;
8964
 
8965
begin
8966
 
8967
   BUSY <= busy_out after 100 ps;
8968
   DRDY <= drdy_out after 100 ps;
8969
   EOC <= eoc_out after 100 ps;
8970
   EOS <= eos_out after 100 ps;
8971
   OT <= ot_out after 100 ps;
8972
   DO <= do_out after 100 ps;
8973
   CHANNEL <= channel_out after 100 ps;
8974
   ALM <= alarm_out after 100 ps;
8975
 
8976
   convst_raw_in <= CONVST;
8977
   convstclk_in <= CONVSTCLK;
8978
   dclk_in <= DCLK;
8979
   den_in <= DEN;
8980
   rst_input <= RESET;
8981
   dwe_in <= DWE;
8982
   di_in <= Di;
8983
   daddr_in <= DADDR;
8984
 
8985
   gsr_in <= GSR;
8986
   convst_in <= '1' when (convst_raw_in = '1' or convstclk_in = '1') else  '0';
8987
   JTAGLOCKED <= '0';
8988
   JTAGMODIFIED <= '0';
8989
   JTAGBUSY <= '0';
8990
 
8991
   DEFAULT_CHECK : process
8992
       variable init40h_tmp : std_logic_vector(15 downto 0);
8993
       variable init41h_tmp : std_logic_vector(15 downto 0);
8994
       variable init42h_tmp : std_logic_vector(15 downto 0);
8995
       variable init4eh_tmp : std_logic_vector(15 downto 0);
8996
       variable init40h_tmp_chan : integer;
8997
       variable init42h_tmp_clk : integer;
8998
       variable tmp_value : std_logic_vector(7 downto 0);
8999
   begin
9000
        init40h_tmp := TO_STDLOGICVECTOR(INIT_40);
9001
        init40h_tmp_chan := SLV_TO_INT(SLV=>init40h_tmp(4 downto 0));
9002
        init41h_tmp := TO_STDLOGICVECTOR(INIT_41);
9003
        init42h_tmp := TO_STDLOGICVECTOR(INIT_42);
9004
        tmp_value :=  init42h_tmp(15 downto 8);
9005
        init42h_tmp_clk := SLV_TO_INT(SLV=>tmp_value);
9006
        init4eh_tmp := TO_STDLOGICVECTOR(INIT_4E);
9007
 
9008
        if ((init41h_tmp(13 downto 12)="11") and (init40h_tmp(8)='1') and (init40h_tmp_chan /= 3 ) and (init40h_tmp_chan < 16)) then
9009
          assert false report " Attribute Syntax warning : The attribute INIT_40 bit[8] must be set to 0 on SYSMON. Long acquistion mode is only allowed for external channels."
9010
          severity warning;
9011
        end if;
9012
 
9013
        if ((init41h_tmp(13 downto 12) /="11") and (init4eh_tmp(10 downto 0) /= "00000000000") and (init4eh_tmp(15 downto 12) /= "0000")) then
9014
           assert false report " Attribute Syntax warning : The attribute INIT_4E Bit[15:12] and bit[10:0] must be set to 0. Long acquistion mode is only allowed for external channels."
9015
          severity warning;
9016
        end if;
9017
 
9018
        if ((init41h_tmp(13 downto 12)="11") and (init40h_tmp(9) = '1') and (init40h_tmp(4 downto 0) /= "00011") and (init40h_tmp_chan < 16)) then
9019
          assert false report " Attribute Syntax warning : The attribute INIT_40 bit[9] must be set to 0 on SYSMON. Event mode timing can only be used with external channels, and only in single channel mode."
9020
          severity warning;
9021
        end if;
9022
 
9023
        if ((init41h_tmp(13 downto 12)="11") and (init40h_tmp(13 downto 12) /= "00") and (INIT_48 /=X"0000") and (INIT_49 /= X"0000")) then
9024
           assert false report " Attribute Syntax warning : The attribute INIT_48 and INIT_49 must be set to 0000h in single channel mode and averaging enabled."
9025
          severity warning;
9026
        end if;
9027
 
9028
        if (init42h_tmp(1 downto 0) /= "00") then
9029
             assert false report
9030
             " Attribute Syntax Error : The attribute INIT_42 Bit[1:0] must be set to 00."
9031
              severity Error;
9032
        end if;
9033
 
9034
        if (init42h_tmp_clk < 8) then
9035
             assert false report
9036
             " Attribute Syntax Error : The attribute INIT_42 Bit[15:8] is the ADC Clock divider and must be equal or greater than 8."
9037
              severity failure;
9038
        end if;
9039
 
9040
        if (INIT_43 /= "0000000000000000") then
9041
             assert false report
9042
             " Warning : The attribute INIT_43 must   be set to 0000."
9043
             severity warning;
9044
        end if;
9045
 
9046
        if (INIT_44 /= "0000000000000000") then
9047
             assert false report
9048
             " Warning : The attribute INIT_44 must   be set to 0000."
9049
             severity warning;
9050
        end if;
9051
 
9052
        if (INIT_45 /= "0000000000000000") then
9053
             assert false report
9054
             " Warning : The attribute INIT_45 must   be set to 0000."
9055
             severity warning;
9056
        end if;
9057
 
9058
        if (INIT_46 /= "0000000000000000") then
9059
             assert false report
9060
             " Warning : The attribute INIT_46 must   be set to 0000."
9061
             severity warning;
9062
        end if;
9063
 
9064
        if (INIT_47 /= "0000000000000000") then
9065
             assert false report
9066
             " Warning : The attribute INIT_47 must   be set to 0000."
9067
             severity warning;
9068
        end if;
9069
 
9070
         wait;
9071
   end process;
9072
 
9073
 
9074
   curr_chan_index <= SLV_TO_INT(curr_chan);
9075
   curr_chan_index_lat <= SLV_TO_INT(curr_chan_lat);
9076
 
9077
  CHEK_COMM_P : process( busy_r )
9078
       variable Message : line;
9079
  begin
9080
  if (busy_r'event and busy_r = '1' ) then
9081
   if (rst_in = '0' and acq_b_u = '0' and ((acq_chan_index = 3) or (acq_chan_index >= 16 and acq_chan_index <= 31))) then
9082
      if ( chan_valn_tmp(acq_chan_index) > chan_val_tmp(acq_chan_index)) then
9083
       Write ( Message, string'("Input File Warning: The N input for external channel "));
9084
       Write ( Message, acq_chan_index);
9085
       Write ( Message, string'(" must be smaller than P input when in unipolar mode (P="));
9086
       Write ( Message, chan_val_tmp(acq_chan_index));
9087
       Write ( Message, string'(" N="));
9088
       Write ( Message, chan_valn_tmp(acq_chan_index));
9089
       Write ( Message, string'(") for SYSMON."));
9090
      assert false report Message.all severity warning;
9091
      DEALLOCATE (Message);
9092
    end if;
9093
 
9094
     if (( chan_valn_tmp(acq_chan_index) > 0.5) or  (chan_valn_tmp(acq_chan_index) < 0.0)) then
9095
       Write ( Message, string'("Input File Warning: The N input for external channel "));
9096
       Write ( Message, acq_chan_index);
9097
       Write ( Message, string'(" should be between 0V to 0.5V when in unipolar mode (N="));
9098
       Write ( Message, chan_valn_tmp(acq_chan_index));
9099
      Write ( Message, string'(") for SYSMON."));
9100
      assert false report Message.all severity warning;
9101
      DEALLOCATE (Message);
9102
    end if;
9103
 
9104
   end if;
9105
  end if;
9106
  end process;
9107
 
9108
  busy_mkup_p : process( dclk_in, rst_in_out)
9109
  begin
9110
    if (rst_in_out = '1') then
9111
       busy_rst <= '1';
9112
       rst_lock <= '1';
9113
       rst_lock_early <= '1';
9114
       busy_rst_cnt <= 0;
9115
    elsif (rising_edge(dclk_in)) then
9116
       if (rst_lock = '1') then
9117
          if (busy_rst_cnt < 29) then
9118
               busy_rst_cnt <= busy_rst_cnt + 1;
9119
               if ( busy_rst_cnt = 26) then
9120
                    rst_lock_early <= '0';
9121
               end if;
9122
          else
9123
               busy_rst <= '0';
9124
               rst_lock <= '0';
9125
          end if;
9126
       end if;
9127
    end if;
9128
  end process;
9129
 
9130
  busy_out_p : process (busy_rst, busy_conv, rst_lock)
9131
  begin
9132
     if (rst_lock = '1') then
9133
         busy_out <= busy_rst;
9134
     else
9135
         busy_out <= busy_conv;
9136
     end if;
9137
  end process;
9138
 
9139
  busy_conv_p : process (dclk_in, rst_in)
9140
  begin
9141
    if (rst_in = '1') then
9142
       busy_conv <= '0';
9143
       cal_chan_update <= '0';
9144
    elsif (rising_edge(dclk_in)) then
9145
        if (seq_reset_flag = '1'  and curr_clkdiv_sel_int <= 3)  then
9146
             busy_conv <= busy_seq_rst;
9147
        elsif (busy_sync_fall = '1') then
9148
            busy_conv <= '0';
9149
        elsif (busy_sync_rise = '1') then
9150
            busy_conv <= '1';
9151
        end if;
9152
 
9153
        if (conv_count = 21 and curr_chan = "01000" ) then
9154
              cal_chan_update  <= '1';
9155
         else
9156
              cal_chan_update  <= '0';
9157
         end if;
9158
    end if;
9159
  end process;
9160
 
9161
  busy_sync_p : process (dclk_in, rst_lock)
9162
  begin
9163
     if (rst_lock = '1') then
9164
        busy_sync1 <= '0';
9165
        busy_sync2 <= '0';
9166
     elsif (rising_edge (dclk_in)) then
9167
         busy_sync1 <= busy_r;
9168
         busy_sync2 <= busy_sync1;
9169
     end if;
9170
  end process;
9171
 
9172
  busy_sync_fall <= '1' when (busy_r = '0' and busy_sync1 = '1') else '0';
9173
  busy_sync_rise <= '1' when (busy_sync1 = '1' and busy_sync2 = '0') else '0';
9174
 
9175
  busy_seq_rst_p : process
9176
    variable tmp_uns_div : unsigned(7 downto 0);
9177
  begin
9178
     if (falling_edge(busy_out) or rising_edge(busy_r)) then
9179
        if (seq_reset_flag = '1' and seq1_0 = "00" and curr_clkdiv_sel_int <= 3) then
9180
           wait until (rising_edge(dclk_in));
9181
           wait  until (rising_edge(dclk_in));
9182
           wait  until (rising_edge(dclk_in));
9183
           wait  until (rising_edge(dclk_in));
9184
           wait  until (rising_edge(dclk_in));
9185
           busy_seq_rst <= '1';
9186
        elsif (seq_reset_flag = '1' and seq1_0 /= "00" and curr_clkdiv_sel_int <= 3) then
9187
            wait  until (rising_edge(dclk_in));
9188
            wait  until (rising_edge(dclk_in));
9189
            wait  until (rising_edge(dclk_in));
9190
            wait  until (rising_edge(dclk_in));
9191
            wait  until (rising_edge(dclk_in));
9192
            wait  until (rising_edge(dclk_in));
9193
            wait  until (rising_edge(dclk_in));
9194
           busy_seq_rst <= '1';
9195
        else
9196
           busy_seq_rst <= '0';
9197
        end if;
9198
     end if;
9199
    wait on busy_out, busy_r;
9200
   end process;
9201
 
9202
  chan_out_p : process(busy_out, rst_in_out, cal_chan_update)
9203
  begin
9204
   if (rst_in_out = '1') then
9205
         channel_out <= "00000";
9206
   elsif (rising_edge(busy_out) or rising_edge(cal_chan_update)) then
9207
           if ( busy_out = '1' and cal_chan_update = '1') then
9208
                channel_out <= "01000";
9209
           end if;
9210
   elsif (falling_edge(busy_out)) then
9211
                channel_out <= curr_chan;
9212
                curr_chan_lat <= curr_chan;
9213
   end if;
9214
  end process;
9215
 
9216
  INT_RST_GEN_P : process
9217
  begin
9218
    int_rst <= '1';
9219
    wait until (rising_edge(dclk_in));
9220
    wait until (rising_edge(dclk_in));
9221
    int_rst <= '0';
9222
    wait;
9223
  end process;
9224
 
9225
  rst_input_t <= rst_input or int_rst;
9226
 
9227
  RST_DE_SYNC_P: process(dclk_in, rst_input_t)
9228
  begin
9229
      if (rst_input_t = '1') then
9230
              rst_in2 <= '1';
9231
              rst_in1 <= '1';
9232
      elsif (dclk_in'event and dclk_in='1') then
9233
              rst_in2 <= rst_in1;
9234
              rst_in1 <= rst_input_t;
9235
     end if;
9236
  end process;
9237
 
9238
    rst_in_not_seq <= rst_in2;
9239
    rst_in <= rst_in2 or seq_reset_dly;
9240
    rst_in_out <= rst_in2 or seq_reset_busy_out;
9241
 
9242
  seq_reset_dly_p : process
9243
  begin
9244
   if (rising_edge(seq_reset)) then
9245
    wait until rising_edge(dclk_in);
9246
    wait until rising_edge(dclk_in);
9247
       seq_reset_dly <= '1';
9248
    wait until rising_edge(dclk_in);
9249
    wait until falling_edge(dclk_in);
9250
       seq_reset_busy_out <= '1';
9251
    wait until rising_edge(dclk_in);
9252
    wait until rising_edge(dclk_in);
9253
    wait until rising_edge(dclk_in);
9254
       seq_reset_dly <= '0';
9255
       seq_reset_busy_out <= '0';
9256
   end if;
9257
    wait on seq_reset, dclk_in;
9258
  end process;
9259
 
9260
 
9261
  seq_reset_flag_p : process (seq_reset_dly, busy_r)
9262
    begin
9263
       if (rising_edge(seq_reset_dly)) then
9264
          seq_reset_flag <= '1';
9265
       elsif (rising_edge(busy_r)) then
9266
          seq_reset_flag <= '0';
9267
       end if;
9268
    end process;
9269
 
9270
  seq_reset_flag_dly_p : process (seq_reset_flag, busy_out)
9271
    begin
9272
       if (rising_edge(seq_reset_flag)) then
9273
          seq_reset_flag_dly <= '1';
9274
       elsif (rising_edge(busy_out)) then
9275
           seq_reset_flag_dly <= '0';
9276
       end if;
9277
    end process;
9278
 
9279
  first_cal_chan_p : process ( busy_out)
9280
    begin
9281
      if (rising_edge(busy_out )) then
9282
          if (seq_reset_flag_dly = '1' and  acq_chan = "01000" and seq1_0 = "00") then
9283
                  first_cal_chan <= '1';
9284
          else
9285
                  first_cal_chan <= '0';
9286
          end if;
9287
      end if;
9288
    end process;
9289
 
9290
 
9291
  ADC_SM: process (adcclk, rst_in, sim_file_flag)
9292
  begin
9293
     if (sim_file_flag = '1') then
9294
        adc_state <= INIT_STATE;
9295
     elsif (rst_in = '1' or rst_lock_early = '1') then
9296
        adc_state <= INIT_STATE;
9297
     elsif (adcclk'event and adcclk = '1') then
9298
         adc_state <= next_state;
9299
     end if;
9300
  end process;
9301
 
9302
  next_state_p : process (adc_state, eos_en, conv_start , conv_end, curr_seq1_0_lat)
9303
  begin
9304
      case (adc_state) is
9305
      when INIT_STATE => next_state <= ACQ_STATE;
9306
 
9307
      when  ACQ_STATE => if (conv_start = '1') then
9308
                                  next_state <= CONV_STATE;
9309
                              else
9310
                                  next_state <= ACQ_STATE;
9311
                              end if;
9312
 
9313
      when  CONV_STATE => if (conv_end = '1') then
9314
                                   next_state <= END_STATE;
9315
                               else
9316
                                   next_state <= CONV_STATE;
9317
                                end if;
9318
 
9319
      when  END_STATE => if (curr_seq1_0_lat = "01")  then
9320
                                if (eos_en = '1') then
9321
                                    next_state <= SINGLE_SEQ_STATE;
9322
                                else
9323
                                    next_state <= ACQ_STATE;
9324
                                end if;
9325
                            else
9326
                                next_state <= ACQ_STATE;
9327
                            end if;
9328
 
9329
      when  SINGLE_SEQ_STATE => next_state <= INIT_STATE;
9330
 
9331
      when  others => next_state <= INIT_STATE;
9332
    end case;
9333
  end process;
9334
 
9335
  seq_en_init_p : process
9336
  begin
9337
      seq_en_init <= '0';
9338
      if (cfg_reg1_init(13 downto 12) /= "11" ) then
9339
          wait for 20 ps;
9340
          seq_en_init <= '1';
9341
          wait for 150 ps;
9342
          seq_en_init <= '0';
9343
      end if;
9344
      wait;
9345
  end process;
9346
 
9347
 
9348
      seq_en <= seq_en_init or  seq_en_drp;
9349
 
9350
  DRPORT_DO_OUT_P : process(dclk_in, gsr_in)
9351
       variable message : line;
9352
       variable di_str : string (16 downto 1);
9353
       variable daddr_str : string (7 downto  1);
9354
       variable di_40 : std_logic_vector(4 downto 0);
9355
       variable valid_daddr : boolean := false;
9356
       variable address : integer;
9357
       variable tmp_value : integer := 0;
9358
       variable tmp_value1 : std_logic_vector (7 downto 0);
9359
  begin
9360
 
9361
     if (gsr_in = '1') then
9362
         drdy_out <= '0';
9363
         daddr_in_lat  <= "0000000";
9364
         do_out <= "0000000000000000";
9365
     elsif (rising_edge(dclk_in)) then
9366
        if (den_in = '1') then
9367
           valid_daddr := addr_is_valid(daddr_in);
9368
           if (valid_daddr) then
9369
               address := slv_to_int(daddr_in);
9370
               if (  (address > 88 or
9371
                   (address >= 13 and address <= 15)
9372
                    or (address >= 39 and address <= 63))) then
9373
                 Write ( Message, string'(" Invalid Input Warning : The DADDR "));
9374
                 Write ( Message, string'(SLV_TO_STR(daddr_in)));
9375
                 Write ( Message, string'("  is not defined. The data in this location is invalid."));
9376
                 assert false report Message.all  severity warning;
9377
                 DEALLOCATE(Message);
9378
               end if;
9379
            end if;
9380
 
9381
            if (drdy_out_tmp1 = '1' or drdy_out_tmp2 = '1' or drdy_out_tmp3 = '1') then
9382
                drdy_out_tmp1 <= '0';
9383
            else
9384
                drdy_out_tmp1 <= '1';
9385
            end if;
9386
            daddr_in_lat  <= daddr_in;
9387
        else
9388
           drdy_out_tmp1 <= '0';
9389
        end if;
9390
 
9391
        drdy_out_tmp2 <= drdy_out_tmp1;
9392
        drdy_out_tmp3 <= drdy_out_tmp2;
9393
        drdy_out <= drdy_out_tmp3;
9394
 
9395
        if (drdy_out_tmp3 = '1') then
9396
            do_out <= do_out_rdtmp;
9397
        end if;
9398
 
9399
-- write  all available daddr addresses
9400
 
9401
        if (dwe_in = '1' and den_in = '1') then
9402
           if (valid_daddr) then
9403
               dr_sram(address) <= di_in;
9404
           end if;
9405
 
9406
           if ( address = 42 and  di_in( 1 downto 0) /= "00") then
9407
             Write ( Message, string'(" Invalid Input Error : The DI bit[1:0] "));
9408
             Write ( Message, bit_vector'(TO_BITVECTOR(di_in(1 downto 0))));
9409
             Write ( Message, string'("  at DADDR "));
9410
             Write ( Message, bit_vector'(TO_BITVECTOR(daddr_in)));
9411
             Write ( Message, string'(" of SYSMON is invalid. These must be set to 00."));
9412
             assert false report Message.all  severity error;
9413
           end if;
9414
 
9415
           tmp_value1 := di_in(15 downto 8) ;
9416
           tmp_value := SLV_TO_INT(SLV=>tmp_value1);
9417
 
9418
           if ( address = 42 and  tmp_value < 8) then
9419
             Write ( Message, string'(" Invalid Input Error : The DI bit[15:8] "));
9420
             Write ( Message, bit_vector'(TO_BITVECTOR(di_in(15 downto 8))));
9421
             Write ( Message, string'("  at DADDR "));
9422
             Write ( Message, bit_vector'(TO_BITVECTOR(daddr_in)));
9423
             Write ( Message, string'(" of SYSMON is invalid. Bit[15:8] of Control Register 42h is the ADC Clock divider and must be equal or greater than 8."));
9424
             assert false report Message.all  severity failure;
9425
           end if;
9426
 
9427
           if ( (address >= 43 and  address <= 47) and di_in(15 downto 0) /= "0000000000000000") then
9428
             Write ( Message, string'(" Invalid Input Error : The DI value "));
9429
             Write ( Message, bit_vector'(TO_BITVECTOR(di_in)));
9430
             Write ( Message, string'("  at DADDR "));
9431
             Write ( Message, bit_vector'(TO_BITVECTOR(daddr_in)));
9432
             Write ( Message, string'(" of SYSMON is invalid. These must be set to 0000."));
9433
             assert false report Message.all  severity error;
9434
             DEALLOCATE(Message);
9435
           end if;
9436
 
9437
          tmp_value := SLV_TO_INT(SLV=>di_in(4 downto 0));
9438
 
9439
          if (address = 40) then
9440
 
9441
           if (((tmp_value = 6) or ( tmp_value = 7) or ((tmp_value >= 10) and (tmp_value <= 15)))) then
9442
             Write ( Message, string'(" Invalid Input Warning : The DI bit[4:0] at DADDR "));
9443
             Write ( Message, bit_vector'(TO_BITVECTOR(daddr_in)));
9444
             Write ( Message, string'(" is  "));
9445
            Write ( Message, bit_vector'(TO_BITVECTOR(di_in(4 downto 0))));
9446
             Write ( Message, string'(", which is invalid analog channel."));
9447
             assert false report Message.all  severity warning;
9448
             DEALLOCATE(Message);
9449
           end if;
9450
 
9451
           if ((cfg_reg1(13 downto 12)="11") and (di_in(8)='1') and (tmp_value /= 3) and (tmp_value < 16)) then
9452
             Write ( Message, string'(" Invalid Input Warning : The DI value is "));
9453
             Write ( Message, bit_vector'(TO_BITVECTOR(di_in)));
9454
             Write ( Message, string'(" at DADDR "));
9455
             Write ( Message, bit_vector'(TO_BITVECTOR(daddr_in)));
9456
             Write ( Message, string'(". Bit[8] of DI must be set to 0. Long acquistion mode is only allowed for external channels."));
9457
             assert false report Message.all  severity warning;
9458
             DEALLOCATE(Message);
9459
           end if;
9460
 
9461
           if ((cfg_reg1(13 downto 12)="11") and (di_in(9)='1') and (tmp_value /= 3) and (tmp_value < 16)) then
9462
             Write ( Message, string'(" Invalid Input Warning : The DI value is "));
9463
             Write ( Message, bit_vector'(TO_BITVECTOR(di_in)));
9464
             Write ( Message, string'(" at DADDR "));
9465
             Write ( Message, bit_vector'(TO_BITVECTOR(daddr_in)));
9466
             Write ( Message, string'(". Bit[9] of DI must be set to 0. Event mode timing can only be used with external channels."));
9467
             assert false report Message.all  severity warning;
9468
             DEALLOCATE(Message);
9469
           end if;
9470
 
9471
           if ((cfg_reg1(13 downto 12)="11") and (di_in(13 downto 12)/="00") and (seq_chan_reg1 /= X"0000") and (seq_chan_reg2 /= X"0000")) then
9472
             Write ( Message, string'(" Invalid Input Warning : The Control Regiter 48h and 49h are "));
9473
             Write ( Message, bit_vector'(TO_BITVECTOR(seq_chan_reg1)));
9474
             Write ( Message, string'(" and  "));
9475
             Write ( Message, bit_vector'(TO_BITVECTOR(seq_chan_reg2)));
9476
             Write ( Message, string'(". Those registers should be set to 0000h in single channel mode and averaging enabled."));
9477
             assert false report Message.all  severity warning;
9478
             DEALLOCATE(Message);
9479
           end if;
9480
        end if;
9481
 
9482
          tmp_value := SLV_TO_INT(SLV=>cfg_reg0(4 downto 0));
9483
 
9484
          if (address = 41) then
9485
 
9486
           if ((di_in(13 downto 12)="11") and (cfg_reg0(8)='1') and (tmp_value /= 3) and (tmp_value < 16)) then
9487
             Write ( Message, string'(" Invalid Input Warning : The Control Regiter 40h value is "));
9488
             Write ( Message, bit_vector'(TO_BITVECTOR(cfg_reg0)));
9489
             Write ( Message, string'(". Bit[8] of Control Regiter 40h must be set to 0. Long acquistion mode is only allowed for external channels."));
9490
             assert false report Message.all  severity warning;
9491
             DEALLOCATE(Message);
9492
           end if;
9493
 
9494
           if ((di_in(13 downto 12)="11") and (cfg_reg0(9)='1') and (tmp_value /= 3) and (tmp_value < 16)) then
9495
             Write ( Message, string'(" Invalid Input Warning : The Control Regiter 40h value is "));
9496
             Write ( Message, bit_vector'(TO_BITVECTOR(cfg_reg0)));
9497
             Write ( Message, string'(". Bit[9] of Control Regiter 40h must be set to 0. Event mode timing can only be used with external channels."));
9498
             assert false report Message.all  severity warning;
9499
             DEALLOCATE(Message);
9500
           end if;
9501
 
9502
           if ((di_in(13 downto 12) /= "11") and (seq_acq_reg1(10 downto 0) /= "00000000000") and (seq_acq_reg1(15 downto 12) /= "0000")) then
9503
             Write ( Message, string'(" Invalid Input Warning : The Control Regiter 4Eh is "));
9504
             Write ( Message, bit_vector'(TO_BITVECTOR(seq_acq_reg1)));
9505
             Write ( Message, string'(". Bit[15:12] and bit[10:0] of this register must be set to 0. Long acquistion mode is only allowed for external channels."));
9506
             assert false report Message.all  severity warning;
9507
             DEALLOCATE(Message);
9508
           end if;
9509
 
9510
           if ((di_in(13 downto 12) = "11") and (cfg_reg0(13 downto 12) /= "00") and (seq_chan_reg1 /= X"0000") and (seq_chan_reg2 /= X"0000")) then
9511
             Write ( Message, string'(" Invalid Input Warning : The Control Regiter 48h and 49h are "));
9512
             Write ( Message, bit_vector'(TO_BITVECTOR(seq_chan_reg1)));
9513
             Write ( Message, string'(" and  "));
9514
             Write ( Message, bit_vector'(TO_BITVECTOR(seq_chan_reg2)));
9515
             Write ( Message, string'(". Those registers should be set to 0000h in single channel mode and averaging enabled."));
9516
             assert false report Message.all  severity warning;
9517
             DEALLOCATE(Message);
9518
           end if;
9519
        end if;
9520
       end if;
9521
 
9522
 
9523
 
9524
        if (daddr_in = "1000001" ) then
9525
           if (dwe_in = '1' and den_in = '1') then
9526
 
9527
                if (di_in(13 downto 12) /= cfg_reg1(13 downto 12)) then
9528
                            seq_reset <= '1';
9529
                else
9530
                            seq_reset <= '0';
9531
                end if;
9532
 
9533
                if (di_in(13 downto 12) /= "11" ) then
9534
                            seq_en_drp <= '1';
9535
                else
9536
                            seq_en_drp <= '0';
9537
                end if;
9538
             else
9539
                        seq_reset <= '0';
9540
                        seq_en_drp <= '0';
9541
             end if;
9542
        else
9543
            seq_reset <= '0';
9544
            seq_en_drp <= '0';
9545
        end if;
9546
     end if;
9547
  end process;
9548
 
9549
  tmp_dr_sram_out <= dr_sram(daddr_in_lat_int) when (daddr_in_lat_int >= 64 and
9550
                daddr_in_lat_int <= 87) else "0000000000000000";
9551
 
9552
  tmp_data_reg_out <= data_reg(daddr_in_lat_int) when (daddr_in_lat_int >= 0 and
9553
                daddr_in_lat_int <= 38) else "0000000000000000";
9554
 
9555
  do_out_rdtmp_p : process( daddr_in_lat, tmp_data_reg_out, tmp_dr_sram_out )
9556
      variable Message : line;
9557
      variable valid_daddr : boolean := false;
9558
  begin
9559
           valid_daddr := addr_is_valid(daddr_in_lat);
9560
           daddr_in_lat_int <= slv_to_int(daddr_in_lat);
9561
           if (valid_daddr) then
9562
              if ((daddr_in_lat_int > 88) or
9563
                               (daddr_in_lat_int >= 13 and daddr_in_lat_int <= 15)
9564
                or (daddr_in_lat_int >= 39 and daddr_in_lat_int <= 63)) then
9565
                    do_out_rdtmp <= "XXXXXXXXXXXXXXXX";
9566
              end if;
9567
 
9568
              if ((daddr_in_lat_int >= 0 and  daddr_in_lat_int <= 12) or
9569
              (daddr_in_lat_int >= 16 and daddr_in_lat_int <= 38)) then
9570
 
9571
                   do_out_rdtmp <= tmp_data_reg_out;
9572
 
9573
               elsif (daddr_in_lat_int >= 64 and daddr_in_lat_int <= 87) then
9574
 
9575
                    do_out_rdtmp <= tmp_dr_sram_out;
9576
             end if;
9577
          end if;
9578
   end process;
9579
 
9580
-- end DRP RAM
9581
 
9582
 
9583
  cfg_reg0 <= dr_sram(16#40#);
9584
  cfg_reg1 <= dr_sram(16#41#);
9585
  cfg_reg2 <= dr_sram(16#42#);
9586
  seq_chan_reg1 <= dr_sram(16#48#);
9587
  seq_chan_reg2 <= dr_sram(16#49#);
9588
  seq_avg_reg1 <= dr_sram(16#4A#);
9589
  seq_avg_reg2 <= dr_sram(16#4B#);
9590
  seq_du_reg1 <= dr_sram(16#4C#);
9591
  seq_du_reg2 <= dr_sram(16#4D#);
9592
  seq_acq_reg1 <= dr_sram(16#4E#);
9593
  seq_acq_reg2 <= dr_sram(16#4F#);
9594
 
9595
  seq1_0 <= cfg_reg1(13 downto 12);
9596
 
9597
  drp_update_p : process
9598
    variable seq_bits : std_logic_vector( 1 downto 0);
9599
   begin
9600
    if (rst_in = '1') then
9601
       wait until (rising_edge(dclk_in));
9602
       wait until (rising_edge(dclk_in));
9603
           seq_bits := seq1_0;
9604
    elsif (rising_edge(drp_update)) then
9605
       seq_bits := curr_seq1_0;
9606
    end if;
9607
 
9608
    if (rising_edge(drp_update) or (rst_in = '1')) then
9609
       if (seq_bits = "00") then
9610
         alarm_en <= "000";
9611
         ot_en <= '1';
9612
       else
9613
         ot_en  <= not cfg_reg1(0);
9614
         alarm_en <= not cfg_reg1(3 downto 1);
9615
       end if;
9616
    end if;
9617
      wait on drp_update, rst_in;
9618
   end process;
9619
 
9620
 
9621
-- Clock divider, generate  and adcclk
9622
 
9623
    sysclk_p : process(dclk_in)
9624
    begin
9625
      if (rising_edge(dclk_in)) then
9626
          sysclk <= not sysclk;
9627
      end if;
9628
    end process;
9629
 
9630
 
9631
    curr_clkdiv_sel_int_p : process (curr_clkdiv_sel)
9632
    begin
9633
        curr_clkdiv_sel_int <= SLV_TO_INT(curr_clkdiv_sel);
9634
    end process;
9635
 
9636
    clk_count_p : process(dclk_in)
9637
       variable clk_count : integer := -1;
9638
    begin
9639
 
9640
       if (rising_edge(dclk_in)) then
9641
        if (curr_clkdiv_sel_int > 2 ) then
9642
            if (clk_count >= curr_clkdiv_sel_int - 1) then
9643
                clk_count := 0;
9644
            else
9645
                clk_count := clk_count + 1;
9646
            end if;
9647
 
9648
            if (clk_count > (curr_clkdiv_sel_int/2) - 1) then
9649
               adcclk_tmp <= '1';
9650
            else
9651
               adcclk_tmp <= '0';
9652
            end if;
9653
        else
9654
             adcclk_tmp <= not adcclk_tmp;
9655
         end if;
9656
      end if;
9657
   end process;
9658
 
9659
        curr_clkdiv_sel <= cfg_reg2(15 downto 8);
9660
        adcclk_div1 <= '0' when (curr_clkdiv_sel_int > 1) else '1';
9661
        adcclk <=  not sysclk when adcclk_div1 = '1' else adcclk_tmp;
9662
 
9663
-- end clock divider
9664
 
9665
-- latch configuration registers
9666
    acq_latch_p : process ( seq1_0, adc_s1_flag, curr_seq, cfg_reg0_adc, rst_in)
9667
    begin
9668
        if ((seq1_0 = "01" and adc_s1_flag = '0') or seq1_0 = "10") then
9669
            acq_acqsel <= curr_seq(8);
9670
        elsif (seq1_0 = "11") then
9671
            acq_acqsel <= cfg_reg0_adc(8);
9672
        else
9673
            acq_acqsel <= '0';
9674
        end if;
9675
 
9676
        if (rst_in = '0') then
9677
          if (seq1_0 /= "11" and  adc_s1_flag = '0') then
9678
            acq_avg <= curr_seq(13 downto 12);
9679
            acq_chan <= curr_seq(4 downto 0);
9680
            acq_b_u <= curr_seq(10);
9681
          else
9682
            acq_avg <= cfg_reg0_adc(13 downto 12);
9683
            acq_chan <= cfg_reg0_adc(4 downto 0);
9684
            acq_b_u <= cfg_reg0_adc(10);
9685
          end if;
9686
        end if;
9687
    end process;
9688
 
9689
    acq_chan_index <= SLV_TO_INT(acq_chan);
9690
 
9691
    conv_end_reg_read_P : process ( adcclk, rst_in)
9692
    begin
9693
       if (rst_in = '1') then
9694
           conv_end_reg_read <= "0000";
9695
       elsif (rising_edge(adcclk)) then
9696
           conv_end_reg_read(3 downto 1) <= conv_end_reg_read(2 downto 0);
9697
           conv_end_reg_read(0) <= single_chan_conv_end or conv_end;
9698
       end if;
9699
   end process;
9700
 
9701
-- synch to DCLK
9702
       busy_reg_read_P : process ( dclk_in, rst_in)
9703
    begin
9704
       if (rst_in = '1') then
9705
           busy_reg_read <= '1';
9706
       elsif (rising_edge(dclk_in)) then
9707
           busy_reg_read <= not conv_end_reg_read(2);
9708
       end if;
9709
   end process;
9710
 
9711
   cfg_reg0_adc_P : process
9712
      variable  first_after_reset : std_ulogic := '1';
9713
   begin
9714
       if (rst_in='1') then
9715
          cfg_reg0_seq <= X"0000";
9716
          cfg_reg0_adc  <= X"0000";
9717
          acq_e_c <= '0';
9718
          first_after_reset := '1';
9719
       elsif (falling_edge(busy_reg_read) or falling_edge(rst_in)) then
9720
          wait until (rising_edge(dclk_in));
9721
          wait until (rising_edge(dclk_in));
9722
          wait until (rising_edge(dclk_in));
9723
          if (first_after_reset = '1') then
9724
             first_after_reset := '0';
9725
             cfg_reg0_adc <= cfg_reg0;
9726
             cfg_reg0_seq <= cfg_reg0;
9727
          else
9728
             cfg_reg0_adc <= cfg_reg0_seq;
9729
             cfg_reg0_seq <= cfg_reg0;
9730
          end if;
9731
          acq_e_c <= cfg_reg0(9);
9732
       end if;
9733
       wait on busy_reg_read, rst_in;
9734
   end process;
9735
 
9736
   busy_r_p : process(conv_start, busy_r_rst, rst_in)
9737
   begin
9738
      if (rst_in = '1') then
9739
         busy_r <= '0';
9740
      elsif (rising_edge(conv_start) and rst_lock = '0') then
9741
          busy_r <= '1';
9742
      elsif (rising_edge(busy_r_rst)) then
9743
          busy_r <= '0';
9744
      end if;
9745
   end process;
9746
 
9747
   curr_seq1_0_p : process( busy_out)
9748
   begin
9749
     if (falling_edge( busy_out)) then
9750
        if (adc_s1_flag = '1') then
9751
            curr_seq1_0 <= "00";
9752
        else
9753
            curr_seq1_0 <= seq1_0;
9754
        end if;
9755
     end if;
9756
   end process;
9757
 
9758
   start_conv_p : process ( conv_start, rst_in)
9759
      variable       Message : line;
9760
   begin
9761
     if (rst_in = '1') then
9762
        analog_mux_in <= 0.0;
9763
        curr_chan <= "00000";
9764
     elsif (rising_edge(conv_start)) then
9765
        if ( ((acq_chan_index = 3) or (acq_chan_index >= 16 and acq_chan_index <= 31))) then
9766
            analog_mux_in <= analog_in_diff(acq_chan_index);
9767
        else
9768
             analog_mux_in <= analog_in_uni(acq_chan_index);
9769
        end if;
9770
        curr_chan <= acq_chan;
9771
        curr_seq1_0_lat <= curr_seq1_0;
9772
 
9773
        if (acq_chan_index = 6 or acq_chan_index = 7 or (acq_chan_index >= 10 and acq_chan_index <= 15)) then
9774
            Write ( Message, string'(" Invalid Input Warning : The analog channel  "));
9775
            Write ( Message, acq_chan_index);
9776
            Write ( Message, string'(" to SYSMON is invalid."));
9777
            assert false report Message.all severity warning;
9778
        end if;
9779
 
9780
        if ((seq1_0 = "01" and adc_s1_flag = '0') or seq1_0 = "10" or seq1_0 = "00") then
9781
                curr_avg_set <= curr_seq(13 downto 12);
9782
                curr_b_u <= curr_seq(10);
9783
                curr_e_c <= '0';
9784
                curr_acq <= curr_seq(8);
9785
            else
9786
                curr_avg_set <= acq_avg;
9787
                curr_b_u <= acq_b_u;
9788
                curr_e_c <= cfg_reg0(9);
9789
                curr_acq <= cfg_reg0(8);
9790
        end if;
9791
      end if;
9792
 
9793
    end  process;
9794
 
9795
-- end latch configuration registers
9796
 
9797
-- sequence control
9798
 
9799
     seq_en_dly <= seq_en after 1 ps;
9800
 
9801
    seq_num_p : process(seq_en_dly)
9802
       variable seq_num_tmp : integer := 0;
9803
       variable si_tmp : integer := 0;
9804
       variable si : integer := 0;
9805
    begin
9806
     if (rising_edge(seq_en_dly)) then
9807
       if (seq1_0  = "01" or seq1_0 = "10") then
9808
          seq_num_tmp := 0;
9809
          for I in 0 to 15 loop
9810
              si := I;
9811
              if (seq_chan_reg1(si) = '1') then
9812
                 seq_num_tmp := seq_num_tmp + 1;
9813
                 seq_mem(seq_num_tmp) <= si;
9814
              end if;
9815
          end loop;
9816
          for I in 16 to 31 loop
9817
              si := I;
9818
              si_tmp := si-16;
9819
              if (seq_chan_reg2(si_tmp) = '1') then
9820
                   seq_num_tmp := seq_num_tmp + 1;
9821
                   seq_mem(seq_num_tmp) <= si;
9822
              end if;
9823
          end loop;
9824
          seq_num <= seq_num_tmp;
9825
        elsif (seq1_0  = "00") then
9826
           seq_num <= 4;
9827
           seq_mem(1) <= 0;
9828
           seq_mem(2) <= 8;
9829
           seq_mem(3) <= 9;
9830
           seq_mem(4) <= 10;
9831
         end if;
9832
     end if;
9833
   end process;
9834
 
9835
 
9836
   curr_seq_p : process(seq_count, seq_en_dly)
9837
      variable seq_curr_i : std_logic_vector(4 downto 0);
9838
      variable seq_curr_index : integer;
9839
      variable tmp_value : integer;
9840
      variable curr_seq_tmp : std_logic_vector(15  downto 0);
9841
    begin
9842
    if (seq_count'event or falling_edge(seq_en_dly)) then
9843
      seq_curr_index := seq_mem(seq_count);
9844
      seq_curr_i := STD_LOGIC_VECTOR(TO_UNSIGNED(seq_curr_index, 5));
9845
      curr_seq_tmp := "0000000000000000";
9846
      if (seq_curr_index >= 0 and seq_curr_index <= 15) then
9847
          curr_seq_tmp(2 downto 0) := seq_curr_i(2 downto 0);
9848
          curr_seq_tmp(4 downto 3) := "01";
9849
          curr_seq_tmp(8) := seq_acq_reg1(seq_curr_index);
9850
          curr_seq_tmp(10) := seq_du_reg1(seq_curr_index);
9851
          if (seq1_0 = "00") then
9852
             curr_seq_tmp(13 downto 12) := "01";
9853
          elsif (seq_avg_reg1(seq_curr_index) = '1') then
9854
             curr_seq_tmp(13 downto 12) := cfg_reg0(13 downto 12);
9855
          else
9856
             curr_seq_tmp(13 downto 12) := "00";
9857
          end if;
9858
          if (seq_curr_index >= 0 and seq_curr_index <= 7) then
9859
             curr_seq_tmp(4 downto 3) := "01";
9860
          else
9861
             curr_seq_tmp(4 downto 3) := "00";
9862
          end if;
9863
      elsif (seq_curr_index >= 16 and seq_curr_index <= 31) then
9864
          tmp_value := seq_curr_index -16;
9865
          curr_seq_tmp(4 downto 0) := seq_curr_i;
9866
          curr_seq_tmp(8) := seq_acq_reg2(tmp_value);
9867
          curr_seq_tmp(10) := seq_du_reg2(tmp_value);
9868
          if (seq_avg_reg2(tmp_value) = '1') then
9869
             curr_seq_tmp(13 downto 12) := cfg_reg0(13 downto 12);
9870
          else
9871
             curr_seq_tmp(13 downto 12) := "00";
9872
          end if;
9873
      end if;
9874
      curr_seq <= curr_seq_tmp;
9875
   end if;
9876
   end process;
9877
 
9878
   eos_en_p : process (adcclk, rst_in)
9879
   begin
9880
        if (rst_in = '1') then
9881
            seq_count <= 1;
9882
            eos_en <= '0';
9883
        elsif (rising_edge(adcclk)) then
9884
            if ((seq_count = seq_num  ) and (adc_state = CONV_STATE and next_state = END_STATE)
9885
                 and  (curr_seq1_0_lat /= "11") and rst_lock = '0') then
9886
                eos_tmp_en <= '1';
9887
            else
9888
                eos_tmp_en <= '0';
9889
            end if;
9890
 
9891
            if ((eos_tmp_en = '1') and (seq_status_avg = 0))  then
9892
                eos_en <= '1';
9893
            else
9894
                eos_en <= '0';
9895
            end if;
9896
 
9897
            if (eos_tmp_en = '1' or curr_seq1_0_lat = "11") then
9898
                seq_count <= 1;
9899
            elsif (seq_count_en = '1' ) then
9900
               if (seq_count >= 32) then
9901
                  seq_count <= 1;
9902
               else
9903
                seq_count <= seq_count +1;
9904
               end if;
9905
            end if;
9906
        end if;
9907
   end process;
9908
 
9909
-- end sequence control
9910
 
9911
-- Acquisition
9912
 
9913
   busy_out_dly <= busy_out after 10 ps;
9914
 
9915
   short_acq_p : process(adc_state, rst_in, first_acq)
9916
   begin
9917
       if (rst_in = '1') then
9918
           shorten_acq <= 0;
9919
       elsif (adc_state'event or first_acq'event) then
9920
         if  ((busy_out_dly = '0') and (adc_state=ACQ_STATE) and (first_acq='1')) then
9921
           shorten_acq <= 1;
9922
         else
9923
           shorten_acq <= 0;
9924
         end if;
9925
       end if;
9926
   end process;
9927
 
9928
   acq_count_p : process (adcclk, rst_in)
9929
   begin
9930
        if (rst_in = '1') then
9931
            acq_count <= 1;
9932
            first_acq <= '1';
9933
        elsif (rising_edge(adcclk)) then
9934
            if (adc_state = ACQ_STATE and rst_lock = '0' and acq_e_c = '0') then
9935
                first_acq <= '0';
9936
 
9937
                if (acq_acqsel = '1') then
9938
                    if (acq_count <= 11) then
9939
                        acq_count <= acq_count + 1 + shorten_acq;
9940
                    end if;
9941
                else
9942
                    if (acq_count <= 4) then
9943
                        acq_count <= acq_count + 1 + shorten_acq;
9944
                    end if;
9945
                end if;
9946
 
9947
                if (next_state = CONV_STATE) then
9948
                    if ((acq_acqsel = '1' and acq_count < 10) or (acq_acqsel = '0' and acq_count < 4)) then
9949
                    assert false report "Warning: Acquisition time not enough for SYSMON."
9950
                    severity warning;
9951
                    end if;
9952
                end if;
9953
            else
9954
                if (first_acq = '1') then
9955
                    acq_count <= 1;
9956
                else
9957
                    acq_count <= 0;
9958
                end if;
9959
            end if;
9960
        end if;
9961
    end process;
9962
 
9963
    conv_start_con_p: process(adc_state, acq_acqsel, acq_count)
9964
    begin
9965
      if (adc_state = ACQ_STATE) then
9966
        if (rst_lock = '0') then
9967
         if ((seq_reset_flag = '0' or (seq_reset_flag = '1' and curr_clkdiv_sel_int > 3))
9968
           and ((acq_acqsel = '1' and acq_count > 10) or (acq_acqsel = '0' and acq_count > 4))) then
9969
                 conv_start_cont <= '1';
9970
         else
9971
                 conv_start_cont <= '0';
9972
         end if;
9973
       end if;
9974
     else
9975
         conv_start_cont <= '0';
9976
     end if;
9977
   end process;
9978
 
9979
   conv_start_sel <= convst_in when (acq_e_c = '1') else conv_start_cont;
9980
   reset_conv_start_tmp <= '1' when (conv_count=2) else '0';
9981
   reset_conv_start <= rst_in or reset_conv_start_tmp;
9982
 
9983
   conv_start_p : process(conv_start_sel, reset_conv_start)
9984
   begin
9985
      if (reset_conv_start ='1') then
9986
          conv_start <= '0';
9987
      elsif (rising_edge(conv_start_sel)) then
9988
          conv_start <= '1';
9989
      end if;
9990
   end process;
9991
 
9992
-- end acquisition
9993
 
9994
 
9995
-- Conversion
9996
    conv_result_p : process (adc_state, next_state, curr_chan, curr_chan_index, analog_mux_in, curr_b_u)
9997
       variable conv_result_int_i : integer := 0;
9998
       variable conv_result_int_tmp : integer := 0;
9999
       variable conv_result_int_tmp_rl : real := 0.0;
10000
       variable adc_analog_tmp : real := 0.0;
10001
    begin
10002
        if ((adc_state = CONV_STATE and next_state = END_STATE) or adc_state = END_STATE) then
10003
            if (curr_chan = "00000") then    -- temperature conversion
10004
                    adc_analog_tmp := (analog_mux_in + 273.0) * 130.0382;
10005
                    adc_temp_result <= adc_analog_tmp;
10006
                    if (adc_analog_tmp >= 65535.0) then
10007
                        conv_result_int_i := 65535;
10008
                    elsif (adc_analog_tmp < 0.0) then
10009
                        conv_result_int_i := 0;
10010
                    else
10011
                        conv_result_int_tmp := real2int(adc_analog_tmp);
10012
                        conv_result_int_tmp_rl := int2real(conv_result_int_tmp);
10013
                        if (adc_analog_tmp - conv_result_int_tmp_rl > 0.9999) then
10014
                            conv_result_int_i := conv_result_int_tmp + 1;
10015
                        else
10016
                            conv_result_int_i := conv_result_int_tmp;
10017
                        end if;
10018
                    end if;
10019
                    conv_result_int <= conv_result_int_i;
10020
                    conv_result <= STD_LOGIC_VECTOR(TO_UNSIGNED(conv_result_int_i, 16));
10021
            elsif (curr_chan = "00001" or curr_chan = "00010") then     -- internal power conversion
10022
                    adc_analog_tmp := analog_mux_in * 65536.0 / 3.0;
10023
                    adc_intpwr_result <= adc_analog_tmp;
10024
                    if (adc_analog_tmp >= 65535.0) then
10025
                        conv_result_int_i := 65535;
10026
                    elsif (adc_analog_tmp < 0.0) then
10027
                        conv_result_int_i := 0;
10028
                    else
10029
                       conv_result_int_tmp := real2int(adc_analog_tmp);
10030
                        conv_result_int_tmp_rl := int2real(conv_result_int_tmp);
10031
                        if (adc_analog_tmp - conv_result_int_tmp_rl > 0.9999) then
10032
                            conv_result_int_i := conv_result_int_tmp + 1;
10033
                        else
10034
                            conv_result_int_i := conv_result_int_tmp;
10035
                        end if;
10036
                    end if;
10037
                    conv_result_int <= conv_result_int_i;
10038
                    conv_result <= STD_LOGIC_VECTOR(TO_UNSIGNED(conv_result_int_i, 16));
10039
            elsif ((curr_chan = "00011") or ((curr_chan_index >= 16) and  (curr_chan_index <= 31))) then
10040
                    adc_analog_tmp :=  (analog_mux_in) * 65536.0;
10041
                    adc_ext_result <= adc_analog_tmp;
10042
                    if (curr_b_u = '1')  then
10043
                        if (adc_analog_tmp > 32767.0) then
10044
                             conv_result_int_i := 32767;
10045
                        elsif (adc_analog_tmp < -32768.0) then
10046
                             conv_result_int_i := -32768;
10047
                        else
10048
                            conv_result_int_tmp := real2int(adc_analog_tmp);
10049
                            conv_result_int_tmp_rl := int2real(conv_result_int_tmp);
10050
                            if (adc_analog_tmp - conv_result_int_tmp_rl > 0.9999) then
10051
                                conv_result_int_i := conv_result_int_tmp + 1;
10052
                            else
10053
                                conv_result_int_i := conv_result_int_tmp;
10054
                            end if;
10055
                        end if;
10056
                    conv_result_int <= conv_result_int_i;
10057
                    conv_result <= STD_LOGIC_VECTOR(TO_SIGNED(conv_result_int_i, 16));
10058
                    else
10059
                       if (adc_analog_tmp  > 65535.0) then
10060
                             conv_result_int_i := 65535;
10061
                        elsif (adc_analog_tmp  < 0.0) then
10062
                             conv_result_int_i := 0;
10063
                        else
10064
                            conv_result_int_tmp := real2int(adc_analog_tmp);
10065
                            conv_result_int_tmp_rl := int2real(conv_result_int_tmp);
10066
                            if (adc_analog_tmp - conv_result_int_tmp_rl > 0.9999) then
10067
                                conv_result_int_i := conv_result_int_tmp + 1;
10068
                            else
10069
                                conv_result_int_i := conv_result_int_tmp;
10070
                            end if;
10071
                        end if;
10072
                    conv_result_int <= conv_result_int_i;
10073
                    conv_result <= STD_LOGIC_VECTOR(TO_UNSIGNED(conv_result_int_i, 16));
10074
                    end if;
10075
            else
10076
                conv_result_int <= 0;
10077
                conv_result <= "0000000000000000";
10078
            end if;
10079
         end if;
10080
 
10081
    end process;
10082
 
10083
 
10084
    conv_count_p : process (adcclk, rst_in)
10085
    begin
10086
        if (rst_in = '1') then
10087
            conv_count <= 6;
10088
            conv_end <= '0';
10089
            seq_status_avg <= 0;
10090
            busy_r_rst <= '0';
10091
            busy_r_rst_done <= '0';
10092
            for i in 0 to 31 loop
10093
                conv_avg_count(i) <= 0;     -- array of integer
10094
            end loop;
10095
            single_chan_conv_end <= '0';
10096
        elsif (rising_edge(adcclk)) then
10097
            if (adc_state = ACQ_STATE) then
10098
               if (busy_r_rst_done = '0') then
10099
                    busy_r_rst <= '1';
10100
               else
10101
                    busy_r_rst <= '0';
10102
               end if;
10103
               busy_r_rst_done <= '1';
10104
            end if;
10105
 
10106
            if (adc_state = ACQ_STATE and conv_start = '1') then
10107
                conv_count <= 0;
10108
                conv_end <= '0';
10109
            elsif (adc_state = CONV_STATE ) then
10110
                busy_r_rst_done <= '0';
10111
                conv_count <= conv_count + 1;
10112
 
10113
                if (((curr_chan /= "01000" ) and (conv_count = conv_time )) or
10114
              ((curr_chan = "01000") and (conv_count = conv_time_cal_1) and (first_cal_chan = '1'))
10115
              or ((curr_chan = "01000") and (conv_count = conv_time_cal) and (first_cal_chan = '0'))) then
10116
                    conv_end <= '1';
10117
                else
10118
                    conv_end <= '0';
10119
                end if;
10120
            else
10121
                conv_end <= '0';
10122
                conv_count <= 0;
10123
            end if;
10124
 
10125
           single_chan_conv_end <= '0';
10126
           if ( (conv_count = conv_time) or (conv_count = 44)) then
10127
                   single_chan_conv_end <= '1';
10128
           end if;
10129
 
10130
            if (adc_state = CONV_STATE and next_state = END_STATE and rst_lock = '0') then
10131
                case curr_avg_set is
10132
                    when "00" => eoc_en <= '1';
10133
                                conv_avg_count(curr_chan_index) <= 0;
10134
                    when "01" =>
10135
                                if (conv_avg_count(curr_chan_index) = 15) then
10136
                                  eoc_en <= '1';
10137
                                  conv_avg_count(curr_chan_index) <= 0;
10138
                                  seq_status_avg <= seq_status_avg - 1;
10139
                                else
10140
                                  eoc_en <= '0';
10141
                                  if (conv_avg_count(curr_chan_index) = 0) then
10142
                                      seq_status_avg <= seq_status_avg + 1;
10143
                                  end if;
10144
                                  conv_avg_count(curr_chan_index) <= conv_avg_count(curr_chan_index) + 1;
10145
                                end if;
10146
                   when "10" =>
10147
                                if (conv_avg_count(curr_chan_index) = 63) then
10148
                                    eoc_en <= '1';
10149
                                    conv_avg_count(curr_chan_index) <= 0;
10150
                                    seq_status_avg <= seq_status_avg - 1;
10151
                                else
10152
                                    eoc_en <= '0';
10153
                                    if (conv_avg_count(curr_chan_index) = 0) then
10154
                                        seq_status_avg <= seq_status_avg + 1;
10155
                                    end if;
10156
                                    conv_avg_count(curr_chan_index) <= conv_avg_count(curr_chan_index) + 1;
10157
                                end if;
10158
                    when "11" =>
10159
                                if (conv_avg_count(curr_chan_index) = 255) then
10160
                                    eoc_en <= '1';
10161
                                    conv_avg_count(curr_chan_index) <= 0;
10162
                                    seq_status_avg <= seq_status_avg - 1;
10163
                                else
10164
                                    eoc_en <= '0';
10165
                                    if (conv_avg_count(curr_chan_index) = 0) then
10166
                                        seq_status_avg <= seq_status_avg + 1;
10167
                                    end if;
10168
                                    conv_avg_count(curr_chan_index) <= conv_avg_count(curr_chan_index) + 1;
10169
                                end if;
10170
                   when  others => eoc_en <= '0';
10171
                end case;
10172
            else
10173
                eoc_en <= '0';
10174
            end if;
10175
 
10176
            if (adc_state = END_STATE) then
10177
                   conv_result_reg <= conv_result;
10178
            end if;
10179
        end if;
10180
   end process;
10181
 
10182
-- end conversion
10183
 
10184
 
10185
-- average
10186
 
10187
    conv_acc_result_p : process(adcclk, rst_in)
10188
       variable conv_acc_vec : std_logic_vector(23 downto 0);
10189
       variable conv_acc_vec_int  : integer;
10190
    begin
10191
        if (rst_in = '1') then
10192
            for j in 0 to 31 loop
10193
                conv_acc(j) <= 0;
10194
            end loop;
10195
            conv_acc_result <= "0000000000000000";
10196
        elsif (rising_edge(adcclk)) then
10197
            if (adc_state = CONV_STATE and  next_state = END_STATE) then
10198
                if (curr_avg_set /= "00" and rst_lock /= '1') then
10199
                    conv_acc(curr_chan_index) <= conv_acc(curr_chan_index) + conv_result_int;
10200
                else
10201
                    conv_acc(curr_chan_index) <= 0;
10202
                end if;
10203
            elsif (eoc_en = '1') then
10204
                conv_acc_vec_int := conv_acc(curr_chan_index);
10205
                if ((curr_b_u = '1') and (((curr_chan_index >= 16) and (curr_chan_index <= 31))
10206
                   or (curr_chan_index = 3))) then
10207
                    conv_acc_vec := STD_LOGIC_VECTOR(TO_SIGNED(conv_acc_vec_int, 24));
10208
                else
10209
                    conv_acc_vec := STD_LOGIC_VECTOR(TO_UNSIGNED(conv_acc_vec_int, 24));
10210
                end if;
10211
                case curr_avg_set(1 downto 0) is
10212
                  when "00" => conv_acc_result <= "0000000000000000";
10213
                  when "01" => conv_acc_result <= conv_acc_vec(19 downto 4);
10214
                  when "10" => conv_acc_result <= conv_acc_vec(21 downto 6);
10215
                  when "11" => conv_acc_result <= conv_acc_vec(23 downto 8);
10216
                  when others => conv_acc_result <= "0000000000000000";
10217
                end case;
10218
                conv_acc(curr_chan_index) <= 0;
10219
            end if;
10220
        end if;
10221
    end process;
10222
 
10223
-- end average
10224
 
10225
-- single sequence
10226
    adc_s1_flag_p : process(adcclk, rst_in)
10227
    begin
10228
        if (rst_in = '1') then
10229
            adc_s1_flag <= '0';
10230
        elsif (rising_edge(adcclk)) then
10231
            if (adc_state = SINGLE_SEQ_STATE) then
10232
                adc_s1_flag <= '1';
10233
            end if;
10234
        end if;
10235
    end process;
10236
 
10237
 
10238
--  end state
10239
    eos_eoc_p: process(adcclk, rst_in)
10240
    begin
10241
        if (rst_in = '1') then
10242
            seq_count_en <= '0';
10243
            eos_out_tmp <= '0';
10244
            eoc_out_tmp <= '0';
10245
        elsif (rising_edge(adcclk)) then
10246
            if ((adc_state = CONV_STATE and next_state = END_STATE) and (curr_seq1_0_lat /= "11")
10247
                  and (rst_lock = '0')) then
10248
                seq_count_en <= '1';
10249
            else
10250
                seq_count_en <= '0';
10251
            end if;
10252
 
10253
            if (rst_lock = '0') then
10254
                 eos_out_tmp <= eos_en;
10255
                 eoc_en_delay <= eoc_en;
10256
                 eoc_out_tmp <= eoc_en_delay;
10257
            else
10258
                 eos_out_tmp <= '0';
10259
                 eoc_en_delay <= '0';
10260
                 eoc_out_tmp <= '0';
10261
            end if;
10262
        end if;
10263
   end process;
10264
 
10265
    data_reg_p : process(eoc_out, rst_in_not_seq)
10266
       variable tmp_uns1 : unsigned(15 downto 0);
10267
       variable tmp_uns2 : unsigned(15 downto 0);
10268
       variable tmp_uns3 : unsigned(15 downto 0);
10269
    begin
10270
        if (rst_in_not_seq = '1') then
10271
            for k in  32 to  39 loop
10272
                if (k >= 36) then
10273
                    data_reg(k) <= "1111111111111111";
10274
                else
10275
                    data_reg(k) <= "0000000000000000";
10276
                end if;
10277
            end loop;
10278
        elsif (rising_edge(eoc_out)) then
10279
            if ( rst_lock = '0') then
10280
                if ((curr_chan_index >= 0 and curr_chan_index <= 3) or
10281
                          (curr_chan_index >= 16 and curr_chan_index <= 31)) then
10282
                    if (curr_avg_set = "00") then
10283
                        data_reg(curr_chan_index) <= conv_result_reg;
10284
                    else
10285
                        data_reg(curr_chan_index) <= conv_acc_result;
10286
                    end if;
10287
                end if;
10288
                if (curr_chan_index = 4) then
10289
                    data_reg(curr_chan_index) <= X"D555";
10290
                end if;
10291
                if (curr_chan_index = 5) then
10292
                    data_reg(curr_chan_index) <= X"0000";
10293
                end if;
10294
                if (curr_chan_index = 0 or curr_chan_index = 1 or curr_chan_index = 2) then
10295
                    tmp_uns2 := UNSIGNED(data_reg(32 + curr_chan_index));
10296
                    tmp_uns3 := UNSIGNED(data_reg(36 + curr_chan_index));
10297
                    if (curr_avg_set = "00") then
10298
                        tmp_uns1 := UNSIGNED(conv_result_reg);
10299
                        if (tmp_uns1 > tmp_uns2) then
10300
                            data_reg(32 + curr_chan_index) <= conv_result_reg;
10301
                         end if;
10302
                        if (tmp_uns1 < tmp_uns3) then
10303
                            data_reg(36 + curr_chan_index) <= conv_result_reg;
10304
                        end if;
10305
                    else
10306
                        tmp_uns1 := UNSIGNED(conv_acc_result);
10307
                        if (tmp_uns1 > tmp_uns2) then
10308
                            data_reg(32 + curr_chan_index) <= conv_acc_result;
10309
                        end if;
10310
                        if (tmp_uns1 < tmp_uns3) then
10311
                            data_reg(36 + curr_chan_index) <= conv_acc_result;
10312
                        end if;
10313
                    end if;
10314
                end if;
10315
           end if;
10316
       end if;
10317
     end process;
10318
 
10319
    data_written_p : process(busy_r, rst_in_not_seq)
10320
    begin
10321
       if (rst_in_not_seq = '1') then
10322
            data_written <= X"0000";
10323
       elsif (falling_edge(busy_r)) then
10324
          if (curr_avg_set = "00") then
10325
               data_written <= conv_result_reg;
10326
           else
10327
              data_written <= conv_acc_result;
10328
           end if;
10329
       end if;
10330
    end process;
10331
 
10332
-- eos and eoc
10333
 
10334
    eoc_out_tmp1_p : process (eoc_out_tmp, eoc_out, rst_in)
10335
    begin
10336
           if (rst_in = '1') then
10337
              eoc_out_tmp1 <= '0';
10338
           elsif (rising_edge(eoc_out)) then
10339
               eoc_out_tmp1 <= '0';
10340
           elsif (rising_edge(eoc_out_tmp)) then
10341
               if (curr_chan /= "01000") then
10342
                  eoc_out_tmp1 <= '1';
10343
               else
10344
                  eoc_out_tmp1 <= '0';
10345
               end if;
10346
           end if;
10347
    end process;
10348
 
10349
    eos_out_tmp1_p : process (eos_out_tmp, eos_out, rst_in)
10350
    begin
10351
           if (rst_in = '1') then
10352
              eos_out_tmp1 <= '0';
10353
           elsif (rising_edge(eos_out)) then
10354
               eos_out_tmp1 <= '0';
10355
           elsif (rising_edge(eos_out_tmp)) then
10356
               eos_out_tmp1 <= '1';
10357
           end if;
10358
    end process;
10359
 
10360
    busy_out_low_edge <= '1' when (busy_out='0' and busy_out_sync='1') else '0';
10361
 
10362
    eoc_eos_out_p : process (dclk_in, rst_in)
10363
    begin
10364
      if (rst_in = '1') then
10365
          op_count <= 15;
10366
          busy_out_sync <= '0';
10367
          drp_update <= '0';
10368
          alarm_update <= '0';
10369
          eoc_out <= '0';
10370
          eos_out <= '0';
10371
      elsif ( rising_edge(dclk_in)) then
10372
         busy_out_sync <= busy_out;
10373
         if (op_count = 3) then
10374
            drp_update <= '1';
10375
          else
10376
            drp_update <= '0';
10377
          end if;
10378
          if (op_count = 5 and eoc_out_tmp1 = '1') then
10379
             alarm_update <= '1';
10380
          else
10381
             alarm_update <= '0';
10382
          end if;
10383
          if (op_count = 9 ) then
10384
             eoc_out <= eoc_out_tmp1;
10385
          else
10386
             eoc_out <= '0';
10387
          end if;
10388
          if (op_count = 9) then
10389
             eos_out <= eos_out_tmp1;
10390
          else
10391
             eos_out <= '0';
10392
          end if;
10393
          if (busy_out_low_edge = '1') then
10394
              op_count <= 0;
10395
          elsif (op_count < 15) then
10396
              op_count <= op_count +1;
10397
          end if;
10398
      end if;
10399
   end process;
10400
 
10401
-- end eos and eoc
10402
 
10403
 
10404
-- alarm
10405
 
10406
    alm_reg_p : process(alarm_update, rst_in_not_seq )
10407
       variable  tmp_unsig1 : unsigned(15 downto 0);
10408
       variable  tmp_unsig2 : unsigned(15 downto 0);
10409
       variable  tmp_unsig3 : unsigned(15 downto 0);
10410
    begin
10411
     if (rst_in_not_seq = '1') then
10412
        ot_out_reg <= '0';
10413
        alarm_out_reg <= "000";
10414
     elsif (rising_edge(alarm_update)) then
10415
       if (rst_lock = '0') then
10416
          if (curr_chan_lat = "00000") then
10417
            tmp_unsig1 := UNSIGNED(data_written);
10418
            tmp_unsig2 := UNSIGNED(dr_sram(16#57#));
10419
            if (tmp_unsig1 >= ot_limit_reg) then
10420
                ot_out_reg <= '1';
10421
            elsif (((tmp_unsig1 < tmp_unsig2) and (curr_seq1_0_lat /= "00")) or
10422
                           ((curr_seq1_0_lat = "00") and (tmp_unsig1 < ot_sf_limit_low_reg))) then
10423
                ot_out_reg <= '0';
10424
            end if;
10425
            tmp_unsig2 := UNSIGNED(dr_sram(16#50#));
10426
            tmp_unsig3 := UNSIGNED(dr_sram(16#54#));
10427
            if ( tmp_unsig1 > tmp_unsig2) then
10428
                     alarm_out_reg(0) <= '1';
10429
            elsif (tmp_unsig1 <= tmp_unsig3) then
10430
                     alarm_out_reg(0) <= '0';
10431
            end if;
10432
          end if;
10433
          tmp_unsig1 := UNSIGNED(data_written);
10434
          tmp_unsig2 := UNSIGNED(dr_sram(16#51#));
10435
          tmp_unsig3 := UNSIGNED(dr_sram(16#55#));
10436
          if (curr_chan_lat = "00001") then
10437
             if ((tmp_unsig1 > tmp_unsig2) or (tmp_unsig1 < tmp_unsig3)) then
10438
                      alarm_out_reg(1) <= '1';
10439
             else
10440
                      alarm_out_reg(1) <= '0';
10441
             end if;
10442
          end if;
10443
          tmp_unsig1 := UNSIGNED(data_written);
10444
          tmp_unsig2 := UNSIGNED(dr_sram(16#52#));
10445
          tmp_unsig3 := UNSIGNED(dr_sram(16#56#));
10446
          if (curr_chan_lat = "00010") then
10447
              if ((tmp_unsig1 > tmp_unsig2) or (tmp_unsig1 < tmp_unsig3)) then
10448
                      alarm_out_reg(2) <= '1';
10449
                 else
10450
                      alarm_out_reg(2) <= '0';
10451
              end if;
10452
          end if;
10453
     end if;
10454
    end if;
10455
   end process;
10456
 
10457
 
10458
    alm_p : process(ot_out_reg, ot_en, alarm_out_reg, alarm_en)
10459
    begin
10460
             ot_out <= ot_out_reg and ot_en;
10461
             alarm_out(0) <= alarm_out_reg(0) and alarm_en(0);
10462
             alarm_out(1) <= alarm_out_reg(1) and alarm_en(1);
10463
             alarm_out(2) <= alarm_out_reg(2) and alarm_en(2);
10464
      end process;
10465
 
10466
-- end alarm
10467
 
10468
 
10469
  READFILE_P : process
10470
      file in_file : text;
10471
      variable open_status : file_open_status;
10472
      variable in_buf    : line;
10473
      variable str_token : string(1 to 12);
10474
      variable str_token_in : string(1 to 12);
10475
      variable str_token_tmp : string(1 to 12);
10476
      variable next_time     : time := 0 ps;
10477
      variable pre_time : time := 0 ps;
10478
      variable time_val : integer := 0;
10479
      variable a1   : real;
10480
 
10481
      variable commentline : boolean := false;
10482
      variable HeaderFound : boolean := false;
10483
      variable read_ok : boolean := false;
10484
      variable token_len : integer;
10485
      variable HeaderCount : integer := 0;
10486
 
10487
      variable vals : ANALOG_DATA := (others => 0.0);
10488
      variable valsn : ANALOG_DATA := (others => 0.0);
10489
      variable inchannel : integer := 0 ;
10490
      type int_a is array (0 to 41) of integer;
10491
      variable index_to_channel : int_a := (others => -1);
10492
      variable low : integer := -1;
10493
      variable low2 : integer := -1;
10494
      variable sim_file_flag1 : std_ulogic := '0';
10495
      variable file_line : integer := 0;
10496
 
10497
      type channm_array is array (0 to 31 ) of string(1 to  12);
10498
      constant chanlist_p : channm_array := (
10499
 
10500
       1 => "VCCINT" & NUL & NUL & NUL & NUL & NUL & NUL,
10501
       2 => "VCCAUX" & NUL & NUL & NUL & NUL & NUL & NUL,
10502
       3 => "VP" & NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL,
10503
       4 => NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL &
10504
             NUL & NUL,
10505
       5 => NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL &
10506
             NUL & NUL,
10507
       6 => "xxxxxxxxxxxx",
10508
       7 => "xxxxxxxxxxxx",
10509
       8 => NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL &
10510
             NUL & NUL,
10511
       9 => NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL &
10512
             NUL & NUL,
10513
       10 => "xxxxxxxxxxxx",
10514
       11 => "xxxxxxxxxxxx",
10515
       12 => "xxxxxxxxxxxx",
10516
       13 => "xxxxxxxxxxxx",
10517
       14 => "xxxxxxxxxxxx",
10518
       15 => "xxxxxxxxxxxx",
10519
       16 => "VAUXP[0]" & NUL & NUL & NUL & NUL,
10520
       17 => "VAUXP[1]" & NUL & NUL & NUL & NUL,
10521
       18 => "VAUXP[2]" & NUL & NUL & NUL & NUL,
10522
       19 => "VAUXP[3]" & NUL & NUL & NUL & NUL,
10523
       20 => "VAUXP[4]" & NUL & NUL & NUL & NUL,
10524
       21 => "VAUXP[5]" & NUL & NUL & NUL & NUL,
10525
       22 => "VAUXP[6]" & NUL & NUL & NUL & NUL,
10526
       23 => "VAUXP[7]" & NUL & NUL & NUL & NUL,
10527
       24 => "VAUXP[8]" & NUL & NUL & NUL & NUL,
10528
       25 => "VAUXP[9]" & NUL & NUL & NUL & NUL,
10529
       26 => "VAUXP[10]" & NUL & NUL & NUL,
10530
       27 => "VAUXP[11]" & NUL & NUL & NUL,
10531
       28 => "VAUXP[12]" & NUL & NUL & NUL,
10532
       29 => "VAUXP[13]" & NUL & NUL & NUL,
10533
       30 => "VAUXP[14]" & NUL & NUL & NUL,
10534
       31 => "VAUXP[15]" & NUL & NUL & NUL
10535
      );
10536
 
10537
      constant chanlist_n : channm_array := (
10538
 
10539
       1 => "xxxxxxxxxxxx",
10540
       2 => "xxxxxxxxxxxx",
10541
       3 => "VN" & NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL,
10542
       4 => NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL &
10543
             NUL & NUL,
10544
       5 => NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL &
10545
             NUL & NUL,
10546
       6 => "xxxxxxxxxxxx",
10547
       7 => "xxxxxxxxxxxx",
10548
       8 => NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL &
10549
             NUL & NUL,
10550
       9 => NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL &
10551
             NUL & NUL,
10552
       10 => "xxxxxxxxxxxx",
10553
       11 => "xxxxxxxxxxxx",
10554
       12 => "xxxxxxxxxxxx",
10555
       13 => "xxxxxxxxxxxx",
10556
       14 => "xxxxxxxxxxxx",
10557
       15 => "xxxxxxxxxxxx",
10558
       16 => "VAUXN[0]" & NUL & NUL & NUL & NUL,
10559
       17 => "VAUXN[1]" & NUL & NUL & NUL & NUL,
10560
       18 => "VAUXN[2]" & NUL & NUL & NUL & NUL,
10561
       19 => "VAUXN[3]" & NUL & NUL & NUL & NUL,
10562
       20 => "VAUXN[4]" & NUL & NUL & NUL & NUL,
10563
       21 => "VAUXN[5]" & NUL & NUL & NUL & NUL,
10564
       22 => "VAUXN[6]" & NUL & NUL & NUL & NUL,
10565
       23 => "VAUXN[7]" & NUL & NUL & NUL & NUL,
10566
       24 => "VAUXN[8]" & NUL & NUL & NUL & NUL,
10567
       25 => "VAUXN[9]" & NUL & NUL & NUL & NUL,
10568
       26 => "VAUXN[10]" & NUL & NUL & NUL,
10569
       27 => "VAUXN[11]" & NUL & NUL & NUL,
10570
       28 => "VAUXN[12]" & NUL & NUL & NUL,
10571
       29 => "VAUXN[13]" & NUL & NUL & NUL,
10572
       30 => "VAUXN[14]" & NUL & NUL & NUL,
10573
       31 => "VAUXN[15]" & NUL & NUL & NUL
10574
           );
10575
 
10576
  begin
10577
 
10578
    file_open(open_status, in_file, SIM_MONITOR_FILE, read_mode);
10579
    if (open_status /= open_ok) then
10580
         assert false report
10581
         "*** Warning: The analog data file for SYSMON was not found. Use the SIM_MONITOR_FILE generic to specify the input analog data file name or use default name: design.txt. "
10582
         severity warning;
10583
         sim_file_flag1 := '1';
10584
         sim_file_flag <= '1';
10585
    end if;
10586
 
10587
   if ( sim_file_flag1 = '0') then
10588
      while (not endfile(in_file) and (not HeaderFound)) loop
10589
        commentline := false;
10590
        readline(in_file, in_buf);
10591
        file_line := file_line + 1;
10592
        if (in_buf'LENGTH > 0 ) then
10593
          skip_blanks(in_buf);
10594
 
10595
          low := in_buf'low;
10596
          low2 := in_buf'low+2;
10597
           if ( low2 <= in_buf'high) then
10598
              if ((in_buf(in_buf'low to in_buf'low+1) = "//" ) or
10599
                  (in_buf(in_buf'low to in_buf'low+1) = "--" )) then
10600
                 commentline := true;
10601
               end if;
10602
 
10603
               while((in_buf'LENGTH > 0 ) and (not commentline)) loop
10604
                   HeaderFound := true;
10605
                   get_token(in_buf, str_token_in, token_len);
10606
                   str_token_tmp := To_Upper(str_token_in);
10607
                   if (str_token_tmp(1 to 4) = "TEMP") then
10608
                      str_token := "TEMP" & NUL & NUL & NUL & NUL & NUL
10609
                                                  & NUL & NUL & NUL;
10610
                   else
10611
                      str_token := str_token_tmp;
10612
                   end if;
10613
 
10614
                   if(token_len > 0) then
10615
                    HeaderCount := HeaderCount + 1;
10616
                   end if;
10617
 
10618
                   if (HeaderCount=1) then
10619
                      if (str_token(1 to token_len) /= "TIME") then
10620
                         infile_format;
10621
                         assert false report
10622
                  " Analog Data File Error : No TIME label is found in the input file for SYSMON."
10623
                         severity failure;
10624
                      end if;
10625
                   elsif (HeaderCount > 1) then
10626
                      inchannel := -1;
10627
                      for i in 0 to 31 loop
10628
                          if (chanlist_p(i) = str_token) then
10629
                             inchannel := i;
10630
                             index_to_channel(headercount) := i;
10631
                           end if;
10632
                       end loop;
10633
                       if (inchannel = -1) then
10634
                         for i in 0 to 31 loop
10635
                           if ( chanlist_n(i) = str_token) then
10636
                             inchannel := i;
10637
                             index_to_channel(headercount) := i+32;
10638
                           end if;
10639
                         end loop;
10640
                       end if;
10641
                       if (inchannel = -1 and token_len >0) then
10642
                           infile_format;
10643
                           assert false report
10644
                    "Analog Data File Error : No valid channel name in the input file for SYSMON. Valid names: TEMP VCCINT VCCAUX VP VN VAUXP[1] VAUXN[1] ....."
10645
                           severity failure;
10646
                       end if;
10647
                  else
10648
                       infile_format;
10649
                       assert false report
10650
                    "Analog Data File Error : NOT found header in the input file for SYSMON. The header is: TIME TEMP VCCINT VCCAUX VP VN VAUXP[1] VAUXN[1] ..."
10651
                           severity failure;
10652
                  end if;
10653
 
10654
           str_token_in := NUL & NUL & NUL & NUL & NUL & NUL & NUL & NUL &
10655
                           NUL & NUL & NUL & NUL;
10656
        end loop;
10657
        end if;
10658
       end if;
10659
      end loop;
10660
 
10661
-----  Read Values
10662
      while (not endfile(in_file)) loop
10663
        commentline := false;
10664
        readline(in_file, in_buf);
10665
        file_line := file_line + 1;
10666
        if (in_buf'length > 0) then
10667
           skip_blanks(in_buf);
10668
 
10669
           if (in_buf'low < in_buf'high) then
10670
             if((in_buf(in_buf'low to in_buf'low+1) = "//" ) or
10671
                    (in_buf(in_buf'low to in_buf'low+1) = "--" )) then
10672
              commentline := true;
10673
             end if;
10674
 
10675
          if(not commentline and in_buf'length > 0) then
10676
            for i IN 1 to HeaderCount Loop
10677
              if ( i=1) then
10678
                 read(in_buf, time_val, read_ok);
10679
                if (not read_ok) then
10680
                  infile_format;
10681
                  assert false report
10682
                   " Analog Data File Error : The time value should be integer in ns scale and the last time value needs bigger than simulation time."
10683
                  severity failure;
10684
                 end if;
10685
                 next_time := time_val * 1 ns;
10686
              else
10687
               read(in_buf, a1, read_ok);
10688
               if (not read_ok) then
10689
                  assert false report
10690
                    "*** Analog Data File Error: The data type should be REAL, e.g. 3.0  0.0  -0.5 "
10691
                  severity failure;
10692
               end if;
10693
               inchannel:= index_to_channel(i);
10694
              if (inchannel >= 32) then
10695
                valsn(inchannel-32):=a1;
10696
              else
10697
                vals(inchannel):=a1;
10698
              end if;
10699
            end if;
10700
           end loop;  -- i loop
10701
 
10702
           if ( now < next_time) then
10703
               wait for ( next_time - now );
10704
           end if;
10705
           for i in 0 to 31 loop
10706
                 chan_val_tmp(i) <= vals(i);
10707
                 chan_valn_tmp(i) <= valsn(i);
10708
                 analog_in_diff(i) <= vals(i)-valsn(i);
10709
                 analog_in_uni(i) <= vals(i);
10710
           end loop;
10711
        end if;
10712
        end if;
10713
       end if;
10714
      end loop;  -- while loop
10715
      file_close(in_file);
10716
    end if;
10717
    wait;
10718
  end process READFILE_P;
10719
 
10720
end SYSMON_V;
10721
 
10722
library IEEE;
10723
use IEEE.STD_LOGIC_1164.all;
10724
 
10725
entity INV is
10726
  port(
10727
    O : out std_ulogic;
10728
 
10729
    I : in std_ulogic
10730
    );
10731
end INV;
10732
 
10733
architecture INV_V of INV is
10734
begin
10735
  O <= (not TO_X01(I));
10736
end INV_V;
10737
 
10738
library IEEE;
10739
use IEEE.STD_LOGIC_1164.all;
10740
 
10741
library unisim;
10742
use unisim.vpkg.all;
10743
use unisim.VCOMPONENTS.all;
10744
 
10745
entity LUT2_L is
10746
  generic(
10747
    INIT : bit_vector := X"0"
10748
    );
10749
 
10750
  port(
10751
    LO : out std_ulogic;
10752
 
10753
    I0 : in std_ulogic;
10754
    I1 : in std_ulogic
10755
    );
10756
end LUT2_L;
10757
 
10758
architecture LUT2_L_V of LUT2_L is
10759
begin
10760
  VITALBehavior    : process (I0, I1)
10761
    variable INIT_reg : std_logic_vector((INIT'length - 1) downto 0) := To_StdLogicVector(INIT);
10762
    variable address : std_logic_vector(1 downto 0);
10763
    variable address_int : integer := 0;
10764
  begin
10765
     address := I1 & I0;
10766
     address_int := SLV_TO_INT(address(1 downto 0));
10767
 
10768
     if ((I1 xor I0) = '1' or (I1 xor I0) = '0') then
10769
       LO <= INIT_reg(address_int);
10770
    else
10771
        if ((INIT_reg(0) = INIT_reg(1)) and (INIT_reg(2) = INIT_reg(3)) and
10772
                              (INIT_reg(0) = INIT_reg(2)))  then
10773
        LO <= INIT_reg(0);
10774
      elsif ((I1 = '0') and (INIT_reg(0) = INIT_reg(1)))  then
10775
        LO <= INIT_reg(0);
10776
      elsif ((I1 = '1') and (INIT_reg(2) = INIT_reg(3)))  then
10777
        LO <= INIT_reg(2);
10778
      elsif ((I0 = '0') and (INIT_reg(0) = INIT_reg(2)))  then
10779
        LO <= INIT_reg(0);
10780
      elsif ((I0 = '1') and (INIT_reg(1)  = INIT_reg(3)))  then
10781
        LO <= INIT_reg(1);
10782
      else
10783
        LO <= 'X';
10784
      end if;
10785
    end if;
10786
  end process;
10787
end LUT2_L_V;
10788
 
10789
library IEEE;
10790
use IEEE.STD_LOGIC_1164.all;
10791
 
10792
library unisim;
10793
use unisim.VPKG.all;
10794
use unisim.VCOMPONENTS.all;
10795
 
10796
entity LUT4 is
10797
  generic(
10798
    INIT : bit_vector := X"0000"
10799
    );
10800
 
10801
  port(
10802
    O : out std_ulogic;
10803
 
10804
    I0 : in std_ulogic;
10805
    I1 : in std_ulogic;
10806
    I2 : in std_ulogic;
10807
    I3 : in std_ulogic
10808
    );
10809
end LUT4;
10810
 
10811
architecture LUT4_V of LUT4 is
10812
 
10813
function lut4_mux4 (d :  std_logic_vector(3 downto 0); s : std_logic_vector(1 downto 0) )
10814
                    return std_logic is
10815
 
10816
       variable lut4_mux4_o : std_logic;
10817
  begin
10818
 
10819
       if (((s(1) xor s(0)) = '1')  or  ((s(1) xor s(0)) = '0')) then
10820
           lut4_mux4_o := d(SLV_TO_INT(s));
10821
       elsif ((d(0) xor d(1)) = '0' and (d(2) xor d(3)) = '0'
10822
                    and (d(0) xor d(2)) = '0') then
10823
           lut4_mux4_o := d(0);
10824
       elsif ((s(1) = '0') and (d(0) = d(1))) then
10825
           lut4_mux4_o := d(0);
10826
       elsif ((s(1) = '1') and (d(2) = d(3))) then
10827
           lut4_mux4_o := d(2);
10828
       elsif ((s(0) = '0') and (d(0) = d(2))) then
10829
           lut4_mux4_o := d(0);
10830
       elsif ((s(0) = '1') and (d(1) = d(3))) then
10831
           lut4_mux4_o := d(1);
10832
       else
10833
           lut4_mux4_o := 'X';
10834
      end if;
10835
 
10836
      return (lut4_mux4_o);
10837
 
10838
  end function lut4_mux4;
10839
 
10840
    constant INIT_reg : std_logic_vector(15 downto 0) := To_StdLogicVector(INIT);
10841
begin
10842
 
10843
  lut_p   : process (I0, I1, I2, I3)
10844
--    variable INIT_reg : std_logic_vector(15 downto 0) := To_StdLogicVector(INIT);
10845
    variable I_reg    : std_logic_vector(3 downto 0);
10846
  begin
10847
 
10848
    I_reg := TO_STDLOGICVECTOR(I3 &  I2 & I1 & I0);
10849
 
10850
    if ((I3 xor I2 xor I1 xor I0) = '1' or (I3 xor I2 xor I1 xor I0) = '0') then
10851
       O <= INIT_reg(SLV_TO_INT(I_reg));
10852
    else
10853
 
10854
       O <= lut4_mux4 (
10855
            (lut4_mux4 ( INIT_reg(15 downto 12), I_reg(1 downto 0)) &
10856
            lut4_mux4 ( INIT_reg(11 downto 8), I_reg(1 downto 0)) &
10857
            lut4_mux4 ( INIT_reg(7 downto 4), I_reg(1 downto 0)) &
10858
            lut4_mux4 ( INIT_reg(3 downto 0), I_reg(1 downto 0))), I_reg(3 downto 2));
10859
 
10860
    end if;
10861
  end process;
10862
end LUT4_V;
10863
 
10864
library IEEE;
10865
use IEEE.STD_LOGIC_1164.all;
10866
 
10867
library unisim;
10868
use unisim.VPKG.all;
10869
use unisim.VCOMPONENTS.all;
10870
 
10871
entity LUT3 is
10872
  generic(
10873
    INIT : bit_vector := X"00"
10874
    );
10875
 
10876
  port(
10877
    O : out std_ulogic;
10878
 
10879
    I0 : in std_ulogic;
10880
    I1 : in std_ulogic;
10881
    I2 : in std_ulogic
10882
    );
10883
end LUT3;
10884
 
10885
architecture LUT3_V of LUT3 is
10886
 
10887
function lut4_mux4 (d : std_logic_vector(3 downto 0); s : std_logic_vector(1 downto 0))
10888
                    return std_logic is
10889
       variable lut4_mux4_o : std_logic;
10890
  begin
10891
 
10892
       if (((s(1) xor s(0)) = '1')  or  ((s(1) xor s(0)) = '0')) then
10893
           lut4_mux4_o := d(SLV_TO_INT(s));
10894
       elsif ((d(0) xor d(1)) = '0' and (d(2) xor d(3)) = '0'
10895
                    and (d(0) xor d(2)) = '0') then
10896
           lut4_mux4_o := d(0);
10897
       elsif ((s(1) = '0') and (d(0) = d(1))) then
10898
           lut4_mux4_o := d(0);
10899
       elsif ((s(1) = '1') and (d(2) = d(3))) then
10900
           lut4_mux4_o := d(2);
10901
       elsif ((s(0) = '0') and (d(0) = d(2))) then
10902
           lut4_mux4_o := d(0);
10903
       elsif ((s(0) = '1') and (d(1) = d(3))) then
10904
           lut4_mux4_o := d(1);
10905
       else
10906
           lut4_mux4_o := 'X';
10907
      end if;
10908
 
10909
      return (lut4_mux4_o);
10910
 
10911
  end function lut4_mux4;
10912
    constant INIT_reg : std_logic_vector(7 downto 0) := To_StdLogicVector(INIT);
10913
begin
10914
  VITALBehavior   : process (I0, I1, I2)
10915
    variable I_reg    : std_logic_vector(2 downto 0);
10916
  begin
10917
 
10918
    I_reg := TO_STDLOGICVECTOR( I2 & I1 & I0);
10919
 
10920
    if ((I2 xor I1 xor I0) = '1' or (I2 xor I1 xor I0) = '0') then
10921
       O <= INIT_reg(SLV_TO_INT(I_reg));
10922
    else
10923
       O <= lut4_mux4(('0' & '0' & lut4_mux4(INIT_reg(7 downto 4), I_reg(1 downto 0)) &
10924
            lut4_mux4(INIT_reg(3 downto 0), I_reg(1 downto 0))), ('0' & I_reg(2)));
10925
    end if;
10926
  end process;
10927
end LUT3_V;
10928
library IEEE;
10929
use IEEE.STD_LOGIC_1164.all;
10930
 
10931
library unisim;
10932
use unisim.VPKG.all;
10933
use unisim.VCOMPONENTS.all;
10934
 
10935
entity LUT2 is
10936
  generic(
10937
    INIT : bit_vector := X"0"
10938
    );
10939
 
10940
  port(
10941
    O : out std_ulogic;
10942
 
10943
    I0 : in std_ulogic;
10944
    I1 : in std_ulogic
10945
    );
10946
end LUT2;
10947
 
10948
architecture LUT2_V of LUT2 is
10949
begin
10950
  VITALBehavior   : process (I0, I1)
10951
    variable INIT_reg : std_logic_vector((INIT'length - 1) downto 0) := To_StdLogicVector(INIT);
10952
    variable address : std_logic_vector(1 downto 0);
10953
    variable address_int : integer := 0;
10954
  begin
10955
     address := I1 & I0;
10956
     address_int := SLV_TO_INT(address(1 downto 0));
10957
 
10958
     if ((I1 xor I0) = '1' or (I1 xor I0) = '0') then
10959
       O <= INIT_reg(address_int);
10960
    else
10961
      if ((INIT_reg(0) = INIT_reg(1)) and (INIT_reg(2) = INIT_reg(3)) and
10962
                              (INIT_reg(0) = INIT_reg(2)))  then
10963
        O <= INIT_reg(0);
10964
      elsif ((I1 = '0') and (INIT_reg(0) = INIT_reg(1)))  then
10965
        O <= INIT_reg(0);
10966
        O <= INIT_reg(0);
10967
      elsif ((I1 = '1') and (INIT_reg(2) = INIT_reg(3)))  then
10968
        O <= INIT_reg(2);
10969
      elsif ((I0 = '0') and (INIT_reg(0) = INIT_reg(2)))  then
10970
        O <= INIT_reg(0);
10971
      elsif ((I0 = '1') and (INIT_reg(1)  = INIT_reg(3)))  then
10972
        O <= INIT_reg(1);
10973
      else
10974
        O <= 'X';
10975
      end if;
10976
    end if;
10977
  end process;
10978
end LUT2_V;
10979
 
10980
library IEEE;
10981
use IEEE.STD_LOGIC_1164.all;
10982
 
10983
entity FDC is
10984
  generic(
10985
    INIT : bit := '0'
10986
    );
10987
 
10988
  port(
10989
    Q : out std_ulogic;
10990
 
10991
    C   : in std_ulogic;
10992
    CLR : in std_ulogic;
10993
    D   : in std_ulogic
10994
    );
10995
end FDC;
10996
 
10997
architecture FDC_V of FDC is
10998
begin
10999
  VITALBehavior         : process(CLR, C)
11000
    variable FIRST_TIME : boolean := true;
11001
  begin
11002
 
11003
    if (FIRST_TIME = true) then
11004
      Q <= TO_X01(INIT);
11005
      FIRST_TIME := false;
11006
    end if;
11007
 
11008
    if (CLR = '1') then
11009
      Q <= '0';
11010
    elsif (rising_edge(C)) then
11011
      Q <= D after 100 ps;
11012
    end if;
11013
end process;
11014
end FDC_V;
11015
 
11016
 
11017
library IEEE;
11018
use IEEE.STD_LOGIC_1164.all;
11019
 
11020
library unisim;
11021
use unisim.VPKG.all;
11022
use unisim.VCOMPONENTS.all;
11023
 
11024
entity LUT3_L is
11025
  generic(
11026
    INIT : bit_vector := X"00"
11027
    );
11028
 
11029
  port(
11030
    LO : out std_ulogic;
11031
 
11032
    I0 : in std_ulogic;
11033
    I1 : in std_ulogic;
11034
    I2 : in std_ulogic
11035
    );
11036
end LUT3_L;
11037
 
11038
architecture LUT3_L_V of LUT3_L is
11039
 
11040
function lut4_mux4 (d : std_logic_vector(3 downto 0); s : std_logic_vector(1 downto 0))
11041
                    return std_logic is
11042
       variable lut4_mux4_o : std_logic;
11043
  begin
11044
 
11045
       if (((s(1) xor s(0)) = '1')  or  ((s(1) xor s(0)) = '0')) then
11046
           lut4_mux4_o := d(SLV_TO_INT(s));
11047
       elsif ((d(0) xor d(1)) = '0' and (d(2) xor d(3)) = '0'
11048
                    and (d(0) xor d(2)) = '0') then
11049
           lut4_mux4_o := d(0);
11050
       elsif ((s(1) = '0') and (d(0) = d(1))) then
11051
           lut4_mux4_o := d(0);
11052
       elsif ((s(1) = '1') and (d(2) = d(3))) then
11053
           lut4_mux4_o := d(2);
11054
       elsif ((s(0) = '0') and (d(0) = d(2))) then
11055
           lut4_mux4_o := d(0);
11056
       elsif ((s(0) = '1') and (d(1) = d(3))) then
11057
           lut4_mux4_o := d(1);
11058
       else
11059
           lut4_mux4_o := 'X';
11060
      end if;
11061
 
11062
      return (lut4_mux4_o);
11063
 
11064
  end function lut4_mux4;
11065
 
11066
    constant INIT_reg : std_logic_vector(7 downto 0) := To_StdLogicVector(INIT);
11067
begin
11068
  VITALBehavior    : process (I0, I1, I2)
11069
    variable I_reg    : std_logic_vector(2 downto 0);
11070
  begin
11071
 
11072
    I_reg := TO_STDLOGICVECTOR( I2 & I1 & I0);
11073
 
11074
    if ((I2 xor I1 xor I0) = '1' or (I2 xor I1 xor I0) = '0') then
11075
       LO <= INIT_reg(SLV_TO_INT(I_reg));
11076
    else
11077
       LO <= lut4_mux4(('0' & '0' & lut4_mux4(INIT_reg(7 downto 4), I_reg(1 downto 0)) &
11078
            lut4_mux4(INIT_reg(3 downto 0), I_reg(1 downto 0))), ('0' & I_reg(2)));
11079
    end if;
11080
 
11081
  end process;
11082
end LUT3_L_V;
11083
 
11084
 
11085
library IEEE;
11086
use IEEE.STD_LOGIC_1164.all;
11087
 
11088
entity LUT1 is
11089
  generic(
11090
    INIT : bit_vector := X"0"
11091
    );
11092
 
11093
  port(
11094
    O : out std_ulogic;
11095
 
11096
    I0 : in std_ulogic
11097
    );
11098
end LUT1;
11099
 
11100
architecture LUT1_V of LUT1 is
11101
 
11102
begin
11103
  VITALBehavior   : process (I0)
11104
    variable INIT_reg : std_logic_vector((INIT'length - 1) downto 0) := To_StdLogicVector(INIT);
11105
  begin
11106
    if (INIT_reg(0) = INIT_reg(1)) then
11107
      O <= INIT_reg(0);
11108
    elsif (I0 = '0') then
11109
      O <= INIT_reg(0);
11110
    elsif (I0 = '1') then
11111
      O <= INIT_reg(1);
11112
    else
11113
      O <= 'X';
11114
    end if;
11115
  end process;
11116
end LUT1_V;
11117
 
11118
library IEEE;
11119
use IEEE.STD_LOGIC_1164.all;
11120
 
11121
library unisim;
11122
use unisim.VPKG.all;
11123
use unisim.VCOMPONENTS.all;
11124
 
11125
entity LUT4_L is
11126
   generic(
11127
      INIT : bit_vector := X"0000"
11128
      );
11129
 
11130
   port(
11131
      LO : out std_ulogic;
11132
 
11133
      I0 : in std_ulogic;
11134
      I1 : in std_ulogic;
11135
      I2 : in std_ulogic;
11136
      I3 : in std_ulogic
11137
      );
11138
end LUT4_L;
11139
 
11140
architecture LUT4_L_V of LUT4_L is
11141
 
11142
function lut4_mux4 (d :  std_logic_vector(3 downto 0); s : std_logic_vector(1 downto 0) )
11143
                    return std_logic is
11144
 
11145
       variable lut4_mux4_o : std_logic;
11146
  begin
11147
 
11148
       if (((s(1) xor s(0)) = '1')  or  ((s(1) xor s(0)) = '0')) then
11149
           lut4_mux4_o := d(SLV_TO_INT(s));
11150
       elsif ((d(0) = d(1)) and (d(2) = d(3)) and (d(0) = d(2))) then
11151
           lut4_mux4_o := d(0);
11152
       elsif ((s(1) = '0') and (d(0) = d(1))) then
11153
           lut4_mux4_o := d(0);
11154
       elsif ((s(1) = '1') and (d(2) = d(3))) then
11155
           lut4_mux4_o := d(2);
11156
       elsif ((s(0) = '0') and (d(0) = d(2))) then
11157
           lut4_mux4_o := d(0);
11158
       elsif ((s(0) = '1') and (d(1) = d(3))) then
11159
           lut4_mux4_o := d(1);
11160
       else
11161
           lut4_mux4_o := 'X';
11162
      end if;
11163
 
11164
      return (lut4_mux4_o);
11165
 
11166
  end function lut4_mux4;
11167
 
11168
    constant INIT_reg : std_logic_vector(15 downto 0) := To_StdLogicVector(INIT);
11169
begin
11170
 
11171
  lut_p   : process (I0, I1, I2, I3)
11172
    variable I_reg    : std_logic_vector(3 downto 0);
11173
  begin
11174
 
11175
    I_reg := TO_STDLOGICVECTOR(I3 &  I2 & I1 & I0);
11176
 
11177
    if ((I3 xor I2 xor I1 xor I0) = '1' or (I3 xor I2 xor I1 xor I0) = '0') then
11178
       LO <= INIT_reg(SLV_TO_INT(I_reg));
11179
    else
11180
       LO <= lut4_mux4 (
11181
            (lut4_mux4 ( INIT_reg(15 downto 12), I_reg(1 downto 0)) &
11182
            lut4_mux4 ( INIT_reg(11 downto 8), I_reg(1 downto 0)) &
11183
            lut4_mux4 ( INIT_reg(7 downto 4), I_reg(1 downto 0)) &
11184
            lut4_mux4 ( INIT_reg(3 downto 0), I_reg(1 downto 0))), I_reg(3 downto 2));
11185
    end if;
11186
end process;
11187
end LUT4_L_V;
11188
 
11189
 
11190
library IEEE;
11191
use IEEE.STD_LOGIC_1164.all;
11192
 
11193
entity FDCE is
11194
  generic(
11195
    INIT : bit := '0'
11196
    );
11197
 
11198
  port(
11199
    Q : out std_ulogic;
11200
 
11201
    C   : in std_ulogic;
11202
    CE  : in std_ulogic;
11203
    CLR : in std_ulogic;
11204
    D   : in std_ulogic
11205
    );
11206
end FDCE;
11207
 
11208
architecture FDCE_V of FDCE is
11209
begin
11210
  VITALBehavior         : process(C, CLR)
11211
    variable FIRST_TIME : boolean := true ;
11212
  begin
11213
 
11214
    if (FIRST_TIME = true) then
11215
      Q <= TO_X01(INIT);
11216
      FIRST_TIME := false;
11217
    end if;
11218
 
11219
    if (CLR = '1') then
11220
      Q   <= '0';
11221
    elsif (rising_edge(C)) then
11222
      if (CE = '1') then
11223
        Q <= D after 100 ps;
11224
      end if;
11225
    end if;
11226
  end process;
11227
end FDCE_V;
11228
 
11229
 
11230
library IEEE;
11231
use IEEE.STD_LOGIC_1164.all;
11232
 
11233
entity FDC_1 is
11234
  generic(
11235
    INIT : bit := '0'
11236
    );
11237
 
11238
  port(
11239
    Q : out std_ulogic;
11240
 
11241
    C   : in std_ulogic;
11242
    CLR : in std_ulogic;
11243
    D   : in std_ulogic
11244
    );
11245
end FDC_1;
11246
 
11247
architecture FDC_1_V of FDC_1 is
11248
begin
11249
  VITALBehavior         : process(C, CLR)
11250
    variable FIRST_TIME : boolean := true ;
11251
  begin
11252
 
11253
    if (FIRST_TIME = true) then
11254
      Q <= TO_X01(INIT);
11255
      FIRST_TIME := false;
11256
    end if;
11257
 
11258
    if (CLR = '1') then
11259
      Q <= '0';
11260
    elsif (falling_edge(C)) then
11261
      Q <= D after 100 ps;
11262
    end if;
11263
  end process;
11264
end FDC_1_V;
11265
 
11266
 
11267
library IEEE;
11268
use IEEE.STD_LOGIC_1164.all;
11269
 
11270
entity FDS is
11271
  generic(
11272
    INIT : bit := '1'
11273
    );
11274
 
11275
  port(
11276
    Q : out std_ulogic;
11277
 
11278
    C : in std_ulogic;
11279
    D : in std_ulogic;
11280
    S : in std_ulogic
11281
    );
11282
end FDS;
11283
 
11284
architecture FDS_V of FDS is
11285
begin
11286
  VITALBehavior         : process(C)
11287
    variable FIRST_TIME : boolean := true ;
11288
  begin
11289
 
11290
    if (FIRST_TIME = true) then
11291
      Q <= TO_X01(INIT);
11292
      FIRST_TIME := false;
11293
    end if;
11294
 
11295
    if (rising_edge(C)) then
11296
      if (S = '1') then
11297
        Q <= '1' after 100 ps;
11298
      else
11299
        Q <= D after 100 ps;
11300
      end if;
11301
    end if;
11302
  end process;
11303
end FDS_V;
11304
 
11305
 
11306
library IEEE;
11307
use IEEE.STD_LOGIC_1164.all;
11308
 
11309
entity MUXCY is
11310
  port(
11311
    O : out std_ulogic;
11312
 
11313
    CI : in std_ulogic;
11314
    DI : in std_ulogic;
11315
    S  : in std_ulogic
11316
    );
11317
end MUXCY;
11318
 
11319
architecture MUXCY_V of MUXCY is
11320
begin
11321
  VITALBehavior   : process (CI, DI, S)
11322
  begin
11323
    if (S = '0') then
11324
      O <= DI;
11325
    elsif (S = '1') then
11326
      O <= CI;
11327
    end if;
11328
  end process;
11329
end MUXCY_V;
11330
 
11331
library IEEE;
11332
use IEEE.STD_LOGIC_1164.all;
11333
 
11334
entity LUT1_L is
11335
  generic(
11336
    INIT : bit_vector := X"0"
11337
    );
11338
 
11339
  port(
11340
    LO : out std_ulogic;
11341
 
11342
    I0 : in std_ulogic
11343
    );
11344
end LUT1_L;
11345
 
11346
architecture LUT1_L_V of LUT1_L is
11347
begin
11348
  VITALBehavior    : process (I0)
11349
    variable INIT_reg : std_logic_vector((INIT'length - 1) downto 0) := To_StdLogicVector(INIT);
11350
  begin
11351
    if (I0 = '0') then
11352
      LO <= INIT_reg(0);
11353
    elsif (I0 = '1') then
11354
      LO <= INIT_reg(1);
11355
    elsif (INIT_reg(0) = INIT_reg(1)) then
11356
      LO <= INIT_reg(0);
11357
    else
11358
      LO <= 'X';
11359
    end if;
11360
  end process;
11361
end LUT1_L_V;
11362
 
11363
 
11364
library IEEE;
11365
use IEEE.STD_LOGIC_1164.all;
11366
 
11367
entity MUXF6 is
11368
 
11369
  port(
11370
    O  : out std_ulogic;
11371
 
11372
    I0 : in  std_ulogic;
11373
    I1 : in  std_ulogic;
11374
    S  : in  std_ulogic
11375
    );
11376
end MUXF6;
11377
 
11378
architecture MUXF6_V of MUXF6 is
11379
begin
11380
  VITALBehavior   : process (I0, I1, S)
11381
  begin
11382
    if (S = '0') then
11383
      O <= I0;
11384
    elsif (S = '1') then
11385
      O <= I1;
11386
    end if;
11387
  end process;
11388
end MUXF6_V;
11389
 
11390
library IEEE;
11391
use IEEE.STD_LOGIC_1164.all;
11392
 
11393
entity MUXF5_D is
11394
  port(
11395
    LO : out std_ulogic;
11396
    O  : out std_ulogic;
11397
 
11398
    I0 : in std_ulogic;
11399
    I1 : in std_ulogic;
11400
    S  : in std_ulogic
11401
    );
11402
end MUXF5_D;
11403
 
11404
architecture MUXF5_D_V of MUXF5_D is
11405
begin
11406
  VITALBehavior    : process (I0, I1, S)
11407
  begin
11408
    if (S = '0') then
11409
      O <= I0;
11410
      LO <= I0;
11411
    elsif (S = '1') then
11412
      O <= I1;
11413
      LO <= I1;
11414
    end if;
11415
  end process;
11416
end MUXF5_D_V;
11417
 
11418
library IEEE;
11419
use IEEE.STD_LOGIC_1164.all;
11420
 
11421
entity XORCY is
11422
  port(
11423
    O : out std_ulogic;
11424
 
11425
    CI : in std_ulogic;
11426
    LI : in std_ulogic
11427
    );
11428
end XORCY;
11429
 
11430
architecture XORCY_V of XORCY is
11431
begin
11432
    O <= (CI xor LI);
11433
end XORCY_V;
11434
 
11435
 
11436
library IEEE;
11437
use IEEE.STD_LOGIC_1164.all;
11438
 
11439
entity MUXCY_L is
11440
  port(
11441
    LO : out std_ulogic;
11442
 
11443
    CI : in std_ulogic;
11444
    DI : in std_ulogic;
11445
    S  : in std_ulogic
11446
    );
11447
end MUXCY_L;
11448
 
11449
architecture MUXCY_L_V of MUXCY_L is
11450
begin
11451
  VITALBehavior    : process (CI, DI, S)
11452
  begin
11453
    if (S = '0') then
11454
      LO <= DI;
11455
    elsif (S = '1') then
11456
      LO <= CI;
11457
    end if;
11458
  end process;
11459
end MUXCY_L_V;
11460
 
11461
 
11462
library IEEE;
11463
use IEEE.STD_LOGIC_1164.all;
11464
 
11465
entity FDSE is
11466
  generic(
11467
    INIT : bit := '1'
11468
    );
11469
 
11470
  port(
11471
    Q : out std_ulogic;
11472
 
11473
    C  : in std_ulogic;
11474
    CE : in std_ulogic;
11475
    D  : in std_ulogic;
11476
    S  : in std_ulogic
11477
    );
11478
end FDSE;
11479
 
11480
architecture FDSE_V of FDSE is
11481
begin
11482
  VITALBehavior         : process(C)
11483
    variable FIRST_TIME : boolean := true ;
11484
  begin
11485
 
11486
    if (FIRST_TIME = true) then
11487
      Q <= TO_X01(INIT);
11488
      FIRST_TIME := false;
11489
    end if;
11490
 
11491
    if (rising_edge(C)) then
11492
      if (S = '1') then
11493
        Q <= '1' after 100 ps;
11494
      elsif (CE = '1') then
11495
        Q <= D after 100 ps;
11496
      end if;
11497
    end if;
11498
  end process;
11499
end FDSE_V;
11500
 
11501
library IEEE;
11502
use IEEE.STD_LOGIC_1164.all;
11503
 
11504
entity MULT_AND is
11505
  port(
11506
    LO : out std_ulogic;
11507
 
11508
    I0 : in std_ulogic;
11509
    I1 : in std_ulogic
11510
    );
11511
 
11512
end MULT_AND;
11513
 
11514
architecture MULT_AND_V of MULT_AND is
11515
begin
11516
  VITALBehavior : process (I1, I0)
11517
  begin
11518
    LO <= (I0 and I1) after 0 ps;
11519
  end process;
11520
end MULT_AND_V;
11521
 
11522
 
11523
library IEEE;
11524
use IEEE.STD_LOGIC_1164.all;
11525
 
11526
entity FDP is
11527
  generic(
11528
    INIT : bit := '1'
11529
    );
11530
 
11531
  port(
11532
    Q : out std_ulogic;
11533
 
11534
    C   : in std_ulogic;
11535
    D   : in std_ulogic;
11536
    PRE : in std_ulogic
11537
    );
11538
end FDP;
11539
 
11540
architecture FDP_V of FDP is
11541
begin
11542
  VITALBehavior         : process(C, PRE)
11543
    variable FIRST_TIME : boolean := true ;
11544
  begin
11545
 
11546
    if (FIRST_TIME = true) then
11547
      Q <= TO_X01(INIT);
11548
      FIRST_TIME := false;
11549
    end if;
11550
 
11551
    if (PRE = '1') then
11552
      Q <= '1';
11553
    elsif (C' event and C = '1') then
11554
      Q <= D after 100 ps;
11555
    end if;
11556
  end process;
11557
end FDP_V;
11558
 
11559
library IEEE;
11560
use IEEE.STD_LOGIC_1164.all;
11561
 
11562
library UNISIM;
11563
use UNISIM.VPKG.all;
11564
 
11565
entity SRL16E is
11566
 
11567
  generic (
11568
       INIT : bit_vector := X"0000"
11569
  );
11570
 
11571
  port (
11572
        Q   : out STD_ULOGIC;
11573
 
11574
        A0  : in STD_ULOGIC;
11575
        A1  : in STD_ULOGIC;
11576
        A2  : in STD_ULOGIC;
11577
        A3  : in STD_ULOGIC;
11578
        CE  : in STD_ULOGIC;
11579
        CLK : in STD_ULOGIC;
11580
        D   : in STD_ULOGIC
11581
       );
11582
end SRL16E;
11583
 
11584
architecture SRL16E_V of SRL16E is
11585
    signal SHIFT_REG : std_logic_vector (16 downto 0) := ('X' & To_StdLogicVector(INIT));
11586
begin
11587
  VITALReadBehavior : process(A0, A1, A2, A3, SHIFT_REG)
11588
 
11589
    variable VALID_ADDR : boolean := FALSE;
11590
    variable LENGTH : integer;
11591
    variable ADDR : std_logic_vector(3 downto 0);
11592
 
11593
  begin
11594
 
11595
    ADDR := (A3, A2, A1, A0);
11596
    VALID_ADDR := ADDR_IS_VALID(SLV => ADDR);
11597
 
11598
    if (VALID_ADDR) then
11599
        LENGTH := SLV_TO_INT(SLV => ADDR);
11600
    else
11601
        LENGTH := 16;
11602
    end if;
11603
    Q <= SHIFT_REG(LENGTH);
11604
 
11605
  end process VITALReadBehavior;
11606
 
11607
  VITALWriteBehavior : process
11608
    variable FIRST_TIME : boolean := TRUE;
11609
  begin
11610
 
11611
    if (FIRST_TIME) then
11612
        wait until ((CE = '1' or CE = '0') and
11613
                   (CLK'last_value = '0' or CLK'last_value = '1') and
11614
                   (CLK = '0' or CLK = '1'));
11615
        FIRST_TIME := FALSE;
11616
    end if;
11617
 
11618
    if (CLK'event AND CLK'last_value = '0') then
11619
      if (CLK = '1') then
11620
        if (CE = '1') then
11621
          for I in 15 downto 1 loop
11622
            SHIFT_REG(I) <= SHIFT_REG(I-1) after 100 ps;
11623
          end loop;
11624
          SHIFT_REG(0) <= D after 100 ps;
11625
        elsif (CE = 'X') then
11626
          SHIFT_REG <= (others => 'X') after 100 ps;
11627
        end if;
11628
      elsif (CLK = 'X') then
11629
        if (CE /= '0') then
11630
          SHIFT_REG <= (others => 'X') after 100 ps;
11631
        end if;
11632
      end if;
11633
    elsif (CLK'event AND CLK'last_value = 'X') then
11634
      if (CLK = '1') then
11635
        if (CE /= '0') then
11636
          SHIFT_REG <= (others => 'X') after 100 ps;
11637
        end if;
11638
      end if;
11639
    end if;
11640
    wait on CLK;
11641
  end process VITALWriteBehavior;
11642
end SRL16E_V;
11643
 
11644
library IEEE;
11645
use IEEE.STD_LOGIC_1164.all;
11646
 
11647
library UNISIM;
11648
use UNISIM.VPKG.all;
11649
 
11650
entity ROM256X1 is
11651
  generic (
11652
    INIT : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000"
11653
    );
11654
 
11655
  port (
11656
    O : out std_ulogic;
11657
 
11658
    A0 : in std_ulogic;
11659
    A1 : in std_ulogic;
11660
    A2 : in std_ulogic;
11661
    A3 : in std_ulogic;
11662
    A4 : in std_ulogic;
11663
    A5 : in std_ulogic;
11664
    A6 : in std_ulogic;
11665
    A7 : in std_ulogic
11666
    );
11667
end ROM256X1;
11668
 
11669
architecture ROM256X1_V of ROM256X1 is
11670
begin
11671
  VITALBehavior         : process (A7, A6, A5, A4, A3, A2, A1, A0)
11672
    variable INIT_BITS  : std_logic_vector(255 downto 0) := "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
11673
    variable MEM        : std_logic_vector( 256 downto 0 );
11674
    variable Index      : integer                        := 256;
11675
    variable Raddress   : std_logic_vector (7 downto 0);
11676
    variable FIRST_TIME : boolean                        := true;
11677
 
11678
  begin
11679
    if (FIRST_TIME = true) then
11680
      INIT_BITS(INIT'length-1 downto 0) := To_StdLogicVector(INIT );
11681
      MEM        := ('X' & INIT_BITS(255 downto 0));
11682
      FIRST_TIME := false;
11683
    end if;
11684
    Raddress     := (A7, A6, A5, A4, A3, A2, A1, A0);
11685
    Index        := SLV_TO_INT(SLV => Raddress );
11686
    O <= MEM(Index);
11687
  end process VITALBehavior;
11688
end ROM256X1_V;
11689
 
11690
library IEEE;
11691
use IEEE.STD_LOGIC_1164.all;
11692
 
11693
entity FDPE is
11694
  generic(
11695
    INIT : bit := '1'
11696
    );
11697
 
11698
  port(
11699
    Q : out std_ulogic;
11700
 
11701
    C   : in std_ulogic;
11702
    CE  : in std_ulogic;
11703
    D   : in std_ulogic;
11704
    PRE : in std_ulogic
11705
    );
11706
end FDPE;
11707
 
11708
architecture FDPE_V of FDPE is
11709
begin
11710
  VITALBehavior         : process(C, PRE)
11711
    variable FIRST_TIME : boolean := true ;
11712
  begin
11713
 
11714
    if (FIRST_TIME = true) then
11715
      Q <= TO_X01(INIT);
11716
      FIRST_TIME := false;
11717
    end if;
11718
 
11719
    if (PRE = '1') then
11720
      Q   <= '1';
11721
    elsif (rising_edge(C)) then
11722
      if (CE = '1') then
11723
        Q <= D after 100 ps;
11724
      end if;
11725
    end if;
11726
  end process;
11727
end FDPE_V;
11728
 
11729
library IEEE;
11730
use IEEE.std_logic_1164.all;
11731
 
11732
library unisim;
11733
use unisim.Vpkg.all;
11734
 
11735
entity MULT18X18 is
11736
    port (
11737
          P     : out std_logic_vector (35 downto 0);
11738
 
11739
          A     : in std_logic_vector (17 downto 0);
11740
          B     : in std_logic_vector (17 downto 0)
11741
          );
11742
 
11743
end MULT18X18;
11744
 
11745
architecture MULT18X18_V of MULT18X18 is
11746
 
11747
function INT_TO_SLV(ARG: integer; SIZE: integer) return std_logic_vector is
11748
 
11749
        variable result : std_logic_vector (SIZE-1 downto 0);
11750
        variable temp : integer := ARG;
11751
begin
11752
        temp := ARG;
11753
        for i in 0 to SIZE-1 loop
11754
                if (temp mod 2) = 1 then
11755
                        result(i) := '1';
11756
                else
11757
                        result(i) := '0';
11758
                end if;
11759
                if temp > 0 then
11760
                        temp := temp /2 ;
11761
                elsif (temp > integer'low) then
11762
                        temp := (temp-1) / 2;
11763
                else
11764
                        temp := temp / 2;
11765
                end if;
11766
        end loop;
11767
        return result;
11768
end;
11769
 
11770
function COMPLEMENT(ARG: std_logic_vector ) return std_logic_vector is
11771
 
11772
        variable        RESULT : std_logic_vector (ARG'left downto 0);
11773
        variable        found1 : std_ulogic := '0';
11774
begin
11775
                for i in  0 to ARG'left  loop
11776
                        if (found1 = '0') then
11777
                                RESULT(i) := ARG(i);
11778
                                if (ARG(i) = '1' ) then
11779
                                        found1 := '1';
11780
                                end if;
11781
                        else
11782
                                RESULT(i) := not ARG(i);
11783
                        end if;
11784
                end loop;
11785
                return result;
11786
end;
11787
 
11788
function VECPLUS(A, B: std_logic_vector ) return std_logic_vector is
11789
 
11790
        variable carry: std_ulogic;
11791
        variable BV, sum: std_logic_vector(A'left downto 0);
11792
 
11793
begin
11794
 
11795
        if (A(A'left) = 'X' or B(B'left) = 'X') then
11796
            sum := (others => 'X');
11797
            return(sum);
11798
        end if;
11799
        carry := '0';
11800
        BV := B;
11801
 
11802
        for i in 0 to A'left loop
11803
            sum(i) := A(i) xor BV(i) xor carry;
11804
            carry := (A(i) and BV(i)) or
11805
                    (A(i) and carry) or
11806
                    (carry and BV(i));
11807
        end loop;
11808
        return sum;
11809
end;
11810
 
11811
begin
11812
 
11813
  VITALBehaviour : process (A, B)
11814
    variable O_zd,O1_zd, O2_zd : std_logic_vector( A'length+B'length-1 downto 0);
11815
    variable IA, IB1,IB2  : integer ;
11816
    variable sign : std_ulogic := '0';
11817
    variable A_i : std_logic_vector(A'left downto 0);
11818
    variable B_i : std_logic_vector(B'left downto 0);
11819
 
11820
  begin
11821
 
11822
    if (Is_X(A) or Is_X(B) ) then
11823
            O_zd := (others => 'X');
11824
    else
11825
       if (A(A'left) = '1' ) then
11826
         A_i :=  complement(A);
11827
       else
11828
         A_i := A;
11829
       end if;
11830
 
11831
       if (B(B'left)  = '1') then
11832
         B_i := complement(B);
11833
       else
11834
         B_i := B;
11835
       end if;
11836
 
11837
        IA := SLV_TO_INT(A_i);
11838
        IB1 := SLV_TO_INT(B_i (17 downto 9));
11839
        IB2 := SLV_TO_INT(B_i (8 downto 0));
11840
 
11841
 
11842
       O1_zd := INT_TO_SLV((IA * IB1), A'length+B'length);
11843
        -- shift I1_zd 9 to the left
11844
           for j in 0 to 8 loop
11845
            O1_zd(A'length+B'length-1 downto 0) := O1_zd(A'length+B'length-2 downto 0) & '0';
11846
           end loop;
11847
       O2_zd := INT_TO_SLV((IA * IB2), A'length+B'length);
11848
       O_zd  := VECPLUS(O1_zd, O2_zd);
11849
 
11850
       sign := A(A'left) xor B(B'left);
11851
       if (sign = '1' ) then
11852
              O_zd := complement(O_zd);
11853
       end if;
11854
    end if;
11855
    P <= O_zd;
11856
  end process VITALBehaviour;
11857
 
11858
end MULT18X18_V ;
11859
 
11860
library IEEE;
11861
use IEEE.std_logic_1164.all;
11862
 
11863
library unisim;
11864
use unisim.Vpkg.all;
11865
 
11866
entity MULT18X18S is
11867
 
11868
  port (
11869
    P  : out std_logic_vector (35 downto 0);
11870
 
11871
    A  : in std_logic_vector (17 downto 0);
11872
    B  : in std_logic_vector (17 downto 0);
11873
    C  : in std_ulogic;
11874
    CE : in std_ulogic;
11875
    R  : in std_ulogic
11876
    );
11877
end MULT18X18S;
11878
 
11879
architecture MULT18X18S_V of MULT18X18S is
11880
 
11881
  function INT_TO_SLV(ARG : integer; SIZE : integer) return std_logic_vector is
11882
 
11883
    variable result : std_logic_vector (SIZE-1 downto 0);
11884
    variable temp   : integer := ARG;
11885
  begin
11886
    temp                      := ARG;
11887
    for i in 0 to SIZE-1 loop
11888
      if (temp mod 2) = 1 then
11889
        result(i)             := '1';
11890
      else
11891
        result(i)             := '0';
11892
      end if;
11893
      if temp > 0 then
11894
        temp                  := temp /2;
11895
      elsif (temp > integer'low) then
11896
        temp                  := (temp-1) / 2;
11897
      else
11898
        temp                  := temp / 2;
11899
      end if;
11900
    end loop;
11901
    return result;
11902
  end;
11903
 
11904
  function COMPLEMENT(ARG : std_logic_vector ) return std_logic_vector is
11905
 
11906
    variable RESULT : std_logic_vector (ARG'left downto 0);
11907
    variable found1 : std_ulogic := '0';
11908
  begin
11909
    for i in 0 to ARG'left loop
11910
      if (found1 = '0') then
11911
        RESULT(i)                := ARG(i);
11912
        if (ARG(i) = '1' ) then
11913
          found1                 := '1';
11914
        end if;
11915
      else
11916
        RESULT(i)                := not ARG(i);
11917
      end if;
11918
    end loop;
11919
    return result;
11920
  end;
11921
 
11922
  function VECPLUS(A, B : std_logic_vector ) return std_logic_vector is
11923
 
11924
    variable carry   : std_ulogic;
11925
    variable BV, sum : std_logic_vector(A'left downto 0);
11926
 
11927
  begin
11928
 
11929
    if (A(A'left) = 'X' or B(B'left) = 'X') then
11930
      sum := (others => 'X');
11931
      return(sum);
11932
    end if;
11933
    carry := '0';
11934
    BV    := B;
11935
 
11936
    for i in 0 to A'left loop
11937
      sum(i) := A(i) xor BV(i) xor carry;
11938
      carry  := (A(i) and BV(i)) or
11939
                (A(i) and carry) or
11940
                (carry and BV(i));
11941
    end loop;
11942
    return sum;
11943
  end;
11944
 
11945
begin
11946
 
11947
  VITALBehaviour                : process (C)
11948
    variable O_zd, O1_zd, O2_zd : std_logic_vector( A'length+B'length-1 downto 0);
11949
    variable B1_zd, B2_zd       : bit_vector(A'length+B'length-1 downto 0);
11950
    variable IA, IB1, Ib2       : integer;
11951
    variable sign               : std_ulogic := '0';
11952
    variable A_i                : std_logic_vector(A'left downto 0);
11953
    variable B_i                : std_logic_vector(B'left downto 0);
11954
 
11955
  begin
11956
 
11957
    if (rising_edge(C)) then
11958
      if (R = '1' ) then
11959
        O_zd    := (others => '0');
11960
      elsif (CE = '1' ) then
11961
        if (Is_X(A) or Is_X(B) ) then
11962
          O_zd  := (others => 'X');
11963
        else
11964
          if (A(A'left) = '1' ) then
11965
            A_i := complement(A);
11966
          else
11967
            A_i := A;
11968
          end if;
11969
 
11970
          if (B(B'left) = '1') then
11971
            B_i := complement(B);
11972
          else
11973
            B_i := B;
11974
          end if;
11975
 
11976
          IA  := SLV_TO_INT(A_i);
11977
          IB1 := SLV_TO_INT(B_i (17 downto 9));
11978
          IB2 := SLV_TO_INT(B_i (8 downto 0));
11979
 
11980
 
11981
          O1_zd                                 := INT_TO_SLV((IA * IB1), A'length+B'length);
11982
          for j in 0 to 8 loop
11983
            O1_zd(A'length+B'length-1 downto 0) := O1_zd(A'length+B'length-2 downto 0) & '0';
11984
          end loop;
11985
          O2_zd                                 := INT_TO_SLV((IA * IB2), A'length+B'length);
11986
          O_zd                                  := VECPLUS(O1_zd, O2_zd);
11987
 
11988
          sign   := A(A'left) xor B(B'left);
11989
          if (sign = '1' ) then
11990
            O_zd := complement(O_zd);
11991
          end if;
11992
        end if;
11993
      end if;
11994
    end if;
11995
    P <= O_zd after 100 ps;
11996
  end process VITALBehaviour;
11997
 
11998
end MULT18X18S_V;
11999
 
12000
library IEEE;
12001
use IEEE.std_logic_1164.all;
12002
 
12003
library unisim;
12004
use unisim.Vpkg.all;
12005
 
12006
entity ROM128X1 is
12007
 
12008
  generic (
12009
    INIT : bit_vector := X"00000000000000000000000000000000"
12010
    );
12011
 
12012
  port (
12013
    O : out std_ulogic;
12014
 
12015
    A0 : in std_ulogic;
12016
    A1 : in std_ulogic;
12017
    A2 : in std_ulogic;
12018
    A3 : in std_ulogic;
12019
    A4 : in std_ulogic;
12020
    A5 : in std_ulogic;
12021
    A6 : in std_ulogic
12022
    );
12023
end ROM128X1;
12024
 
12025
architecture ROM128X1_V of ROM128X1 is
12026
begin
12027
  VITALBehavior         : process (A6, A5, A4, A3, A2, A1, A0)
12028
    variable INIT_BITS  : std_logic_vector(127 downto 0) := To_StdLogicVector(INIT);
12029
    variable MEM        : std_logic_vector( 128 downto 0 );
12030
    variable Index      : integer := 128;
12031
    variable Raddress   : std_logic_vector (6 downto 0);
12032
    variable FIRST_TIME : boolean := true;
12033
 
12034
  begin
12035
    if (FIRST_TIME = true) then
12036
      MEM        := ('X' & INIT_BITS(127 downto 0));
12037
      FIRST_TIME := false;
12038
    end if;
12039
    Raddress     := (A6, A5, A4, A3, A2, A1, A0);
12040
    Index        := SLV_TO_INT(SLV => Raddress);
12041
    O <= MEM(Index);
12042
  end process VITALBehavior;
12043
end ROM128X1_V;
12044
 
12045
library IEEE;
12046
use IEEE.std_logic_1164.all;
12047
 
12048
library unisim;
12049
use unisim.Vpkg.all;
12050
 
12051
entity ROM16X1 is
12052
  generic (
12053
       INIT : bit_vector := X"0000"
12054
  );
12055
 
12056
  port (
12057
        O : out std_ulogic;
12058
 
12059
        A0 : in std_ulogic;
12060
        A1 : in std_ulogic;
12061
        A2 : in std_ulogic;
12062
        A3 : in std_ulogic
12063
       );
12064
end ROM16X1;
12065
 
12066
architecture ROM16X1_V of ROM16X1 is
12067
begin
12068
  VITALBehavior : process (A3, A2, A1, A0)
12069
    variable INIT_BITS  : std_logic_vector(15 downto 0) := To_StdLogicVector(INIT);
12070
    variable MEM : std_logic_vector( 16 downto 0 ) ;
12071
    variable Index : integer := 16;
12072
    variable FIRST_TIME : boolean := TRUE;
12073
  begin
12074
     if (FIRST_TIME = TRUE) then
12075
       MEM := ('X' & INIT_BITS(15 downto 0));
12076
      FIRST_TIME := FALSE;
12077
    end if;
12078
    Index := DECODE_ADDR4(ADDRESS => (A3, A2, A1, A0));
12079
    O <= MEM(Index);
12080
  end process VITALBehavior;
12081
end ROM16X1_V;
12082
 
12083
library IEEE;
12084
use IEEE.STD_LOGIC_1164.all;
12085
 
12086
entity MUXF7 is
12087
  port(
12088
    O : out std_ulogic;
12089
 
12090
    I0 : in std_ulogic;
12091
    I1 : in std_ulogic;
12092
    S  : in std_ulogic
12093
    );
12094
end MUXF7;
12095
 
12096
architecture MUXF7_V of MUXF7 is
12097
begin
12098
  VITALBehavior   : process (I0, I1, S)
12099
  begin
12100
    if (S = '0') then
12101
      O <= I0;
12102
    elsif (S = '1') then
12103
      O <= I1;
12104
    end if;
12105
  end process;
12106
end MUXF7_V;
12107
 
12108
----- CELL IODELAY -----
12109
library IEEE;
12110
use IEEE.STD_LOGIC_1164.all;
12111
 
12112
 
12113
library unisim;
12114
use unisim.vpkg.all;
12115
 
12116
entity IODELAY is
12117
 
12118
  generic(
12119
 
12120
      DELAY_SRC         : string        := "I";
12121
      HIGH_PERFORMANCE_MODE             : boolean       := true;
12122
      IDELAY_TYPE       : string        := "DEFAULT";
12123
      IDELAY_VALUE      : integer       := 0;
12124
      ODELAY_VALUE      : integer       := 0;
12125
      REFCLK_FREQUENCY  : real          := 200.0;
12126
      SIGNAL_PATTERN    : string        := "DATA"
12127
      );
12128
 
12129
  port(
12130
      DATAOUT   : out std_ulogic;
12131
 
12132
      C         : in  std_ulogic;
12133
      CE        : in  std_ulogic;
12134
      DATAIN    : in  std_ulogic;
12135
      IDATAIN   : in  std_ulogic;
12136
      INC       : in  std_ulogic;
12137
      ODATAIN   : in  std_ulogic;
12138
      RST       : in  std_ulogic;
12139
      T         : in  std_ulogic
12140
      );
12141
 
12142
end IODELAY;
12143
 
12144
architecture IODELAY_V OF IODELAY is
12145
 
12146
  constant      ILEAK_ADJUST            : real := 1.0;
12147
  constant      D_IOBDELAY_OFFSET       : real := 0.0;
12148
 
12149
-----------------------------------------------------------
12150
 
12151
  constant      MAX_IDELAY_COUNT        : integer := 63;
12152
  constant      MIN_IDELAY_COUNT        : integer := 0;
12153
  constant      MAX_ODELAY_COUNT        : integer := 63;
12154
  constant      MIN_ODELAY_COUNT        : integer := 0;
12155
 
12156
  constant      MAX_REFCLK_FREQUENCY    : real := 225.0;
12157
  constant      MIN_REFCLK_FREQUENCY    : real := 175.0;
12158
 
12159
 
12160
  signal        C_ipd           : std_ulogic := 'X';
12161
  signal        CE_ipd          : std_ulogic := 'X';
12162
  signal GSR            : std_ulogic := '0';
12163
  signal        GSR_ipd         : std_ulogic := 'X';
12164
  signal        DATAIN_ipd      : std_ulogic := 'X';
12165
  signal        IDATAIN_ipd     : std_ulogic := 'X';
12166
  signal        INC_ipd         : std_ulogic := 'X';
12167
  signal        ODATAIN_ipd     : std_ulogic := 'X';
12168
  signal        RST_ipd         : std_ulogic := 'X';
12169
  signal        T_ipd           : std_ulogic := 'X';
12170
 
12171
  signal        C_dly           : std_ulogic := 'X';
12172
  signal        CE_dly          : std_ulogic := 'X';
12173
  signal        GSR_dly         : std_ulogic := '0';
12174
  signal        DATAIN_dly      : std_ulogic := 'X';
12175
  signal        IDATAIN_dly     : std_ulogic := 'X';
12176
  signal        INC_dly         : std_ulogic := 'X';
12177
  signal        ODATAIN_dly     : std_ulogic := 'X';
12178
  signal        RST_dly         : std_ulogic := 'X';
12179
  signal        T_dly           : std_ulogic := 'X';
12180
 
12181
  signal        IDATAOUT_delayed        : std_ulogic := 'X';
12182
--  signal      IDATAOUT_zd             : std_ulogic := 'X';
12183
--  signal      IDATAOUT_viol           : std_ulogic := 'X';
12184
 
12185
  signal        ODATAOUT_delayed        : std_ulogic := 'X';
12186
--  signal      ODATAOUT_zd             : std_ulogic := 'X';
12187
--  signal      ODATAOUT_viol           : std_ulogic := 'X';
12188
 
12189
  signal        DATAOUT_zd              : std_ulogic := 'X';
12190
--  signal      DATAOUT_viol            : std_ulogic := 'X';
12191
 
12192
  signal        iDelay          : time := 0.0 ps;
12193
  signal        oDelay          : time := 0.0 ps;
12194
 
12195
  signal        idata_mux       : std_ulogic := 'X';
12196
  signal        Violation       : std_ulogic := '0';
12197
 
12198
begin
12199
 
12200
  ---------------------
12201
  --  INPUT PATH DELAYs
12202
  --------------------
12203
 
12204
  C_dly                  <= C                   after 0 ps;
12205
  CE_dly                 <= CE                  after 0 ps;
12206
  DATAIN_dly             <= DATAIN              after 0 ps;
12207
  IDATAIN_dly            <= IDATAIN             after 0 ps;
12208
  INC_dly                <= INC                 after 0 ps;
12209
  ODATAIN_dly            <= ODATAIN             after 0 ps;
12210
  RST_dly                <= RST                 after 0 ps;
12211
  T_dly                  <= T                   after 0 ps;
12212
 
12213
  --------------------
12214
  --  BEHAVIOR SECTION
12215
  --------------------
12216
 
12217
--####################################################################
12218
--#####                     Initialize                           #####
12219
--####################################################################
12220
  prcs_init:process
12221
  variable TapCount_var   : integer := 0;
12222
  variable IsTapDelay_var : boolean := true;
12223
  variable idelaytypefixed_var  : boolean := false;
12224
  variable idelaytypedefault_var : boolean := false;
12225
  begin
12226
     -------- SIGNAL_PATTERN check
12227
     if((SIGNAL_PATTERN /= "CLOCK") and (SIGNAL_PATTERN /= "DATA"))then
12228
         assert false
12229
         report "Attribute Syntax Error: Legal values for SIGNAL_PATTERN are DATA or CLOCK"
12230
         severity Failure;
12231
     end if;
12232
 
12233
     -------- HIGH_PERFORMANCE_MODE check
12234
 
12235
     case HIGH_PERFORMANCE_MODE is
12236
       when true | false => null;
12237
       when others =>
12238
          assert false
12239
          report "Attribute Syntax Error: The attribute HIGH_PERFORMANCE_MODE on IODELAY must be set to either true or false."
12240
          severity Failure;
12241
     end case;
12242
 
12243
     -------- IDELAY_TYPE check
12244
 
12245
     if(IDELAY_TYPE = "FIXED") then
12246
        idelaytypefixed_var := true;
12247
     elsif(IDELAY_TYPE = "VARIABLE") then
12248
        idelaytypefixed_var := false;
12249
     elsif(IDELAY_TYPE = "DEFAULT") then
12250
        idelaytypedefault_var := true;
12251
        idelaytypefixed_var := false;
12252
     else
12253
       GenericValueCheckMessage
12254
       (  HeaderMsg  => " Attribute Syntax Warning ",
12255
          GenericName => " IDELAY_TYPE ",
12256
          EntityName => "/IODELAY",
12257
          GenericValue => IDELAY_TYPE,
12258
          Unit => "",
12259
          ExpectedValueMsg => " The Legal values for this attribute are ",
12260
          ExpectedGenericValue => " DEFAULT, FIXED or VARIABLE ",
12261
          TailMsg => "",
12262
          MsgSeverity => failure
12263
       );
12264
     end if;
12265
 
12266
     -------- IDELAY_VALUE check
12267
 
12268
     if((IDELAY_VALUE < MIN_IDELAY_COUNT) or (ODELAY_VALUE > MAX_IDELAY_COUNT)) then
12269
        GenericValueCheckMessage
12270
        (  HeaderMsg  => " Attribute Syntax Warning ",
12271
           GenericName => " IDELAY_VALUE ",
12272
           EntityName => "/IODELAY",
12273
           GenericValue => IDELAY_VALUE,
12274
           Unit => "",
12275
           ExpectedValueMsg => " The Legal values for this attribute are ",
12276
           ExpectedGenericValue => " 0, 1, 2, ..., 62, 63 ",
12277
           TailMsg => "",
12278
           MsgSeverity => failure
12279
        );
12280
     end if;
12281
 
12282
     -------- ODELAY_VALUE check
12283
 
12284
     if((ODELAY_VALUE < MIN_ODELAY_COUNT) or (ODELAY_VALUE > MAX_ODELAY_COUNT)) then
12285
        GenericValueCheckMessage
12286
        (  HeaderMsg  => " Attribute Syntax Warning ",
12287
           GenericName => " ODELAY_VALUE ",
12288
           EntityName => "/IODELAY",
12289
           GenericValue => ODELAY_VALUE,
12290
           Unit => "",
12291
           ExpectedValueMsg => " The Legal values for this attribute are ",
12292
           ExpectedGenericValue => " 0, 1, 2, ..., 62, 63 ",
12293
           TailMsg => "",
12294
           MsgSeverity => failure
12295
        );
12296
     end if;
12297
 
12298
     -------- REFCLK_FREQUENCY check
12299
 
12300
     if((REFCLK_FREQUENCY < MIN_REFCLK_FREQUENCY) or (REFCLK_FREQUENCY > MAX_REFCLK_FREQUENCY)) then
12301
         assert false
12302
         report "Attribute Syntax Error: Legal values for REFCLK_FREQUENCY are 175.0 to 225.0"
12303
         severity Failure;
12304
     end if;
12305
 
12306
 
12307
     wait;
12308
  end process prcs_init;
12309
--####################################################################
12310
--#####                  CALCULATE iDelay                        #####
12311
--####################################################################
12312
  prcs_calc_idelay:process(C_dly, GSR_dly, RST_dly)
12313
  variable idelay_count_var : integer :=0;
12314
  variable FIRST_TIME   : boolean :=true;
12315
  variable BaseTime_var : time    := 1 ps ;
12316
  variable CALC_TAPDELAY : real := 0.0;
12317
  begin
12318
     if(IDELAY_TYPE = "VARIABLE") then
12319
       if((GSR_dly = '1') or (FIRST_TIME))then
12320
          idelay_count_var := IDELAY_VALUE;
12321
          CALC_TAPDELAY := ((1.0/REFCLK_FREQUENCY) * (1.0/64.0) * ILEAK_ADJUST * 1000000.0) + D_IOBDELAY_OFFSET ;
12322
          iDelay        <= real(idelay_count_var) * CALC_TAPDELAY * BaseTime_var;
12323
          FIRST_TIME   := false;
12324
       elsif(GSR_dly = '0') then
12325
          if(rising_edge(C_dly)) then
12326
             if(RST_dly = '1') then
12327
               idelay_count_var := IDELAY_VALUE;
12328
             elsif((RST_dly = '0') and (CE_dly = '1')) then
12329
                  if(INC_dly = '1') then
12330
                     if (idelay_count_var < MAX_IDELAY_COUNT) then
12331
                        idelay_count_var := idelay_count_var + 1;
12332
                     else
12333
                        idelay_count_var := MIN_IDELAY_COUNT;
12334
                     end if;
12335
                  elsif(INC_dly = '0') then
12336
                     if (idelay_count_var > MIN_IDELAY_COUNT) then
12337
                         idelay_count_var := idelay_count_var - 1;
12338
                     else
12339
                         idelay_count_var := MAX_IDELAY_COUNT;
12340
                     end if;
12341
 
12342
                  end if; -- INC_dly
12343
             end if; -- RST_dly
12344
             iDelay <= real(idelay_count_var) *  CALC_TAPDELAY * BaseTime_var;
12345
          end if; -- C_dly
12346
       end if; -- GSR_dly
12347
 
12348
     end if; -- IDELAY_TYPE
12349
  end process prcs_calc_idelay;
12350
 
12351
--####################################################################
12352
--#####                  CALCULATE oDelay                         #####
12353
--####################################################################
12354
  prcs_calc_odelay:process(C_dly, GSR_dly, RST_dly)
12355
  variable odelay_count_var : integer :=0;
12356
  variable FIRST_TIME   : boolean :=true;
12357
  variable BaseTime_var : time    := 1 ps ;
12358
  variable CALC_TAPDELAY : real := 0.0;
12359
  begin
12360
     if((GSR_dly = '1') or (FIRST_TIME))then
12361
        odelay_count_var := ODELAY_VALUE;
12362
        CALC_TAPDELAY := ((1.0/REFCLK_FREQUENCY) * (1.0/64.0) * ILEAK_ADJUST * 1000000.0) + D_IOBDELAY_OFFSET ;
12363
        oDelay        <= real(odelay_count_var) * CALC_TAPDELAY * BaseTime_var;
12364
        FIRST_TIME   := false;
12365
     end if;
12366
 
12367
--     elsif(GSR_dly = '0') then
12368
--        if(rising_edge(C_dly)) then
12369
--           if(RST_dly = '1') then
12370
--             odelay_count_var := ODELAY_VALUE;
12371
--           elsif((RST_dly = '0') and (CE_dly = '1')) then
12372
--                if(INC_dly = '1') then
12373
--                   if (odelay_count_var < MAX_ODELAY_COUNT) then
12374
--                      odelay_count_var := odelay_count_var + 1;
12375
--                   else
12376
--                      odelay_count_var := MIN_ODELAY_COUNT;
12377
--                   end if;
12378
--                elsif(INC_dly = '0') then
12379
--                   if (odelay_count_var > MIN_ODELAY_COUNT) then
12380
--                       odelay_count_var := odelay_count_var - 1;
12381
--                   else
12382
--                       odelay_count_var := MAX_ODELAY_COUNT;
12383
--                   end if;
12384
--
12385
--                end if; -- INC_dly
12386
--           end if; -- RST_dly
12387
--           oDelay <= real(odelay_count_var) *  CALC_TAPDELAY * BaseTime_var;
12388
--        end if; -- C_dly
12389
--     end if; -- GSR_dly
12390
 
12391
  end process prcs_calc_odelay;
12392
 
12393
--####################################################################
12394
--#####                      SELECT IDATA_MUX                    #####
12395
--####################################################################
12396
  prcs_idata_mux:process(DATAIN_dly, IDATAIN_dly, ODATAIN_dly, T_dly)
12397
  begin
12398
      if(DELAY_SRC = "I") then
12399
            idata_mux <= IDATAIN_dly;
12400
      elsif(DELAY_SRC = "O") then
12401
            idata_mux <= ODATAIN_dly;
12402
      elsif(DELAY_SRC = "IO") then
12403
            idata_mux <= (IDATAIN_dly and T_dly) or (ODATAIN_dly and (not T_dly));
12404
      elsif(DELAY_SRC = "DATAIN") then
12405
            idata_mux <= DATAIN_dly;
12406
      else
12407
         assert false
12408
         report "Attribute Syntax Error : Legal values for DELAY_SRC on IODELAY instance are I, O, IO or DATAIN."
12409
         severity Failure;
12410
      end if;
12411
  end process prcs_idata_mux;
12412
--####################################################################
12413
--#####                      SELECT I/O                          #####
12414
--####################################################################
12415
  prcs_selectio:process(IDATAOUT_Delayed, ODATAOUT_Delayed, T_dly)
12416
  begin
12417
     if(DELAY_SRC = "IO") then
12418
        if(T_dly = '1') then
12419
           DATAOUT_zd <= IDATAOUT_delayed;
12420
        elsif(T_dly = '0') then
12421
           DATAOUT_zd <= ODATAOUT_delayed;
12422
        end if;
12423
     elsif(DELAY_SRC = "O") then
12424
        DATAOUT_zd <= ODATAOUT_delayed;
12425
     else
12426
        DATAOUT_zd <= IDATAOUT_delayed;
12427
     end if;
12428
  end process prcs_selectio;
12429
 
12430
--####################################################################
12431
--#####                      DELAY IDATA                         #####
12432
--####################################################################
12433
  prcs_idata:process(idata_mux)
12434
--  variable CALC_TAPDELAY : real := ((1.0/REFCLK_FREQUENCY) * K ) + OFFSET;
12435
  variable CALC_TAPDELAY : real := ((1.0/REFCLK_FREQUENCY) * (1.0/64.0) * ILEAK_ADJUST * 1000000.0) + D_IOBDELAY_OFFSET ;
12436
  begin
12437
     if(IDELAY_TYPE = "FIXED") then
12438
         IDATAOUT_delayed <= transport idata_mux after ((real(IDELAY_VALUE) * CALC_TAPDELAY) * 1.0 ps);
12439
     else
12440
         IDATAOUT_delayed <= transport idata_mux after iDelay;
12441
     end if;
12442
  end process prcs_idata;
12443
 
12444
--####################################################################
12445
--#####                      DELAY ODATA                         #####
12446
--####################################################################
12447
  prcs_odata:process(idata_mux)
12448
  begin
12449
     ODATAOUT_delayed <= transport idata_mux after oDelay;
12450
  end process prcs_odata;
12451
 
12452
--####################################################################
12453
--#####                         OUTPUT                           #####
12454
--####################################################################
12455
  prcs_output:process(DATAOUT_zd)
12456
  begin
12457
      DATAOUT <= DATAOUT_zd ;
12458
  end process prcs_output;
12459
--####################################################################
12460
 
12461
 
12462
end IODELAY_V;
12463
 
12464
 
12465
----- CELL ISERDES -----
12466
library IEEE;
12467
use IEEE.STD_LOGIC_1164.all;
12468
use IEEE.std_logic_arith.all;
12469
 
12470
 
12471
library unisim;
12472
use unisim.vpkg.all;
12473
use unisim.vcomponents.all;
12474
 
12475
--////////////////////////////////////////////////////////////
12476
--////////////////////////// BSCNTRL /////////////////////////
12477
--////////////////////////////////////////////////////////////
12478
entity bscntrl is
12479
  generic(
12480
      SRTYPE        : string;
12481
      INIT_BITSLIPCNT   : bit_vector(3 downto 0)
12482
      );
12483
  port(
12484
      CLKDIV_INT        : out std_ulogic;
12485
      MUXC              : out std_ulogic;
12486
 
12487
      BITSLIP           : in std_ulogic;
12488
      C23               : in std_ulogic;
12489
      C45               : in std_ulogic;
12490
      C67               : in std_ulogic;
12491
      CLK               : in std_ulogic;
12492
      CLKDIV            : in std_ulogic;
12493
      DATA_RATE         : in std_ulogic;
12494
      GSR               : in std_ulogic;
12495
      R                 : in std_ulogic;
12496
      SEL               : in std_logic_vector (1 downto 0)
12497
      );
12498
 
12499
end bscntrl;
12500
 
12501
architecture bscntrl_V of bscntrl is
12502
--  constant DELAY_FFBSC                : time       := 300 ns;
12503
--  constant DELAY_MXBSC                : time       := 60  ns;
12504
  constant DELAY_FFBSC                  : time       := 300 ps;
12505
  constant DELAY_MXBSC                  : time       := 60  ps;
12506
 
12507
  signal AttrSRtype             : integer := 0;
12508
 
12509
  signal q1                     : std_ulogic := 'X';
12510
  signal q2                     : std_ulogic := 'X';
12511
  signal q3                     : std_ulogic := 'X';
12512
  signal mux                    : std_ulogic := 'X';
12513
  signal qhc1                   : std_ulogic := 'X';
12514
  signal qhc2                   : std_ulogic := 'X';
12515
  signal qlc1                   : std_ulogic := 'X';
12516
  signal qlc2                   : std_ulogic := 'X';
12517
  signal qr1                    : std_ulogic := 'X';
12518
  signal qr2                    : std_ulogic := 'X';
12519
  signal mux1                   : std_ulogic := 'X';
12520
  signal clkdiv_zd              : std_ulogic := 'X';
12521
 
12522
begin
12523
--####################################################################
12524
--#####                     Initialize                           #####
12525
--####################################################################
12526
  prcs_init:process
12527
  begin
12528
 
12529
     if((SRTYPE = "ASYNC") or (SRTYPE = "async")) then
12530
        AttrSrtype <= 0;
12531
     elsif((SRTYPE = "SYNC") or (SRTYPE = "sync")) then
12532
        AttrSrtype <= 1;
12533
     end if;
12534
 
12535
     wait;
12536
  end process prcs_init;
12537
--####################################################################
12538
--#####              Divide by 2 - 8 counter                     #####
12539
--####################################################################
12540
  prcs_div_2_8_cntr:process(qr2, CLK, GSR)
12541
  variable clkdiv_int_var       :  std_ulogic := TO_X01(INIT_BITSLIPCNT(0));
12542
  variable q1_var               :  std_ulogic := TO_X01(INIT_BITSLIPCNT(1));
12543
  variable q2_var               :  std_ulogic := TO_X01(INIT_BITSLIPCNT(2));
12544
  variable q3_var               :  std_ulogic := TO_X01(INIT_BITSLIPCNT(3));
12545
  begin
12546
     if(GSR = '1') then
12547
         clkdiv_int_var := TO_X01(INIT_BITSLIPCNT(0));
12548
         q1_var         := TO_X01(INIT_BITSLIPCNT(1));
12549
         q2_var         := TO_X01(INIT_BITSLIPCNT(2));
12550
         q3_var         := TO_X01(INIT_BITSLIPCNT(3));
12551
     elsif(GSR = '0') then
12552
        case AttrSRtype is
12553
           when 0 =>
12554
           --------------- // async SET/RESET
12555
                   if(qr2 = '1') then
12556
                      clkdiv_int_var := '0';
12557
                      q1_var := '0';
12558
                      q2_var := '0';
12559
                      q3_var := '0';
12560
                   elsif (qhc1 = '1') then
12561
                      clkdiv_int_var := clkdiv_int_var;
12562
                      q1_var := q1_var;
12563
                      q2_var := q2_var;
12564
                      q3_var := q3_var;
12565
                   else
12566
                      if(rising_edge(CLK)) then
12567
                         q3_var := q2_var;
12568
                         q2_var :=( NOT((NOT clkdiv_int_var) and (NOT q2_var)) and q1_var);
12569
                         q1_var := clkdiv_int_var;
12570
                         clkdiv_int_var := mux;
12571
                      end if;
12572
                   end if;
12573
 
12574
           when 1 =>
12575
           --------------- // sync SET/RESET
12576
                   if(rising_edge(CLK)) then
12577
                      if(qr2 = '1') then
12578
                         clkdiv_int_var := '0';
12579
                         q1_var := '0';
12580
                         q2_var := '0';
12581
                         q3_var := '0';
12582
                      elsif (qhc1 = '1') then
12583
                         clkdiv_int_var := clkdiv_int_var;
12584
                         q1_var := q1_var;
12585
                         q2_var := q2_var;
12586
                         q3_var := q3_var;
12587
                      else
12588
                         q3_var := q2_var;
12589
                         q2_var :=( NOT((NOT clkdiv_int_var) and (NOT q2_var)) and q1_var);
12590
                         q1_var := clkdiv_int_var;
12591
                         clkdiv_int_var := mux;
12592
                      end if;
12593
                   end if;
12594
 
12595
           when others =>
12596
                   null;
12597
           end case;
12598
 
12599
 
12600
     end if;
12601
 
12602
     q1 <= q1_var after DELAY_FFBSC;
12603
     q2 <= q2_var after DELAY_FFBSC;
12604
     q3 <= q3_var after DELAY_FFBSC;
12605
     clkdiv_zd <= clkdiv_int_var after DELAY_FFBSC;
12606
 
12607
  end process prcs_div_2_8_cntr;
12608
--####################################################################
12609
--#####          Divider selections and 4:1 selector mux         #####
12610
--####################################################################
12611
  prcs_mux_sel:process(sel, c23 , c45 , c67 , clkdiv_zd , q1 , q2 , q3)
12612
  begin
12613
    case sel is
12614
        when "00" =>
12615
              mux <= NOT (clkdiv_zd or  (c23 and q1)) after DELAY_MXBSC;
12616
        when "01" =>
12617
              mux <= NOT (q1 or (c45 and q2)) after DELAY_MXBSC;
12618
        when "10" =>
12619
              mux <= NOT (q2 or (c67 and q3)) after DELAY_MXBSC;
12620
        when "11" =>
12621
              mux <= NOT (q3) after DELAY_MXBSC;
12622
        when others =>
12623
              mux <= NOT (clkdiv_zd or  (c23 and q1)) after DELAY_MXBSC;
12624
    end case;
12625
  end process prcs_mux_sel;
12626
--####################################################################
12627
--#####                  Bitslip control logic                   #####
12628
--####################################################################
12629
  prcs_logictrl:process(qr1, clkdiv)
12630
  begin
12631
      case AttrSRtype is
12632
          when 0 =>
12633
           --------------- // async SET/RESET
12634
               if(qr1 = '1') then
12635
                 qlc1        <= '0' after DELAY_FFBSC;
12636
                 qlc2        <= '0' after DELAY_FFBSC;
12637
               elsif(bitslip = '0') then
12638
                 qlc1        <= qlc1 after DELAY_FFBSC;
12639
                 qlc2        <= '0'  after DELAY_FFBSC;
12640
               else
12641
                   if(rising_edge(clkdiv)) then
12642
                      qlc1      <= NOT qlc1 after DELAY_FFBSC;
12643
                      qlc2      <= (bitslip and mux1) after DELAY_FFBSC;
12644
                   end if;
12645
               end if;
12646
 
12647
          when 1 =>
12648
           --------------- // sync SET/RESET
12649
               if(rising_edge(clkdiv)) then
12650
                  if(qr1 = '1') then
12651
                    qlc1        <= '0' after DELAY_FFBSC;
12652
                    qlc2        <= '0' after DELAY_FFBSC;
12653
                  elsif(bitslip = '0') then
12654
                    qlc1        <= qlc1 after DELAY_FFBSC;
12655
                    qlc2        <= '0'  after DELAY_FFBSC;
12656
                  else
12657
                    qlc1      <= NOT qlc1 after DELAY_FFBSC;
12658
                    qlc2      <= (bitslip and mux1) after DELAY_FFBSC;
12659
                  end if;
12660
               end if;
12661
          when others =>
12662
                  null;
12663
      end case;
12664
  end process  prcs_logictrl;
12665
 
12666
--####################################################################
12667
--#####        Mux to select between sdr "0" and ddr "1"         #####
12668
--####################################################################
12669
  prcs_sdr_ddr_mux:process(qlc1, DATA_RATE)
12670
  begin
12671
    case DATA_RATE is
12672
        when '0' =>
12673
             mux1 <= qlc1 after DELAY_MXBSC;
12674
        when '1' =>
12675
             mux1 <= '1' after DELAY_MXBSC;
12676
        when others =>
12677
             null;
12678
    end case;
12679
  end process  prcs_sdr_ddr_mux;
12680
 
12681
--####################################################################
12682
--#####                       qhc1 and qhc2                      #####
12683
--####################################################################
12684
  prcs_qhc1_qhc2:process(qr2, CLK)
12685
  begin
12686
-- FP TMP -- should CLK and q2 have to be rising_edge
12687
     case AttrSRtype is
12688
        when 0 =>
12689
         --------------- // async SET/RESET
12690
             if(qr2 = '1') then
12691
                qhc1 <= '0' after DELAY_FFBSC;
12692
                qhc2 <= '0' after DELAY_FFBSC;
12693
             elsif(rising_edge(CLK)) then
12694
                qhc1 <= (qlc2 and (NOT qhc2)) after DELAY_FFBSC;
12695
                qhc2 <= qlc2 after DELAY_FFBSC;
12696
             end if;
12697
 
12698
        when 1 =>
12699
         --------------- // sync SET/RESET
12700
             if(rising_edge(CLK)) then
12701
                if(qr2 = '1') then
12702
                   qhc1 <= '0' after DELAY_FFBSC;
12703
                   qhc2 <= '0' after DELAY_FFBSC;
12704
                else
12705
                   qhc1 <= (qlc2 and (NOT qhc2)) after DELAY_FFBSC;
12706
                   qhc2 <= qlc2 after DELAY_FFBSC;
12707
                end if;
12708
             end if;
12709
 
12710
        when others =>
12711
             null;
12712
     end case;
12713
 
12714
  end process  prcs_qhc1_qhc2;
12715
 
12716
--####################################################################
12717
--#####     Mux drives ctrl lines of mux in front of 2nd rnk FFs  ####
12718
--####################################################################
12719
  prcs_muxc:process(mux1, DATA_RATE)
12720
  begin
12721
    case DATA_RATE is
12722
        when '0' =>
12723
             muxc <= mux1 after DELAY_MXBSC;
12724
        when '1' =>
12725
             muxc <= '0'  after DELAY_MXBSC;
12726
        when others =>
12727
             null;
12728
    end case;
12729
  end process  prcs_muxc;
12730
 
12731
--####################################################################
12732
--#####                       Asynchronous set flops             #####
12733
--####################################################################
12734
  prcs_qr1:process(R, CLKDIV)
12735
  begin
12736
-- FP TMP -- should CLKDIV and R have to be rising_edge
12737
     case AttrSRtype is
12738
        when 0 =>
12739
         --------------- // async SET/RESET
12740
             if(R = '1') then
12741
                qr1        <= '1' after DELAY_FFBSC;
12742
             elsif(rising_edge(CLKDIV)) then
12743
                qr1        <= '0' after DELAY_FFBSC;
12744
             end if;
12745
 
12746
        when 1 =>
12747
         --------------- // sync SET/RESET
12748
             if(rising_edge(CLKDIV)) then
12749
                if(R = '1') then
12750
                   qr1        <= '1' after DELAY_FFBSC;
12751
                else
12752
                   qr1        <= '0' after DELAY_FFBSC;
12753
                end if;
12754
             end if;
12755
 
12756
        when others =>
12757
             null;
12758
     end case;
12759
  end process  prcs_qr1;
12760
----------------------------------------------------------------------
12761
  prcs_qr2:process(R, CLK)
12762
  begin
12763
-- FP TMP -- should CLK and R have to be rising_edge
12764
     case AttrSRtype is
12765
        when 0 =>
12766
         --------------- // async SET/RESET
12767
             if(R = '1') then
12768
                qr2        <= '1' after DELAY_FFBSC;
12769
             elsif(rising_edge(CLK)) then
12770
                qr2        <= qr1 after DELAY_FFBSC;
12771
             end if;
12772
 
12773
        when 1 =>
12774
         --------------- // sync SET/RESET
12775
             if(rising_edge(CLK)) then
12776
                if(R = '1') then
12777
                   qr2        <= '1' after DELAY_FFBSC;
12778
                else
12779
                   qr2        <= qr1 after DELAY_FFBSC;
12780
                end if;
12781
             end if;
12782
 
12783
        when others =>
12784
             null;
12785
     end case;
12786
  end process  prcs_qr2;
12787
--####################################################################
12788
--#####                         OUTPUT                           #####
12789
--####################################################################
12790
  prcs_output:process(clkdiv_zd)
12791
  begin
12792
      CLKDIV_INT <= clkdiv_zd;
12793
  end process prcs_output;
12794
--####################################################################
12795
end bscntrl_V;
12796
 
12797
library IEEE;
12798
use IEEE.STD_LOGIC_1164.all;
12799
use IEEE.std_logic_arith.all;
12800
 
12801
 
12802
library unisim;
12803
use unisim.vpkg.all;
12804
use unisim.vcomponents.all;
12805
 
12806
--////////////////////////////////////////////////////////////
12807
--//////////////////////// ICE MODULE ////////////////////////
12808
--////////////////////////////////////////////////////////////
12809
 
12810
entity ice_module is
12811
  generic(
12812
      SRTYPE  : string;
12813
      INIT_CE : bit_vector(1 downto 0)
12814
      );
12815
  port(
12816
      ICE               : out std_ulogic;
12817
 
12818
      CE1               : in std_ulogic;
12819
      CE2               : in std_ulogic;
12820
      GSR               : in std_ulogic;
12821
      NUM_CE            : in std_ulogic;
12822
      CLKDIV            : in std_ulogic;
12823
      R                 : in std_ulogic
12824
      );
12825
end ice_module;
12826
 
12827
architecture ice_V of ice_module is
12828
--  constant DELAY_FFICE                : time := 300 ns;
12829
--  constant DELAY_MXICE                : time := 60 ns;
12830
  constant DELAY_FFICE                  : time := 300 ps;
12831
  constant DELAY_MXICE                  : time := 60 ps;
12832
 
12833
  signal AttrSRtype             : integer := 0;
12834
 
12835
  signal ce1r                   : std_ulogic := 'X';
12836
  signal ce2r                   : std_ulogic := 'X';
12837
  signal cesel                  : std_logic_vector(1 downto 0) := (others => 'X');
12838
 
12839
  signal ice_zd                 : std_ulogic := 'X';
12840
 
12841
begin
12842
 
12843
--####################################################################
12844
--#####                     Initialize                           #####
12845
--####################################################################
12846
  prcs_init:process
12847
  begin
12848
 
12849
     if((SRTYPE = "ASYNC") or (SRTYPE = "async")) then
12850
        AttrSrtype <= 0;
12851
     elsif((SRTYPE = "SYNC") or (SRTYPE = "sync")) then
12852
        AttrSrtype <= 1;
12853
     end if;
12854
 
12855
     wait;
12856
  end process prcs_init;
12857
 
12858
--###################################################################
12859
--#####                      update cesel                       #####
12860
--###################################################################
12861
 
12862
  cesel  <= NUM_CE & CLKDIV;
12863
 
12864
--####################################################################
12865
--#####                         registers                        #####
12866
--####################################################################
12867
  prcs_reg:process(CLKDIV, GSR)
12868
  variable ce1r_var             :  std_ulogic := TO_X01(INIT_CE(1));
12869
  variable ce2r_var             :  std_ulogic := TO_X01(INIT_CE(0));
12870
  begin
12871
     if(GSR = '1') then
12872
         ce1r_var               := TO_X01(INIT_CE(1));
12873
         ce2r_var               := TO_X01(INIT_CE(0));
12874
     elsif(GSR = '0') then
12875
        case AttrSRtype is
12876
           when 0 =>
12877
            --------------- // async SET/RESET
12878
                if(R = '1') then
12879
                   ce1r_var := '0';
12880
                   ce2r_var := '0';
12881
                elsif(rising_edge(CLKDIV)) then
12882
                   ce1r_var := ce1;
12883
                   ce2r_var := ce2;
12884
                end if;
12885
 
12886
           when 1 =>
12887
            --------------- // sync SET/RESET
12888
                if(rising_edge(CLKDIV)) then
12889
                   if(R = '1') then
12890
                      ce1r_var := '0';
12891
                      ce2r_var := '0';
12892
                   else
12893
                      ce1r_var := ce1;
12894
                      ce2r_var := ce2;
12895
                   end if;
12896
                end if;
12897
 
12898
           when others =>
12899
                null;
12900
 
12901
        end case;
12902
    end if;
12903
 
12904
   ce1r <= ce1r_var after DELAY_FFICE;
12905
   ce2r <= ce2r_var after DELAY_FFICE;
12906
 
12907
  end process prcs_reg;
12908
--####################################################################
12909
--#####                        Output mux                        #####
12910
--####################################################################
12911
  prcs_mux:process(cesel, ce1, ce1r, ce2r)
12912
  begin
12913
    case cesel is
12914
        when "00" =>
12915
             ice_zd  <= ce1;
12916
        when "01" =>
12917
             ice_zd  <= ce1;
12918
-- 426606
12919
        when "10" =>
12920
             ice_zd  <= ce2r;
12921
        when "11" =>
12922
             ice_zd  <= ce1r;
12923
        when others =>
12924
             null;
12925
    end case;
12926
  end process  prcs_mux;
12927
 
12928
--####################################################################
12929
--#####                         OUTPUT                           #####
12930
--####################################################################
12931
  prcs_output:process(ice_zd)
12932
  begin
12933
      ICE <= ice_zd;
12934
  end process prcs_output;
12935
end ice_V;
12936
 
12937
library IEEE;
12938
use IEEE.STD_LOGIC_1164.all;
12939
use IEEE.std_logic_arith.all;
12940
 
12941
 
12942
library unisim;
12943
use unisim.vpkg.all;
12944
use unisim.vcomponents.all;
12945
use unisim.vcomponents.all;
12946
 
12947
----- CELL ISERDES -----
12948
--////////////////////////////////////////////////////////////
12949
--////////////////////////// ISERDES /////////////////////////
12950
--////////////////////////////////////////////////////////////
12951
 
12952
entity ISERDES is
12953
 
12954
  generic(
12955
 
12956
      DDR_CLK_EDGE      : string        := "SAME_EDGE_PIPELINED";
12957
      INIT_BITSLIPCNT   : bit_vector(3 downto 0) := "0000";
12958
      INIT_CE           : bit_vector(1 downto 0) := "00";
12959
      INIT_RANK1_PARTIAL: bit_vector(4 downto 0) := "00000";
12960
      INIT_RANK2        : bit_vector(5 downto 0) := "000000";
12961
      INIT_RANK3        : bit_vector(5 downto 0) := "000000";
12962
      SERDES            : boolean       := TRUE;
12963
      SRTYPE            : string        := "ASYNC";
12964
 
12965
      BITSLIP_ENABLE    : boolean       := false;
12966
      DATA_RATE         : string        := "DDR";
12967
      DATA_WIDTH        : integer       := 4;
12968
      INIT_Q1           : bit           := '0';
12969
      INIT_Q2           : bit           := '0';
12970
      INIT_Q3           : bit           := '0';
12971
      INIT_Q4           : bit           := '0';
12972
      INTERFACE_TYPE    : string        := "MEMORY";
12973
      IOBDELAY          : string        := "NONE";
12974
      IOBDELAY_TYPE     : string        := "DEFAULT";
12975
      IOBDELAY_VALUE    : integer       := 0;
12976
      NUM_CE            : integer       := 2;
12977
      SERDES_MODE       : string        := "MASTER";
12978
      SRVAL_Q1          : bit           := '0';
12979
      SRVAL_Q2          : bit           := '0';
12980
      SRVAL_Q3          : bit           := '0';
12981
      SRVAL_Q4          : bit           := '0'
12982
      );
12983
 
12984
  port(
12985
      O                 : out std_ulogic;
12986
      Q1                : out std_ulogic;
12987
      Q2                : out std_ulogic;
12988
      Q3                : out std_ulogic;
12989
      Q4                : out std_ulogic;
12990
      Q5                : out std_ulogic;
12991
      Q6                : out std_ulogic;
12992
      SHIFTOUT1         : out std_ulogic;
12993
      SHIFTOUT2         : out std_ulogic;
12994
 
12995
      BITSLIP           : in std_ulogic;
12996
      CE1               : in std_ulogic;
12997
      CE2               : in std_ulogic;
12998
      CLK               : in std_ulogic;
12999
      CLKDIV            : in std_ulogic;
13000
      D                 : in std_ulogic;
13001
      DLYCE             : in std_ulogic;
13002
      DLYINC            : in std_ulogic;
13003
      DLYRST            : in std_ulogic;
13004
      OCLK              : in std_ulogic;
13005
      REV               : in std_ulogic;
13006
      SHIFTIN1          : in std_ulogic;
13007
      SHIFTIN2          : in std_ulogic;
13008
      SR                : in std_ulogic
13009
    );
13010
 
13011
end ISERDES;
13012
 
13013
architecture ISERDES_V OF ISERDES is
13014
 
13015
component bscntrl
13016
  generic (
13017
      SRTYPE            : string;
13018
      INIT_BITSLIPCNT   : bit_vector(3 downto 0)
13019
    );
13020
  port(
13021
      CLKDIV_INT        : out std_ulogic;
13022
      MUXC              : out std_ulogic;
13023
 
13024
      BITSLIP           : in std_ulogic;
13025
      C23               : in std_ulogic;
13026
      C45               : in std_ulogic;
13027
      C67               : in std_ulogic;
13028
      CLK               : in std_ulogic;
13029
      CLKDIV            : in std_ulogic;
13030
      DATA_RATE         : in std_ulogic;
13031
      GSR               : in std_ulogic;
13032
      R                 : in std_ulogic;
13033
      SEL               : in std_logic_vector (1 downto 0)
13034
      );
13035
end component;
13036
 
13037
component ice_module
13038
  generic(
13039
      SRTYPE            : string;
13040
      INIT_CE           : bit_vector(1 downto 0)
13041
      );
13042
  port(
13043
      ICE               : out std_ulogic;
13044
 
13045
      CE1               : in std_ulogic;
13046
      CE2               : in std_ulogic;
13047
      GSR               : in std_ulogic;
13048
      NUM_CE            : in std_ulogic;
13049
      CLKDIV            : in std_ulogic;
13050
      R                 : in std_ulogic
13051
      );
13052
end component;
13053
 
13054
component IDELAY
13055
  generic(
13056
      IOBDELAY_VALUE : integer := 0;
13057
      IOBDELAY_TYPE  : string  := "DEFAULT"
13058
    );
13059
 
13060
  port(
13061
      O      : out std_ulogic;
13062
 
13063
      C      : in  std_ulogic;
13064
      CE     : in  std_ulogic;
13065
 
13066
      I      : in  std_ulogic;
13067
      INC    : in  std_ulogic;
13068
      RST    : in  std_ulogic
13069
    );
13070
end component;
13071
 
13072
--  constant DELAY_FFINP          : time       := 300 ns;
13073
--  constant DELAY_MXINP1         : time       := 60  ns;
13074
--  constant DELAY_MXINP2         : time       := 120 ns;
13075
--  constant DELAY_OCLKDLY        : time       := 750 ns;
13076
 
13077
  constant SYNC_PATH_DELAY      : time       := 100 ps;
13078
 
13079
  constant DELAY_FFINP          : time       := 300 ps;
13080
  constant DELAY_MXINP1         : time       := 60  ps;
13081
  constant DELAY_MXINP2         : time       := 120 ps;
13082
  constant DELAY_OCLKDLY        : time       := 750 ps;
13083
 
13084
  constant MAX_DATAWIDTH        : integer    := 4;
13085
 
13086
  signal BITSLIP_ipd            : std_ulogic := 'X';
13087
  signal CE1_ipd                : std_ulogic := 'X';
13088
  signal CE2_ipd                : std_ulogic := 'X';
13089
  signal CLK_ipd                : std_ulogic := 'X';
13090
  signal CLKDIV_ipd             : std_ulogic := 'X';
13091
  signal D_ipd                  : std_ulogic := 'X';
13092
  signal DLYCE_ipd              : std_ulogic := 'X';
13093
  signal DLYINC_ipd             : std_ulogic := 'X';
13094
  signal DLYRST_ipd             : std_ulogic := 'X';
13095
  signal GSR                    : std_ulogic := '0';
13096
  signal GSR_ipd                : std_ulogic := 'X';
13097
  signal OCLK_ipd               : std_ulogic := 'X';
13098
  signal REV_ipd                : std_ulogic := 'X';
13099
  signal SR_ipd                 : std_ulogic := 'X';
13100
  signal SHIFTIN1_ipd           : std_ulogic := 'X';
13101
  signal SHIFTIN2_ipd           : std_ulogic := 'X';
13102
 
13103
  signal BITSLIP_dly            : std_ulogic := 'X';
13104
  signal CE1_dly                : std_ulogic := 'X';
13105
  signal CE2_dly                : std_ulogic := 'X';
13106
  signal CLK_dly                : std_ulogic := 'X';
13107
  signal CLKDIV_dly             : std_ulogic := 'X';
13108
  signal D_dly                  : std_ulogic := 'X';
13109
  signal DLYCE_dly              : std_ulogic := 'X';
13110
  signal DLYINC_dly             : std_ulogic := 'X';
13111
  signal DLYRST_dly             : std_ulogic := 'X';
13112
  signal GSR_dly                : std_ulogic := 'X';
13113
  signal OCLK_dly               : std_ulogic := 'X';
13114
  signal REV_dly                : std_ulogic := 'X';
13115
  signal SR_dly                 : std_ulogic := 'X';
13116
  signal SHIFTIN1_dly           : std_ulogic := 'X';
13117
  signal SHIFTIN2_dly           : std_ulogic := 'X';
13118
 
13119
 
13120
  signal O_zd                   : std_ulogic := 'X';
13121
  signal Q1_zd                  : std_ulogic := 'X';
13122
  signal Q2_zd                  : std_ulogic := 'X';
13123
  signal Q3_zd                  : std_ulogic := 'X';
13124
  signal Q4_zd                  : std_ulogic := 'X';
13125
  signal Q5_zd                  : std_ulogic := 'X';
13126
  signal Q6_zd                  : std_ulogic := 'X';
13127
  signal SHIFTOUT1_zd           : std_ulogic := 'X';
13128
  signal SHIFTOUT2_zd           : std_ulogic := 'X';
13129
 
13130
  signal O_viol                 : std_ulogic := 'X';
13131
  signal Q1_viol                : std_ulogic := 'X';
13132
  signal Q2_viol                : std_ulogic := 'X';
13133
  signal Q3_viol                : std_ulogic := 'X';
13134
  signal Q4_viol                : std_ulogic := 'X';
13135
  signal Q5_viol                : std_ulogic := 'X';
13136
  signal Q6_viol                : std_ulogic := 'X';
13137
  signal SHIFTOUT1_viol         : std_ulogic := 'X';
13138
  signal SHIFTOUT2_viol         : std_ulogic := 'X';
13139
 
13140
  signal AttrSerdes             : std_ulogic := 'X';
13141
  signal AttrMode               : std_ulogic := 'X';
13142
  signal AttrDataRate           : std_ulogic := 'X';
13143
  signal AttrDataWidth          : std_logic_vector(3 downto 0) := (others => 'X');
13144
  signal AttrInterfaceType      : std_ulogic := 'X';
13145
  signal AttrBitslipEnable      : std_ulogic := 'X';
13146
  signal AttrNumCe              : std_ulogic := 'X';
13147
  signal AttrDdrClkEdge         : std_logic_vector(1 downto 0) := (others => 'X');
13148
  signal AttrSRtype             : integer := 0;
13149
  signal AttrIobDelay           : integer := 0;
13150
 
13151
  signal sel1                   : std_logic_vector(1 downto 0) := (others => 'X');
13152
  signal selrnk3                : std_logic_vector(3 downto 0) := (others => 'X');
13153
  signal bsmux                  : std_logic_vector(2 downto 0) := (others => 'X');
13154
  signal cntr                   : std_logic_vector(4 downto 0) := (others => 'X');
13155
 
13156
  signal q1rnk1                 : std_ulogic := 'X';
13157
  signal q2nrnk1                : std_ulogic := 'X';
13158
  signal q5rnk1                 : std_ulogic := 'X';
13159
  signal q6rnk1                 : std_ulogic := 'X';
13160
  signal q6prnk1                : std_ulogic := 'X';
13161
 
13162
  signal q1prnk1                : std_ulogic := 'X';
13163
  signal q2prnk1                : std_ulogic := 'X';
13164
  signal q3rnk1                 : std_ulogic := 'X';
13165
  signal q4rnk1                 : std_ulogic := 'X';
13166
 
13167
  signal dataq5rnk1             : std_ulogic := 'X';
13168
  signal dataq6rnk1             : std_ulogic := 'X';
13169
 
13170
  signal dataq3rnk1             : std_ulogic := 'X';
13171
  signal dataq4rnk1             : std_ulogic := 'X';
13172
 
13173
  signal oclkmux                : std_ulogic := '0';
13174
  signal memmux                 : std_ulogic := '0';
13175
  signal q2pmux                 : std_ulogic := '0';
13176
 
13177
  signal clkdiv_int             : std_ulogic := '0';
13178
  signal clkdivmux              : std_ulogic := '0';
13179
 
13180
  signal q1rnk2                 : std_ulogic := 'X';
13181
  signal q2rnk2                 : std_ulogic := 'X';
13182
  signal q3rnk2                 : std_ulogic := 'X';
13183
  signal q4rnk2                 : std_ulogic := 'X';
13184
  signal q5rnk2                 : std_ulogic := 'X';
13185
  signal q6rnk2                 : std_ulogic := 'X';
13186
  signal dataq1rnk2             : std_ulogic := 'X';
13187
  signal dataq2rnk2             : std_ulogic := 'X';
13188
  signal dataq3rnk2             : std_ulogic := 'X';
13189
  signal dataq4rnk2             : std_ulogic := 'X';
13190
  signal dataq5rnk2             : std_ulogic := 'X';
13191
  signal dataq6rnk2             : std_ulogic := 'X';
13192
 
13193
  signal muxc                   : std_ulogic := 'X';
13194
 
13195
  signal q1rnk3                 : std_ulogic := 'X';
13196
  signal q2rnk3                 : std_ulogic := 'X';
13197
  signal q3rnk3                 : std_ulogic := 'X';
13198
  signal q4rnk3                 : std_ulogic := 'X';
13199
  signal q5rnk3                 : std_ulogic := 'X';
13200
  signal q6rnk3                 : std_ulogic := 'X';
13201
 
13202
  signal c23                    : std_ulogic := 'X';
13203
  signal c45                    : std_ulogic := 'X';
13204
  signal c67                    : std_ulogic := 'X';
13205
  signal sel                    : std_logic_vector(1 downto 0) := (others => 'X');
13206
 
13207
  signal ice                    : std_ulogic := 'X';
13208
  signal datain                 : std_ulogic := 'X';
13209
  signal idelay_out             : std_ulogic := 'X';
13210
 
13211
  signal CLKN_dly               : std_ulogic := '0';
13212
 
13213
begin
13214
 
13215
  ---------------------
13216
  --  INPUT PATH DELAYs
13217
  --------------------
13218
 
13219
  BITSLIP_dly            <= BITSLIP             after 0 ps;
13220
  CE1_dly                <= CE1                 after 0 ps;
13221
  CE2_dly                <= CE2                 after 0 ps;
13222
  CLK_dly                <= CLK                 after 0 ps;
13223
  CLKDIV_dly             <= CLKDIV              after 0 ps;
13224
  D_dly                  <= D                   after 0 ps;
13225
  DLYCE_dly              <= DLYCE               after 0 ps;
13226
  DLYINC_dly             <= DLYINC              after 0 ps;
13227
  DLYRST_dly             <= DLYRST              after 0 ps;
13228
  GSR_dly                <= GSR                 after 0 ps;
13229
  OCLK_dly               <= OCLK                after 0 ps;
13230
  REV_dly                <= REV                 after 0 ps;
13231
  SHIFTIN1_dly           <= SHIFTIN1            after 0 ps;
13232
  SHIFTIN2_dly           <= SHIFTIN2            after 0 ps;
13233
  SR_dly                 <= SR                  after 0 ps;
13234
 
13235
  --------------------
13236
  --  BEHAVIOR SECTION
13237
  --------------------
13238
 
13239
--####################################################################
13240
--#####                     Initialize                           #####
13241
--####################################################################
13242
  prcs_init:process
13243
  variable AttrSerdes_var               : std_ulogic := 'X';
13244
  variable AttrMode_var                 : std_ulogic := 'X';
13245
  variable AttrDataRate_var             : std_ulogic := 'X';
13246
  variable AttrDataWidth_var            : std_logic_vector(3 downto 0) := (others => 'X');
13247
  variable AttrInterfaceType_var        : std_ulogic := 'X';
13248
  variable AttrBitslipEnable_var        : std_ulogic := 'X';
13249
  variable AttrDdrClkEdge_var           : std_logic_vector(1 downto 0) := (others => 'X');
13250
  variable AttrIobDelay_var             : integer := 0;
13251
 
13252
  begin
13253
      -------------------- SERDES validity check --------------------
13254
      if(SERDES = true) then
13255
        AttrSerdes_var := '1';
13256
      else
13257
        AttrSerdes_var := '0';
13258
      end if;
13259
 
13260
      ------------- SERDES_MODE validity check --------------------
13261
      if((SERDES_MODE = "MASTER") or (SERDES_MODE = "master")) then
13262
         AttrMode_var := '0';
13263
      elsif((SERDES_MODE = "SLAVE") or (SERDES_MODE = "slave")) then
13264
         AttrMode_var := '1';
13265
      else
13266
        GenericValueCheckMessage
13267
          (  HeaderMsg  => " Attribute Syntax Warning ",
13268
             GenericName => "SERDES_MODE ",
13269
             EntityName => "/ISERDES",
13270
             GenericValue => SERDES_MODE,
13271
             Unit => "",
13272
             ExpectedValueMsg => " The Legal values for this attribute are ",
13273
             ExpectedGenericValue => " MASTER or SLAVE.",
13274
             TailMsg => "",
13275
             MsgSeverity => FAILURE
13276
         );
13277
      end if;
13278
 
13279
      ------------------ DATA_RATE validity check ------------------
13280
      if((DATA_RATE = "DDR") or (DATA_RATE = "ddr")) then
13281
         AttrDataRate_var := '0';
13282
      elsif((DATA_RATE = "SDR") or (DATA_RATE = "sdr")) then
13283
         AttrDataRate_var := '1';
13284
      else
13285
        GenericValueCheckMessage
13286
          (  HeaderMsg  => " Attribute Syntax Warning ",
13287
             GenericName => " DATA_RATE ",
13288
             EntityName => "/ISERDES",
13289
             GenericValue => DATA_RATE,
13290
             Unit => "",
13291
             ExpectedValueMsg => " The Legal values for this attribute are ",
13292
             ExpectedGenericValue => " DDR or SDR. ",
13293
             TailMsg => "",
13294
             MsgSeverity => Failure
13295
         );
13296
      end if;
13297
 
13298
      ------------------ DATA_WIDTH validity check ------------------
13299
      if((DATA_WIDTH = 2) or (DATA_WIDTH = 3) or  (DATA_WIDTH = 4) or
13300
         (DATA_WIDTH = 5) or (DATA_WIDTH = 6) or  (DATA_WIDTH = 7) or
13301
         (DATA_WIDTH = 8) or (DATA_WIDTH = 10)) then
13302
         AttrDataWidth_var := CONV_STD_LOGIC_VECTOR(DATA_WIDTH, MAX_DATAWIDTH);
13303
      else
13304
        GenericValueCheckMessage
13305
          (  HeaderMsg  => " Attribute Syntax Warning ",
13306
             GenericName => " DATA_WIDTH ",
13307
             EntityName => "/ISERDES",
13308
             GenericValue => DATA_WIDTH,
13309
             Unit => "",
13310
             ExpectedValueMsg => " The Legal values for this attribute are ",
13311
             ExpectedGenericValue => " 2, 3, 4, 5, 6, 7, 8, or 10 ",
13312
             TailMsg => "",
13313
             MsgSeverity => Failure
13314
         );
13315
      end if;
13316
      ------------ DATA_WIDTH /DATA_RATE combination check ------------
13317
      if((DATA_RATE = "DDR") or (DATA_RATE = "ddr")) then
13318
         case (DATA_WIDTH) is
13319
             when 4|6|8|10  => null;
13320
             when others       =>
13321
                GenericValueCheckMessage
13322
                (  HeaderMsg  => " Attribute Syntax Warning ",
13323
                   GenericName => " DATA_WIDTH ",
13324
                   EntityName => "/ISERDES",
13325
                   GenericValue => DATA_WIDTH,
13326
                   Unit => "",
13327
                   ExpectedValueMsg => " The Legal values for DDR mode are ",
13328
                   ExpectedGenericValue => " 4, 6, 8, or 10 ",
13329
                   TailMsg => "",
13330
                   MsgSeverity => Failure
13331
                );
13332
          end case;
13333
      end if;
13334
 
13335
      if((DATA_RATE = "SDR") or (DATA_RATE = "sdr")) then
13336
         case (DATA_WIDTH) is
13337
             when 2|3|4|5|6|7|8  => null;
13338
             when others       =>
13339
                GenericValueCheckMessage
13340
                (  HeaderMsg  => " Attribute Syntax Warning ",
13341
                   GenericName => " DATA_WIDTH ",
13342
                   EntityName => "/ISERDES",
13343
                   GenericValue => DATA_WIDTH,
13344
                   Unit => "",
13345
                   ExpectedValueMsg => " The Legal values for SDR mode are ",
13346
                   ExpectedGenericValue => " 2, 3, 4, 5, 6, 7 or 8",
13347
                   TailMsg => "",
13348
                   MsgSeverity => Failure
13349
                );
13350
          end case;
13351
      end if;
13352
      ---------------- INTERFACE_TYPE validity check ---------------
13353
      if((INTERFACE_TYPE = "MEMORY") or (INTERFACE_TYPE = "MEMORY")) then
13354
         AttrInterfaceType_var := '0';
13355
      elsif((INTERFACE_TYPE = "NETWORKING") or (INTERFACE_TYPE = "networking")) then
13356
         AttrInterfaceType_var := '1';
13357
      else
13358
        GenericValueCheckMessage
13359
          (  HeaderMsg  => " Attribute Syntax Warning ",
13360
             GenericName => "INTERFACE_TYPE ",
13361
             EntityName => "/ISERDES",
13362
             GenericValue => INTERFACE_TYPE,
13363
             Unit => "",
13364
             ExpectedValueMsg => " The Legal values for this attribute are ",
13365
             ExpectedGenericValue => " MEMORY or NETWORKING.",
13366
             TailMsg => "",
13367
             MsgSeverity => FAILURE
13368
         );
13369
      end if;
13370
 
13371
      ---------------- BITSLIP_ENABLE validity check -------------------
13372
      if(BITSLIP_ENABLE = false) then
13373
         AttrBitslipEnable_var := '0';
13374
      elsif(BITSLIP_ENABLE = true) then
13375
         AttrBitslipEnable_var := '1';
13376
      else
13377
        GenericValueCheckMessage
13378
          (  HeaderMsg  => " Attribute Syntax Warning ",
13379
             GenericName => " BITSLIP_ENABLE ",
13380
             EntityName => "/ISERDES",
13381
             GenericValue => BITSLIP_ENABLE,
13382
             Unit => "",
13383
             ExpectedValueMsg => " The Legal values for this attribute are ",
13384
             ExpectedGenericValue => " TRUE or FALSE ",
13385
             TailMsg => "",
13386
             MsgSeverity => Failure
13387
         );
13388
      end if;
13389
 
13390
      ----------------     NUM_CE validity check    -------------------
13391
      case NUM_CE is
13392
         when 1 =>
13393
                AttrNumCe <= '0';
13394
         when 2 =>
13395
                AttrNumCe <= '1';
13396
         when others =>
13397
                GenericValueCheckMessage
13398
                  (  HeaderMsg  => " Attribute Syntax Warning ",
13399
                     GenericName => " NUM_CE ",
13400
                     EntityName => "/ISERDES",
13401
                     GenericValue => NUM_CE,
13402
                     Unit => "",
13403
                     ExpectedValueMsg => " The Legal values for this attribute are ",
13404
                     ExpectedGenericValue => " 1 or 2 ",
13405
                     TailMsg => "",
13406
                     MsgSeverity => Failure
13407
                  );
13408
      end case;
13409
      ----------------     IOBDELAY validity check  -------------------
13410
      if((IOBDELAY = "NONE") or (IOBDELAY = "none")) then
13411
         AttrIobDelay_var := 0;
13412
      elsif((IOBDELAY = "IBUF") or (IOBDELAY = "ibuf")) then
13413
         AttrIobDelay_var := 1;
13414
      elsif((IOBDELAY = "IFD") or (IOBDELAY = "ifd")) then
13415
         AttrIobDelay_var := 2;
13416
      elsif((IOBDELAY = "BOTH") or (IOBDELAY = "both")) then
13417
         AttrIobDelay_var := 3;
13418
      else
13419
        GenericValueCheckMessage
13420
          (  HeaderMsg  => " Attribute Syntax Warning ",
13421
             GenericName => " IOBDELAY ",
13422
             EntityName => "/ISERDES",
13423
             GenericValue => IOBDELAY,
13424
             Unit => "",
13425
             ExpectedValueMsg => " The Legal values for this attribute are ",
13426
             ExpectedGenericValue => " NONE or IBUF or IFD or BOTH ",
13427
             TailMsg => "",
13428
             MsgSeverity => Failure
13429
         );
13430
      end if;
13431
      ------------     IOBDELAY_VALUE validity check  -----------------
13432
      ------------     IOBDELAY_TYPE validity check   -----------------
13433
--
13434
--
13435
--
13436
      ------------------ DDR_CLK_EDGE validity check ------------------
13437
      if((DDR_CLK_EDGE = "SAME_EDGE_PIPELINED") or (DDR_CLK_EDGE = "same_edge_pipelined")) then
13438
         AttrDdrClkEdge_var := "00";
13439
      elsif((DDR_CLK_EDGE = "SAME_EDGE") or (DDR_CLK_EDGE = "same_edge")) then
13440
         AttrDdrClkEdge_var := "01";
13441
      elsif((DDR_CLK_EDGE = "OPPOSITE_EDGE") or (DDR_CLK_EDGE = "opposite_edge")) then
13442
         AttrDdrClkEdge_var := "10";
13443
      else
13444
        GenericValueCheckMessage
13445
          (  HeaderMsg  => " Attribute Syntax Warning ",
13446
             GenericName => " DDR_CLK_EDGE ",
13447
             EntityName => "/ISERDES",
13448
             GenericValue => DDR_CLK_EDGE,
13449
             Unit => "",
13450
             ExpectedValueMsg => " The Legal values for this attribute are ",
13451
             ExpectedGenericValue => " SAME_EDGE_PIPELINED or SAME_EDGE or OPPOSITE_EDGE ",
13452
             TailMsg => "",
13453
             MsgSeverity => Failure
13454
         );
13455
      end if;
13456
      ------------------ DATA_RATE validity check ------------------
13457
      if((SRTYPE = "ASYNC") or (SRTYPE = "async")) then
13458
         AttrSrtype <= 0;
13459
      elsif((SRTYPE = "SYNC") or (SRTYPE = "sync")) then
13460
         AttrSrtype <= 1;
13461
      else
13462
        GenericValueCheckMessage
13463
          (  HeaderMsg  => " Attribute Syntax Warning ",
13464
             GenericName => " SRTYPE ",
13465
             EntityName => "/ISERDES",
13466
             GenericValue => SRTYPE,
13467
             Unit => "",
13468
             ExpectedValueMsg => " The Legal values for this attribute are ",
13469
             ExpectedGenericValue => " ASYNC or SYNC. ",
13470
             TailMsg => "",
13471
             MsgSeverity => ERROR
13472
         );
13473
      end if;
13474
---------------------------------------------------------------------
13475
 
13476
     AttrSerdes         <= AttrSerdes_var;
13477
     AttrMode           <= AttrMode_var;
13478
     AttrDataRate       <= AttrDataRate_var;
13479
     AttrDataWidth      <= AttrDataWidth_var;
13480
     AttrInterfaceType  <= AttrInterfaceType_var;
13481
     AttrBitslipEnable  <= AttrBitslipEnable_var;
13482
     AttrDdrClkEdge     <= AttrDdrClkEdge_var;
13483
     AttrIobDelay       <= AttrIobDelay_var;
13484
 
13485
     sel1     <= AttrMode_var & AttrDataRate_var;
13486
     selrnk3  <= AttrSerdes_var & AttrBitslipEnable_var & AttrDdrClkEdge_var;
13487
     cntr     <= AttrDataRate_var & AttrDataWidth_var;
13488
 
13489
     wait;
13490
  end process prcs_init;
13491
 
13492
--###################################################################
13493
--#####               SHIFTOUT1 and SHIFTOUT2                   #####
13494
--###################################################################
13495
 
13496
  SHIFTOUT2_zd <= q5rnk1;
13497
  SHIFTOUT1_zd <= q6rnk1;
13498
 
13499
--###################################################################
13500
--#####                     q1rnk1 reg                          #####
13501
--###################################################################
13502
  prcs_Q1_rnk1:process(CLK_dly, GSR_dly, REV_dly, SR_dly)
13503
  variable q1rnk1_var         : std_ulogic := TO_X01(INIT_Q1);
13504
  begin
13505
     if(GSR_dly = '1') then
13506
         q1rnk1_var  :=  TO_X01(INIT_Q1);
13507
     elsif(GSR_dly = '0') then
13508
        case AttrSRtype is
13509
           when 0 =>
13510
           --------------- // async SET/RESET
13511
                   if((SR_dly = '1') and (not ((REV_dly = '1') and (TO_X01(SRVAL_Q1) = '1')))) then
13512
                      q1rnk1_var := TO_X01(SRVAL_Q1);
13513
                   elsif(REV_dly = '1') then
13514
                      q1rnk1_var := not TO_X01(SRVAL_Q1);
13515
                   elsif((SR_dly = '0') and (REV_dly = '0')) then
13516
                      if(ice = '1') then
13517
                         if(rising_edge(CLK_dly)) then
13518
                            q1rnk1_var := datain;
13519
                         end if;
13520
                      end if;
13521
                   end if;
13522
 
13523
           when 1 =>
13524
           --------------- // sync SET/RESET
13525
                   if(rising_edge(CLK_dly)) then
13526
                      if((SR_dly = '1') and (not ((REV_dly = '1') and (TO_X01(SRVAL_Q1) = '1')))) then
13527
                         q1rnk1_var := TO_X01(SRVAL_Q1);
13528
                      Elsif(REV_dly = '1') then
13529
                         q1rnk1_var := not TO_X01(SRVAL_Q1);
13530
                      elsif((SR_dly = '0') and (REV_dly = '0')) then
13531
                         if(ice = '1') then
13532
                            q1rnk1_var := datain;
13533
                         end if;
13534
                      end if;
13535
                   end if;
13536
 
13537
           when others =>
13538
                   null;
13539
 
13540
        end case;
13541
     end if;
13542
 
13543
     q1rnk1  <= q1rnk1_var  after DELAY_FFINP;
13544
 
13545
  end process prcs_Q1_rnk1;
13546
--###################################################################
13547
--#####              q5rnk1, q6rnk1 and q6prnk1 reg             #####
13548
--###################################################################
13549
  prcs_Q5Q6Q6p_rnk1:process(CLK_dly, GSR_dly, SR_dly)
13550
  variable q5rnk1_var         : std_ulogic := TO_X01(INIT_RANK1_PARTIAL(2));
13551
  variable q6rnk1_var         : std_ulogic := TO_X01(INIT_RANK1_PARTIAL(1));
13552
  variable q6prnk1_var        : std_ulogic := TO_X01(INIT_RANK1_PARTIAL(0));
13553
  begin
13554
     if(GSR_dly = '1') then
13555
         q5rnk1_var  := TO_X01(INIT_RANK1_PARTIAL(2));
13556
         q6rnk1_var  := TO_X01(INIT_RANK1_PARTIAL(1));
13557
         q6prnk1_var := TO_X01(INIT_RANK1_PARTIAL(0));
13558
     elsif(GSR_dly = '0') then
13559
        case AttrSRtype is
13560
           when 0 =>
13561
           --------- // async SET/RESET  -- Not full featured FFs
13562
                   if(SR_dly = '1') then
13563
                      q5rnk1_var  := '0';
13564
                      q6rnk1_var  := '0';
13565
                      q6prnk1_var := '0';
13566
                   elsif(SR_dly = '0') then
13567
                      if(rising_edge(CLK_dly)) then
13568
                         q5rnk1_var  := dataq5rnk1;
13569
                         q6rnk1_var  := dataq6rnk1;
13570
                         q6prnk1_var := q6rnk1;
13571
                      end if;
13572
                   end if;
13573
 
13574
           when 1 =>
13575
           --------- // sync SET/RESET  -- Not full featured FFs
13576
                   if(rising_edge(CLK_dly)) then
13577
                      if(SR_dly = '1') then
13578
                         q5rnk1_var  := '0';
13579
                         q6rnk1_var  := '0';
13580
                         q6prnk1_var := '0';
13581
                      elsif(SR_dly = '0') then
13582
                         q5rnk1_var  := dataq5rnk1;
13583
                         q6rnk1_var  := dataq6rnk1;
13584
                         q6prnk1_var := q6rnk1;
13585
                      end if;
13586
                   end if;
13587
 
13588
           when others =>
13589
                   null;
13590
 
13591
        end case;
13592
     end if;
13593
 
13594
     q5rnk1  <= q5rnk1_var  after DELAY_FFINP;
13595
     q6rnk1  <= q6rnk1_var  after DELAY_FFINP;
13596
     q6prnk1 <= q6prnk1_var after DELAY_FFINP;
13597
 
13598
  end process prcs_Q5Q6Q6p_rnk1;
13599
--###################################################################
13600
--#####                     q2nrnk1 reg                          #####
13601
--###################################################################
13602
  prcs_Q2_rnk1:process(CLK_dly, GSR_dly, SR_dly, REV_dly)
13603
  variable q2nrnk1_var         : std_ulogic := TO_X01(INIT_Q2);
13604
  begin
13605
     if(GSR_dly = '1') then
13606
         q2nrnk1_var  := TO_X01(INIT_Q2);
13607
     elsif(GSR_dly = '0') then
13608
        case AttrSRtype is
13609
           when 0 =>
13610
           --------------- // async SET/RESET
13611
                   if((SR_dly = '1') and (not ((REV_dly = '1') and (TO_X01(SRVAL_Q2) = '1')))) then
13612
                      q2nrnk1_var  := TO_X01(SRVAL_Q2);
13613
                   elsif(REV_dly = '1') then
13614
                      q2nrnk1_var  := not TO_X01(SRVAL_Q2);
13615
                   elsif((SR_dly = '0') and (REV_dly = '0')) then
13616
                      if(ice = '1') then
13617
                         if(falling_edge(CLK_dly)) then
13618
                            q2nrnk1_var     := datain;
13619
                         end if;
13620
                      end if;
13621
                   end if;
13622
 
13623
           when 1 =>
13624
           --------------- // sync SET/RESET
13625
                   if(falling_edge(CLK_dly)) then
13626
                      if((SR_dly = '1') and (not ((REV_dly = '1') and (TO_X01(SRVAL_Q2) = '1')))) then
13627
                         q2nrnk1_var  := TO_X01(SRVAL_Q2);
13628
                      elsif(REV_dly = '1') then
13629
                         q2nrnk1_var  := not TO_X01(SRVAL_Q2);
13630
                      elsif((SR_dly = '0') and (REV_dly = '0')) then
13631
                         if(ice = '1') then
13632
                            q2nrnk1_var := datain;
13633
                         end if;
13634
                      end if;
13635
                   end if;
13636
 
13637
           when others =>
13638
                   null;
13639
 
13640
        end case;
13641
     end if;
13642
 
13643
     q2nrnk1  <= q2nrnk1_var after DELAY_FFINP;
13644
 
13645
  end process prcs_Q2_rnk1;
13646
--###################################################################
13647
--#####                       q2prnk1 reg                       #####
13648
--###################################################################
13649
  prcs_Q2p_rnk1:process(q2pmux, GSR_dly, REV_dly, SR_dly)
13650
  variable q2prnk1_var        : std_ulogic := TO_X01(INIT_Q4);
13651
  begin
13652
     if(GSR_dly = '1') then
13653
         q2prnk1_var := TO_X01(INIT_Q4);
13654
     elsif(GSR_dly = '0') then
13655
        case AttrSRtype is
13656
           when 0 =>
13657
           --------------- // async SET/RESET
13658
                   if((SR_dly = '1') and (not ((REV_dly = '1') and (TO_X01(SRVAL_Q4) = '1')))) then
13659
                      q2prnk1_var := TO_X01(SRVAL_Q4);
13660
                   elsif(REV_dly = '1') then
13661
                      q2prnk1_var := not TO_X01(SRVAL_Q4);
13662
                   elsif((SR_dly = '0') and (REV_dly = '0')) then
13663
                      if(ice = '1') then
13664
                         if(rising_edge(q2pmux)) then
13665
                            q2prnk1_var := q2nrnk1;
13666
                         end if;
13667
                      end if;
13668
                   end if;
13669
 
13670
           when 1 =>
13671
           --------------- // sync SET/RESET
13672
                   if(rising_edge(q2pmux)) then
13673
                      if((SR_dly = '1') and (not ((REV_dly = '1') and (TO_X01(SRVAL_Q4) = '1')))) then
13674
                         q2prnk1_var := TO_X01(SRVAL_Q4);
13675
                      elsif(REV_dly = '1') then
13676
                         q2prnk1_var := not TO_X01(SRVAL_Q4);
13677
                      elsif((SR_dly = '0') and (REV_dly = '0')) then
13678
                         if(ice = '1') then
13679
                              q2prnk1_var := q2nrnk1;
13680
                         end if;
13681
                      end if;
13682
                   end if;
13683
 
13684
           when others =>
13685
                   null;
13686
 
13687
        end case;
13688
     end if;
13689
 
13690
     q2prnk1  <= q2prnk1_var after DELAY_FFINP;
13691
 
13692
  end process prcs_Q2p_rnk1;
13693
--###################################################################
13694
--#####                      q1prnk1  reg                       #####
13695
--###################################################################
13696
  prcs_Q1p_rnk1:process(memmux, GSR_dly, REV_dly, SR_dly)
13697
  variable q1prnk1_var        : std_ulogic := TO_X01(INIT_Q3);
13698
  begin
13699
     if(GSR_dly = '1') then
13700
         q1prnk1_var := TO_X01(INIT_Q3);
13701
     elsif(GSR_dly = '0') then
13702
        case AttrSRtype is
13703
           when 0 =>
13704
           --------------- // async SET/RESET
13705
                   if((SR_dly = '1') and (not ((REV_dly = '1') and (TO_X01(SRVAL_Q3) = '1')))) then
13706
                      q1prnk1_var := TO_X01(SRVAL_Q3);
13707
                   elsif(REV_dly = '1') then
13708
                      q1prnk1_var := not TO_X01(SRVAL_Q3);
13709
                   elsif((SR_dly = '0') and (REV_dly = '0')) then
13710
                      if(ice = '1') then
13711
                         if(rising_edge(memmux)) then
13712
                            q1prnk1_var := q1rnk1;
13713
                         end if;
13714
                      end if;
13715
                   end if;
13716
 
13717
 
13718
           when 1 =>
13719
           --------------- // sync SET/RESET
13720
                   if(rising_edge(memmux)) then
13721
                      if((SR_dly = '1') and (not ((REV_dly = '1') and (TO_X01(SRVAL_Q3) = '1')))) then
13722
                         q1prnk1_var := TO_X01(SRVAL_Q3);
13723
                      elsif(REV_dly = '1') then
13724
                         q1prnk1_var := not TO_X01(SRVAL_Q3);
13725
                      elsif((SR_dly = '0') and (REV_dly = '0')) then
13726
                         if(ice = '1') then
13727
                            q1prnk1_var := q1rnk1;
13728
                         end if;
13729
                      end if;
13730
                   end if;
13731
 
13732
           when others =>
13733
                   null;
13734
 
13735
        end case;
13736
     end if;
13737
 
13738
     q1prnk1  <= q1prnk1_var after DELAY_FFINP;
13739
 
13740
  end process prcs_Q1p_rnk1;
13741
--###################################################################
13742
--#####                  q3rnk1 and q4rnk1 reg                  #####
13743
--###################################################################
13744
  prcs_Q3Q4_rnk1:process(memmux, GSR_dly, SR_dly)
13745
  variable q3rnk1_var         : std_ulogic := TO_X01(INIT_RANK1_PARTIAL(4));
13746
  variable q4rnk1_var         : std_ulogic := TO_X01(INIT_RANK1_PARTIAL(3));
13747
  begin
13748
     if(GSR_dly = '1') then
13749
         q3rnk1_var  := TO_X01(INIT_RANK1_PARTIAL(4));
13750
         q4rnk1_var  := TO_X01(INIT_RANK1_PARTIAL(3));
13751
     elsif(GSR_dly = '0') then
13752
        case AttrSRtype is
13753
           when 0 =>
13754
           -------- // async SET/RESET  -- not fully featured FFs
13755
                   if(SR_dly = '1') then
13756
                      q3rnk1_var  := '0';
13757
                      q4rnk1_var  := '0';
13758
                   elsif(SR_dly = '0') then
13759
                      if(rising_edge(memmux)) then
13760
                         q3rnk1_var  := dataq3rnk1;
13761
                         q4rnk1_var  := dataq4rnk1;
13762
                      end if;
13763
                   end if;
13764
 
13765
           when 1 =>
13766
           -------- // sync SET/RESET -- not fully featured FFs
13767
                   if(rising_edge(memmux)) then
13768
                      if(SR_dly = '1') then
13769
                         q3rnk1_var  := '0';
13770
                         q4rnk1_var  := '0';
13771
                      elsif(SR_dly = '0') then
13772
                         q3rnk1_var  := dataq3rnk1;
13773
                         q4rnk1_var  := dataq4rnk1;
13774
                      end if;
13775
                   end if;
13776
 
13777
           when others =>
13778
                   null;
13779
 
13780
        end case;
13781
     end if;
13782
 
13783
     q3rnk1   <= q3rnk1_var after DELAY_FFINP;
13784
     q4rnk1   <= q4rnk1_var after DELAY_FFINP;
13785
 
13786
  end process prcs_Q3Q4_rnk1;
13787
--###################################################################
13788
--#####        clock mux --  oclkmux with delay element         #####
13789
--###################################################################
13790
--  prcs_oclkmux:process(OCLK_dly)
13791
--  begin
13792
--     case AttrOclkDelay is
13793
--           when '0' =>
13794
--                    oclkmux <= OCLK_dly after DELAY_MXINP1;
13795
--           when '1' =>
13796
--                    oclkmux <= OCLK_dly after DELAY_OCLKDLY;
13797
--           when others =>
13798
--                    oclkmux <= OCLK_dly after DELAY_MXINP1;
13799
--     end case;
13800
--  end process prcs_oclkmux;
13801
--
13802
--
13803
--
13804
--///////////////////////////////////////////////////////////////////
13805
--// Mux elements for the 1st Rank
13806
--///////////////////////////////////////////////////////////////////
13807
--###################################################################
13808
--#####              memmux -- 4 clock muxes in first rank      #####
13809
--###################################################################
13810
  prcs_memmux:process(CLK_dly, OCLK_dly)
13811
  begin
13812
     case AttrInterfaceType is
13813
           when '0' =>
13814
                    memmux <= OCLK_dly after DELAY_MXINP1;
13815
           when '1' =>
13816
                    memmux <= CLK_dly after DELAY_MXINP1;
13817
           when others =>
13818
                    memmux <= OCLK_dly after DELAY_MXINP1;
13819
     end case;
13820
  end process prcs_memmux;
13821
 
13822
--###################################################################
13823
--#####      q2pmux -- Optional inverter for q2p (4th flop in rank1)
13824
--###################################################################
13825
  prcs_q2pmux:process(memmux)
13826
  begin
13827
     case AttrInterfaceType is
13828
           when '0' =>
13829
                    q2pmux <= not memmux after DELAY_MXINP1;
13830
           when '1' =>
13831
                    q2pmux <= memmux after DELAY_MXINP1;
13832
           when others =>
13833
                    q2pmux <= memmux after DELAY_MXINP1;
13834
     end case;
13835
  end process prcs_q2pmux;
13836
--###################################################################
13837
--#####                data input muxes for q3q4  and q5q6      #####
13838
--###################################################################
13839
  prcs_Q3Q4_mux:process(q1prnk1, q2prnk1, q3rnk1, SHIFTIN1_dly, SHIFTIN2_dly)
13840
  begin
13841
     case sel1 is
13842
           when "00" =>
13843
                    dataq3rnk1 <= q1prnk1 after DELAY_MXINP1;
13844
                    dataq4rnk1 <= q2prnk1 after DELAY_MXINP1;
13845
           when "01" =>
13846
                    dataq3rnk1 <= q1prnk1 after DELAY_MXINP1;
13847
                    dataq4rnk1 <= q3rnk1  after DELAY_MXINP1;
13848
           when "10" =>
13849
                    dataq3rnk1 <= SHIFTIN2_dly after DELAY_MXINP1;
13850
                    dataq4rnk1 <= SHIFTIN1_dly after DELAY_MXINP1;
13851
           when "11" =>
13852
                    dataq3rnk1 <= SHIFTIN1_dly after DELAY_MXINP1;
13853
                    dataq4rnk1 <= q3rnk1   after DELAY_MXINP1;
13854
           when others =>
13855
                    dataq3rnk1 <= q1prnk1 after DELAY_MXINP1;
13856
                    dataq4rnk1 <= q2prnk1 after DELAY_MXINP1;
13857
     end case;
13858
 
13859
  end process prcs_Q3Q4_mux;
13860
----------------------------------------------------------------------
13861
  prcs_Q5Q6_mux:process(q3rnk1, q4rnk1, q5rnk1)
13862
  begin
13863
     case AttrDataRate is
13864
           when '0' =>
13865
                    dataq5rnk1 <= q3rnk1 after DELAY_MXINP1;
13866
                    dataq6rnk1 <= q4rnk1 after DELAY_MXINP1;
13867
           when '1' =>
13868
                    dataq5rnk1 <= q4rnk1 after DELAY_MXINP1;
13869
                    dataq6rnk1 <= q5rnk1 after DELAY_MXINP1;
13870
           when others =>
13871
                    dataq5rnk1 <= q4rnk1 after DELAY_MXINP1;
13872
                    dataq6rnk1 <= q5rnk1 after DELAY_MXINP1;
13873
     end case;
13874
  end process prcs_Q5Q6_mux;
13875
 
13876
 
13877
 
13878
---////////////////////////////////////////////////////////////////////
13879
---                       2nd rank of registors
13880
---////////////////////////////////////////////////////////////////////
13881
 
13882
--###################################################################
13883
--#####    clkdivmux to choose between clkdiv_int or CLKDIV     #####
13884
--###################################################################
13885
  prcs_clkdivmux:process(clkdiv_int, CLKDIV_dly)
13886
  begin
13887
     case AttrBitslipEnable is
13888
           when '0' =>
13889
                    clkdivmux <= CLKDIV_dly after DELAY_MXINP1;
13890
           when '1' =>
13891
                    clkdivmux <= clkdiv_int after DELAY_MXINP1;
13892
           when others =>
13893
                    clkdivmux <= CLKDIV_dly after DELAY_MXINP1;
13894
     end case;
13895
  end process prcs_clkdivmux;
13896
 
13897
--###################################################################
13898
--#####  q1rnk2, q2rnk2, q3rnk2,q4rnk2 ,q5rnk2 and q6rnk2 reg   #####
13899
--###################################################################
13900
  prcs_Q1Q2Q3Q4Q5Q6_rnk2:process(clkdivmux, GSR_dly, SR_dly)
13901
  variable q1rnk2_var         : std_ulogic := TO_X01(INIT_RANK2(0));
13902
  variable q2rnk2_var         : std_ulogic := TO_X01(INIT_RANK2(1));
13903
  variable q3rnk2_var         : std_ulogic := TO_X01(INIT_RANK2(2));
13904
  variable q4rnk2_var         : std_ulogic := TO_X01(INIT_RANK2(3));
13905
  variable q5rnk2_var         : std_ulogic := TO_X01(INIT_RANK2(4));
13906
  variable q6rnk2_var         : std_ulogic := TO_X01(INIT_RANK2(5));
13907
  begin
13908
     if(GSR_dly = '1') then
13909
         q1rnk2_var := TO_X01(INIT_RANK2(0));
13910
         q2rnk2_var := TO_X01(INIT_RANK2(1));
13911
         q3rnk2_var := TO_X01(INIT_RANK2(2));
13912
         q4rnk2_var := TO_X01(INIT_RANK2(3));
13913
         q5rnk2_var := TO_X01(INIT_RANK2(4));
13914
         q6rnk2_var := TO_X01(INIT_RANK2(5));
13915
     elsif(GSR_dly = '0') then
13916
        case AttrSRtype is
13917
           when 0 =>
13918
           --------------- // async SET/RESET
13919
                   if(SR_dly = '1') then
13920
                      q1rnk2_var := '0';
13921
                      q2rnk2_var := '0';
13922
                      q3rnk2_var := '0';
13923
                      q4rnk2_var := '0';
13924
                      q5rnk2_var := '0';
13925
                      q6rnk2_var := '0';
13926
                   elsif(SR_dly = '0') then
13927
                       if(rising_edge(clkdivmux)) then
13928
                           q1rnk2_var := dataq1rnk2;
13929
                           q2rnk2_var := dataq2rnk2;
13930
                           q3rnk2_var := dataq3rnk2;
13931
                           q4rnk2_var := dataq4rnk2;
13932
                           q5rnk2_var := dataq5rnk2;
13933
                           q6rnk2_var := dataq6rnk2;
13934
                       end if;
13935
                   end if;
13936
 
13937
           when 1 =>
13938
           --------------- // sync SET/RESET
13939
                   if(rising_edge(clkdivmux)) then
13940
                      if(SR_dly = '1') then
13941
                         q1rnk2_var := '0';
13942
                         q2rnk2_var := '0';
13943
                         q3rnk2_var := '0';
13944
                         q4rnk2_var := '0';
13945
                         q5rnk2_var := '0';
13946
                         q6rnk2_var := '0';
13947
                      elsif(SR_dly = '0') then
13948
                         q1rnk2_var := dataq1rnk2;
13949
                         q2rnk2_var := dataq2rnk2;
13950
                         q3rnk2_var := dataq3rnk2;
13951
                         q4rnk2_var := dataq4rnk2;
13952
                         q5rnk2_var := dataq5rnk2;
13953
                         q6rnk2_var := dataq6rnk2;
13954
                      end if;
13955
                   end if;
13956
           when others =>
13957
                   null;
13958
        end case;
13959
     end if;
13960
 
13961
     q1rnk2  <= q1rnk2_var after DELAY_FFINP;
13962
     q2rnk2  <= q2rnk2_var after DELAY_FFINP;
13963
     q3rnk2  <= q3rnk2_var after DELAY_FFINP;
13964
     q4rnk2  <= q4rnk2_var after DELAY_FFINP;
13965
     q5rnk2  <= q5rnk2_var after DELAY_FFINP;
13966
     q6rnk2  <= q6rnk2_var after DELAY_FFINP;
13967
 
13968
  end process prcs_Q1Q2Q3Q4Q5Q6_rnk2;
13969
 
13970
--###################################################################
13971
--#####                    update bitslip mux                   #####
13972
--###################################################################
13973
 
13974
  bsmux  <= AttrBitslipEnable & AttrDataRate & muxc;
13975
 
13976
--###################################################################
13977
--#####    Data mux for 2nd rank of registers                  ######
13978
--###################################################################
13979
  prcs_Q1Q2Q3Q4Q5Q6_rnk2_mux:process(bsmux, q1rnk1, q1prnk1, q2prnk1,
13980
                           q3rnk1, q4rnk1, q5rnk1, q6rnk1, q6prnk1)
13981
  begin
13982
     case bsmux is
13983
        when "000" | "001" =>
13984
                 dataq1rnk2 <= q2prnk1 after DELAY_MXINP2;
13985
                 dataq2rnk2 <= q1prnk1 after DELAY_MXINP2;
13986
                 dataq3rnk2 <= q4rnk1  after DELAY_MXINP2;
13987
                 dataq4rnk2 <= q3rnk1  after DELAY_MXINP2;
13988
                 dataq5rnk2 <= q6rnk1  after DELAY_MXINP2;
13989
                 dataq6rnk2 <= q5rnk1  after DELAY_MXINP2;
13990
        when "100"  =>
13991
                 dataq1rnk2 <= q2prnk1 after DELAY_MXINP2;
13992
                 dataq2rnk2 <= q1prnk1 after DELAY_MXINP2;
13993
                 dataq3rnk2 <= q4rnk1  after DELAY_MXINP2;
13994
                 dataq4rnk2 <= q3rnk1  after DELAY_MXINP2;
13995
                 dataq5rnk2 <= q6rnk1  after DELAY_MXINP2;
13996
                 dataq6rnk2 <= q5rnk1  after DELAY_MXINP2;
13997
        when "101"  =>
13998
                 dataq1rnk2 <= q1prnk1 after DELAY_MXINP2;
13999
                 dataq2rnk2 <= q4rnk1  after DELAY_MXINP2;
14000
                 dataq3rnk2 <= q3rnk1  after DELAY_MXINP2;
14001
                 dataq4rnk2 <= q6rnk1  after DELAY_MXINP2;
14002
                 dataq5rnk2 <= q5rnk1  after DELAY_MXINP2;
14003
                 dataq6rnk2 <= q6prnk1 after DELAY_MXINP2;
14004
        when "010" | "011" | "110" | "111" =>
14005
                 dataq1rnk2 <= q1rnk1  after DELAY_MXINP2;
14006
                 dataq2rnk2 <= q1prnk1 after DELAY_MXINP2;
14007
                 dataq3rnk2 <= q3rnk1  after DELAY_MXINP2;
14008
                 dataq4rnk2 <= q4rnk1  after DELAY_MXINP2;
14009
                 dataq5rnk2 <= q5rnk1  after DELAY_MXINP2;
14010
                 dataq6rnk2 <= q6rnk1  after DELAY_MXINP2;
14011
        when others =>
14012
                 dataq1rnk2 <= q2prnk1 after DELAY_MXINP2;
14013
                 dataq2rnk2 <= q1prnk1 after DELAY_MXINP2;
14014
                 dataq3rnk2 <= q4rnk1  after DELAY_MXINP2;
14015
                 dataq4rnk2 <= q3rnk1  after DELAY_MXINP2;
14016
                 dataq5rnk2 <= q6rnk1  after DELAY_MXINP2;
14017
                 dataq6rnk2 <= q5rnk1  after DELAY_MXINP2;
14018
     end case;
14019
  end process prcs_Q1Q2Q3Q4Q5Q6_rnk2_mux;
14020
 
14021
---////////////////////////////////////////////////////////////////////
14022
---                       3rd rank of registors
14023
---////////////////////////////////////////////////////////////////////
14024
 
14025
--###################################################################
14026
--#####  q1rnk3, q2rnk3, q3rnk3, q4rnk3, q5rnk3 and q6rnk3 reg   #####
14027
--###################################################################
14028
  prcs_Q1Q2Q3Q4Q5Q6_rnk3:process(CLKDIV_dly, GSR_dly, SR_dly)
14029
  variable q1rnk3_var         : std_ulogic := TO_X01(INIT_RANK3(0));
14030
  variable q2rnk3_var         : std_ulogic := TO_X01(INIT_RANK3(1));
14031
  variable q3rnk3_var         : std_ulogic := TO_X01(INIT_RANK3(2));
14032
  variable q4rnk3_var         : std_ulogic := TO_X01(INIT_RANK3(3));
14033
  variable q5rnk3_var         : std_ulogic := TO_X01(INIT_RANK3(4));
14034
  variable q6rnk3_var         : std_ulogic := TO_X01(INIT_RANK3(5));
14035
  begin
14036
     if(GSR_dly = '1') then
14037
         q1rnk3_var := TO_X01(INIT_RANK3(0));
14038
         q2rnk3_var := TO_X01(INIT_RANK3(1));
14039
         q3rnk3_var := TO_X01(INIT_RANK3(2));
14040
         q4rnk3_var := TO_X01(INIT_RANK3(3));
14041
         q5rnk3_var := TO_X01(INIT_RANK3(4));
14042
         q6rnk3_var := TO_X01(INIT_RANK3(5));
14043
     elsif(GSR_dly = '0') then
14044
        case AttrSRtype is
14045
           when 0 =>
14046
           --------------- // async SET/RESET
14047
                   if(SR_dly = '1') then
14048
                      q1rnk3_var := '0';
14049
                      q2rnk3_var := '0';
14050
                      q3rnk3_var := '0';
14051
                      q4rnk3_var := '0';
14052
                      q5rnk3_var := '0';
14053
                      q6rnk3_var := '0';
14054
                   elsif(SR_dly = '0') then
14055
                       if(rising_edge(CLKDIV_dly)) then
14056
                           q1rnk3_var := q1rnk2;
14057
                           q2rnk3_var := q2rnk2;
14058
                           q3rnk3_var := q3rnk2;
14059
                           q4rnk3_var := q4rnk2;
14060
                           q5rnk3_var := q5rnk2;
14061
                           q6rnk3_var := q6rnk2;
14062
                        end if;
14063
                   end if;
14064
 
14065
           when 1 =>
14066
           --------------- // sync SET/RESET
14067
                   if(rising_edge(CLKDIV_dly)) then
14068
                      if(SR_dly = '1') then
14069
                         q1rnk3_var := '0';
14070
                         q2rnk3_var := '0';
14071
                         q3rnk3_var := '0';
14072
                         q4rnk3_var := '0';
14073
                         q5rnk3_var := '0';
14074
                         q6rnk3_var := '0';
14075
                      elsif(SR_dly = '0') then
14076
                         q1rnk3_var := q1rnk2;
14077
                         q2rnk3_var := q2rnk2;
14078
                         q3rnk3_var := q3rnk2;
14079
                         q4rnk3_var := q4rnk2;
14080
                         q5rnk3_var := q5rnk2;
14081
                         q6rnk3_var := q6rnk2;
14082
                      end if;
14083
                   end if;
14084
           when others =>
14085
                   null;
14086
        end case;
14087
     end if;
14088
 
14089
     q1rnk3  <= q1rnk3_var after DELAY_FFINP;
14090
     q2rnk3  <= q2rnk3_var after DELAY_FFINP;
14091
     q3rnk3  <= q3rnk3_var after DELAY_FFINP;
14092
     q4rnk3  <= q4rnk3_var after DELAY_FFINP;
14093
     q5rnk3  <= q5rnk3_var after DELAY_FFINP;
14094
     q6rnk3  <= q6rnk3_var after DELAY_FFINP;
14095
 
14096
  end process prcs_Q1Q2Q3Q4Q5Q6_rnk3;
14097
 
14098
---////////////////////////////////////////////////////////////////////
14099
---                       Outputs
14100
---////////////////////////////////////////////////////////////////////
14101
  prcs_Q1Q2_rnk3_mux:process(q1rnk1, q1prnk1, q1rnk2, q1rnk3,
14102
                           q2nrnk1, q2prnk1, q2rnk2, q2rnk3)
14103
  begin
14104
     case selrnk3 is
14105
        when "0000" | "0100" | "0X00" =>
14106
                 Q1_zd <= q1prnk1 after DELAY_MXINP1;
14107
                 Q2_zd <= q2prnk1 after DELAY_MXINP1;
14108
        when "0001" | "0101" | "0X01" =>
14109
                 Q1_zd <= q1rnk1  after DELAY_MXINP1;
14110
                 Q2_zd <= q2prnk1 after DELAY_MXINP1;
14111
        when "0010" | "0110" | "0X10" =>
14112
                 Q1_zd <= q1rnk1  after DELAY_MXINP1;
14113
                 Q2_zd <= q2nrnk1 after DELAY_MXINP1;
14114
        when "1000" | "1001" | "1010" | "1011" | "10X0" | "10X1" |
14115
             "100X" | "101X" | "10XX" =>
14116
                 Q1_zd <= q1rnk2 after DELAY_MXINP1;
14117
                 Q2_zd <= q2rnk2 after DELAY_MXINP1;
14118
        when "1100" | "1101" | "1110" | "1111" | "11X0" | "11X1" |
14119
             "110X" | "111X" | "11XX" =>
14120
                 Q1_zd <= q1rnk3 after DELAY_MXINP1;
14121
                 Q2_zd <= q2rnk3 after DELAY_MXINP1;
14122
        when others =>
14123
                 Q1_zd <= q1rnk2 after DELAY_MXINP1;
14124
                 Q2_zd <= q2rnk2 after DELAY_MXINP1;
14125
     end case;
14126
  end process prcs_Q1Q2_rnk3_mux;
14127
--------------------------------------------------------------------
14128
  prcs_Q3Q4Q5Q6_rnk3_mux:process(q3rnk2, q3rnk3, q4rnk2, q4rnk3,
14129
                                 q5rnk2, q5rnk3, q6rnk2, q6rnk3)
14130
  begin
14131
     case AttrBitslipEnable is
14132
        when '0'  =>
14133
                 Q3_zd <= q3rnk2 after DELAY_MXINP1;
14134
                 Q4_zd <= q4rnk2 after DELAY_MXINP1;
14135
                 Q5_zd <= q5rnk2 after DELAY_MXINP1;
14136
                 Q6_zd <= q6rnk2 after DELAY_MXINP1;
14137
        when '1'  =>
14138
                 Q3_zd <= q3rnk3 after DELAY_MXINP1;
14139
                 Q4_zd <= q4rnk3 after DELAY_MXINP1;
14140
                 Q5_zd <= q5rnk3 after DELAY_MXINP1;
14141
                 Q6_zd <= q6rnk3 after DELAY_MXINP1;
14142
        when others =>
14143
                 Q3_zd <= q3rnk2 after DELAY_MXINP1;
14144
                 Q4_zd <= q4rnk2 after DELAY_MXINP1;
14145
                 Q5_zd <= q5rnk2 after DELAY_MXINP1;
14146
                 Q6_zd <= q6rnk2 after DELAY_MXINP1;
14147
     end case;
14148
  end process prcs_Q3Q4Q5Q6_rnk3_mux;
14149
----------------------------------------------------------------------
14150
-----------    Inverted CLK  -----------------------------------------
14151
----------------------------------------------------------------------
14152
 
14153
  CLKN_dly <= not CLK_dly;
14154
 
14155
----------------------------------------------------------------------
14156
-----------    Instant BSCNTRL  --------------------------------------
14157
----------------------------------------------------------------------
14158
  INST_BSCNTRL : BSCNTRL
14159
  generic map (
14160
      SRTYPE => SRTYPE,
14161
      INIT_BITSLIPCNT => INIT_BITSLIPCNT
14162
     )
14163
  port map (
14164
      CLKDIV_INT => clkdiv_int,
14165
      MUXC       => muxc,
14166
 
14167
      BITSLIP    => BITSLIP_dly,
14168
      C23        => c23,
14169
      C45        => c45,
14170
      C67        => c67,
14171
      CLK        => CLKN_dly,
14172
      CLKDIV     => CLKDIV_dly,
14173
      DATA_RATE  => AttrDataRate,
14174
      GSR        => GSR_dly,
14175
      R          => SR_dly,
14176
      SEL        => sel
14177
      );
14178
 
14179
--###################################################################
14180
--#####           Set value of the counter in BSCNTRL           #####
14181
--###################################################################
14182
  prcs_bscntrl_cntr:process
14183
  begin
14184
     wait for 10 ps;
14185
     case cntr is
14186
        when "00100" =>
14187
                 c23<='0'; c45<='0'; c67<='0'; sel<="00";
14188
        when "00110" =>
14189
                 c23<='1'; c45<='0'; c67<='0'; sel<="00";
14190
        when "01000" =>
14191
                 c23<='0'; c45<='0'; c67<='0'; sel<="01";
14192
        when "01010" =>
14193
                 c23<='0'; c45<='1'; c67<='0'; sel<="01";
14194
        when "10010" =>
14195
                 c23<='0'; c45<='0'; c67<='0'; sel<="00";
14196
        when "10011" =>
14197
                 c23<='1'; c45<='0'; c67<='0'; sel<="00";
14198
        when "10100" =>
14199
                 c23<='0'; c45<='0'; c67<='0'; sel<="01";
14200
        when "10101" =>
14201
                 c23<='0'; c45<='1'; c67<='0'; sel<="01";
14202
        when "10110" =>
14203
                 c23<='0'; c45<='0'; c67<='0'; sel<="10";
14204
        when "10111" =>
14205
                 c23<='0'; c45<='0'; c67<='1'; sel<="10";
14206
        when "11000" =>
14207
                 c23<='0'; c45<='0'; c67<='0'; sel<="11";
14208
        when others =>
14209
                assert FALSE
14210
                report "Error : DATA_WIDTH or DATA_RATE has illegal values."
14211
                severity failure;
14212
     end case;
14213
     wait on cntr, c23, c45, c67, sel;
14214
 
14215
  end process prcs_bscntrl_cntr;
14216
 
14217
----------------------------------------------------------------------
14218
-----------    Instant Clock Enable Circuit  -------------------------
14219
----------------------------------------------------------------------
14220
  INST_ICE : ICE_MODULE
14221
  generic map (
14222
      SRTYPE => SRTYPE,
14223
      INIT_CE => INIT_CE
14224
     )
14225
  port map (
14226
      ICE       => ice,
14227
 
14228
      CE1       => CE1_dly,
14229
      CE2       => CE2_dly,
14230
      GSR       => GSR_dly,
14231
      NUM_CE    => AttrNumCe,
14232
      CLKDIV    => CLKDIV_dly,
14233
      R         => SR_dly
14234
      );
14235
----------------------------------------------------------------------
14236
-----------    Instant IDELAY  ---------------------------------------
14237
----------------------------------------------------------------------
14238
  INST_IDELAY : IDELAY
14239
  generic map (
14240
      IOBDELAY_VALUE => IOBDELAY_VALUE,
14241
      IOBDELAY_TYPE  => IOBDELAY_TYPE
14242
     )
14243
  port map (
14244
      O         => idelay_out,
14245
 
14246
      C         => CLKDIV_dly,
14247
      CE        => DLYCE_dly,
14248
 
14249
      I         => D_dly,
14250
      INC       => DLYINC_dly,
14251
      RST       => DLYRST_dly
14252
      );
14253
 
14254
--###################################################################
14255
--#####           IOBDELAY -- Delay input Data                  #####
14256
--###################################################################
14257
  prcs_d_delay:process(D_dly, idelay_out)
14258
  begin
14259
     case AttrIobDelay is
14260
        when 0 =>
14261
               O_zd   <= D_dly;
14262
               datain <= D_dly;
14263
        when 1 =>
14264
               O_zd   <= idelay_out;
14265
               datain <= D_dly;
14266
        when 2 =>
14267
               O_zd   <= D_dly;
14268
               datain <= idelay_out;
14269
        when 3 =>
14270
               O_zd   <= idelay_out;
14271
               datain <= idelay_out;
14272
        when others =>
14273
               null;
14274
     end case;
14275
  end process prcs_d_delay;
14276
 
14277
--####################################################################
14278
 
14279
--####################################################################
14280
--#####                         OUTPUT                           #####
14281
--####################################################################
14282
  prcs_output:process(O_zd, Q1_zd, Q2_zd, Q3_zd, Q4_zd, Q5_zd, Q6_zd,
14283
                      SHIFTOUT1_zd, SHIFTOUT2_zd)
14284
  begin
14285
      O  <= O_zd;
14286
      Q1 <= Q1_zd after SYNC_PATH_DELAY;
14287
      Q2 <= Q2_zd after SYNC_PATH_DELAY;
14288
      Q3 <= Q3_zd after SYNC_PATH_DELAY;
14289
      Q4 <= Q4_zd after SYNC_PATH_DELAY;
14290
      Q5 <= Q5_zd after SYNC_PATH_DELAY;
14291
      Q6 <= Q6_zd after SYNC_PATH_DELAY;
14292
      SHIFTOUT1 <= SHIFTOUT1_zd after SYNC_PATH_DELAY;
14293
      SHIFTOUT2 <= SHIFTOUT2_zd after SYNC_PATH_DELAY;
14294
  end process prcs_output;
14295
--####################################################################
14296
 
14297
 
14298
end ISERDES_V;
14299
 
14300
 
14301
 
14302
library IEEE;
14303
use IEEE.STD_LOGIC_1164.all;
14304
 
14305
library UNISIM;
14306
use UNISIM.VPKG.all;
14307
 
14308
entity RAM16X1S is
14309
 
14310
  generic (
14311
    INIT : bit_vector(15 downto 0) := X"0000"
14312
    );
14313
 
14314
  port (
14315
    O : out std_ulogic;
14316
 
14317
    A0   : in std_ulogic;
14318
    A1   : in std_ulogic;
14319
    A2   : in std_ulogic;
14320
    A3   : in std_ulogic;
14321
    D    : in std_ulogic;
14322
    WCLK : in std_ulogic;
14323
    WE   : in std_ulogic
14324
    );
14325
end RAM16X1S;
14326
 
14327
architecture RAM16X1S_V of RAM16X1S is
14328
  signal MEM : std_logic_vector(16 downto 0) := ('X' & To_StdLogicVector(INIT));
14329
 
14330
begin
14331
  VITALReadBehavior  : process(A0, A1, A2, A3, MEM)
14332
    variable Index   : integer := 16;
14333
    variable Address : std_logic_vector(3 downto 0);
14334
  begin
14335
    Address                    := (A3, A2, A1, A0);
14336
    Index                      := SLV_TO_INT(SLV => Address);
14337
    O <= MEM(Index);
14338
  end process VITALReadBehavior;
14339
 
14340
  VITALWriteBehavior : process(WCLK)
14341
    variable Index   : integer := 16;
14342
    variable Address : std_logic_vector (3 downto 0);
14343
  begin
14344
    if (rising_edge(WCLK)) then
14345
      if (WE = '1') then
14346
        Address                := (A3, A2, A1, A0);
14347
        Index                  := SLV_TO_INT(SLV => Address);
14348
        MEM(Index) <= D after 100 ps;
14349
      end if;
14350
    end if;
14351
  end process VITALWriteBehavior;
14352
end RAM16X1S_V;
14353
 
14354
library IEEE;
14355
use IEEE.STD_LOGIC_1164.all;
14356
 
14357
library UNISIM;
14358
use UNISIM.VPKG.all;
14359
 
14360
entity RAM16X1D is
14361
 
14362
  generic (
14363
       INIT : bit_vector(15 downto 0) := X"0000"
14364
  );
14365
 
14366
  port (
14367
        DPO   : out std_ulogic;
14368
        SPO   : out std_ulogic;
14369
 
14370
        A0    : in std_ulogic;
14371
        A1    : in std_ulogic;
14372
        A2    : in std_ulogic;
14373
        A3    : in std_ulogic;
14374
        D     : in std_ulogic;
14375
        DPRA0 : in std_ulogic;
14376
        DPRA1 : in std_ulogic;
14377
        DPRA2 : in std_ulogic;
14378
        DPRA3 : in std_ulogic;
14379
        WCLK  : in std_ulogic;
14380
        WE    : in std_ulogic
14381
       );
14382
end RAM16X1D;
14383
 
14384
architecture RAM16X1D_V of RAM16X1D is
14385
  signal MEM       : std_logic_vector( 16 downto 0 ) := ('X' & To_StdLogicVector(INIT) );
14386
 
14387
begin
14388
 VITALReadBehavior : process(A0, A1, A2, A3, DPRA3, DPRA2, DPRA1, DPRA0, MEM)
14389
       Variable Index_SP   : integer  := 16 ;
14390
       Variable Index_DP   : integer  := 16 ;
14391
 
14392
  begin
14393
    Index_SP := DECODE_ADDR4(ADDRESS => (A3, A2, A1, A0));
14394
    Index_DP := DECODE_ADDR4(ADDRESS => (DPRA3, DPRA2, DPRA1, DPRA0));
14395
    SPO <= MEM(Index_SP);
14396
    DPO <= MEM(Index_DP);
14397
 
14398
  end process VITALReadBehavior;
14399
 
14400
 VITALWriteBehavior : process(WCLK)
14401
    variable Index_SP  : integer := 16;
14402
    variable Index_DP  : integer := 16;
14403
  begin
14404
    Index_SP := DECODE_ADDR4(ADDRESS => (A3, A2, A1, A0));
14405
    if ((WE = '1') and (wclk'event) and (wclk'last_value = '0') and (wclk = '1')) then
14406
      MEM(Index_SP) <= D after 100 ps;
14407
    end if;
14408
  end process VITALWriteBehavior;
14409
end RAM16X1D_V;
14410
 
14411
library IEEE;
14412
use IEEE.STD_LOGIC_1164.all;
14413
 
14414
library UNISIM;
14415
use UNISIM.VPKG.all;
14416
 
14417
entity ROM32X1 is
14418
  generic (
14419
    INIT : bit_vector := X"00000000"
14420
    );
14421
 
14422
  port (
14423
    O : out std_ulogic;
14424
 
14425
    A0 : in std_ulogic;
14426
    A1 : in std_ulogic;
14427
    A2 : in std_ulogic;
14428
    A3 : in std_ulogic;
14429
    A4 : in std_ulogic
14430
    );
14431
end ROM32X1;
14432
 
14433
architecture ROM32X1_V of ROM32X1 is
14434
begin
14435
  VITALBehavior         : process (A4, A3, A2, A1, A0)
14436
    variable INIT_BITS  : std_logic_vector(31 downto 0) := To_StdLogicVector(INIT);
14437
    variable MEM        : std_logic_vector( 32 downto 0 );
14438
    variable Index      : integer                       := 32;
14439
    variable FIRST_TIME : boolean                       := true;
14440
 
14441
  begin
14442
    if (FIRST_TIME = true) then
14443
      MEM        := ('X' & INIT_BITS(31 downto 0));
14444
      FIRST_TIME := false;
14445
    end if;
14446
    Index        := DECODE_ADDR5(ADDRESS => (A4, A3, A2, A1, A0));
14447
    O <= MEM(Index);
14448
  end process VITALBehavior;
14449
end ROM32X1_V;
14450
 
14451
library IEEE;
14452
use IEEE.std_logic_1164.all;
14453
 
14454
library unisim;
14455
use unisim.Vpkg.all;
14456
 
14457
entity ROM64X1 is
14458
 
14459
  generic (
14460
    INIT : bit_vector := X"0000000000000000"
14461
    );
14462
 
14463
  port (
14464
    O  : out std_ulogic;
14465
 
14466
    A0 : in std_ulogic;
14467
    A1 : in std_ulogic;
14468
    A2 : in std_ulogic;
14469
    A3 : in std_ulogic;
14470
    A4 : in std_ulogic;
14471
    A5 : in std_ulogic
14472
    );
14473
end ROM64X1;
14474
 
14475
architecture ROM64X1_V of ROM64X1 is
14476
begin
14477
  VITALBehavior         : process (A5, A4, A3, A2, A1, A0)
14478
    variable INIT_BITS  : std_logic_vector(63 downto 0) := To_StdLogicVector(INIT);
14479
    variable MEM        : std_logic_vector( 64 downto 0 );
14480
    variable Index      : integer := 64;
14481
    variable Raddress   : std_logic_vector (5 downto 0);
14482
    variable FIRST_TIME : boolean := true;
14483
 
14484
  begin
14485
    if (FIRST_TIME = true) then
14486
      MEM        := ('X' & INIT_BITS(63 downto 0));
14487
      FIRST_TIME := false;
14488
    end if;
14489
    Raddress     := (A5, A4, A3, A2, A1, A0);
14490
    Index        := SLV_TO_INT(SLV => Raddress);
14491
    O <= MEM(Index);
14492
  end process VITALBehavior;
14493
end ROM64X1_V;
14494
 
14495
library IEEE;
14496
use IEEE.STD_LOGIC_1164.all;
14497
--use IEEE.STD_LOGIC_SIGNED.all;
14498
--use IEEE.STD_LOGIC_ARITH.all;
14499
library grlib;
14500
use grlib.stdlib.all;
14501
library STD;
14502
use STD.TEXTIO.all;
14503
 
14504
 
14505
library unisim;
14506
use unisim.vpkg.all;
14507
 
14508
entity DSP48 is
14509
 
14510
  generic(
14511
 
14512
        AREG            : integer       := 1;
14513
        B_INPUT         : string        := "DIRECT";
14514
        BREG            : integer       := 1;
14515
        CARRYINREG      : integer       := 1;
14516
        CARRYINSELREG   : integer       := 1;
14517
        CREG            : integer       := 1;
14518
        LEGACY_MODE     : string        := "MULT18X18S";
14519
        MREG            : integer       := 1;
14520
        OPMODEREG       : integer       := 1;
14521
        PREG            : integer       := 1;
14522
        SUBTRACTREG     : integer       := 1
14523
        );
14524
 
14525
  port(
14526
        BCOUT                   : out std_logic_vector(17 downto 0);
14527
        P                       : out std_logic_vector(47 downto 0);
14528
        PCOUT                   : out std_logic_vector(47 downto 0);
14529
 
14530
        A                       : in  std_logic_vector(17 downto 0);
14531
        B                       : in  std_logic_vector(17 downto 0);
14532
        BCIN                    : in  std_logic_vector(17 downto 0);
14533
        C                       : in  std_logic_vector(47 downto 0);
14534
        CARRYIN                 : in  std_ulogic;
14535
        CARRYINSEL              : in  std_logic_vector(1 downto 0);
14536
        CEA                     : in  std_ulogic;
14537
        CEB                     : in  std_ulogic;
14538
        CEC                     : in  std_ulogic;
14539
        CECARRYIN               : in  std_ulogic;
14540
        CECINSUB                : in  std_ulogic;
14541
        CECTRL                  : in  std_ulogic;
14542
        CEM                     : in  std_ulogic;
14543
        CEP                     : in  std_ulogic;
14544
        CLK                     : in  std_ulogic;
14545
        OPMODE                  : in  std_logic_vector(6 downto 0);
14546
        PCIN                    : in  std_logic_vector(47 downto 0);
14547
        RSTA                    : in  std_ulogic;
14548
        RSTB                    : in  std_ulogic;
14549
        RSTC                    : in  std_ulogic;
14550
        RSTCARRYIN              : in  std_ulogic;
14551
        RSTCTRL                 : in  std_ulogic;
14552
        RSTM                    : in  std_ulogic;
14553
        RSTP                    : in  std_ulogic;
14554
        SUBTRACT                : in  std_ulogic
14555
      );
14556
 
14557
end DSP48;
14558
 
14559
-- architecture body                    --
14560
 
14561
architecture DSP48_V of DSP48 is
14562
 
14563
    procedure invalid_opmode_preg_msg( OPMODE : IN string ;
14564
                                   CARRYINSEL : IN string ) is
14565
    variable Message : line;
14566
    begin
14567
       Write ( Message, string'("OPMODE Input Warning : The OPMODE "));
14568
       Write ( Message,  OPMODE);
14569
       Write ( Message, string'(" with CARRYINSEL "));
14570
       Write ( Message,  CARRYINSEL);
14571
       Write ( Message, string'(" to DSP48 instance "));
14572
       Write ( Message, string'("requires attribute PREG set to 1."));
14573
       assert false report Message.all severity Warning;
14574
       DEALLOCATE (Message);
14575
    end invalid_opmode_preg_msg;
14576
 
14577
    procedure invalid_opmode_mreg_msg( OPMODE : IN string ;
14578
                                   CARRYINSEL : IN string ) is
14579
    variable Message : line;
14580
    begin
14581
       Write ( Message, string'("OPMODE Input Warning : The OPMODE "));
14582
       Write ( Message,  OPMODE);
14583
       Write ( Message, string'(" with CARRYINSEL "));
14584
       Write ( Message,  CARRYINSEL);
14585
       Write ( Message, string'(" to DSP48 instance "));
14586
       Write ( Message, string'("requires attribute MREG set to 1."));
14587
       assert false report Message.all severity Warning;
14588
       DEALLOCATE (Message);
14589
    end invalid_opmode_mreg_msg;
14590
 
14591
    procedure invalid_opmode_no_mreg_msg( OPMODE : IN string ;
14592
                                      CARRYINSEL : IN string ) is
14593
    variable Message : line;
14594
    begin
14595
       Write ( Message, string'("OPMODE Input Warning : The OPMODE "));
14596
       Write ( Message,  OPMODE);
14597
       Write ( Message, string'(" with CARRYINSEL "));
14598
       Write ( Message,  CARRYINSEL);
14599
       Write ( Message, string'(" to DSP48 instance "));
14600
       Write ( Message, string'("requires attribute MREG set to 0."));
14601
       assert false report Message.all severity Warning;
14602
       DEALLOCATE (Message);
14603
    end invalid_opmode_no_mreg_msg;
14604
 
14605
 
14606
 
14607
 
14608
  constant SYNC_PATH_DELAY : time := 100 ps;
14609
 
14610
  constant MAX_P          : integer    := 48;
14611
  constant MAX_PCIN       : integer    := 48;
14612
  constant MAX_OPMODE     : integer    := 7;
14613
  constant MAX_BCIN       : integer    := 18;
14614
  constant MAX_B          : integer    := 18;
14615
  constant MAX_A          : integer    := 18;
14616
  constant MAX_C          : integer    := 48;
14617
 
14618
  constant MSB_PCIN       : integer    := 47;
14619
  constant MSB_OPMODE     : integer    := 6;
14620
  constant MSB_BCIN       : integer    := 17;
14621
  constant MSB_B          : integer    := 17;
14622
  constant MSB_A          : integer    := 17;
14623
  constant MSB_C          : integer    := 47;
14624
  constant MSB_CARRYINSEL : integer    := 1;
14625
 
14626
  constant MSB_P          : integer    := 47;
14627
  constant MSB_PCOUT      : integer    := 47;
14628
  constant MSB_BCOUT      : integer    := 17;
14629
 
14630
  constant SHIFT_MUXZ     : integer    := 17;
14631
 
14632
  signal        A_ipd           : std_logic_vector(MSB_A downto 0) := (others => '0');
14633
  signal        B_ipd           : std_logic_vector(MSB_B downto 0) := (others => '0');
14634
  signal        BCIN_ipd        : std_logic_vector(MSB_BCIN downto 0) := (others => '0');
14635
  signal        C_ipd           : std_logic_vector(MSB_C downto 0)    := (others => '0');
14636
  signal        CARRYIN_ipd     : std_ulogic := '0';
14637
  signal        CARRYINSEL_ipd  : std_logic_vector(MSB_CARRYINSEL downto 0)  := (others => '0');
14638
  signal        CEA_ipd         : std_ulogic := '0';
14639
  signal        CEB_ipd         : std_ulogic := '0';
14640
  signal        CEC_ipd         : std_ulogic := '0';
14641
  signal        CECARRYIN_ipd   : std_ulogic := '0';
14642
  signal        CECINSUB_ipd    : std_ulogic := '0';
14643
  signal        CECTRL_ipd      : std_ulogic := '0';
14644
  signal        CEM_ipd         : std_ulogic := '0';
14645
  signal        CEP_ipd         : std_ulogic := '0';
14646
  signal        CLK_ipd         : std_ulogic := '0';
14647
  signal GSR            : std_ulogic := '0';
14648
  signal        GSR_ipd         : std_ulogic := '0';
14649
  signal        OPMODE_ipd      : std_logic_vector(MSB_OPMODE downto 0)  := (others => '0');
14650
  signal        PCIN_ipd        : std_logic_vector(MSB_PCIN downto 0) := (others => '0');
14651
  signal        RSTA_ipd        : std_ulogic := '0';
14652
  signal        RSTB_ipd        : std_ulogic := '0';
14653
  signal        RSTC_ipd        : std_ulogic := '0';
14654
  signal        RSTCARRYIN_ipd  : std_ulogic := '0';
14655
  signal        RSTCTRL_ipd     : std_ulogic := '0';
14656
  signal        RSTM_ipd        : std_ulogic := '0';
14657
  signal        RSTP_ipd        : std_ulogic := '0';
14658
  signal        SUBTRACT_ipd    : std_ulogic := '0';
14659
 
14660
  signal        A_dly           : std_logic_vector(MSB_A downto 0) := (others => '0');
14661
  signal        B_dly           : std_logic_vector(MSB_B downto 0) := (others => '0');
14662
  signal        BCIN_dly        : std_logic_vector(MSB_BCIN downto 0) := (others => '0');
14663
  signal        C_dly           : std_logic_vector(MSB_C downto 0) := (others => '0');
14664
  signal        CARRYIN_dly     : std_ulogic := '0';
14665
  signal        CARRYINSEL_dly  : std_logic_vector(MSB_CARRYINSEL downto 0)  := (others => '0');
14666
  signal        CEA_dly         : std_ulogic := '0';
14667
  signal        CEB_dly         : std_ulogic := '0';
14668
  signal        CEC_dly         : std_ulogic := '0';
14669
  signal        CECARRYIN_dly   : std_ulogic := '0';
14670
  signal        CECINSUB_dly    : std_ulogic := '0';
14671
  signal        CECTRL_dly      : std_ulogic := '0';
14672
  signal        CEM_dly         : std_ulogic := '0';
14673
  signal        CEP_dly         : std_ulogic := '0';
14674
  signal        CLK_dly         : std_ulogic := '0';
14675
  signal        GSR_dly         : std_ulogic := '0';
14676
  signal        OPMODE_dly      : std_logic_vector(MSB_OPMODE downto 0)  := (others => '0');
14677
  signal        PCIN_dly        : std_logic_vector(MSB_PCIN downto 0)     := (others => '0');
14678
  signal        RSTA_dly        : std_ulogic := '0';
14679
  signal        RSTB_dly        : std_ulogic := '0';
14680
  signal        RSTC_dly        : std_ulogic := '0';
14681
  signal        RSTCARRYIN_dly  : std_ulogic := '0';
14682
  signal        RSTCTRL_dly     : std_ulogic := '0';
14683
  signal        RSTM_dly        : std_ulogic := '0';
14684
  signal        RSTP_dly        : std_ulogic := '0';
14685
  signal        SUBTRACT_dly    : std_ulogic := '0';
14686
 
14687
  signal        BCOUT_zd        : std_logic_vector(MSB_BCOUT downto 0) := (others => '0');
14688
  signal        P_zd            : std_logic_vector(MSB_P downto 0) := (others => '0');
14689
  signal        PCOUT_zd                : std_logic_vector(MSB_PCOUT downto 0) := (others => '0');
14690
 
14691
  --- Internal Signal Declarations
14692
  signal        qa_o_reg1       : std_logic_vector(MSB_A downto 0) := (others => '0');
14693
  signal        qa_o_reg2       : std_logic_vector(MSB_A downto 0) := (others => '0');
14694
  signal        qa_o_mux        : std_logic_vector(MSB_A downto 0) := (others => '0');
14695
 
14696
  signal        b_o_mux         : std_logic_vector(MSB_B downto 0) := (others => '0');
14697
  signal        qb_o_reg1       : std_logic_vector(MSB_B downto 0) := (others => '0');
14698
  signal        qb_o_reg2       : std_logic_vector(MSB_B downto 0) := (others => '0');
14699
  signal        qb_o_mux        : std_logic_vector(MSB_B downto 0) := (others => '0');
14700
 
14701
  signal        qc_o_reg        : std_logic_vector(MSB_C downto 0) := (others => '0');
14702
  signal        qc_o_mux        : std_logic_vector(MSB_C downto 0) := (others => '0');
14703
 
14704
  signal        mult_o_int      : std_logic_vector((MSB_A + MSB_B + 1) downto 0) := (others => '0');
14705
  signal        mult_o_reg      : std_logic_vector((MSB_A + MSB_B + 1) downto 0) := (others => '0');
14706
  signal        mult_o_mux      : std_logic_vector((MSB_A + MSB_B + 1) downto 0) := (others => '0');
14707
 
14708
  signal        opmode_o_reg    : std_logic_vector(MSB_OPMODE downto 0) := (others => '0');
14709
  signal        opmode_o_mux    : std_logic_vector(MSB_OPMODE downto 0) := (others => '0');
14710
 
14711
  signal        muxx_o_mux      : std_logic_vector(MSB_P downto 0) := (others => '0');
14712
  signal        muxy_o_mux      : std_logic_vector(MSB_P downto 0) := (others => '0');
14713
  signal        muxz_o_mux      : std_logic_vector(MSB_P downto 0) := (others => '0');
14714
 
14715
  signal        subtract_o_reg  : std_ulogic := '0';
14716
  signal        subtract_o_mux  : std_ulogic := '0';
14717
 
14718
  signal        carryinsel_o_reg        : std_logic_vector(MSB_CARRYINSEL downto 0) := (others => '0');
14719
  signal        carryinsel_o_mux        : std_logic_vector(MSB_CARRYINSEL downto 0) := (others => '0');
14720
 
14721
  signal        qcarryin_o_reg1 : std_ulogic := '0';
14722
  signal        carryin0_o_mux  : std_ulogic := '0';
14723
  signal        carryin1_o_mux  : std_ulogic := '0';
14724
  signal        carryin2_o_mux  : std_ulogic := '0';
14725
 
14726
  signal        qcarryin_o_reg2 : std_ulogic := '0';
14727
 
14728
  signal        carryin_o_mux   : std_ulogic := '0';
14729
 
14730
  signal        accum_o         : std_logic_vector(MSB_P downto 0) := (others => '0');
14731
  signal        qp_o_reg        : std_logic_vector(MSB_P downto 0) := (others => '0');
14732
  signal        qp_o_mux        : std_logic_vector(MSB_P downto 0) := (others => '0');
14733
 
14734
  signal        add_i_int      : std_logic_vector(47 downto 0) := (others => '0');
14735
  signal        add_o_int      : std_logic_vector(47 downto 0) := (others => '0');
14736
 
14737
  signal        reg_p_int         : std_logic_vector(47 downto 0) := (others => '0');
14738
  signal        p_o_int         : std_logic_vector(47 downto 0) := (others => '0');
14739
 
14740
  signal        subtract1_o_int : std_ulogic := '0';
14741
  signal        carryinsel1_o_int : std_logic_vector(1 downto 0) := (others => '0');
14742
  signal        carry1_o_int     : std_ulogic := '0';
14743
  signal        carry2_o_int     : std_ulogic := '0';
14744
 
14745
 
14746
  signal        output_x_sig    : std_ulogic := '0';
14747
 
14748
  signal   RST_META          : std_ulogic := '0';
14749
 
14750
  signal   DefDelay          : time := 10 ps;
14751
 
14752
begin
14753
 
14754
  ---------------------
14755
  --  INPUT PATH DELAYs
14756
  ---------------------
14757
 
14758
  A_dly                  <= A                   after 0 ps;
14759
  B_dly                  <= B                   after 0 ps;
14760
  BCIN_dly               <= BCIN                after 0 ps;
14761
  C_dly                  <= C                   after 0 ps;
14762
  CARRYIN_dly            <= CARRYIN             after 0 ps;
14763
  CARRYINSEL_dly         <= CARRYINSEL          after 0 ps;
14764
  CEA_dly                <= CEA                 after 0 ps;
14765
  CEB_dly                <= CEB                 after 0 ps;
14766
  CEC_dly                <= CEC                 after 0 ps;
14767
  CECARRYIN_dly          <= CECARRYIN           after 0 ps;
14768
  CECINSUB_dly           <= CECINSUB            after 0 ps;
14769
  CECTRL_dly             <= CECTRL              after 0 ps;
14770
  CEM_dly                <= CEM                 after 0 ps;
14771
  CEP_dly                <= CEP                 after 0 ps;
14772
  CLK_dly                <= CLK                 after 0 ps;
14773
  GSR_dly                <= GSR                 after 0 ps;
14774
  OPMODE_dly             <= OPMODE              after 0 ps;
14775
  PCIN_dly               <= PCIN                after 0 ps;
14776
  RSTA_dly               <= RSTA                after 0 ps;
14777
  RSTB_dly               <= RSTB                after 0 ps;
14778
  RSTC_dly               <= RSTC                after 0 ps;
14779
  RSTCARRYIN_dly         <= RSTCARRYIN          after 0 ps;
14780
  RSTCTRL_dly            <= RSTCTRL             after 0 ps;
14781
  RSTM_dly               <= RSTM                after 0 ps;
14782
  RSTP_dly               <= RSTP                after 0 ps;
14783
  SUBTRACT_dly           <= SUBTRACT            after 0 ps;
14784
 
14785
  --------------------
14786
  --  BEHAVIOR SECTION
14787
  --------------------
14788
 
14789
--####################################################################
14790
--#####                        Initialization                      ###
14791
--####################################################################
14792
 prcs_init:process
14793
  begin
14794
     if((LEGACY_MODE /="NONE") and (LEGACY_MODE /="MULT18X18") and
14795
        (LEGACY_MODE /="MULT18X18S")) then
14796
        assert false
14797
        report "Attribute Syntax Error: The allowed values for LEGACY_MODE are NONE, MULT18X18 or MULT18X18S."
14798
        severity Failure;
14799
     elsif((LEGACY_MODE ="MULT18X18") and (MREG /= 0)) then
14800
        assert false
14801
        report "Attribute Syntax Error: The attribute LEGACY_MODE on DSP48 is set to MULT18X18. This requires attribute MREG to be set to 0."
14802
        severity Failure;
14803
     elsif((LEGACY_MODE ="MULT18X18S") and (MREG /= 1)) then
14804
        assert false
14805
        report "Attribute Syntax Error: The attribute LEGACY_MODE on DSP48 is set to MULT18X18S. This requires attribute MREG to be set to 1."
14806
        severity Failure;
14807
     end if;
14808
 
14809
     wait;
14810
  end process prcs_init;
14811
--####################################################################
14812
--#####    Input Register A with two levels of registers and a mux ###
14813
--####################################################################
14814
  prcs_qa_2lvl:process(CLK_dly, GSR_dly)
14815
  begin
14816
      if(GSR_dly = '1') then
14817
          qa_o_reg1 <= ( others => '0');
14818
          qa_o_reg2 <= ( others => '0');
14819
      elsif (GSR_dly = '0') then
14820
         if(rising_edge(CLK_dly)) then
14821
--FP            if((RSTA_dly = '1') and (CEA_dly = '1')) then
14822
            if(RSTA_dly = '1') then
14823
               qa_o_reg1 <= ( others => '0');
14824
               qa_o_reg2 <= ( others => '0');
14825
            elsif ((RSTA_dly = '0') and  (CEA_dly = '1')) then
14826
               qa_o_reg2 <= qa_o_reg1;
14827
               qa_o_reg1 <= A_dly;
14828
            end if;
14829
         end if;
14830
      end if;
14831
  end process prcs_qa_2lvl;
14832
------------------------------------------------------------------
14833
  prcs_qa_o_mux:process(A_dly, qa_o_reg1, qa_o_reg2)
14834
  begin
14835
     case AREG is
14836
       when 0 => qa_o_mux <= A_dly;
14837
       when 1 => qa_o_mux <= qa_o_reg1;
14838
       when 2 => qa_o_mux <= qa_o_reg2;
14839
       when others =>
14840
            assert false
14841
            report "Attribute Syntax Error: The allowed values for AREG are 0 or 1 or 2"
14842
            severity Failure;
14843
     end case;
14844
  end process prcs_qa_o_mux;
14845
 
14846
--####################################################################
14847
--#####    Input Register B with two levels of registers and a mux ###
14848
--####################################################################
14849
 prcs_b_in:process(B_dly, BCIN_dly)
14850
  begin
14851
     if(B_INPUT ="DIRECT") then
14852
        b_o_mux <= B_dly;
14853
     elsif(B_INPUT ="CASCADE") then
14854
        b_o_mux <= BCIN_dly;
14855
     else
14856
        assert false
14857
        report "Attribute Syntax Error: The allowed values for B_INPUT are DIRECT or CASCADE."
14858
        severity Failure;
14859
     end if;
14860
 
14861
  end process prcs_b_in;
14862
------------------------------------------------------------------
14863
 prcs_qb_2lvl:process(CLK_dly, GSR_dly)
14864
  begin
14865
      if(GSR_dly = '1') then
14866
          qb_o_reg1 <= ( others => '0');
14867
          qb_o_reg2 <= ( others => '0');
14868
      elsif (GSR_dly = '0') then
14869
         if(rising_edge(CLK_dly)) then
14870
-- FP            if((RSTB_dly = '1') and (CEB_dly = '1')) then
14871
            if(RSTB_dly = '1') then
14872
               qb_o_reg1 <= ( others => '0');
14873
               qb_o_reg2 <= ( others => '0');
14874
            elsif ((RSTB_dly = '0') and  (CEB_dly = '1')) then
14875
               qb_o_reg2 <= qb_o_reg1;
14876
               qb_o_reg1 <= b_o_mux;
14877
            end if;
14878
         end if;
14879
      end if;
14880
  end process prcs_qb_2lvl;
14881
------------------------------------------------------------------
14882
  prcs_qb_o_mux:process(b_o_mux, qb_o_reg1, qb_o_reg2)
14883
  begin
14884
     case BREG is
14885
       when 0 => qb_o_mux <= b_o_mux;
14886
       when 1 => qb_o_mux <= qb_o_reg1;
14887
       when 2 => qb_o_mux <= qb_o_reg2;
14888
       when others =>
14889
            assert false
14890
            report "Attribute Syntax Error: The allowed values for BREG are 0 or 1 or 2 "
14891
            severity Failure;
14892
     end case;
14893
 
14894
  end process prcs_qb_o_mux;
14895
 
14896
--####################################################################
14897
--#####    Input Register C with 0, 1, level of registers        #####
14898
--####################################################################
14899
  prcs_qc_1lvl:process(CLK_dly, GSR_dly)
14900
  begin
14901
      if(GSR_dly = '1') then
14902
         qc_o_reg <= ( others => '0');
14903
      elsif (GSR_dly = '0') then
14904
         if(rising_edge(CLK_dly)) then
14905
-- FP           if((RSTC_dly = '1') and (CEC_dly = '1'))then
14906
            if(RSTC_dly = '1') then
14907
               qc_o_reg <= ( others => '0');
14908
            elsif ((RSTC_dly = '0') and (CEC_dly = '1')) then
14909
               qc_o_reg <= C_dly;
14910
            end if;
14911
         end if;
14912
      end if;
14913
  end process prcs_qc_1lvl;
14914
------------------------------------------------------------------
14915
  prcs_qc_o_mux:process(C_dly, qc_o_reg)
14916
  begin
14917
     case CREG is
14918
      when 0 => qc_o_mux <= C_dly;
14919
      when 1 => qc_o_mux <= qc_o_reg;
14920
      when others =>
14921
           assert false
14922
           report "Attribute Syntax Error: The allowed values for CREG are 0 or 1"
14923
           severity Failure;
14924
      end case;
14925
  end process prcs_qc_o_mux;
14926
 
14927
--####################################################################
14928
--#####                     Mulitplier                           #####
14929
--####################################################################
14930
  prcs_mult:process(qa_o_mux, qb_o_mux)
14931
  begin
14932
--     mult_o_int <=  qa_o_mux * qb_o_mux;
14933
     mult_o_int <=  signed_mul(qa_o_mux, qb_o_mux);
14934
  end process prcs_mult;
14935
------------------------------------------------------------------
14936
  prcs_mult_reg:process(CLK_dly, GSR_dly)
14937
  begin
14938
      if(GSR_dly = '1') then
14939
         mult_o_reg <= ( others => '0');
14940
      elsif (GSR_dly = '0') then
14941
         if(rising_edge(CLK_dly)) then
14942
--FP            if((RSTM_dly = '1') and (CEM_dly = '1'))then
14943
            if(RSTM_dly = '1') then
14944
               mult_o_reg <= ( others => '0');
14945
            elsif ((RSTM_dly = '0') and (CEM_dly = '1')) then
14946
               mult_o_reg <= mult_o_int;
14947
            end if;
14948
         end if;
14949
      end if;
14950
  end process prcs_mult_reg;
14951
------------------------------------------------------------------
14952
  prcs_mult_mux:process(mult_o_reg, mult_o_int)
14953
  begin
14954
     case MREG is
14955
      when 0 => mult_o_mux <= mult_o_int;
14956
      when 1 => mult_o_mux <= mult_o_reg;
14957
      when others =>
14958
           assert false
14959
           report "Attribute Syntax Error: The allowed values for MREG are 0 or 1"
14960
           severity Failure;
14961
      end case;
14962
  end process prcs_mult_mux;
14963
 
14964
--####################################################################
14965
--#####                        OpMode                            #####
14966
--####################################################################
14967
  prcs_opmode_reg:process(CLK_dly, GSR_dly)
14968
  begin
14969
      if(GSR_dly = '1') then
14970
         opmode_o_reg <= ( others => '0');
14971
      elsif (GSR_dly = '0') then
14972
         if(rising_edge(CLK_dly)) then
14973
--FP            if((RSTCTRL_dly = '1') and (CECTRL_dly = '1'))then
14974
            if(RSTCTRL_dly = '1') then
14975
               opmode_o_reg <= ( others => '0');
14976
            elsif ((RSTCTRL_dly = '0') and (CECTRL_dly = '1')) then
14977
               opmode_o_reg <= OPMODE_dly;
14978
            end if;
14979
         end if;
14980
      end if;
14981
  end process prcs_opmode_reg;
14982
------------------------------------------------------------------
14983
  prcs_opmode_mux:process(opmode_o_reg, OPMODE_dly)
14984
  begin
14985
     case OPMODEREG is
14986
      when 0 => opmode_o_mux <= OPMODE_dly;
14987
      when 1 => opmode_o_mux <= opmode_o_reg;
14988
      when others =>
14989
           assert false
14990
           report "Attribute Syntax Error: The allowed values for OPMODEREG are 0 or 1"
14991
           severity Failure;
14992
      end case;
14993
  end process prcs_opmode_mux;
14994
--####################################################################
14995
--#####                        MUX_XYZ                           #####
14996
--####################################################################
14997
--  prcs_mux_xyz:process(opmode_o_mux,,,, FP)
14998
      -- FP ?? more (Z) should be added to sensitivity list
14999
  prcs_mux_xyz:process(opmode_o_mux, qp_o_mux, qa_o_mux, qb_o_mux, mult_o_mux,
15000
                       qc_o_mux, PCIN_dly, output_x_sig)
15001
  begin
15002
    if(output_x_sig = '1') then
15003
      muxx_o_mux(MSB_P downto 0) <= ( others => 'X');
15004
      muxy_o_mux(MSB_P downto 0) <= ( others => 'X');
15005
      muxz_o_mux(MSB_P downto 0) <= ( others => 'X');
15006
    elsif(output_x_sig = '0') then
15007
    --MUX_X -----
15008
       case opmode_o_mux(1 downto 0) is
15009
         when "00" => muxx_o_mux <= ( others => '0');
15010
         -- FP ?? better way to concat ? and sign extend ?
15011
         when "01" => muxx_o_mux((MAX_A + MAX_B - 1) downto 0) <= mult_o_mux;
15012
                   if(mult_o_mux(MAX_A + MAX_B - 1) = '1') then
15013
                     muxx_o_mux(MSB_PCIN downto (MAX_A + MAX_B)) <=  ( others => '1');
15014
                   elsif (mult_o_mux(MSB_A + MSB_B + 1) = '0') then
15015
                     muxx_o_mux(MSB_PCIN downto (MAX_A + MAX_B)) <=  ( others => '0');
15016
                   end if;
15017
 
15018
         when "10" => muxx_o_mux <= qp_o_mux;
15019
         when "11" => if(qa_o_mux(MSB_A) = '0') then
15020
                        muxx_o_mux(MSB_P downto 0)  <= ("000000000000" & qa_o_mux & qb_o_mux);
15021
                      elsif(qa_o_mux(MSB_A) = '1') then
15022
                        muxx_o_mux(MSB_P downto 0)  <= ("111111111111" & qa_o_mux & qb_o_mux);
15023
                      end if;
15024
--      when "11" => muxx_o_mux(MSB_B downto 0)  <= qb_o_mux;
15025
--                   muxx_o_mux((MAX_A + MAX_B - 1) downto MAX_B) <= qa_o_mux;
15026
--
15027
--                  if(mult_o_mux(MAX_A + MAX_B - 1) = '1') then
15028
--                     muxx_o_mux(MSB_PCIN downto (MAX_A + MAX_B)) <=  ( others => '1');
15029
--                   elsif (mult_o_mux(MSB_A + MSB_B + 1) = '0') then
15030
--                     muxx_o_mux(MSB_PCIN downto (MAX_A + MAX_B)) <=  ( others => '0');
15031
--                   end if;
15032
      when others => null;
15033
--            assert false
15034
--            report "Error: input signal OPMODE(1 downto 0) has unknown values"
15035
--            severity Failure;
15036
       end case;
15037
 
15038
    --MUX_Y -----
15039
       case opmode_o_mux(3 downto 2) is
15040
         when "00" => muxy_o_mux <= ( others => '0');
15041
         when "01" => muxy_o_mux <= ( others => '0');
15042
         when "10" => null;
15043
         when "11" => muxy_o_mux <= qc_o_mux;
15044
         when others => null;
15045
--            assert false
15046
--            report "Error: input signal OPMODE(3 downto 2) has unknown values"
15047
--            severity Failure;
15048
       end case;
15049
    --MUX_Z -----
15050
       case opmode_o_mux(6 downto 4) is
15051
         when "000" => muxz_o_mux <= ( others => '0');
15052
         when "001" => muxz_o_mux <= PCIN_dly;
15053
         when "010" => muxz_o_mux <= qp_o_mux;
15054
         when "011" => muxz_o_mux <= qc_o_mux;
15055
         when "100" => null;
15056
      -- FP ?? better shift possible ?
15057
         when "101" => if(PCIN_dly(MSB_PCIN) = '0') then
15058
                         muxz_o_mux  <= ( others => '0');
15059
                       elsif(PCIN_dly(MSB_PCIN) = '1') then
15060
                         muxz_o_mux  <= ( others => '1');
15061
                       end if;
15062
                       muxz_o_mux ((MSB_PCIN - SHIFT_MUXZ) downto 0) <= PCIN_dly(MSB_PCIN downto SHIFT_MUXZ );
15063
         when "110" => if(qp_o_mux(MSB_P) = '0') then
15064
                         muxz_o_mux  <= ( others => '0');
15065
                       elsif(qp_o_mux(MSB_P) = '1') then
15066
                         muxz_o_mux  <= ( others => '1');
15067
                       end if;
15068
--                    muxz_o_mux ((MAX_P - SHIFT_MUXZ) downto 0) <= qp_o_mux(MSB_P downto (SHIFT_MUXZ - 1));
15069
                       muxz_o_mux ((MSB_P - SHIFT_MUXZ) downto 0) <= qp_o_mux(MSB_P downto SHIFT_MUXZ );
15070
 
15071
         when "111" => null;
15072
         when others => null;
15073
--            assert false
15074
--            report "Error: input signal OPMODE(6 downto 4) has unknown values"
15075
--            severity Failure;
15076
       end case;
15077
    end if;
15078
  end process prcs_mux_xyz;
15079
--####################################################################
15080
--#####                        Subtract                          #####
15081
--####################################################################
15082
  prcs_subtract_reg:process(CLK_dly, GSR_dly)
15083
  begin
15084
      if(GSR_dly = '1') then
15085
         subtract_o_reg <= '0';
15086
      elsif (GSR_dly = '0') then
15087
         if(rising_edge(CLK_dly)) then
15088
            if(RSTCTRL_dly = '1') then
15089
               subtract_o_reg <= '0';
15090
            elsif ((RSTCTRL_dly = '0') and (CECINSUB_dly = '1'))then
15091
               subtract_o_reg <= SUBTRACT_dly;
15092
            end if;
15093
         end if;
15094
      end if;
15095
  end process prcs_subtract_reg;
15096
------------------------------------------------------------------
15097
  prcs_subtract_mux:process(subtract_o_reg, SUBTRACT_dly)
15098
  begin
15099
     case SUBTRACTREG is
15100
      when 0 => subtract_o_mux <= SUBTRACT_dly;
15101
      when 1 => subtract_o_mux <= subtract_o_reg;
15102
      when others =>
15103
           assert false
15104
           report "Attribute Syntax Error: The allowed values for SUBTRACTREG are 0 or 1"
15105
           severity Failure;
15106
      end case;
15107
  end process prcs_subtract_mux;
15108
 
15109
--####################################################################
15110
--#####                     CarryInSel                           #####
15111
--####################################################################
15112
  prcs_carryinsel_reg:process(CLK_dly, GSR_dly)
15113
  begin
15114
      if(GSR_dly = '1') then
15115
         carryinsel_o_reg <= ( others => '0');
15116
      elsif (GSR_dly = '0') then
15117
         if(rising_edge(CLK_dly)) then
15118
--FP            if((RSTCTRL_dly = '1') and (CECTRL_dly = '1'))then
15119
            if(RSTCTRL_dly = '1') then
15120
               carryinsel_o_reg <= ( others => '0');
15121
            elsif ((RSTCTRL_dly = '0') and (CECTRL_dly = '1')) then
15122
               carryinsel_o_reg <= CARRYINSEL_dly;
15123
            end if;
15124
         end if;
15125
      end if;
15126
  end process prcs_carryinsel_reg;
15127
------------------------------------------------------------------
15128
  prcs_carryinsel_mux:process(carryinsel_o_reg, CARRYINSEL_dly)
15129
  begin
15130
     case CARRYINSELREG is
15131
       when 0 => carryinsel_o_mux <= CARRYINSEL_dly;
15132
       when 1 => carryinsel_o_mux <= carryinsel_o_reg;
15133
       when others =>
15134
           assert false
15135
           report "Attribute Syntax Error: The allowed values for CARRYINSELREG are 0 or 1"
15136
           severity Failure;
15137
     end case;
15138
  end process prcs_carryinsel_mux;
15139
 
15140
--####################################################################
15141
--#####                       CarryIn                            #####
15142
--####################################################################
15143
  prcs_carryin_reg1:process(CLK_dly, GSR_dly)
15144
  begin
15145
      if(GSR_dly = '1') then
15146
         qcarryin_o_reg1 <= '0';
15147
      elsif (GSR_dly = '0') then
15148
         if(rising_edge(CLK_dly)) then
15149
            if(RSTCARRYIN_dly = '1') then
15150
               qcarryin_o_reg1 <= '0';
15151
            elsif((RSTCARRYIN_dly = '0') and (CECINSUB_dly = '1')) then
15152
               qcarryin_o_reg1 <= CARRYIN_dly;
15153
            end if;
15154
         end if;
15155
      end if;
15156
  end process prcs_carryin_reg1;
15157
------------------------------------------------------------------
15158
  prcs_carryin0_mux:process(qcarryin_o_reg1, CARRYIN_dly)
15159
  begin
15160
     case CARRYINREG is
15161
       when 0 => carryin0_o_mux <= CARRYIN_dly;
15162
       when 1 => carryin0_o_mux <= qcarryin_o_reg1;
15163
       when others =>
15164
            assert false
15165
            report "Attribute Syntax Error: The allowed values for CARRYINREG are 0 or 1"
15166
            severity Failure;
15167
     end case;
15168
  end process prcs_carryin0_mux;
15169
------------------------------------------------------------------
15170
  prcs_carryin1_mux:process(opmode_o_mux(0), opmode_o_mux(1), qa_o_mux(17), qb_o_mux(17))
15171
  begin
15172
     case (opmode_o_mux(0) and opmode_o_mux(1)) is
15173
       when '0' => carryin1_o_mux <= NOT(qa_o_mux(17) xor qb_o_mux(17));
15174
       when '1' => carryin1_o_mux <= NOT qa_o_mux(17);
15175
       when others => null;
15176
--           assert false
15177
--           report "Error: UNKOWN Value at PORT OPMODE(1) "
15178
--           severity Failure;
15179
     end case;
15180
  end process prcs_carryin1_mux;
15181
------------------------------------------------------------------
15182
  prcs_carryin2_mux:process(opmode_o_mux(0), opmode_o_mux(1), qp_o_mux(47), PCIN_dly(47))
15183
  begin
15184
     if(((opmode_o_mux(1) = '1') and (opmode_o_mux(0) = '0')) or
15185
        (opmode_o_mux(5) = '1') or
15186
        (NOT ((opmode_o_mux(6) = '1') or (opmode_o_mux(4) = '1')))) then
15187
        carryin2_o_mux <= NOT qp_o_mux(47);
15188
     else
15189
        carryin2_o_mux <= NOT PCIN_dly(47);
15190
     end if;
15191
  end process prcs_carryin2_mux;
15192
------------------------------------------------------------------
15193
  prcs_carryin_reg2:process(CLK_dly, GSR_dly)
15194
  begin
15195
      if(GSR_dly = '1') then
15196
         qcarryin_o_reg2 <= '0';
15197
      elsif (GSR_dly = '0') then
15198
         if(rising_edge(CLK_dly)) then
15199
            if(RSTCARRYIN_dly = '1') then
15200
               qcarryin_o_reg2 <= '0';
15201
            elsif ((RSTCARRYIN_dly = '0') and (CECARRYIN_dly = '1'))then
15202
               qcarryin_o_reg2 <= carryin1_o_mux;
15203
            end if;
15204
         end if;
15205
      end if;
15206
  end process prcs_carryin_reg2;
15207
------------------------------------------------------------------
15208
  prcs_carryin_mux:process(carryinsel_o_mux, carryin0_o_mux, carryin1_o_mux, carryin2_o_mux, qcarryin_o_reg2)
15209
  begin
15210
     case carryinsel_o_mux is
15211
       when "00" => carryin_o_mux  <= carryin0_o_mux;
15212
       when "01" => carryin_o_mux  <= carryin2_o_mux;
15213
       when "10" => carryin_o_mux  <= carryin1_o_mux;
15214
       when "11" => carryin_o_mux  <= qcarryin_o_reg2;
15215
       when others => null;
15216
--           assert false
15217
--           report "Error: UNKOWN Value at carryinsel_o_mux"
15218
--           severity Failure;
15219
     end case;
15220
  end process prcs_carryin_mux;
15221
--####################################################################
15222
--#####                       ACCUM                              #####
15223
--####################################################################
15224
--
15225
--  NOTE :  moved it to the drc process
15226
--
15227
--  prcs_accum_xyz:process(muxx_o_mux, muxy_o_mux, muxz_o_mux, subtract_o_mux, carryin_o_mux )
15228
--  variable carry_var : integer;
15229
--  begin
15230
--       if(carryin_o_mux = '1') then
15231
--          carry_var := 1;
15232
--       elsif (carryin_o_mux = '0') then
15233
--          carry_var := 0;
15234
----       else
15235
----          assert false
15236
----          report "Error : CarryIn has Unknown value."
15237
----          severity Failure;
15238
--       end if;
15239
 
15240
--       if(subtract_o_mux = '0') then
15241
--         accum_o <=  muxz_o_mux + (muxx_o_mux + muxy_o_mux + carryin_o_mux);
15242
--       elsif(subtract_o_mux = '1') then
15243
--         accum_o <=  muxz_o_mux - (muxx_o_mux + muxy_o_mux + carryin_o_mux);
15244
----       else
15245
----          assert false
15246
----          report "Error : Subtract has Unknown value."
15247
----          severity Failure;
15248
--       end if;
15249
--  end process prcs_accum_xyz;
15250
--####################################################################
15251
--#####                       PCOUT                               #####
15252
--####################################################################
15253
  prcs_qp_reg:process(CLK_dly, GSR_dly)
15254
  begin
15255
      if(GSR_dly = '1') then
15256
         qp_o_reg <=  ( others => '0');
15257
      elsif (GSR_dly = '0') then
15258
         if(rising_edge(CLK_dly)) then
15259
            if(RSTP_dly = '1') then
15260
               qp_o_reg <= ( others => '0');
15261
            elsif ((RSTP_dly = '0') and (CEP_dly = '1')) then
15262
               qp_o_reg <= accum_o;
15263
            end if;
15264
         end if;
15265
      end if;
15266
  end process prcs_qp_reg;
15267
------------------------------------------------------------------
15268
  prcs_qp_mux:process(accum_o, qp_o_reg)
15269
  begin
15270
     case PREG is
15271
       when 0 => qp_o_mux <= accum_o;
15272
       when 1 => qp_o_mux <= qp_o_reg;
15273
       when others =>
15274
           assert false
15275
           report "Attribute Syntax Error: The allowed values for PREG are 0 or 1"
15276
           severity Failure;
15277
     end case;
15278
 
15279
  end process prcs_qp_mux;
15280
--####################################################################
15281
--#####                   ZERO_DELAY_OUTPUTS                     #####
15282
--####################################################################
15283
  prcs_zero_delay_outputs:process(qb_o_mux, qp_o_mux)
15284
  begin
15285
    BCOUT_zd <= qb_o_mux;
15286
    P_zd     <= qp_o_mux;
15287
    PCOUT_zd <= qp_o_mux;
15288
  end process prcs_zero_delay_outputs;
15289
 
15290
--####################################################################
15291
--#####                 PMODE DRC                                #####
15292
--####################################################################
15293
  prcs_opmode_drc:process(opmode_o_mux, carryinsel_o_mux, subtract_o_mux,
15294
                       muxx_o_mux, muxy_o_mux, muxz_o_mux, carryin_o_mux)
15295
  variable Message : line;
15296
  variable invalid_opmode_flg : boolean := true;
15297
  variable add_flg : boolean := true;
15298
  variable opmode_carryinsel_var : std_logic_vector(8 downto 0) := (others => '0');
15299
  begin
15300
--    if now > 100 ns then
15301
--    The above line was cusing the intial values of A, B or C not trigger
15302
      opmode_carryinsel_var := opmode_o_mux & carryinsel_o_mux;
15303
      case opmode_carryinsel_var is
15304
 
15305
 
15306
        when "000000000" =>
15307
                          invalid_opmode_flg := true ;
15308
                          add_flg := true ;
15309
                          output_x_sig <= '0';
15310
 
15311
        when "000001000" =>
15312
                          if (PREG /= 1) then
15313
                             accum_o <= (others => 'X');
15314
                             add_flg := false;
15315
                             if(invalid_opmode_flg) then
15316
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15317
                             end if;
15318
                             invalid_opmode_flg := false;
15319
                          else
15320
                             invalid_opmode_flg := true;
15321
                             add_flg := true;
15322
                             output_x_sig <= '0';
15323
                          end if;
15324
 
15325
        when "000001100" =>
15326
                          invalid_opmode_flg := true ;
15327
                          add_flg := true ;
15328
                          output_x_sig <= '0';
15329
 
15330
        when "000010100" =>
15331
                          invalid_opmode_flg := true ;
15332
                          add_flg := true ;
15333
                          output_x_sig <= '0';
15334
 
15335
        when "000110000" =>
15336
                          invalid_opmode_flg := true ;
15337
                          add_flg := true ;
15338
                          output_x_sig <= '0';
15339
 
15340
        when "000111000" =>
15341
                          if (PREG /= 1) then
15342
                             accum_o <= (others => 'X');
15343
                             add_flg := false;
15344
                             if(invalid_opmode_flg) then
15345
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15346
                             end if;
15347
                             invalid_opmode_flg := false;
15348
                          else
15349
                             invalid_opmode_flg := true;
15350
                             add_flg := true;
15351
                             output_x_sig <= '0';
15352
                          end if;
15353
 
15354
        when "000111001" =>
15355
                          if (PREG /= 1) then
15356
                             accum_o <= (others => 'X');
15357
                             add_flg := false;
15358
                             if(invalid_opmode_flg) then
15359
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15360
                             end if;
15361
                             invalid_opmode_flg := false;
15362
                          else
15363
                             invalid_opmode_flg := true;
15364
                             add_flg := true;
15365
                             output_x_sig <= '0';
15366
                          end if;
15367
 
15368
        when "000111100" =>
15369
                          invalid_opmode_flg := true ;
15370
                          add_flg := true ;
15371
                          output_x_sig <= '0';
15372
 
15373
        when "000111110" =>
15374
                          invalid_opmode_flg := true ;
15375
                          add_flg := true ;
15376
                          output_x_sig <= '0';
15377
 
15378
        when "001000000" =>
15379
                          invalid_opmode_flg := true ;
15380
                          add_flg := true ;
15381
                          output_x_sig <= '0';
15382
 
15383
        when "001001000" =>
15384
                          if (PREG /= 1) then
15385
                             accum_o <= (others => 'X');
15386
                             add_flg := false;
15387
                             if(invalid_opmode_flg) then
15388
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15389
                             end if;
15390
                             invalid_opmode_flg := false;
15391
                          else
15392
                             invalid_opmode_flg := true;
15393
                             add_flg := true;
15394
                             output_x_sig <= '0';
15395
                          end if;
15396
 
15397
        when "001001001" =>
15398
                          if (PREG /= 1) then
15399
                             accum_o <= (others => 'X');
15400
                             add_flg := false;
15401
                             if(invalid_opmode_flg) then
15402
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15403
                             end if;
15404
                             invalid_opmode_flg := false;
15405
                          else
15406
                             invalid_opmode_flg := true;
15407
                             add_flg := true;
15408
                             output_x_sig <= '0';
15409
                          end if;
15410
 
15411
        when "001001100" =>
15412
                          invalid_opmode_flg := true ;
15413
                          add_flg := true ;
15414
                          output_x_sig <= '0';
15415
 
15416
        when "001001101" =>
15417
                          invalid_opmode_flg := true ;
15418
                          add_flg := true ;
15419
                          output_x_sig <= '0';
15420
 
15421
        when "001001110" =>
15422
                          invalid_opmode_flg := true ;
15423
                          add_flg := true ;
15424
                          output_x_sig <= '0';
15425
 
15426
        when "001010100" =>
15427
                          invalid_opmode_flg := true ;
15428
                          add_flg := true ;
15429
                          output_x_sig <= '0';
15430
 
15431
        when "001010101" =>
15432
                          invalid_opmode_flg := true ;
15433
                          add_flg := true ;
15434
                          output_x_sig <= '0';
15435
 
15436
        when "001010110" =>
15437
                          invalid_opmode_flg := true ;
15438
                          add_flg := true ;
15439
                          output_x_sig <= '0';
15440
 
15441
        when "001010111" =>
15442
                          invalid_opmode_flg := true ;
15443
                          add_flg := true ;
15444
                          output_x_sig <= '0';
15445
 
15446
        when "001110000" =>
15447
                          invalid_opmode_flg := true ;
15448
                          add_flg := true ;
15449
                          output_x_sig <= '0';
15450
 
15451
        when "001110001" =>
15452
                          invalid_opmode_flg := true ;
15453
                          add_flg := true ;
15454
                          output_x_sig <= '0';
15455
 
15456
        when "001111000" =>
15457
                          if (PREG /= 1) then
15458
                             accum_o <= (others => 'X');
15459
                             add_flg := false;
15460
                             if(invalid_opmode_flg) then
15461
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15462
                             end if;
15463
                             invalid_opmode_flg := false;
15464
                          else
15465
                             invalid_opmode_flg := true;
15466
                             add_flg := true;
15467
                             output_x_sig <= '0';
15468
                          end if;
15469
 
15470
        when "001111001" =>
15471
                          if (PREG /= 1) then
15472
                             accum_o <= (others => 'X');
15473
                             add_flg := false;
15474
                             if(invalid_opmode_flg) then
15475
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15476
                             end if;
15477
                             invalid_opmode_flg := false;
15478
                          else
15479
                             invalid_opmode_flg := true;
15480
                             add_flg := true;
15481
                             output_x_sig <= '0';
15482
                          end if;
15483
 
15484
        when "001111100" =>
15485
                          invalid_opmode_flg := true ;
15486
                          add_flg := true ;
15487
                          output_x_sig <= '0';
15488
 
15489
        when "001111101" =>
15490
                          invalid_opmode_flg := true ;
15491
                          add_flg := true ;
15492
                          output_x_sig <= '0';
15493
 
15494
        when "001111110" =>
15495
                          invalid_opmode_flg := true ;
15496
                          add_flg := true ;
15497
                          output_x_sig <= '0';
15498
 
15499
        when "010000000" =>
15500
                          if (PREG /= 1) then
15501
                             accum_o <= (others => 'X');
15502
                             add_flg := false;
15503
                             if(invalid_opmode_flg) then
15504
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15505
                             end if;
15506
                             invalid_opmode_flg := false;
15507
                          else
15508
                             invalid_opmode_flg := true;
15509
                             add_flg := true;
15510
                             output_x_sig <= '0';
15511
                          end if;
15512
 
15513
        when "010001000" =>
15514
                          if (PREG /= 1) then
15515
                             accum_o <= (others => 'X');
15516
                             add_flg := false;
15517
                             if(invalid_opmode_flg) then
15518
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15519
                             end if;
15520
                             invalid_opmode_flg := false;
15521
                          else
15522
                             invalid_opmode_flg := true;
15523
                             add_flg := true;
15524
                             output_x_sig <= '0';
15525
                          end if;
15526
 
15527
        when "010001100" =>
15528
                          if (PREG /= 1) then
15529
                             accum_o <= (others => 'X');
15530
                             add_flg := false;
15531
                             if(invalid_opmode_flg) then
15532
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15533
                             end if;
15534
                             invalid_opmode_flg := false;
15535
                          else
15536
                             invalid_opmode_flg := true;
15537
                             add_flg := true;
15538
                             output_x_sig <= '0';
15539
                          end if;
15540
 
15541
        when "010001101" =>
15542
                          if (PREG /= 1) then
15543
                             accum_o <= (others => 'X');
15544
                             add_flg := false;
15545
                             if(invalid_opmode_flg) then
15546
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15547
                             end if;
15548
                             invalid_opmode_flg := false;
15549
                          else
15550
                             invalid_opmode_flg := true;
15551
                             add_flg := true;
15552
                             output_x_sig <= '0';
15553
                          end if;
15554
 
15555
        when "010010100" =>
15556
                          if (PREG /= 1) then
15557
                             accum_o <= (others => 'X');
15558
                             add_flg := false;
15559
                             if(invalid_opmode_flg) then
15560
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15561
                             end if;
15562
                             invalid_opmode_flg := false;
15563
                          else
15564
                             invalid_opmode_flg := true;
15565
                             add_flg := true;
15566
                             output_x_sig <= '0';
15567
                          end if;
15568
 
15569
        when "010010101" =>
15570
                          if (PREG /= 1) then
15571
                             accum_o <= (others => 'X');
15572
                             add_flg := false;
15573
                             if(invalid_opmode_flg) then
15574
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15575
                             end if;
15576
                             invalid_opmode_flg := false;
15577
                          else
15578
                             invalid_opmode_flg := true;
15579
                             add_flg := true;
15580
                             output_x_sig <= '0';
15581
                          end if;
15582
 
15583
        when "010110000" =>
15584
                          if (PREG /= 1) then
15585
                             accum_o <= (others => 'X');
15586
                             add_flg := false;
15587
                             if(invalid_opmode_flg) then
15588
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15589
                             end if;
15590
                             invalid_opmode_flg := false;
15591
                          else
15592
                             invalid_opmode_flg := true;
15593
                             add_flg := true;
15594
                             output_x_sig <= '0';
15595
                          end if;
15596
 
15597
        when "010110001" =>
15598
                          if (PREG /= 1) then
15599
                             accum_o <= (others => 'X');
15600
                             add_flg := false;
15601
                             if(invalid_opmode_flg) then
15602
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15603
                             end if;
15604
                             invalid_opmode_flg := false;
15605
                          else
15606
                             invalid_opmode_flg := true;
15607
                             add_flg := true;
15608
                             output_x_sig <= '0';
15609
                          end if;
15610
 
15611
        when "010111000" =>
15612
                          if (PREG /= 1) then
15613
                             accum_o <= (others => 'X');
15614
                             add_flg := false;
15615
                             if(invalid_opmode_flg) then
15616
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15617
                             end if;
15618
                             invalid_opmode_flg := false;
15619
                          else
15620
                             invalid_opmode_flg := true;
15621
                             add_flg := true;
15622
                             output_x_sig <= '0';
15623
                          end if;
15624
 
15625
        when "010111001" =>
15626
                          if (PREG /= 1) then
15627
                             accum_o <= (others => 'X');
15628
                             add_flg := false;
15629
                             if(invalid_opmode_flg) then
15630
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15631
                             end if;
15632
                             invalid_opmode_flg := false;
15633
                          else
15634
                             invalid_opmode_flg := true;
15635
                             add_flg := true;
15636
                             output_x_sig <= '0';
15637
                          end if;
15638
 
15639
        when "010111100" =>
15640
                          if (PREG /= 1) then
15641
                             accum_o <= (others => 'X');
15642
                             add_flg := false;
15643
                             if(invalid_opmode_flg) then
15644
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15645
                             end if;
15646
                             invalid_opmode_flg := false;
15647
                          else
15648
                             invalid_opmode_flg := true;
15649
                             add_flg := true;
15650
                             output_x_sig <= '0';
15651
                          end if;
15652
 
15653
        when "010111101" =>
15654
                          if (PREG /= 1) then
15655
                             accum_o <= (others => 'X');
15656
                             add_flg := false;
15657
                             if(invalid_opmode_flg) then
15658
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15659
                             end if;
15660
                             invalid_opmode_flg := false;
15661
                          else
15662
                             invalid_opmode_flg := true;
15663
                             add_flg := true;
15664
                             output_x_sig <= '0';
15665
                          end if;
15666
 
15667
        when "010111110" =>
15668
                          if (PREG /= 1) then
15669
                             accum_o <= (others => 'X');
15670
                             add_flg := false;
15671
                             if(invalid_opmode_flg) then
15672
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15673
                             end if;
15674
                             invalid_opmode_flg := false;
15675
                          else
15676
                             invalid_opmode_flg := true;
15677
                             add_flg := true;
15678
                             output_x_sig <= '0';
15679
                          end if;
15680
 
15681
        when "011000000" =>
15682
                          invalid_opmode_flg := true ;
15683
                          add_flg := true ;
15684
                          output_x_sig <= '0';
15685
 
15686
        when "011001000" =>
15687
                          if (PREG /= 1) then
15688
                             accum_o <= (others => 'X');
15689
                             add_flg := false;
15690
                             if(invalid_opmode_flg) then
15691
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15692
                             end if;
15693
                             invalid_opmode_flg := false;
15694
                          else
15695
                             invalid_opmode_flg := true;
15696
                             add_flg := true;
15697
                             output_x_sig <= '0';
15698
                          end if;
15699
 
15700
        when "011001001" =>
15701
                          if (PREG /= 1) then
15702
                             accum_o <= (others => 'X');
15703
                             add_flg := false;
15704
                             if(invalid_opmode_flg) then
15705
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15706
                             end if;
15707
                             invalid_opmode_flg := false;
15708
                          else
15709
                             invalid_opmode_flg := true;
15710
                             add_flg := true;
15711
                             output_x_sig <= '0';
15712
                          end if;
15713
 
15714
        when "011001100" =>
15715
                          invalid_opmode_flg := true ;
15716
                          add_flg := true ;
15717
                          output_x_sig <= '0';
15718
 
15719
        when "011001110" =>
15720
                          invalid_opmode_flg := true ;
15721
                          add_flg := true ;
15722
                          output_x_sig <= '0';
15723
 
15724
        when "011010100" =>
15725
                          invalid_opmode_flg := true ;
15726
                          add_flg := true ;
15727
                          output_x_sig <= '0';
15728
 
15729
        when "011010110" =>
15730
                          if (MREG /= 0) then
15731
                             accum_o <= (others => 'X');
15732
                             add_flg := false;
15733
                             if(invalid_opmode_flg) then
15734
                                invalid_opmode_no_mreg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15735
                             end if;
15736
                             invalid_opmode_flg := false;
15737
                          else
15738
                             invalid_opmode_flg := true;
15739
                             add_flg := true;
15740
                             output_x_sig <= '0';
15741
                          end if;
15742
 
15743
        when "011010111" =>
15744
                          if (MREG /= 1) then
15745
                             accum_o <= (others => 'X');
15746
                             add_flg := false;
15747
                             if(invalid_opmode_flg) then
15748
                                invalid_opmode_mreg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15749
                             end if;
15750
                             invalid_opmode_flg := false;
15751
                          else
15752
                             invalid_opmode_flg := true;
15753
                             add_flg := true;
15754
                             output_x_sig <= '0';
15755
                          end if;
15756
 
15757
        when "011110000" =>
15758
                          invalid_opmode_flg := true ;
15759
                          add_flg := true ;
15760
                          output_x_sig <= '0';
15761
 
15762
        when "011111000" =>
15763
                          if (PREG /= 1) then
15764
                             accum_o <= (others => 'X');
15765
                             add_flg := false;
15766
                             if(invalid_opmode_flg) then
15767
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15768
                             end if;
15769
                             invalid_opmode_flg := false;
15770
                          else
15771
                             invalid_opmode_flg := true;
15772
                             add_flg := true;
15773
                             output_x_sig <= '0';
15774
                          end if;
15775
 
15776
        when "011111100" =>
15777
                          invalid_opmode_flg := true ;
15778
                          add_flg := true ;
15779
                          output_x_sig <= '0';
15780
 
15781
 
15782
        when "011111101" =>
15783
                          invalid_opmode_flg := true ;
15784
                          add_flg := true ;
15785
                          output_x_sig <= '0';
15786
 
15787
        when "101000000" =>
15788
                          invalid_opmode_flg := true ;
15789
                          add_flg := true ;
15790
                          output_x_sig <= '0';
15791
 
15792
        when "101001000" =>
15793
                          if (PREG /= 1) then
15794
                             accum_o <= (others => 'X');
15795
                             add_flg := false;
15796
                             if(invalid_opmode_flg) then
15797
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15798
                             end if;
15799
                             invalid_opmode_flg := false;
15800
                          else
15801
                             invalid_opmode_flg := true;
15802
                             add_flg := true;
15803
                             output_x_sig <= '0';
15804
                          end if;
15805
 
15806
        when "101001100" =>
15807
                          invalid_opmode_flg := true ;
15808
                          add_flg := true ;
15809
                          output_x_sig <= '0';
15810
 
15811
        when "101001101" =>
15812
                          invalid_opmode_flg := true ;
15813
                          add_flg := true ;
15814
                          output_x_sig <= '0';
15815
 
15816
        when "101001110" =>
15817
                          invalid_opmode_flg := true ;
15818
                          add_flg := true ;
15819
                          output_x_sig <= '0';
15820
 
15821
        when "101010100" =>
15822
                          invalid_opmode_flg := true ;
15823
                          add_flg := true ;
15824
                          output_x_sig <= '0';
15825
 
15826
        when "101010101" =>
15827
                          invalid_opmode_flg := true ;
15828
                          add_flg := true ;
15829
                          output_x_sig <= '0';
15830
 
15831
        when "101010110" =>
15832
                          invalid_opmode_flg := true ;
15833
                          add_flg := true ;
15834
                          output_x_sig <= '0';
15835
 
15836
        when "101010111" =>
15837
                          invalid_opmode_flg := true ;
15838
                          add_flg := true ;
15839
                          output_x_sig <= '0';
15840
 
15841
        when "101110000" =>
15842
                          invalid_opmode_flg := true ;
15843
                          add_flg := true ;
15844
                          output_x_sig <= '0';
15845
 
15846
        when "101110001" =>
15847
                          invalid_opmode_flg := true ;
15848
                          add_flg := true ;
15849
                          output_x_sig <= '0';
15850
 
15851
        when "101111000" =>
15852
                          if (PREG /= 1) then
15853
                             accum_o <= (others => 'X');
15854
                             add_flg := false;
15855
                             if(invalid_opmode_flg) then
15856
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15857
                             end if;
15858
                             invalid_opmode_flg := false;
15859
                          else
15860
                             invalid_opmode_flg := true;
15861
                             add_flg := true;
15862
                             output_x_sig <= '0';
15863
                          end if;
15864
 
15865
        when "101111001" =>
15866
                          if (PREG /= 1) then
15867
                             accum_o <= (others => 'X');
15868
                             add_flg := false;
15869
                             if(invalid_opmode_flg) then
15870
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15871
                             end if;
15872
                             invalid_opmode_flg := false;
15873
                          else
15874
                             invalid_opmode_flg := true;
15875
                             add_flg := true;
15876
                             output_x_sig <= '0';
15877
                          end if;
15878
 
15879
        when "101111100" =>
15880
                          invalid_opmode_flg := true ;
15881
                          add_flg := true ;
15882
                          output_x_sig <= '0';
15883
 
15884
        when "101111101" =>
15885
                          invalid_opmode_flg := true ;
15886
                          add_flg := true ;
15887
                          output_x_sig <= '0';
15888
 
15889
        when "101111110" =>
15890
                          invalid_opmode_flg := true ;
15891
                          add_flg := true ;
15892
                          output_x_sig <= '0';
15893
 
15894
        when "110000000" =>
15895
                          if (PREG /= 1) then
15896
                             accum_o <= (others => 'X');
15897
                             add_flg := false;
15898
                             if(invalid_opmode_flg) then
15899
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15900
                             end if;
15901
                             invalid_opmode_flg := false;
15902
                          else
15903
                             invalid_opmode_flg := true;
15904
                             add_flg := true;
15905
                             output_x_sig <= '0';
15906
                          end if;
15907
 
15908
        when "110001000" =>
15909
                          if (PREG /= 1) then
15910
                             accum_o <= (others => 'X');
15911
                             add_flg := false;
15912
                             if(invalid_opmode_flg) then
15913
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15914
                             end if;
15915
                             invalid_opmode_flg := false;
15916
                          else
15917
                             invalid_opmode_flg := true;
15918
                             add_flg := true;
15919
                             output_x_sig <= '0';
15920
                          end if;
15921
 
15922
        when "110001100" =>
15923
                          if (PREG /= 1) then
15924
                             accum_o <= (others => 'X');
15925
                             add_flg := false;
15926
                             if(invalid_opmode_flg) then
15927
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15928
                             end if;
15929
                             invalid_opmode_flg := false;
15930
                          else
15931
                             invalid_opmode_flg := true;
15932
                             add_flg := true;
15933
                             output_x_sig <= '0';
15934
                          end if;
15935
 
15936
        when "110001101" =>
15937
                          if (PREG /= 1) then
15938
                             accum_o <= (others => 'X');
15939
                             add_flg := false;
15940
                             if(invalid_opmode_flg) then
15941
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15942
                             end if;
15943
                             invalid_opmode_flg := false;
15944
                          else
15945
                             invalid_opmode_flg := true;
15946
                             add_flg := true;
15947
                             output_x_sig <= '0';
15948
                          end if;
15949
 
15950
        when "110010100" =>
15951
                          if (PREG /= 1) then
15952
                             accum_o <= (others => 'X');
15953
                             add_flg := false;
15954
                             if(invalid_opmode_flg) then
15955
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15956
                             end if;
15957
                             invalid_opmode_flg := false;
15958
                          else
15959
                             invalid_opmode_flg := true;
15960
                             add_flg := true;
15961
                             output_x_sig <= '0';
15962
                          end if;
15963
 
15964
        when "110010101" =>
15965
                          if (PREG /= 1) then
15966
                             accum_o <= (others => 'X');
15967
                             add_flg := false;
15968
                             if(invalid_opmode_flg) then
15969
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15970
                             end if;
15971
                             invalid_opmode_flg := false;
15972
                          else
15973
                             invalid_opmode_flg := true;
15974
                             add_flg := true;
15975
                             output_x_sig <= '0';
15976
                          end if;
15977
 
15978
        when "110110000" =>
15979
                          if (PREG /= 1) then
15980
                             accum_o <= (others => 'X');
15981
                             add_flg := false;
15982
                             if(invalid_opmode_flg) then
15983
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15984
                             end if;
15985
                             invalid_opmode_flg := false;
15986
                          else
15987
                             invalid_opmode_flg := true;
15988
                             add_flg := true;
15989
                             output_x_sig <= '0';
15990
                          end if;
15991
 
15992
        when "110110001" =>
15993
                          if (PREG /= 1) then
15994
                             accum_o <= (others => 'X');
15995
                             add_flg := false;
15996
                             if(invalid_opmode_flg) then
15997
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
15998
                             end if;
15999
                             invalid_opmode_flg := false;
16000
                          else
16001
                             invalid_opmode_flg := true;
16002
                             add_flg := true;
16003
                             output_x_sig <= '0';
16004
                          end if;
16005
 
16006
        when "110111000" =>
16007
                          if (PREG /= 1) then
16008
                             accum_o <= (others => 'X');
16009
                             add_flg := false;
16010
                             if(invalid_opmode_flg) then
16011
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
16012
                             end if;
16013
                             invalid_opmode_flg := false;
16014
                          else
16015
                             invalid_opmode_flg := true;
16016
                             add_flg := true;
16017
                             output_x_sig <= '0';
16018
                          end if;
16019
 
16020
        when "110111001" =>
16021
                          if (PREG /= 1) then
16022
                             accum_o <= (others => 'X');
16023
                             add_flg := false;
16024
                             if(invalid_opmode_flg) then
16025
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
16026
                             end if;
16027
                             invalid_opmode_flg := false;
16028
                          else
16029
                             invalid_opmode_flg := true;
16030
                             add_flg := true;
16031
                             output_x_sig <= '0';
16032
                          end if;
16033
 
16034
        when "110111100" =>
16035
                          if (PREG /= 1) then
16036
                             accum_o <= (others => 'X');
16037
                             add_flg := false;
16038
                             if(invalid_opmode_flg) then
16039
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
16040
                             end if;
16041
                             invalid_opmode_flg := false;
16042
                          else
16043
                             invalid_opmode_flg := true;
16044
                             add_flg := true;
16045
                             output_x_sig <= '0';
16046
                          end if;
16047
 
16048
        when "110111101" =>
16049
                          if (PREG /= 1) then
16050
                             accum_o <= (others => 'X');
16051
                             add_flg := false;
16052
                             if(invalid_opmode_flg) then
16053
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
16054
                             end if;
16055
                             invalid_opmode_flg := false;
16056
                          else
16057
                             invalid_opmode_flg := true;
16058
                             add_flg := true;
16059
                             output_x_sig <= '0';
16060
                          end if;
16061
 
16062
        when "110111110" =>
16063
                          if (PREG /= 1) then
16064
                             accum_o <= (others => 'X');
16065
                             add_flg := false;
16066
                             if(invalid_opmode_flg) then
16067
                                invalid_opmode_preg_msg(slv_to_str(opmode_o_mux), slv_to_str(carryinsel_o_mux));
16068
                             end if;
16069
                             invalid_opmode_flg := false;
16070
                          else
16071
                             invalid_opmode_flg := true;
16072
                             add_flg := true;
16073
                             output_x_sig <= '0';
16074
                          end if;
16075
        when others    =>
16076
                       if(invalid_opmode_flg = true) then
16077
                          invalid_opmode_flg := false;
16078
                          add_flg := false;
16079
                          output_x_sig <= '1';
16080
                          accum_o <= (others => 'X');
16081
                          Write ( Message, string'("OPMODE Input Warning : The OPMODE "));
16082
                          Write ( Message,  slv_to_str(opmode_o_mux));
16083
                          Write ( Message, string'(" with CARRYINSEL  "));
16084
                          Write ( Message,  slv_to_str(carryinsel_o_mux));
16085
                          Write ( Message, string'(" to DSP48 instance"));
16086
                          Write ( Message, string'(" is invalid."));
16087
                          assert false report Message.all severity Warning;
16088
                          DEALLOCATE (Message);
16089
                        end if;
16090
      end case;
16091
 
16092
 
16093
      if(add_flg) then
16094
         if(subtract_o_mux = '0') then
16095
            accum_o <=  muxz_o_mux + (muxx_o_mux + muxy_o_mux + carryin_o_mux);
16096
         elsif(subtract_o_mux = '1') then
16097
            accum_o <=  muxz_o_mux - (muxx_o_mux + muxy_o_mux + carryin_o_mux);
16098
         end if;
16099
      end if;
16100
--    end if;
16101
  end process prcs_opmode_drc;
16102
 
16103
--####################################################################
16104
--#####                         OUTPUT                           #####
16105
--####################################################################
16106
  prcs_output:process(BCOUT_zd, PCOUT_zd, P_zd)
16107
  begin
16108
      BCOUT  <= BCOUT_zd after SYNC_PATH_DELAY;
16109
      P      <= P_zd     after SYNC_PATH_DELAY;
16110
      PCOUT  <= PCOUT_zd after SYNC_PATH_DELAY;
16111
  end process prcs_output;
16112
 
16113
 
16114
 
16115
end DSP48_V;
16116
 
16117
library IEEE;
16118
use IEEE.STD_LOGIC_1164.all;
16119
 
16120
library grlib;
16121
use grlib.stdlib.all;
16122
 
16123
library STD;
16124
use STD.TEXTIO.all;
16125
 
16126
library unisim;
16127
use unisim.vcomponents.all;
16128
use unisim.vpkg.all;
16129
 
16130
entity ARAMB36_INTERNAL is
16131
 
16132
  generic (
16133
 
16134
    BRAM_MODE : string := "TRUE_DUAL_PORT";
16135
    BRAM_SIZE : integer := 36;
16136
    DOA_REG : integer := 0;
16137
    DOB_REG : integer := 0;
16138
    EN_ECC_READ : boolean := FALSE;
16139
    EN_ECC_SCRUB : boolean := FALSE;
16140
    EN_ECC_WRITE : boolean := FALSE;
16141
    INITP_00 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16142
    INITP_01 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16143
    INITP_02 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16144
    INITP_03 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16145
    INITP_04 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16146
    INITP_05 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16147
    INITP_06 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16148
    INITP_07 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16149
    INITP_08 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16150
    INITP_09 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16151
    INITP_0A : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16152
    INITP_0B : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16153
    INITP_0C : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16154
    INITP_0D : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16155
    INITP_0E : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16156
    INITP_0F : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16157
    INIT_00 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16158
    INIT_01 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16159
    INIT_02 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16160
    INIT_03 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16161
    INIT_04 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16162
    INIT_05 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16163
    INIT_06 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16164
    INIT_07 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16165
    INIT_08 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16166
    INIT_09 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16167
    INIT_0A : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16168
    INIT_0B : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16169
    INIT_0C : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16170
    INIT_0D : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16171
    INIT_0E : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16172
    INIT_0F : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16173
    INIT_10 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16174
    INIT_11 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16175
    INIT_12 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16176
    INIT_13 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16177
    INIT_14 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16178
    INIT_15 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16179
    INIT_16 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16180
    INIT_17 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16181
    INIT_18 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16182
    INIT_19 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16183
    INIT_1A : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16184
    INIT_1B : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16185
    INIT_1C : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16186
    INIT_1D : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16187
    INIT_1E : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16188
    INIT_1F : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16189
    INIT_20 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16190
    INIT_21 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16191
    INIT_22 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16192
    INIT_23 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16193
    INIT_24 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16194
    INIT_25 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16195
    INIT_26 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16196
    INIT_27 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16197
    INIT_28 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16198
    INIT_29 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16199
    INIT_2A : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16200
    INIT_2B : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16201
    INIT_2C : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16202
    INIT_2D : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16203
    INIT_2E : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16204
    INIT_2F : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16205
    INIT_30 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16206
    INIT_31 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16207
    INIT_32 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16208
    INIT_33 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16209
    INIT_34 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16210
    INIT_35 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16211
    INIT_36 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16212
    INIT_37 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16213
    INIT_38 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16214
    INIT_39 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16215
    INIT_3A : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16216
    INIT_3B : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16217
    INIT_3C : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16218
    INIT_3D : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16219
    INIT_3E : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16220
    INIT_3F : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16221
    INIT_40 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16222
    INIT_41 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16223
    INIT_42 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16224
    INIT_43 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16225
    INIT_44 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16226
    INIT_45 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16227
    INIT_46 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16228
    INIT_47 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16229
    INIT_48 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16230
    INIT_49 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16231
    INIT_4A : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16232
    INIT_4B : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16233
    INIT_4C : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16234
    INIT_4D : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16235
    INIT_4E : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16236
    INIT_4F : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16237
    INIT_50 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16238
    INIT_51 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16239
    INIT_52 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16240
    INIT_53 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16241
    INIT_54 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16242
    INIT_55 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16243
    INIT_56 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16244
    INIT_57 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16245
    INIT_58 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16246
    INIT_59 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16247
    INIT_5A : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16248
    INIT_5B : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16249
    INIT_5C : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16250
    INIT_5D : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16251
    INIT_5E : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16252
    INIT_5F : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16253
    INIT_60 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16254
    INIT_61 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16255
    INIT_62 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16256
    INIT_63 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16257
    INIT_64 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16258
    INIT_65 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16259
    INIT_66 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16260
    INIT_67 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16261
    INIT_68 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16262
    INIT_69 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16263
    INIT_6A : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16264
    INIT_6B : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16265
    INIT_6C : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16266
    INIT_6D : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16267
    INIT_6E : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16268
    INIT_6F : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16269
    INIT_70 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16270
    INIT_71 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16271
    INIT_72 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16272
    INIT_73 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16273
    INIT_74 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16274
    INIT_75 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16275
    INIT_76 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16276
    INIT_77 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16277
    INIT_78 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16278
    INIT_79 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16279
    INIT_7A : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16280
    INIT_7B : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16281
    INIT_7C : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16282
    INIT_7D : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16283
    INIT_7E : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16284
    INIT_7F : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
16285
    INIT_A : bit_vector := X"000000000000000000";
16286
    INIT_B : bit_vector := X"000000000000000000";
16287
    RAM_EXTENSION_A : string := "NONE";
16288
    RAM_EXTENSION_B : string := "NONE";
16289
    READ_WIDTH_A : integer := 0;
16290
    READ_WIDTH_B : integer := 0;
16291
    SETUP_ALL : time := 1000 ps;
16292
    SETUP_READ_FIRST : time := 3000 ps;
16293
    SIM_COLLISION_CHECK : string := "ALL";
16294
    SRVAL_A : bit_vector := X"000000000000000000";
16295
    SRVAL_B : bit_vector := X"000000000000000000";
16296
    WRITE_MODE_A : string := "WRITE_FIRST";
16297
    WRITE_MODE_B : string := "WRITE_FIRST";
16298
    WRITE_WIDTH_A : integer := 0;
16299
    WRITE_WIDTH_B : integer := 0
16300
 
16301
    );
16302
 
16303
  port (
16304
 
16305
    CASCADEOUTLATA : out std_ulogic;
16306
    CASCADEOUTLATB : out std_ulogic;
16307
    CASCADEOUTREGA : out std_ulogic;
16308
    CASCADEOUTREGB : out std_ulogic;
16309
    DBITERR : out std_ulogic;
16310
    DOA : out std_logic_vector(63 downto 0);
16311
    DOB : out std_logic_vector(63 downto 0);
16312
    DOPA : out std_logic_vector(7 downto 0);
16313
    DOPB : out std_logic_vector(7 downto 0);
16314
    ECCPARITY : out std_logic_vector(7 downto 0);
16315
    SBITERR : out std_ulogic;
16316
 
16317
    ADDRA : in std_logic_vector(15 downto 0);
16318
    ADDRB : in std_logic_vector(15 downto 0);
16319
    CASCADEINLATA : in std_ulogic;
16320
    CASCADEINLATB : in std_ulogic;
16321
    CASCADEINREGA : in std_ulogic;
16322
    CASCADEINREGB : in std_ulogic;
16323
    CLKA : in std_ulogic;
16324
    CLKB : in std_ulogic;
16325
    DIA : in std_logic_vector(63 downto 0);
16326
    DIB : in std_logic_vector(63 downto 0);
16327
    DIPA : in std_logic_vector(7 downto 0);
16328
    DIPB : in std_logic_vector(7 downto 0);
16329
    ENA : in std_ulogic;
16330
    ENB : in std_ulogic;
16331
    REGCEA : in std_ulogic;
16332
    REGCEB : in std_ulogic;
16333
    REGCLKA : in std_ulogic;
16334
    REGCLKB : in std_ulogic;
16335
    SSRA : in std_ulogic;
16336
    SSRB : in std_ulogic;
16337
    WEA : in std_logic_vector(7 downto 0);
16338
    WEB : in std_logic_vector(7 downto 0)
16339
 
16340
  );
16341
end ARAMB36_INTERNAL;
16342
 
16343
-- Architecture body --
16344
 
16345
architecture ARAMB36_INTERNAL_V of ARAMB36_INTERNAL is
16346
 
16347
    signal ADDRA_dly    : std_logic_vector(15 downto 0) := (others => 'X');
16348
    signal CLKA_dly     : std_ulogic                    := 'X';
16349
    signal DIA_dly      : std_logic_vector(63 downto 0) := (others => 'X');
16350
    signal DIPA_dly     : std_logic_vector(7 downto 0)  := (others => 'X');
16351
    signal ENA_dly      : std_ulogic                    := 'X';
16352
    signal REGCEA_dly   : std_ulogic                    := 'X';
16353
    signal SSRA_dly     : std_ulogic                    := 'X';
16354
    signal WEA_dly      : std_logic_vector(7 downto 0)  := (others => 'X');
16355
    signal CASCADEINLATA_dly      : std_ulogic          := 'X';
16356
    signal CASCADEINREGA_dly      : std_ulogic          := 'X';
16357
    signal ADDRB_dly    : std_logic_vector(15 downto 0) := (others => 'X');
16358
    signal CLKB_dly     : std_ulogic                    := 'X';
16359
    signal DIB_dly      : std_logic_vector(63 downto 0) := (others => 'X');
16360
    signal DIPB_dly     : std_logic_vector(7 downto 0)  := (others => 'X');
16361
    signal ENB_dly      : std_ulogic                    := 'X';
16362
    signal REGCEB_dly   : std_ulogic                    := 'X';
16363
    signal REGCLKA_dly   : std_ulogic                    := 'X';
16364
    signal REGCLKB_dly   : std_ulogic                    := 'X';
16365
    signal SSRB_dly     : std_ulogic                    := 'X';
16366
    signal WEB_dly      : std_logic_vector(7 downto 0)  := (others => 'X');
16367
    signal CASCADEINLATB_dly      : std_ulogic          := 'X';
16368
    signal CASCADEINREGB_dly      : std_ulogic          := 'X';
16369
 
16370
    signal sbiterr_out : std_ulogic := '0';
16371
    signal dbiterr_out : std_ulogic := '0';
16372
    signal sbiterr_outreg : std_ulogic := '0';
16373
    signal dbiterr_outreg : std_ulogic := '0';
16374
    signal sbiterr_out_out : std_ulogic := '0';
16375
    signal dbiterr_out_out : std_ulogic := '0';
16376
    signal doa_out : std_logic_vector(63 downto 0) := (others => '0');
16377
    signal dopa_out : std_logic_vector(7 downto 0) := (others => '0');
16378
    signal doa_outreg : std_logic_vector(63 downto 0) := (others => '0');
16379
    signal dopa_outreg : std_logic_vector(7 downto 0) := (others => '0');
16380
    signal dob_outreg : std_logic_vector(63 downto 0) := (others => '0');
16381
    signal dopb_outreg : std_logic_vector(7 downto 0) := (others => '0');
16382
    signal dob_out : std_logic_vector(63 downto 0) := (others => '0');
16383
    signal dopb_out : std_logic_vector(7 downto 0) := (others => '0');
16384
 
16385
    signal doa_out_mux : std_logic_vector(63 downto 0) := (others => '0');
16386
    signal dopa_out_mux : std_logic_vector(7 downto 0) := (others => '0');
16387
    signal doa_outreg_mux : std_logic_vector(63 downto 0) := (others => '0');
16388
    signal dopa_outreg_mux : std_logic_vector(7 downto 0) := (others => '0');
16389
    signal dob_outreg_mux : std_logic_vector(63 downto 0) := (others => '0');
16390
    signal dopb_outreg_mux : std_logic_vector(7 downto 0) := (others => '0');
16391
    signal dob_out_mux : std_logic_vector(63 downto 0) := (others => '0');
16392
    signal dopb_out_mux : std_logic_vector(7 downto 0) := (others => '0');
16393
 
16394
    signal doa_out_out : std_logic_vector(63 downto 0) := (others => '0');
16395
    signal dopa_out_out : std_logic_vector(7 downto 0) := (others => '0');
16396
    signal dob_out_out : std_logic_vector(63 downto 0) := (others => '0');
16397
    signal dopb_out_out : std_logic_vector(7 downto 0) := (others => '0');
16398
    signal addra_dly_15_reg : std_logic := '0';
16399
    signal addrb_dly_15_reg : std_logic := '0';
16400
    signal addra_dly_15_reg1 : std_logic := '0';
16401
    signal addrb_dly_15_reg1 : std_logic := '0';
16402
    signal cascade_a : std_logic_vector(1 downto 0) := (others => '0');
16403
    signal cascade_b : std_logic_vector(1 downto 0) := (others => '0');
16404
    signal GSR_dly : std_ulogic := 'X';
16405
    signal eccparity_out : std_logic_vector(7 downto 0) := (others => 'X');
16406
    signal SRVAL_A_STD : std_logic_vector(SRVAL_A'length-1 downto 0) := To_StdLogicVector(SRVAL_A);
16407
    signal SRVAL_B_STD : std_logic_vector(SRVAL_B'length-1 downto 0) := To_StdLogicVector(SRVAL_B);
16408
    signal INIT_A_STD : std_logic_vector(INIT_A'length-1 downto 0) := To_StdLogicVector(INIT_A);
16409
    signal INIT_B_STD : std_logic_vector(INIT_B'length-1 downto 0) := To_StdLogicVector(INIT_B);
16410
    signal di_x : std_logic_vector(63 downto 0) := (others => 'X');
16411
 
16412
  function GetWidestWidth (
16413
    wr_width_a : in integer;
16414
    rd_width_a : in integer;
16415
    wr_width_b : in integer;
16416
    rd_width_b : in integer
16417
    ) return integer is
16418
    variable func_widest_width : integer;
16419
  begin
16420
    if ((wr_width_a >= wr_width_b) and (wr_width_a >= rd_width_a) and (wr_width_a >= rd_width_b)) then
16421
      func_widest_width := wr_width_a;
16422
    elsif ((wr_width_b >= wr_width_a) and (wr_width_b >= rd_width_a) and (wr_width_b >= rd_width_b)) then
16423
      func_widest_width := wr_width_b;
16424
    elsif ((rd_width_a >= wr_width_a) and (rd_width_a >= wr_width_b) and (rd_width_a >= rd_width_b)) then
16425
      func_widest_width := rd_width_a;
16426
    elsif ((rd_width_b >= wr_width_a) and (rd_width_b >= wr_width_b) and (rd_width_b >= rd_width_a)) then
16427
      func_widest_width := rd_width_b;
16428
    end if;
16429
    return func_widest_width;
16430
  end;
16431
 
16432
 
16433
  function GetWidth (
16434
    rdwr_width : in integer
16435
    ) return integer is
16436
    variable func_width : integer;
16437
  begin
16438
    case rdwr_width is
16439
      when 1 => func_width := 1;
16440
      when 2 => func_width := 2;
16441
      when 4 => func_width := 4;
16442
      when 9 => func_width := 8;
16443
      when 18 => func_width := 16;
16444
      when 36 => func_width := 32;
16445
      when 72 => func_width := 64;
16446
      when others => func_width := 1;
16447
    end case;
16448
    return func_width;
16449
  end;
16450
 
16451
 
16452
  function GetWidthp (
16453
    rdwr_widthp : in integer
16454
    ) return integer is
16455
    variable func_widthp : integer;
16456
  begin
16457
    case rdwr_widthp is
16458
      when 9 => func_widthp := 1;
16459
      when 18 => func_widthp := 2;
16460
      when 36 => func_widthp := 4;
16461
      when 72 => func_widthp := 8;
16462
      when others => func_widthp := 1;
16463
    end case;
16464
    return func_widthp;
16465
  end;
16466
 
16467
 
16468
  function GetMemoryDepth (
16469
    rdwr_width : in integer;
16470
    func_bram_size : in integer
16471
    ) return integer is
16472
    variable func_mem_depth : integer;
16473
  begin
16474
    case rdwr_width is
16475
      when 1 => if (func_bram_size = 18) then
16476
                  func_mem_depth := 16384;
16477
                else
16478
                  func_mem_depth := 32768;
16479
                end if;
16480
      when 2 => if (func_bram_size = 18) then
16481
                  func_mem_depth := 8192;
16482
                else
16483
                  func_mem_depth := 16384;
16484
                end if;
16485
      when 4 => if (func_bram_size = 18) then
16486
                  func_mem_depth := 4096;
16487
                else
16488
                  func_mem_depth := 8192;
16489
                end if;
16490
      when 9 => if (func_bram_size = 18) then
16491
                  func_mem_depth := 2048;
16492
                else
16493
                  func_mem_depth := 4096;
16494
                end if;
16495
      when 18 => if (func_bram_size = 18) then
16496
                   func_mem_depth := 1024;
16497
                 else
16498
                   func_mem_depth := 2048;
16499
                 end if;
16500
      when 36 => if (func_bram_size = 18) then
16501
                   func_mem_depth := 512;
16502
                 else
16503
                   func_mem_depth := 1024;
16504
                 end if;
16505
      when 72 => if (func_bram_size = 18) then
16506
                   func_mem_depth := 0;
16507
                 else
16508
                   func_mem_depth := 512;
16509
                 end if;
16510
      when others => func_mem_depth := 32768;
16511
    end case;
16512
    return func_mem_depth;
16513
  end;
16514
 
16515
 
16516
  function GetMemoryDepthP (
16517
    rdwr_width : in integer;
16518
    func_bram_size : in integer
16519
    ) return integer is
16520
    variable func_memp_depth : integer;
16521
  begin
16522
    case rdwr_width is
16523
      when 9 => if (func_bram_size = 18) then
16524
                  func_memp_depth := 2048;
16525
                else
16526
                  func_memp_depth := 4096;
16527
                end if;
16528
      when 18 => if (func_bram_size = 18) then
16529
                   func_memp_depth := 1024;
16530
                 else
16531
                   func_memp_depth := 2048;
16532
                 end if;
16533
      when 36 => if (func_bram_size = 18) then
16534
                   func_memp_depth := 512;
16535
                 else
16536
                   func_memp_depth := 1024;
16537
                 end if;
16538
      when 72 => if (func_bram_size = 18) then
16539
                   func_memp_depth := 0;
16540
                 else
16541
                   func_memp_depth := 512;
16542
                 end if;
16543
      when others => func_memp_depth := 4096;
16544
    end case;
16545
    return func_memp_depth;
16546
  end;
16547
 
16548
 
16549
  function GetAddrBitLSB (
16550
    rdwr_width : in integer
16551
    ) return integer is
16552
    variable func_lsb : integer;
16553
  begin
16554
    case rdwr_width is
16555
      when 1 => func_lsb := 0;
16556
      when 2 => func_lsb := 1;
16557
      when 4 => func_lsb := 2;
16558
      when 9 => func_lsb := 3;
16559
      when 18 => func_lsb := 4;
16560
      when 36 => func_lsb := 5;
16561
      when 72 => func_lsb := 6;
16562
      when others => func_lsb := 10;
16563
    end case;
16564
    return func_lsb;
16565
  end;
16566
 
16567
 
16568
  function GetAddrBit124 (
16569
    rdwr_width : in integer;
16570
    w_width : in integer
16571
    ) return integer is
16572
    variable func_widest_width : integer;
16573
  begin
16574
    case rdwr_width is
16575
      when 1 => case w_width is
16576
                  when 2 => func_widest_width := 0;
16577
                  when 4 => func_widest_width := 1;
16578
                  when 9 => func_widest_width := 2;
16579
                  when 18 => func_widest_width := 3;
16580
                  when 36 => func_widest_width := 4;
16581
                  when 72 => func_widest_width := 5;
16582
                  when others => func_widest_width := 10;
16583
                end case;
16584
      when 2 => case w_width is
16585
                  when 4 => func_widest_width := 1;
16586
                  when 9 => func_widest_width := 2;
16587
                  when 18 => func_widest_width := 3;
16588
                  when 36 => func_widest_width := 4;
16589
                  when 72 => func_widest_width := 5;
16590
                  when others => func_widest_width := 10;
16591
                end case;
16592
      when 4 => case w_width is
16593
                  when 9 => func_widest_width := 2;
16594
                  when 18 => func_widest_width := 3;
16595
                  when 36 => func_widest_width := 4;
16596
                  when 72 => func_widest_width := 5;
16597
                  when others => func_widest_width := 10;
16598
                end case;
16599
      when others => func_widest_width := 10;
16600
    end case;
16601
    return func_widest_width;
16602
  end;
16603
 
16604
 
16605
  function GetAddrBit8 (
16606
    rdwr_width : in integer;
16607
    w_width : in integer
16608
    ) return integer is
16609
    variable func_widest_width : integer;
16610
  begin
16611
    case rdwr_width is
16612
      when 9 => case w_width is
16613
                  when 18 => func_widest_width := 3;
16614
                  when 36 => func_widest_width := 4;
16615
                  when 72 => func_widest_width := 5;
16616
                  when others => func_widest_width := 10;
16617
                end case;
16618
      when others => func_widest_width := 10;
16619
    end case;
16620
    return func_widest_width;
16621
  end;
16622
 
16623
 
16624
  function GetAddrBit16 (
16625
    rdwr_width : in integer;
16626
    w_width : in integer
16627
    ) return integer is
16628
    variable func_widest_width : integer;
16629
  begin
16630
    case rdwr_width is
16631
      when 18 => case w_width is
16632
                  when 36 => func_widest_width := 4;
16633
                  when 72 => func_widest_width := 5;
16634
                  when others => func_widest_width := 10;
16635
                end case;
16636
      when others => func_widest_width := 10;
16637
    end case;
16638
    return func_widest_width;
16639
  end;
16640
 
16641
 
16642
  function GetAddrBit32 (
16643
    rdwr_width : in integer;
16644
    w_width : in integer
16645
    ) return integer is
16646
    variable func_widest_width : integer;
16647
  begin
16648
    case rdwr_width is
16649
      when 36 => case w_width is
16650
                  when 72 => func_widest_width := 5;
16651
                  when others => func_widest_width := 10;
16652
                end case;
16653
      when others => func_widest_width := 10;
16654
    end case;
16655
    return func_widest_width;
16656
  end;
16657
 
16658
  ---------------------------------------------------------------------------
16659
  -- Function SLV_X_TO_HEX returns a hex string version of the std_logic_vector
16660
  -- argument.
16661
  ---------------------------------------------------------------------------
16662
  function SLV_X_TO_HEX (
16663
    SLV : in std_logic_vector;
16664
    string_length : in integer
16665
    ) return string is
16666
 
16667
    variable i : integer := 1;
16668
    variable j : integer := 1;
16669
    variable STR : string(string_length downto 1);
16670
    variable nibble : std_logic_vector(3 downto 0) := "0000";
16671
    variable full_nibble_count : integer := 0;
16672
    variable remaining_bits : integer := 0;
16673
 
16674
  begin
16675
    full_nibble_count := SLV'length/4;
16676
    remaining_bits := SLV'length mod 4;
16677
    for i in 1 to full_nibble_count loop
16678
      nibble := SLV(((4*i) - 1) downto ((4*i) - 4));
16679
      if (((nibble(0) xor nibble(1) xor nibble (2) xor nibble(3)) /= '1') and
16680
          (nibble(0) xor nibble(1) xor nibble (2) xor nibble(3)) /= '0')  then
16681
        STR(j) := 'x';
16682
      elsif (nibble = "0000")  then
16683
        STR(j) := '0';
16684
      elsif (nibble = "0001")  then
16685
        STR(j) := '1';
16686
      elsif (nibble = "0010")  then
16687
        STR(j) := '2';
16688
      elsif (nibble = "0011")  then
16689
        STR(j) := '3';
16690
      elsif (nibble = "0100")  then
16691
        STR(j) := '4';
16692
      elsif (nibble = "0101")  then
16693
        STR(j) := '5';
16694
      elsif (nibble = "0110")  then
16695
        STR(j) := '6';
16696
      elsif (nibble = "0111")  then
16697
        STR(j) := '7';
16698
      elsif (nibble = "1000")  then
16699
        STR(j) := '8';
16700
      elsif (nibble = "1001")  then
16701
        STR(j) := '9';
16702
      elsif (nibble = "1010")  then
16703
        STR(j) := 'a';
16704
      elsif (nibble = "1011")  then
16705
        STR(j) := 'b';
16706
      elsif (nibble = "1100")  then
16707
        STR(j) := 'c';
16708
      elsif (nibble = "1101")  then
16709
        STR(j) := 'd';
16710
      elsif (nibble = "1110")  then
16711
        STR(j) := 'e';
16712
      elsif (nibble = "1111")  then
16713
        STR(j) := 'f';
16714
      end if;
16715
      j := j + 1;
16716
    end loop;
16717
 
16718
    if (remaining_bits /= 0) then
16719
      nibble := "0000";
16720
      nibble((remaining_bits -1) downto 0) := SLV((SLV'length -1) downto (SLV'length - remaining_bits));
16721
      if (((nibble(0) xor nibble(1) xor nibble (2) xor nibble(3)) /= '1') and
16722
          (nibble(0) xor nibble(1) xor nibble (2) xor nibble(3)) /= '0')  then
16723
        STR(j) := 'x';
16724
      elsif (nibble = "0000")  then
16725
        STR(j) := '0';
16726
      elsif (nibble = "0001")  then
16727
        STR(j) := '1';
16728
      elsif (nibble = "0010")  then
16729
        STR(j) := '2';
16730
      elsif (nibble = "0011")  then
16731
        STR(j) := '3';
16732
      elsif (nibble = "0100")  then
16733
        STR(j) := '4';
16734
      elsif (nibble = "0101")  then
16735
        STR(j) := '5';
16736
      elsif (nibble = "0110")  then
16737
        STR(j) := '6';
16738
      elsif (nibble = "0111")  then
16739
        STR(j) := '7';
16740
      elsif (nibble = "1000")  then
16741
        STR(j) := '8';
16742
      elsif (nibble = "1001")  then
16743
        STR(j) := '9';
16744
      elsif (nibble = "1010")  then
16745
        STR(j) := 'a';
16746
      elsif (nibble = "1011")  then
16747
        STR(j) := 'b';
16748
      elsif (nibble = "1100")  then
16749
        STR(j) := 'c';
16750
      elsif (nibble = "1101")  then
16751
        STR(j) := 'd';
16752
      elsif (nibble = "1110")  then
16753
        STR(j) := 'e';
16754
      elsif (nibble = "1111")  then
16755
        STR(j) := 'f';
16756
      end if;
16757
    end if;
16758
    return STR;
16759
  end SLV_X_TO_HEX;
16760
 
16761
  constant widest_width : integer := GetWidestWidth(WRITE_WIDTH_A, READ_WIDTH_A, WRITE_WIDTH_B, READ_WIDTH_B);
16762
  constant mem_depth : integer := GetMemoryDepth(widest_width, BRAM_SIZE);
16763
  constant memp_depth : integer := GetMemoryDepthP(widest_width, BRAM_SIZE);
16764
  constant width : integer := GetWidth(widest_width);
16765
  constant widthp : integer := GetWidthp(widest_width);
16766
  constant wa_width : integer := GetWidth(WRITE_WIDTH_A);
16767
  constant wb_width : integer := GetWidth(WRITE_WIDTH_B);
16768
  constant ra_width : integer := GetWidth(READ_WIDTH_A);
16769
  constant rb_width : integer := GetWidth(READ_WIDTH_B);
16770
  constant wa_widthp : integer := GetWidthp(WRITE_WIDTH_A);
16771
  constant wb_widthp : integer := GetWidthp(WRITE_WIDTH_B);
16772
  constant ra_widthp : integer := GetWidthp(READ_WIDTH_A);
16773
  constant rb_widthp : integer := GetWidthp(READ_WIDTH_B);
16774
  constant r_addra_lbit_124 : integer := GetAddrBitLSB(READ_WIDTH_A);
16775
  constant r_addrb_lbit_124 : integer := GetAddrBitLSB(READ_WIDTH_B);
16776
  constant w_addra_lbit_124 : integer := GetAddrBitLSB(WRITE_WIDTH_A);
16777
  constant w_addrb_lbit_124 : integer := GetAddrBitLSB(WRITE_WIDTH_B);
16778
  constant w_addra_bit_124 : integer := GetAddrBit124(WRITE_WIDTH_A, widest_width);
16779
  constant r_addra_bit_124 : integer := GetAddrBit124(READ_WIDTH_A, widest_width);
16780
  constant w_addrb_bit_124 : integer := GetAddrBit124(WRITE_WIDTH_B, widest_width);
16781
  constant r_addrb_bit_124 : integer := GetAddrBit124(READ_WIDTH_B, widest_width);
16782
  constant w_addra_bit_8 : integer := GetAddrBit8(WRITE_WIDTH_A, widest_width);
16783
  constant r_addra_bit_8 : integer := GetAddrBit8(READ_WIDTH_A, widest_width);
16784
  constant w_addrb_bit_8 : integer := GetAddrBit8(WRITE_WIDTH_B, widest_width);
16785
  constant r_addrb_bit_8 : integer := GetAddrBit8(READ_WIDTH_B, widest_width);
16786
  constant w_addra_bit_16 : integer := GetAddrBit16(WRITE_WIDTH_A, widest_width);
16787
  constant r_addra_bit_16 : integer := GetAddrBit16(READ_WIDTH_A, widest_width);
16788
  constant w_addrb_bit_16 : integer := GetAddrBit16(WRITE_WIDTH_B, widest_width);
16789
  constant r_addrb_bit_16 : integer := GetAddrBit16(READ_WIDTH_B, widest_width);
16790
  constant w_addra_bit_32 : integer := GetAddrBit32(WRITE_WIDTH_A, widest_width);
16791
  constant r_addra_bit_32 : integer := GetAddrBit32(READ_WIDTH_A, widest_width);
16792
  constant w_addrb_bit_32 : integer := GetAddrBit32(WRITE_WIDTH_B, widest_width);
16793
  constant r_addrb_bit_32 : integer := GetAddrBit32(READ_WIDTH_B, widest_width);
16794
  constant col_addr_lsb : integer := GetAddrBitLSB(widest_width);
16795
 
16796
  type Two_D_array_type is array ((mem_depth -  1) downto 0) of std_logic_vector((width - 1) downto 0);
16797
  type Two_D_parity_array_type is array ((memp_depth - 1) downto 0) of std_logic_vector((widthp -1) downto 0);
16798
 
16799
  function slv_to_two_D_array(
16800
    slv_length : integer;
16801
    slv_width : integer;
16802
    SLV : in std_logic_vector
16803
    )
16804
    return two_D_array_type is
16805
    variable two_D_array : two_D_array_type;
16806
    variable intermediate : std_logic_vector((slv_width - 1) downto 0);
16807
  begin
16808
    for i in 0 to (slv_length - 1) loop
16809
      intermediate := SLV(((i*slv_width) + (slv_width - 1)) downto (i* slv_width));
16810
      two_D_array(i) := intermediate;
16811
    end loop;
16812
    return two_D_array;
16813
  end;
16814
 
16815
  function slv_to_two_D_parity_array(
16816
    slv_length : integer;
16817
    slv_width : integer;
16818
    SLV : in std_logic_vector
16819
    )
16820
    return two_D_parity_array_type is
16821
    variable two_D_parity_array : two_D_parity_array_type;
16822
    variable intermediate : std_logic_vector((slv_width - 1) downto 0);
16823
  begin
16824
    for i in 0 to (slv_length - 1)loop
16825
      intermediate := SLV(((i*slv_width) + (slv_width - 1)) downto (i* slv_width));
16826
      two_D_parity_array(i) := intermediate;
16827
    end loop;
16828
    return two_D_parity_array;
16829
  end;
16830
 
16831
 
16832
  function fn_dip_ecc (
16833
    encode : in std_logic;
16834
    di_in : in std_logic_vector (63 downto 0);
16835
    dip_in : in std_logic_vector (7 downto 0)
16836
    ) return std_logic_vector is
16837
    variable fn_dip_ecc : std_logic_vector (7 downto 0);
16838
  begin
16839
 
16840
    fn_dip_ecc(0) := di_in(0) xor di_in(1) xor di_in(3) xor di_in(4) xor di_in(6) xor di_in(8)
16841
                  xor di_in(10) xor di_in(11) xor di_in(13) xor di_in(15) xor di_in(17) xor di_in(19)
16842
                  xor di_in(21) xor di_in(23) xor di_in(25) xor di_in(26) xor di_in(28)
16843
                  xor di_in(30) xor di_in(32) xor di_in(34) xor di_in(36) xor di_in(38)
16844
                  xor di_in(40) xor di_in(42) xor di_in(44) xor di_in(46) xor di_in(48)
16845
                  xor di_in(50) xor di_in(52) xor di_in(54) xor di_in(56) xor di_in(57) xor di_in(59)
16846
                  xor di_in(61) xor di_in(63);
16847
 
16848
    fn_dip_ecc(1) := di_in(0) xor di_in(2) xor di_in(3) xor di_in(5) xor di_in(6) xor di_in(9)
16849
                     xor di_in(10) xor di_in(12) xor di_in(13) xor di_in(16) xor di_in(17)
16850
                     xor di_in(20) xor di_in(21) xor di_in(24) xor di_in(25) xor di_in(27) xor di_in(28)
16851
                     xor di_in(31) xor di_in(32) xor di_in(35) xor di_in(36) xor di_in(39)
16852
                     xor di_in(40) xor di_in(43) xor di_in(44) xor di_in(47) xor di_in(48)
16853
                     xor di_in(51) xor di_in(52) xor di_in(55) xor di_in(56) xor di_in(58) xor di_in(59)
16854
                     xor di_in(62) xor di_in(63);
16855
 
16856
    fn_dip_ecc(2) := di_in(1) xor di_in(2) xor di_in(3) xor di_in(7) xor di_in(8) xor di_in(9)
16857
                     xor di_in(10) xor di_in(14) xor di_in(15) xor di_in(16) xor di_in(17)
16858
                     xor di_in(22) xor di_in(23) xor di_in(24) xor di_in(25) xor di_in(29)
16859
                     xor di_in(30) xor di_in(31) xor di_in(32) xor di_in(37) xor di_in(38) xor di_in(39)
16860
                     xor di_in(40) xor di_in(45) xor di_in(46) xor di_in(47) xor di_in(48)
16861
                     xor di_in(53) xor di_in(54) xor di_in(55) xor di_in(56)
16862
                     xor di_in(60) xor di_in(61) xor di_in(62) xor di_in(63);
16863
 
16864
    fn_dip_ecc(3) := di_in(4) xor di_in(5) xor di_in(6) xor di_in(7) xor di_in(8) xor di_in(9)
16865
                     xor di_in(10) xor di_in(18) xor di_in(19)
16866
                     xor di_in(20) xor di_in(21) xor di_in(22) xor di_in(23) xor di_in(24) xor di_in(25)
16867
                     xor di_in(33) xor di_in(34) xor di_in(35) xor di_in(36) xor di_in(37) xor di_in(38) xor di_in(39)
16868
                     xor di_in(40) xor di_in(49)
16869
                     xor di_in(50) xor di_in(51) xor di_in(52) xor di_in(53) xor di_in(54) xor di_in(55) xor di_in(56);
16870
 
16871
    fn_dip_ecc(4) := di_in(11) xor di_in(12) xor di_in(13) xor di_in(14) xor di_in(15) xor di_in(16) xor di_in(17)
16872
                     xor di_in(18) xor di_in(19) xor di_in(20) xor di_in(21) xor di_in(22) xor di_in(23) xor di_in(24)
16873
                     xor di_in(25) xor di_in(41) xor di_in(42) xor di_in(43) xor di_in(44) xor di_in(45) xor di_in(46)
16874
                     xor di_in(47) xor di_in(48) xor di_in(49) xor di_in(50) xor di_in(51) xor di_in(52) xor di_in(53)
16875
                     xor di_in(54) xor di_in(55) xor di_in(56);
16876
 
16877
 
16878
    fn_dip_ecc(5) := di_in(26) xor di_in(27) xor di_in(28) xor di_in(29)
16879
                     xor di_in(30) xor di_in(31) xor di_in(32) xor di_in(33) xor di_in(34) xor di_in(35) xor di_in(36)
16880
                     xor di_in(37) xor di_in(38) xor di_in(39) xor di_in(40) xor di_in(41) xor di_in(42) xor di_in(43)
16881
                     xor di_in(44) xor di_in(45) xor di_in(46) xor di_in(47) xor di_in(48) xor di_in(49) xor di_in(50)
16882
                     xor di_in(51) xor di_in(52) xor di_in(53) xor di_in(54) xor di_in(55) xor di_in(56);
16883
 
16884
    fn_dip_ecc(6) := di_in(57) xor di_in(58) xor di_in(59)
16885
                     xor di_in(60) xor di_in(61) xor di_in(62) xor di_in(63);
16886
 
16887
    if (encode = '1') then
16888
 
16889
      fn_dip_ecc(7) := fn_dip_ecc(0) xor fn_dip_ecc(1) xor fn_dip_ecc(2) xor fn_dip_ecc(3) xor fn_dip_ecc(4) xor fn_dip_ecc(5)
16890
                       xor fn_dip_ecc(6) xor di_in(0) xor di_in(1) xor di_in(2) xor di_in(3) xor di_in(4) xor di_in(5)
16891
                       xor di_in(6) xor di_in(7) xor di_in(8) xor di_in(9) xor di_in(10) xor di_in(11) xor di_in(12)
16892
                       xor di_in(13) xor di_in(14) xor di_in(15) xor di_in(16) xor di_in(17) xor di_in(18) xor di_in(19)
16893
                       xor di_in(20) xor di_in(21) xor di_in(22) xor di_in(23) xor di_in(24) xor di_in(25) xor di_in(26)
16894
                       xor di_in(27) xor di_in(28) xor di_in(29) xor di_in(30) xor di_in(31) xor di_in(32) xor di_in(33)
16895
                       xor di_in(34) xor di_in(35) xor di_in(36) xor di_in(37) xor di_in(38) xor di_in(39) xor di_in(40)
16896
                       xor di_in(41) xor di_in(42) xor di_in(43) xor di_in(44) xor di_in(45) xor di_in(46) xor di_in(47)
16897
                       xor di_in(48) xor di_in(49) xor di_in(50) xor di_in(51) xor di_in(52) xor di_in(53) xor di_in(54)
16898
                       xor di_in(55) xor di_in(56) xor di_in(57) xor di_in(58) xor di_in(59) xor di_in(60) xor di_in(61)
16899
                       xor di_in(62) xor di_in(63);
16900
 
16901
    else
16902
 
16903
      fn_dip_ecc(7) := dip_in(0) xor dip_in(1) xor dip_in(2) xor dip_in(3) xor dip_in(4) xor dip_in(5)
16904
                       xor dip_in(6) xor di_in(0) xor di_in(1) xor di_in(2) xor di_in(3) xor di_in(4) xor di_in(5)
16905
                       xor di_in(6) xor di_in(7) xor di_in(8) xor di_in(9) xor di_in(10) xor di_in(11) xor di_in(12)
16906
                       xor di_in(13) xor di_in(14) xor di_in(15) xor di_in(16) xor di_in(17) xor di_in(18) xor di_in(19)
16907
                       xor di_in(20) xor di_in(21) xor di_in(22) xor di_in(23) xor di_in(24) xor di_in(25) xor di_in(26)
16908
                       xor di_in(27) xor di_in(28) xor di_in(29) xor di_in(30) xor di_in(31) xor di_in(32) xor di_in(33)
16909
                       xor di_in(34) xor di_in(35) xor di_in(36) xor di_in(37) xor di_in(38) xor di_in(39) xor di_in(40)
16910
                       xor di_in(41) xor di_in(42) xor di_in(43) xor di_in(44) xor di_in(45) xor di_in(46) xor di_in(47)
16911
                       xor di_in(48) xor di_in(49) xor di_in(50) xor di_in(51) xor di_in(52) xor di_in(53) xor di_in(54)
16912
                       xor di_in(55) xor di_in(56) xor di_in(57) xor di_in(58) xor di_in(59) xor di_in(60) xor di_in(61)
16913
                       xor di_in(62) xor di_in(63);
16914
    end if;
16915
 
16916
    return fn_dip_ecc;
16917
 
16918
  end fn_dip_ecc;
16919
 
16920
 
16921
  procedure prcd_chk_for_col_msg (
16922
    constant wea_tmp : in std_ulogic;
16923
    constant web_tmp : in std_ulogic;
16924
    constant addra_tmp : in std_logic_vector (15 downto 0);
16925
    constant addrb_tmp : in std_logic_vector (15 downto 0);
16926
    variable col_wr_wr_msg : inout std_ulogic;
16927
    variable col_wra_rdb_msg : inout std_ulogic;
16928
    variable col_wrb_rda_msg : inout std_ulogic
16929
    ) is
16930
 
16931
    variable string_length_1 : integer;
16932
    variable string_length_2 : integer;
16933
    variable message : LINE;
16934
    constant MsgSeverity : severity_level := Error;
16935
 
16936
  begin
16937
 
16938
    if ((SIM_COLLISION_CHECK = "ALL" or SIM_COLLISION_CHECK = "WARNING_ONLY")
16939
        and (not(((WRITE_MODE_B = "READ_FIRST" and web_tmp = '1' and wea_tmp = '0') and (not(rising_edge(clka_dly) and (not(rising_edge(clkb_dly))))))
16940
              or ((WRITE_MODE_A = "READ_FIRST" and wea_tmp = '1' and web_tmp = '0') and (not(rising_edge(clkb_dly) and (not(rising_edge(clka_dly))))))))) then
16941
 
16942
      if ((addra_tmp'length mod 4) = 0) then
16943
        string_length_1 := addra_tmp'length/4;
16944
      elsif ((addra_tmp'length mod 4) > 0) then
16945
        string_length_1 := addra_tmp'length/4 + 1;
16946
      end if;
16947
      if ((addrb_tmp'length mod 4) = 0) then
16948
        string_length_2 := addrb_tmp'length/4;
16949
      elsif ((addrb_tmp'length mod 4) > 0) then
16950
        string_length_2 := addrb_tmp'length/4 + 1;
16951
      end if;
16952
 
16953
      if (wea_tmp = '1' and web_tmp = '1' and col_wr_wr_msg = '1') then
16954
        Write ( message, STRING'(" Memory Collision Error on ARAMB36_INTERNAL :"));
16955
        Write ( message, STRING'(ARAMB36_INTERNAL'path_name));
16956
        Write ( message, STRING'(" at simulation time "));
16957
        Write ( message, now);
16958
        Write ( message, STRING'("."));
16959
        Write ( message, LF );
16960
        Write ( message, STRING'(" A write was requested to the same address simultaneously at both Port A and Port B of the RAM."));
16961
        Write ( message, STRING'(" The contents written to the RAM at address location "));
16962
        Write ( message, SLV_X_TO_HEX(addra_tmp, string_length_1));
16963
        Write ( message, STRING'(" (hex) "));
16964
        Write ( message, STRING'("of Port A and address location "));
16965
        Write ( message, SLV_X_TO_HEX(addrb_tmp, string_length_2));
16966
        Write ( message, STRING'(" (hex) "));
16967
        Write ( message, STRING'("of Port B are unknown. "));
16968
        ASSERT FALSE REPORT message.ALL SEVERITY MsgSeverity;
16969
        DEALLOCATE (message);
16970
        col_wr_wr_msg := '0';
16971
 
16972
      elsif (wea_tmp = '1' and web_tmp = '0' and col_wra_rdb_msg = '1') then
16973
        Write ( message, STRING'(" Memory Collision Error on ARAMB36_INTERNAL :"));
16974
        Write ( message, STRING'(ARAMB36_INTERNAL'path_name));
16975
        Write ( message, STRING'(" at simulation time "));
16976
        Write ( message, now);
16977
        Write ( message, STRING'("."));
16978
        Write ( message, LF );
16979
        Write ( message, STRING'(" A read was performed on address "));
16980
        Write ( message, SLV_X_TO_HEX(addrb_tmp, string_length_2));
16981
        Write ( message, STRING'(" (hex) "));
16982
        Write ( message, STRING'("of port B while a write was requested to the same address on Port A. "));
16983
        Write ( message, STRING'(" The write will be successful however the read value on port B is unknown until the next CLKB cycle. "));
16984
        ASSERT FALSE REPORT message.ALL SEVERITY MsgSeverity;
16985
        DEALLOCATE (message);
16986
        col_wra_rdb_msg := '0';
16987
 
16988
      elsif (wea_tmp = '0' and web_tmp = '1' and col_wrb_rda_msg = '1') then
16989
        Write ( message, STRING'(" Memory Collision Error on ARAMB36_INTERNAL :"));
16990
        Write ( message, STRING'(ARAMB36_INTERNAL'path_name));
16991
        Write ( message, STRING'(" at simulation time "));
16992
        Write ( message, now);
16993
        Write ( message, STRING'("."));
16994
        Write ( message, LF );
16995
        Write ( message, STRING'(" A read was performed on address "));
16996
        Write ( message, SLV_X_TO_HEX(addra_tmp, string_length_1));
16997
        Write ( message, STRING'(" (hex) "));
16998
        Write ( message, STRING'("of port A while a write was requested to the same address on Port B. "));
16999
        Write ( message, STRING'(" The write will be successful however the read value on port A is unknown until the next CLKA cycle. "));
17000
        ASSERT FALSE REPORT message.ALL SEVERITY MsgSeverity;
17001
        DEALLOCATE (message);
17002
        col_wrb_rda_msg := '0';
17003
 
17004
      end if;
17005
 
17006
    end if;
17007
 
17008
  end prcd_chk_for_col_msg;
17009
 
17010
 
17011
  procedure prcd_write_ram (
17012
    constant we : in std_logic;
17013
    constant di : in std_logic_vector;
17014
    constant dip : in std_logic;
17015
    variable mem_proc : inout std_logic_vector;
17016
    variable memp_proc : inout std_logic
17017
    ) is
17018
 
17019
    alias di_tmp : std_logic_vector (di'length-1 downto 0) is di;
17020
    alias mem_proc_tmp : std_logic_vector (mem_proc'length-1 downto 0) is mem_proc;
17021
 
17022
    begin
17023
      if (we = '1') then
17024
        mem_proc_tmp := di_tmp;
17025
 
17026
        if (width >= 8) then
17027
          memp_proc := dip;
17028
        end if;
17029
      end if;
17030
  end prcd_write_ram;
17031
 
17032
 
17033
  procedure prcd_write_ram_col (
17034
    constant we_o : in std_logic;
17035
    constant we : in std_logic;
17036
    constant di : in std_logic_vector;
17037
    constant dip : in std_logic;
17038
    variable mem_proc : inout std_logic_vector;
17039
    variable memp_proc : inout std_logic
17040
    ) is
17041
 
17042
    alias di_tmp : std_logic_vector (di'length-1 downto 0) is di;
17043
    alias mem_proc_tmp : std_logic_vector (mem_proc'length-1 downto 0) is mem_proc;
17044
    variable i : integer := 0;
17045
 
17046
    begin
17047
      if (we = '1') then
17048
 
17049
        for i in 0 to di'length-1 loop
17050
          if ((mem_proc_tmp(i) /= 'X') or (not(we = we_o and we = '1'))) then
17051
            mem_proc_tmp(i) := di_tmp(i);
17052
          end if;
17053
        end loop;
17054
 
17055
        if (width >= 8 and ((memp_proc /= 'X') or (not(we = we_o and we = '1')))) then
17056
          memp_proc := dip;
17057
        end if;
17058
 
17059
      end if;
17060
  end prcd_write_ram_col;
17061
 
17062
 
17063
  procedure prcd_x_buf (
17064
    constant wr_rd_mode : in std_logic_vector (1 downto 0);
17065
    constant do_uindex : in integer;
17066
    constant do_lindex : in integer;
17067
    constant dop_index : in integer;
17068
    constant do_ltmp : in std_logic_vector (63 downto 0);
17069
    variable do_tmp : inout std_logic_vector (63 downto 0);
17070
    constant dop_ltmp : in std_logic_vector (7 downto 0);
17071
    variable dop_tmp : inout std_logic_vector (7 downto 0)
17072
    ) is
17073
 
17074
    variable i : integer;
17075
 
17076
    begin
17077
      if (wr_rd_mode = "01") then
17078
        for i in do_lindex to do_uindex loop
17079
          if (do_ltmp(i) = 'X') then
17080
            do_tmp(i) := 'X';
17081
          end if;
17082
        end loop;
17083
 
17084
        if (dop_ltmp(dop_index) = 'X') then
17085
          dop_tmp(dop_index) := 'X';
17086
        end if;
17087
 
17088
      else
17089
        do_tmp(do_lindex + 7 downto do_lindex) := do_ltmp(do_lindex + 7 downto do_lindex);
17090
        dop_tmp(dop_index) := dop_ltmp(dop_index);
17091
      end if;
17092
 
17093
  end prcd_x_buf;
17094
 
17095
 
17096
  procedure prcd_rd_ram_a (
17097
    constant addra_tmp : in std_logic_vector (15 downto 0);
17098
    variable doa_tmp : inout std_logic_vector (63 downto 0);
17099
    variable dopa_tmp : inout std_logic_vector (7 downto 0);
17100
    constant mem : in Two_D_array_type;
17101
    constant memp : in Two_D_parity_array_type
17102
    ) is
17103
    variable prcd_tmp_addra_dly_depth : integer;
17104
    variable prcd_tmp_addra_dly_width : integer;
17105
 
17106
  begin
17107
 
17108
    case ra_width is
17109
 
17110
      when 1 | 2 | 4 => if (ra_width >= width) then
17111
                          prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto r_addra_lbit_124));
17112
                          doa_tmp(ra_width-1 downto 0) := mem(prcd_tmp_addra_dly_depth);
17113
                        else
17114
                          prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto r_addra_bit_124 + 1));
17115
                          prcd_tmp_addra_dly_width := SLV_TO_INT(addra_tmp(r_addra_bit_124 downto r_addra_lbit_124));
17116
                          doa_tmp(ra_width-1 downto 0) := mem(prcd_tmp_addra_dly_depth)((prcd_tmp_addra_dly_width * ra_width) + ra_width - 1 downto prcd_tmp_addra_dly_width * ra_width);
17117
                        end if;
17118
 
17119
      when 8 => if (ra_width >= width) then
17120
                  prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto 3));
17121
                  doa_tmp(7 downto 0) := mem(prcd_tmp_addra_dly_depth);
17122
                  dopa_tmp(0 downto 0) := memp(prcd_tmp_addra_dly_depth);
17123
                else
17124
                  prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto r_addra_bit_8 + 1));
17125
                  prcd_tmp_addra_dly_width := SLV_TO_INT(addra_tmp(r_addra_bit_8 downto 3));
17126
                  doa_tmp(7 downto 0) := mem(prcd_tmp_addra_dly_depth)((prcd_tmp_addra_dly_width * 8) + 7 downto prcd_tmp_addra_dly_width * 8);
17127
                  dopa_tmp(0 downto 0) := memp(prcd_tmp_addra_dly_depth)(prcd_tmp_addra_dly_width downto prcd_tmp_addra_dly_width);
17128
                end if;
17129
 
17130
      when 16 => if (ra_width >= width) then
17131
                  prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto 4));
17132
                  doa_tmp(15 downto 0) := mem(prcd_tmp_addra_dly_depth);
17133
                  dopa_tmp(1 downto 0) := memp(prcd_tmp_addra_dly_depth);
17134
                 else
17135
                  prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto r_addra_bit_16 + 1));
17136
                  prcd_tmp_addra_dly_width := SLV_TO_INT(addra_tmp(r_addra_bit_16 downto 4));
17137
                  doa_tmp(15 downto 0) := mem(prcd_tmp_addra_dly_depth)((prcd_tmp_addra_dly_width * 16) + 15 downto prcd_tmp_addra_dly_width * 16);
17138
                  dopa_tmp(1 downto 0) := memp(prcd_tmp_addra_dly_depth)((prcd_tmp_addra_dly_width * 2) + 1 downto prcd_tmp_addra_dly_width * 2);
17139
                 end if;
17140
 
17141
      when 32 => if (ra_width >= width) then
17142
                  prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto 5));
17143
                  doa_tmp(31 downto 0) := mem(prcd_tmp_addra_dly_depth);
17144
                  dopa_tmp(3 downto 0) := memp(prcd_tmp_addra_dly_depth);
17145
                end if;
17146
 
17147
      when 64 => if (ra_width >= width) then
17148
                  prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto 6));
17149
                  doa_tmp(63 downto 0) := mem(prcd_tmp_addra_dly_depth);
17150
                  dopa_tmp(7 downto 0) := memp(prcd_tmp_addra_dly_depth);
17151
                end if;
17152
 
17153
      when others => null;
17154
 
17155
    end case;
17156
 
17157
  end prcd_rd_ram_a;
17158
 
17159
 
17160
  procedure prcd_rd_ram_b (
17161
    constant addrb_tmp : in std_logic_vector (15 downto 0);
17162
    variable dob_tmp : inout std_logic_vector (63 downto 0);
17163
    variable dopb_tmp : inout std_logic_vector (7 downto 0);
17164
    constant mem : in Two_D_array_type;
17165
    constant memp : in Two_D_parity_array_type
17166
    ) is
17167
    variable prcd_tmp_addrb_dly_depth : integer;
17168
    variable prcd_tmp_addrb_dly_width : integer;
17169
 
17170
  begin
17171
 
17172
    case rb_width is
17173
 
17174
      when 1 | 2 | 4 => if (rb_width >= width) then
17175
                          prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto r_addrb_lbit_124));
17176
                          dob_tmp(rb_width-1 downto 0) := mem(prcd_tmp_addrb_dly_depth);
17177
                        else
17178
                          prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto r_addrb_bit_124 + 1));
17179
                          prcd_tmp_addrb_dly_width := SLV_TO_INT(addrb_tmp(r_addrb_bit_124 downto r_addrb_lbit_124));
17180
                          dob_tmp(rb_width-1 downto 0) := mem(prcd_tmp_addrb_dly_depth)((prcd_tmp_addrb_dly_width * rb_width) + rb_width - 1 downto prcd_tmp_addrb_dly_width * rb_width);
17181
                        end if;
17182
 
17183
      when 8 => if (rb_width >= width) then
17184
                  prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto 3));
17185
                  dob_tmp(7 downto 0) := mem(prcd_tmp_addrb_dly_depth);
17186
                  dopb_tmp(0 downto 0) := memp(prcd_tmp_addrb_dly_depth);
17187
                else
17188
                  prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto r_addrb_bit_8 + 1));
17189
                  prcd_tmp_addrb_dly_width := SLV_TO_INT(addrb_tmp(r_addrb_bit_8 downto 3));
17190
                  dob_tmp(7 downto 0) := mem(prcd_tmp_addrb_dly_depth)((prcd_tmp_addrb_dly_width * 8) + 7 downto prcd_tmp_addrb_dly_width * 8);
17191
                  dopb_tmp(0 downto 0) := memp(prcd_tmp_addrb_dly_depth)(prcd_tmp_addrb_dly_width downto prcd_tmp_addrb_dly_width);
17192
                end if;
17193
 
17194
      when 16 => if (rb_width >= width) then
17195
                  prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto 4));
17196
                  dob_tmp(15 downto 0) := mem(prcd_tmp_addrb_dly_depth);
17197
                  dopb_tmp(1 downto 0) := memp(prcd_tmp_addrb_dly_depth);
17198
                 else
17199
                  prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto r_addrb_bit_16 + 1));
17200
                  prcd_tmp_addrb_dly_width := SLV_TO_INT(addrb_tmp(r_addrb_bit_16 downto 4));
17201
                  dob_tmp(15 downto 0) := mem(prcd_tmp_addrb_dly_depth)((prcd_tmp_addrb_dly_width * 16) + 15 downto prcd_tmp_addrb_dly_width * 16);
17202
                  dopb_tmp(1 downto 0) := memp(prcd_tmp_addrb_dly_depth)((prcd_tmp_addrb_dly_width * 2) + 1 downto prcd_tmp_addrb_dly_width * 2);
17203
                 end if;
17204
 
17205
      when 32 => if (rb_width >= width) then
17206
                  prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto 5));
17207
                  dob_tmp(31 downto 0) := mem(prcd_tmp_addrb_dly_depth);
17208
                  dopb_tmp(3 downto 0) := memp(prcd_tmp_addrb_dly_depth);
17209
                end if;
17210
 
17211
      when others => null;
17212
 
17213
    end case;
17214
 
17215
  end prcd_rd_ram_b;
17216
 
17217
 
17218
  procedure prcd_col_wr_ram_a (
17219
    constant seq : in std_logic_vector (1 downto 0);
17220
    constant web_tmp : in std_logic_vector (7 downto 0);
17221
    constant wea_tmp : in std_logic_vector (7 downto 0);
17222
    constant dia_tmp : in std_logic_vector (63 downto 0);
17223
    constant dipa_tmp : in std_logic_vector (7 downto 0);
17224
    constant addrb_tmp : in std_logic_vector (15 downto 0);
17225
    constant addra_tmp : in std_logic_vector (15 downto 0);
17226
    variable mem : inout Two_D_array_type;
17227
    variable memp : inout Two_D_parity_array_type;
17228
    variable col_wr_wr_msg : inout std_ulogic;
17229
    variable col_wra_rdb_msg : inout std_ulogic;
17230
    variable col_wrb_rda_msg : inout std_ulogic
17231
    ) is
17232
    variable prcd_tmp_addra_dly_depth : integer;
17233
    variable prcd_tmp_addra_dly_width : integer;
17234
    variable junk : std_ulogic;
17235
 
17236
  begin
17237
 
17238
    case wa_width is
17239
 
17240
      when 1 | 2 | 4 => if (not(wea_tmp(0) = '1' and web_tmp(0) = '1' and wa_width > wb_width) or seq = "10") then
17241
                          if (wa_width >= width) then
17242
                            prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto w_addra_lbit_124));
17243
                            prcd_write_ram_col (web_tmp(0), wea_tmp(0), dia_tmp(wa_width-1 downto 0), '0', mem(prcd_tmp_addra_dly_depth), junk);
17244
                          else
17245
                            prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto w_addra_bit_124 + 1));
17246
                            prcd_tmp_addra_dly_width := SLV_TO_INT(addra_tmp(w_addra_bit_124 downto w_addra_lbit_124));
17247
                            prcd_write_ram_col (web_tmp(0), wea_tmp(0), dia_tmp(wa_width-1 downto 0), '0', mem(prcd_tmp_addra_dly_depth)((prcd_tmp_addra_dly_width * wa_width) + wa_width - 1 downto (prcd_tmp_addra_dly_width * wa_width)), junk);
17248
                          end if;
17249
 
17250
                          if (seq = "00") then
17251
                            prcd_chk_for_col_msg (wea_tmp(0), web_tmp(0), addra_tmp, addrb_tmp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
17252
                          end if;
17253
                        end if;
17254
 
17255
      when 8 => if (not(wea_tmp(0) = '1' and web_tmp(0) = '1' and wa_width > wb_width) or seq = "10") then
17256
                  if (wa_width >= width) then
17257
                    prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto 3));
17258
                    prcd_write_ram_col (web_tmp(0), wea_tmp(0), dia_tmp(7 downto 0), dipa_tmp(0), mem(prcd_tmp_addra_dly_depth), memp(prcd_tmp_addra_dly_depth)(0));
17259
                  else
17260
                    prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto w_addra_bit_8 + 1));
17261
                    prcd_tmp_addra_dly_width := SLV_TO_INT(addra_tmp(w_addra_bit_8 downto 3));
17262
                    prcd_write_ram_col (web_tmp(0), wea_tmp(0), dia_tmp(7 downto 0), dipa_tmp(0), mem(prcd_tmp_addra_dly_depth)((prcd_tmp_addra_dly_width * 8) + 7 downto (prcd_tmp_addra_dly_width * 8)), memp(prcd_tmp_addra_dly_depth)((prcd_tmp_addra_dly_width)));
17263
                  end if;
17264
 
17265
                  if (seq = "00") then
17266
                    prcd_chk_for_col_msg (wea_tmp(0), web_tmp(0), addra_tmp, addrb_tmp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
17267
                  end if;
17268
                end if;
17269
 
17270
      when 16 => if (not(wea_tmp(0) = '1' and web_tmp(0) = '1' and wa_width > wb_width) or seq = "10") then
17271
                  if (wa_width >= width) then
17272
                    prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto 4));
17273
                    prcd_write_ram_col (web_tmp(0), wea_tmp(0), dia_tmp(7 downto 0), dipa_tmp(0), mem(prcd_tmp_addra_dly_depth)(7 downto 0), memp(prcd_tmp_addra_dly_depth)(0));
17274
                  else
17275
                    prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto w_addra_bit_16 + 1));
17276
                    prcd_tmp_addra_dly_width := SLV_TO_INT(addra_tmp(w_addra_bit_16 downto 4));
17277
                    prcd_write_ram_col (web_tmp(0), wea_tmp(0), dia_tmp(7 downto 0), dipa_tmp(0), mem(prcd_tmp_addra_dly_depth)((prcd_tmp_addra_dly_width * 16) + 7 downto (prcd_tmp_addra_dly_width * 16)), memp(prcd_tmp_addra_dly_depth)((prcd_tmp_addra_dly_width * 2)));
17278
                  end if;
17279
 
17280
                  if (seq = "00") then
17281
                    prcd_chk_for_col_msg (wea_tmp(0), web_tmp(0), addra_tmp, addrb_tmp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
17282
                  end if;
17283
 
17284
                  if (wa_width >= width) then
17285
                    prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto 4));
17286
                    prcd_write_ram_col (web_tmp(1), wea_tmp(1), dia_tmp(15 downto 8), dipa_tmp(1), mem(prcd_tmp_addra_dly_depth)(15 downto 8), memp(prcd_tmp_addra_dly_depth)(1));
17287
                  else
17288
                    prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto w_addra_bit_16 + 1));
17289
                    prcd_tmp_addra_dly_width := SLV_TO_INT(addra_tmp(w_addra_bit_16 downto 4));
17290
                    prcd_write_ram_col (web_tmp(1), wea_tmp(1), dia_tmp(15 downto 8), dipa_tmp(1), mem(prcd_tmp_addra_dly_depth)((prcd_tmp_addra_dly_width * 16) + 15 downto (prcd_tmp_addra_dly_width * 16) + 8), memp(prcd_tmp_addra_dly_depth)((prcd_tmp_addra_dly_width * 2) + 1));
17291
                  end if;
17292
 
17293
                  if (seq = "00") then
17294
                    prcd_chk_for_col_msg (wea_tmp(1), web_tmp(1), addra_tmp, addrb_tmp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
17295
                  end if;
17296
 
17297
                end if;
17298
 
17299
      when 32 => if (not(wea_tmp(0) = '1' and web_tmp(0) = '1' and wa_width > wb_width) or seq = "10") then
17300
 
17301
                   prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto 5));
17302
                   prcd_write_ram_col (web_tmp(0), wea_tmp(0), dia_tmp(7 downto 0), dipa_tmp(0), mem(prcd_tmp_addra_dly_depth)(7 downto 0), memp(prcd_tmp_addra_dly_depth)(0));
17303
 
17304
                   if (seq = "00") then
17305
                     prcd_chk_for_col_msg (wea_tmp(0), web_tmp(0), addra_tmp, addrb_tmp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
17306
                   end if;
17307
 
17308
                   prcd_write_ram_col (web_tmp(1), wea_tmp(1), dia_tmp(15 downto 8), dipa_tmp(1), mem(prcd_tmp_addra_dly_depth)(15 downto 8), memp(prcd_tmp_addra_dly_depth)(1));
17309
 
17310
                   if (seq = "00") then
17311
                     prcd_chk_for_col_msg (wea_tmp(1), web_tmp(1), addra_tmp, addrb_tmp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
17312
                   end if;
17313
 
17314
                   prcd_write_ram_col (web_tmp(2), wea_tmp(2), dia_tmp(23 downto 16), dipa_tmp(2), mem(prcd_tmp_addra_dly_depth)(23 downto 16), memp(prcd_tmp_addra_dly_depth)(2));
17315
 
17316
                   if (seq = "00") then
17317
                     prcd_chk_for_col_msg (wea_tmp(2), web_tmp(2), addra_tmp, addrb_tmp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
17318
                   end if;
17319
 
17320
                   prcd_write_ram_col (web_tmp(3), wea_tmp(3), dia_tmp(31 downto 24), dipa_tmp(3), mem(prcd_tmp_addra_dly_depth)(31 downto 24), memp(prcd_tmp_addra_dly_depth)(3));
17321
 
17322
                   if (seq = "00") then
17323
                     prcd_chk_for_col_msg (wea_tmp(3), web_tmp(3), addra_tmp, addrb_tmp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
17324
                   end if;
17325
 
17326
                 end if;
17327
      when 64 => null;
17328
--                   prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto 6));
17329
--                   prcd_write_ram_col ('0', '1', dia_tmp(7 downto 0), dipa_tmp(0), mem(prcd_tmp_addra_dly_depth)(7 downto 0), memp(prcd_tmp_addra_dly_depth)(0));
17330
----                          if (seq = "00")
17331
----                            prcd_chk_for_col_msg (wea_tmp(0), web_tmp(0), addra_tmp, addrb_tmp);
17332
--
17333
--                   prcd_write_ram_col ('0', '1', dia_tmp(15 downto 8), dipa_tmp(1), mem(prcd_tmp_addra_dly_depth)(15 downto 8), memp(prcd_tmp_addra_dly_depth)(1));
17334
----                          if (seq = "00")
17335
----                            prcd_chk_for_col_msg (wea_tmp(1), web_tmp(1), addra_tmp, addrb_tmp);
17336
--
17337
--                   prcd_write_ram_col ('0', '1', dia_tmp(23 downto 16), dipa_tmp(2), mem(prcd_tmp_addra_dly_depth)(23 downto 16), memp(prcd_tmp_addra_dly_depth)(2));
17338
----                          if (seq = "00")
17339
----                            prcd_chk_for_col_msg (wea_tmp(2), web_tmp(2), addra_tmp, addrb_tmp);
17340
--
17341
--                   prcd_write_ram_col ('0', '1', dia_tmp(31 downto 24), dipa_tmp(3), mem(prcd_tmp_addra_dly_depth)(31 downto 24), memp(prcd_tmp_addra_dly_depth)(3));
17342
----                          if (seq = "00")
17343
----                            prcd_chk_for_col_msg (wea_tmp(3), web_tmp(3), addra_tmp, addrb_tmp);
17344
--
17345
--                   prcd_write_ram_col ('0', '1', dia_tmp(39 downto 32), dipa_tmp(4), mem(prcd_tmp_addra_dly_depth)(39 downto 32), memp(prcd_tmp_addra_dly_depth)(4));
17346
----                          if (seq = "00")
17347
----                            prcd_chk_for_col_msg (wea_tmp(4), web_tmp(4), addra_tmp, addrb_tmp);
17348
--
17349
--                   prcd_write_ram_col ('0', '1', dia_tmp(47 downto 40), dipa_tmp(5), mem(prcd_tmp_addra_dly_depth)(47 downto 40), memp(prcd_tmp_addra_dly_depth)(5));
17350
----                          if (seq = "00")
17351
----                            prcd_chk_for_col_msg (wea_tmp(5), web_tmp(5), addra_tmp, addrb_tmp);
17352
--
17353
--                   prcd_write_ram_col ('0', '1', dia_tmp(55 downto 48), dipa_tmp(6), mem(prcd_tmp_addra_dly_depth)(55 downto 48), memp(prcd_tmp_addra_dly_depth)(6));
17354
----                          if (seq = "00")
17355
----                            prcd_chk_for_col_msg (wea_tmp(6), web_tmp(6), addra_tmp, addrb_tmp);
17356
--
17357
--                   prcd_write_ram_col ('0', '1', dia_tmp(63 downto 56), dipa_tmp(7), mem(prcd_tmp_addra_dly_depth)(63 downto 56), memp(prcd_tmp_addra_dly_depth)(7));
17358
----                          if (seq = "00")
17359
----                            prcd_chk_for_col_msg (wea_tmp(7), web_tmp(7), addra_tmp, addrb_tmp);
17360
--
17361
      when others => null;
17362
 
17363
    end case;
17364
 
17365
  end prcd_col_wr_ram_a;
17366
 
17367
 
17368
  procedure prcd_col_wr_ram_b (
17369
    constant seq : in std_logic_vector (1 downto 0);
17370
    constant wea_tmp : in std_logic_vector (7 downto 0);
17371
    constant web_tmp : in std_logic_vector (7 downto 0);
17372
    constant dib_tmp : in std_logic_vector (63 downto 0);
17373
    constant dipb_tmp : in std_logic_vector (7 downto 0);
17374
    constant addra_tmp : in std_logic_vector (15 downto 0);
17375
    constant addrb_tmp : in std_logic_vector (15 downto 0);
17376
    variable mem : inout Two_D_array_type;
17377
    variable memp : inout Two_D_parity_array_type;
17378
    variable col_wr_wr_msg : inout std_ulogic;
17379
    variable col_wra_rdb_msg : inout std_ulogic;
17380
    variable col_wrb_rda_msg : inout std_ulogic
17381
    ) is
17382
    variable prcd_tmp_addrb_dly_depth : integer;
17383
    variable prcd_tmp_addrb_dly_width : integer;
17384
    variable junk : std_ulogic;
17385
 
17386
  begin
17387
 
17388
    case wb_width is
17389
 
17390
      when 1 | 2 | 4 => if (not(wea_tmp(0) = '1' and web_tmp(0) = '1' and wb_width > wa_width) or seq = "10") then
17391
                          if (wb_width >= width) then
17392
                            prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto w_addrb_lbit_124));
17393
                            prcd_write_ram_col (wea_tmp(0), web_tmp(0), dib_tmp(wb_width-1 downto 0), '0', mem(prcd_tmp_addrb_dly_depth), junk);
17394
                          else
17395
                            prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto w_addrb_bit_124 + 1));
17396
                            prcd_tmp_addrb_dly_width := SLV_TO_INT(addrb_tmp(w_addrb_bit_124 downto w_addrb_lbit_124));
17397
                            prcd_write_ram_col (wea_tmp(0), web_tmp(0), dib_tmp(wb_width-1 downto 0), '0', mem(prcd_tmp_addrb_dly_depth)((prcd_tmp_addrb_dly_width * wb_width) + wb_width - 1 downto (prcd_tmp_addrb_dly_width * wb_width)), junk);
17398
                          end if;
17399
 
17400
                          if (seq = "00") then
17401
                            prcd_chk_for_col_msg (wea_tmp(0), web_tmp(0), addra_tmp, addrb_tmp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
17402
                          end if;
17403
                        end if;
17404
 
17405
      when 8 => if (not(wea_tmp(0) = '1' and web_tmp(0) = '1' and wb_width > wa_width) or seq = "10") then
17406
                  if (wb_width >= width) then
17407
                    prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto 3));
17408
                    prcd_write_ram_col (wea_tmp(0), web_tmp(0), dib_tmp(7 downto 0), dipb_tmp(0), mem(prcd_tmp_addrb_dly_depth), memp(prcd_tmp_addrb_dly_depth)(0));
17409
                  else
17410
                    prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto w_addrb_bit_8 + 1));
17411
                    prcd_tmp_addrb_dly_width := SLV_TO_INT(addrb_tmp(w_addrb_bit_8 downto 3));
17412
                    prcd_write_ram_col (wea_tmp(0), web_tmp(0), dib_tmp(7 downto 0), dipb_tmp(0), mem(prcd_tmp_addrb_dly_depth)((prcd_tmp_addrb_dly_width * 8) + 7 downto (prcd_tmp_addrb_dly_width * 8)), memp(prcd_tmp_addrb_dly_depth)((prcd_tmp_addrb_dly_width)));
17413
                  end if;
17414
 
17415
                  if (seq = "00") then
17416
                    prcd_chk_for_col_msg (wea_tmp(0), web_tmp(0), addra_tmp, addrb_tmp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
17417
                  end if;
17418
                end if;
17419
 
17420
      when 16 => if (not(wea_tmp(0) = '1' and web_tmp(0) = '1' and wb_width > wa_width) or seq = "10") then
17421
                  if (wb_width >= width) then
17422
                    prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto 4));
17423
                    prcd_write_ram_col (wea_tmp(0), web_tmp(0), dib_tmp(7 downto 0), dipb_tmp(0), mem(prcd_tmp_addrb_dly_depth)(7 downto 0), memp(prcd_tmp_addrb_dly_depth)(0));
17424
                  else
17425
                    prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto w_addrb_bit_16 + 1));
17426
                    prcd_tmp_addrb_dly_width := SLV_TO_INT(addrb_tmp(w_addrb_bit_16 downto 4));
17427
                    prcd_write_ram_col (wea_tmp(0), web_tmp(0), dib_tmp(7 downto 0), dipb_tmp(0), mem(prcd_tmp_addrb_dly_depth)((prcd_tmp_addrb_dly_width * 16) + 7 downto (prcd_tmp_addrb_dly_width * 16)), memp(prcd_tmp_addrb_dly_depth)((prcd_tmp_addrb_dly_width * 2)));
17428
                  end if;
17429
 
17430
                  if (seq = "00") then
17431
                    prcd_chk_for_col_msg (wea_tmp(0), web_tmp(0), addra_tmp, addrb_tmp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
17432
                  end if;
17433
 
17434
                  if (wb_width >= width) then
17435
                    prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto 4));
17436
                    prcd_write_ram_col (wea_tmp(1), web_tmp(1), dib_tmp(15 downto 8), dipb_tmp(1), mem(prcd_tmp_addrb_dly_depth)(15 downto 8), memp(prcd_tmp_addrb_dly_depth)(1));
17437
                  else
17438
                    prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto w_addrb_bit_16 + 1));
17439
                    prcd_tmp_addrb_dly_width := SLV_TO_INT(addrb_tmp(w_addrb_bit_16 downto 4));
17440
                    prcd_write_ram_col (wea_tmp(1), web_tmp(1), dib_tmp(15 downto 8), dipb_tmp(1), mem(prcd_tmp_addrb_dly_depth)((prcd_tmp_addrb_dly_width * 16) + 15 downto (prcd_tmp_addrb_dly_width * 16) + 8), memp(prcd_tmp_addrb_dly_depth)((prcd_tmp_addrb_dly_width * 2) + 1));
17441
                  end if;
17442
 
17443
                  if (seq = "00") then
17444
                    prcd_chk_for_col_msg (wea_tmp(1), web_tmp(1), addra_tmp, addrb_tmp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
17445
                  end if;
17446
 
17447
                end if;
17448
      when 32 => if (not(wea_tmp(0) = '1' and web_tmp(0) = '1' and wb_width > wa_width) or seq = "10") then
17449
 
17450
                   prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto 5));
17451
                   prcd_write_ram_col (wea_tmp(0), web_tmp(0), dib_tmp(7 downto 0), dipb_tmp(0), mem(prcd_tmp_addrb_dly_depth)(7 downto 0), memp(prcd_tmp_addrb_dly_depth)(0));
17452
                   if (seq = "00") then
17453
                     prcd_chk_for_col_msg (wea_tmp(0), web_tmp(0), addra_tmp, addrb_tmp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
17454
                   end if;
17455
 
17456
                   prcd_write_ram_col (wea_tmp(1), web_tmp(1), dib_tmp(15 downto 8), dipb_tmp(1), mem(prcd_tmp_addrb_dly_depth)(15 downto 8), memp(prcd_tmp_addrb_dly_depth)(1));
17457
                   if (seq = "00") then
17458
                     prcd_chk_for_col_msg (wea_tmp(1), web_tmp(1), addra_tmp, addrb_tmp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
17459
                   end if;
17460
 
17461
                   prcd_write_ram_col (wea_tmp(2), web_tmp(2), dib_tmp(23 downto 16), dipb_tmp(2), mem(prcd_tmp_addrb_dly_depth)(23 downto 16), memp(prcd_tmp_addrb_dly_depth)(2));
17462
                   if (seq = "00") then
17463
                     prcd_chk_for_col_msg (wea_tmp(2), web_tmp(2), addra_tmp, addrb_tmp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
17464
                   end if;
17465
 
17466
                   prcd_write_ram_col (wea_tmp(3), web_tmp(3), dib_tmp(31 downto 24), dipb_tmp(3), mem(prcd_tmp_addrb_dly_depth)(31 downto 24), memp(prcd_tmp_addrb_dly_depth)(3));
17467
                   if (seq = "00") then
17468
                     prcd_chk_for_col_msg (wea_tmp(3), web_tmp(3), addra_tmp, addrb_tmp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
17469
                   end if;
17470
 
17471
                 end if;
17472
      when 64 =>
17473
                   prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto 6));
17474
                   prcd_write_ram_col (wea_tmp(0), web_tmp(0), dib_tmp(7 downto 0), dipb_tmp(0), mem(prcd_tmp_addrb_dly_depth)(7 downto 0), memp(prcd_tmp_addrb_dly_depth)(0));
17475
                   if (seq = "00") then
17476
                     prcd_chk_for_col_msg (wea_tmp(0), web_tmp(0), addra_tmp, addrb_tmp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
17477
                   end if;
17478
 
17479
                   prcd_write_ram_col (wea_tmp(1), web_tmp(1), dib_tmp(15 downto 8), dipb_tmp(1), mem(prcd_tmp_addrb_dly_depth)(15 downto 8), memp(prcd_tmp_addrb_dly_depth)(1));
17480
                   if (seq = "00") then
17481
                     prcd_chk_for_col_msg (wea_tmp(1), web_tmp(1), addra_tmp, addrb_tmp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
17482
                   end if;
17483
 
17484
                   prcd_write_ram_col (wea_tmp(2), web_tmp(2), dib_tmp(23 downto 16), dipb_tmp(2), mem(prcd_tmp_addrb_dly_depth)(23 downto 16), memp(prcd_tmp_addrb_dly_depth)(2));
17485
                   if (seq = "00") then
17486
                     prcd_chk_for_col_msg (wea_tmp(2), web_tmp(2), addra_tmp, addrb_tmp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
17487
                   end if;
17488
 
17489
                   prcd_write_ram_col (wea_tmp(3), web_tmp(3), dib_tmp(31 downto 24), dipb_tmp(3), mem(prcd_tmp_addrb_dly_depth)(31 downto 24), memp(prcd_tmp_addrb_dly_depth)(3));
17490
                   if (seq = "00") then
17491
                     prcd_chk_for_col_msg (wea_tmp(3), web_tmp(3), addra_tmp, addrb_tmp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
17492
                   end if;
17493
 
17494
                   prcd_write_ram_col (wea_tmp(4), web_tmp(4), dib_tmp(39 downto 32), dipb_tmp(4), mem(prcd_tmp_addrb_dly_depth)(39 downto 32), memp(prcd_tmp_addrb_dly_depth)(4));
17495
                   if (seq = "00") then
17496
                     prcd_chk_for_col_msg (wea_tmp(4), web_tmp(4), addra_tmp, addrb_tmp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
17497
                   end if;
17498
 
17499
                   prcd_write_ram_col (wea_tmp(5), web_tmp(5), dib_tmp(47 downto 40), dipb_tmp(5), mem(prcd_tmp_addrb_dly_depth)(47 downto 40), memp(prcd_tmp_addrb_dly_depth)(5));
17500
                   if (seq = "00") then
17501
                     prcd_chk_for_col_msg (wea_tmp(5), web_tmp(5), addra_tmp, addrb_tmp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
17502
                   end if;
17503
 
17504
                   prcd_write_ram_col (wea_tmp(6), web_tmp(6), dib_tmp(55 downto 48), dipb_tmp(6), mem(prcd_tmp_addrb_dly_depth)(55 downto 48), memp(prcd_tmp_addrb_dly_depth)(6));
17505
                   if (seq = "00") then
17506
                     prcd_chk_for_col_msg (wea_tmp(6), web_tmp(6), addra_tmp, addrb_tmp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
17507
                   end if;
17508
 
17509
                   prcd_write_ram_col (wea_tmp(7), web_tmp(7), dib_tmp(63 downto 56), dipb_tmp(7), mem(prcd_tmp_addrb_dly_depth)(63 downto 56), memp(prcd_tmp_addrb_dly_depth)(7));
17510
                   if (seq = "00") then
17511
                     prcd_chk_for_col_msg (wea_tmp(7), web_tmp(7), addra_tmp, addrb_tmp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
17512
                   end if;
17513
 
17514
      when others => null;
17515
 
17516
    end case;
17517
 
17518
  end prcd_col_wr_ram_b;
17519
 
17520
 
17521
  procedure prcd_col_rd_ram_a (
17522
    constant viol_type_tmp : in std_logic_vector (1 downto 0);
17523
    constant seq : in std_logic_vector (1 downto 0);
17524
    constant web_tmp : in std_logic_vector (7 downto 0);
17525
    constant wea_tmp : in std_logic_vector (7 downto 0);
17526
    constant addra_tmp : in std_logic_vector (15 downto 0);
17527
    variable doa_tmp : inout std_logic_vector (63 downto 0);
17528
    variable dopa_tmp : inout std_logic_vector (7 downto 0);
17529
    constant mem : in Two_D_array_type;
17530
    constant memp : in Two_D_parity_array_type;
17531
    constant wr_mode_a_tmp : in std_logic_vector (1 downto 0)
17532
 
17533
    ) is
17534
    variable prcd_tmp_addra_dly_depth : integer;
17535
    variable prcd_tmp_addra_dly_width : integer;
17536
    variable junk : std_ulogic;
17537
    variable doa_ltmp : std_logic_vector (63 downto 0);
17538
    variable dopa_ltmp : std_logic_vector (7 downto 0);
17539
 
17540
  begin
17541
 
17542
    doa_ltmp := (others => '0');
17543
    dopa_ltmp := (others => '0');
17544
 
17545
    case ra_width is
17546
 
17547
      when 1 | 2 | 4 => if ((web_tmp(0) = '1' and wea_tmp(0) = '1') or (seq = "01" and web_tmp(0) = '1' and wea_tmp(0) = '0' and viol_type_tmp = "10") or (seq = "01" and WRITE_MODE_A /= "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST") or (seq = "01" and WRITE_MODE_A = "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST" and web_tmp(0) = '1') or (seq = "11" and WRITE_MODE_A = "WRITE_FIRST" and web_tmp(0) /= '1')) then
17548
 
17549
                          if (ra_width >= width) then
17550
                            prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto r_addra_lbit_124));
17551
                            doa_ltmp(ra_width-1 downto 0) := mem(prcd_tmp_addra_dly_depth);
17552
                          else
17553
                            prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto r_addra_bit_124 + 1));
17554
                            prcd_tmp_addra_dly_width := SLV_TO_INT(addra_tmp(r_addra_bit_124 downto r_addra_lbit_124));
17555
                            doa_ltmp(ra_width-1 downto 0) := mem(prcd_tmp_addra_dly_depth)(((prcd_tmp_addra_dly_width * ra_width) + ra_width - 1) downto (prcd_tmp_addra_dly_width * ra_width));
17556
 
17557
                          end if;
17558
                          prcd_x_buf (wr_mode_a_tmp, 3, 0, 0, doa_ltmp, doa_tmp, dopa_ltmp, dopa_tmp);
17559
                        end if;
17560
 
17561
      when 8 => if ((web_tmp(0) = '1' and wea_tmp(0) = '1') or (seq = "01" and web_tmp(0) = '1' and wea_tmp(0) = '0' and viol_type_tmp = "10") or (seq = "01" and WRITE_MODE_A /= "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST") or (seq = "01" and WRITE_MODE_A = "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST" and web_tmp(0) = '1') or (seq = "11" and WRITE_MODE_A = "WRITE_FIRST" and web_tmp(0) /= '1')) then
17562
 
17563
                  if (ra_width >= width) then
17564
                    prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto 3));
17565
                    doa_ltmp(7 downto 0) := mem(prcd_tmp_addra_dly_depth);
17566
                    dopa_ltmp(0) := memp(prcd_tmp_addra_dly_depth)(0);
17567
                  else
17568
                    prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto r_addra_bit_8 + 1));
17569
                    prcd_tmp_addra_dly_width := SLV_TO_INT(addra_tmp(r_addra_bit_8 downto 3));
17570
                    doa_ltmp(7 downto 0) := mem(prcd_tmp_addra_dly_depth)(((prcd_tmp_addra_dly_width * 8) + 7) downto (prcd_tmp_addra_dly_width * 8));
17571
                    dopa_ltmp(0) := memp(prcd_tmp_addra_dly_depth)(prcd_tmp_addra_dly_width);
17572
                  end if;
17573
                  prcd_x_buf (wr_mode_a_tmp, 7, 0, 0, doa_ltmp, doa_tmp, dopa_ltmp, dopa_tmp);
17574
 
17575
                end if;
17576
 
17577
      when 16 => if ((web_tmp(0) = '1' and wea_tmp(0) = '1') or (seq = "01" and web_tmp(0) = '1' and wea_tmp(0) = '0' and viol_type_tmp = "10") or (seq = "01" and WRITE_MODE_A /= "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST") or (seq = "01" and WRITE_MODE_A = "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST" and web_tmp(0) = '1') or (seq = "11" and WRITE_MODE_A = "WRITE_FIRST" and web_tmp(0) /= '1')) then
17578
 
17579
                  if (ra_width >= width) then
17580
                    prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto 4));
17581
                    doa_ltmp(7 downto 0) := mem(prcd_tmp_addra_dly_depth)(7 downto 0);
17582
                    dopa_ltmp(0) := memp(prcd_tmp_addra_dly_depth)(0);
17583
                  else
17584
                    prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto r_addra_bit_16 + 1));
17585
                    prcd_tmp_addra_dly_width := SLV_TO_INT(addra_tmp(r_addra_bit_16 downto 4));
17586
 
17587
                    doa_ltmp(7 downto 0) := mem(prcd_tmp_addra_dly_depth)(((prcd_tmp_addra_dly_width * 16) + 7) downto (prcd_tmp_addra_dly_width * 16));
17588
                    dopa_ltmp(0) := memp(prcd_tmp_addra_dly_depth)(prcd_tmp_addra_dly_width * 2);
17589
                  end if;
17590
                  prcd_x_buf (wr_mode_a_tmp, 7, 0, 0, doa_ltmp, doa_tmp, dopa_ltmp, dopa_tmp);
17591
 
17592
                end if;
17593
 
17594
                if ((web_tmp(1) = '1' and wea_tmp(1) = '1') or (seq = "01" and web_tmp(1) = '1' and wea_tmp(1) = '0' and viol_type_tmp = "10") or (seq = "01" and WRITE_MODE_A /= "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST") or (seq = "01" and WRITE_MODE_A = "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST" and web_tmp(1) = '1') or (seq = "11" and WRITE_MODE_A = "WRITE_FIRST" and web_tmp(1) /= '1')) then
17595
 
17596
                  if (ra_width >= width) then
17597
                    prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto 4));
17598
                    doa_ltmp(15 downto 8) := mem(prcd_tmp_addra_dly_depth)(15 downto 8);
17599
                    dopa_ltmp(1) := memp(prcd_tmp_addra_dly_depth)(1);
17600
                  else
17601
                    prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto r_addra_bit_16 + 1));
17602
                    prcd_tmp_addra_dly_width := SLV_TO_INT(addra_tmp(r_addra_bit_16 downto 4));
17603
 
17604
                    doa_ltmp(15 downto 8) := mem(prcd_tmp_addra_dly_depth)(((prcd_tmp_addra_dly_width * 16) + 15) downto ((prcd_tmp_addra_dly_width * 16) + 8));
17605
                    dopa_ltmp(1) := memp(prcd_tmp_addra_dly_depth)((prcd_tmp_addra_dly_width * 2) + 1);
17606
                  end if;
17607
                  prcd_x_buf (wr_mode_a_tmp, 15, 8, 1, doa_ltmp, doa_tmp, dopa_ltmp, dopa_tmp);
17608
 
17609
                end if;
17610
 
17611
      when 32 => if (ra_width >= width) then
17612
 
17613
                   prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto 5));
17614
 
17615
                   if ((web_tmp(0) = '1' and wea_tmp(0) = '1') or (seq = "01" and web_tmp(0) = '1' and wea_tmp(0) = '0' and viol_type_tmp = "10") or (seq = "01" and WRITE_MODE_A /= "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST") or (seq = "01" and WRITE_MODE_A = "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST" and web_tmp(0) = '1') or (seq = "11" and WRITE_MODE_A = "WRITE_FIRST" and web_tmp(0) /= '1')) then
17616
 
17617
                     doa_ltmp(7 downto 0) := mem(prcd_tmp_addra_dly_depth)(7 downto 0);
17618
                     dopa_ltmp(0) := memp(prcd_tmp_addra_dly_depth)(0);
17619
                     prcd_x_buf (wr_mode_a_tmp, 7, 0, 0, doa_ltmp, doa_tmp, dopa_ltmp, dopa_tmp);
17620
 
17621
                   end if;
17622
 
17623
                   if ((web_tmp(1) = '1' and wea_tmp(1) = '1') or (seq = "01" and web_tmp(1) = '1' and wea_tmp(1) = '0' and viol_type_tmp = "10") or (seq = "01" and WRITE_MODE_A /= "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST") or (seq = "01" and WRITE_MODE_A = "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST" and web_tmp(1) = '1') or (seq = "11" and WRITE_MODE_A = "WRITE_FIRST" and web_tmp(1) /= '1')) then
17624
 
17625
                     doa_ltmp(15 downto 8) := mem(prcd_tmp_addra_dly_depth)(15 downto 8);
17626
                     dopa_ltmp(1) := memp(prcd_tmp_addra_dly_depth)(1);
17627
                     prcd_x_buf (wr_mode_a_tmp, 15, 8, 1, doa_ltmp, doa_tmp, dopa_ltmp, dopa_tmp);
17628
 
17629
                   end if;
17630
 
17631
                   if ((web_tmp(2) = '1' and wea_tmp(2) = '1') or (seq = "01" and web_tmp(2) = '1' and wea_tmp(2) = '0' and viol_type_tmp = "10") or (seq = "01" and WRITE_MODE_A /= "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST") or (seq = "01" and WRITE_MODE_A = "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST" and web_tmp(2) = '1') or (seq = "11" and WRITE_MODE_A = "WRITE_FIRST" and web_tmp(2) /= '1')) then
17632
 
17633
                     doa_ltmp(23 downto 16) := mem(prcd_tmp_addra_dly_depth)(23 downto 16);
17634
                     dopa_ltmp(2) := memp(prcd_tmp_addra_dly_depth)(2);
17635
                     prcd_x_buf (wr_mode_a_tmp, 23, 16, 2, doa_ltmp, doa_tmp, dopa_ltmp, dopa_tmp);
17636
 
17637
                   end if;
17638
 
17639
                   if ((web_tmp(3) = '1' and wea_tmp(3) = '1') or (seq = "01" and web_tmp(3) = '1' and wea_tmp(3) = '0' and viol_type_tmp = "10") or (seq = "01" and WRITE_MODE_A /= "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST") or (seq = "01" and WRITE_MODE_A = "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST" and web_tmp(3) = '1') or (seq = "11" and WRITE_MODE_A = "WRITE_FIRST" and web_tmp(3) /= '1')) then
17640
 
17641
                     doa_ltmp(31 downto 24) := mem(prcd_tmp_addra_dly_depth)(31 downto 24);
17642
                     dopa_ltmp(3) := memp(prcd_tmp_addra_dly_depth)(3);
17643
                     prcd_x_buf (wr_mode_a_tmp, 31, 24, 3, doa_ltmp, doa_tmp, dopa_ltmp, dopa_tmp);
17644
 
17645
                   end if;
17646
 
17647
                end if;
17648
 
17649
      when 64 =>
17650
                   prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto 6));
17651
 
17652
                   if ((web_tmp(0) = '1' and wea_tmp(0) = '1') or (seq = "01" and web_tmp(0) = '1' and wea_tmp(0) = '0' and viol_type_tmp = "10") or (seq = "01" and WRITE_MODE_A /= "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST") or (seq = "01" and WRITE_MODE_A = "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST" and web_tmp(0) = '1') or (seq = "11" and WRITE_MODE_A = "WRITE_FIRST" and web_tmp(0) /= '1')) then
17653
 
17654
                     doa_ltmp(7 downto 0) := mem(prcd_tmp_addra_dly_depth)(7 downto 0);
17655
                     dopa_ltmp(0) := memp(prcd_tmp_addra_dly_depth)(0);
17656
                     prcd_x_buf (wr_mode_a_tmp, 7, 0, 0, doa_ltmp, doa_tmp, dopa_ltmp, dopa_tmp);
17657
 
17658
                   end if;
17659
 
17660
                   if ((web_tmp(1) = '1' and wea_tmp(1) = '1') or (seq = "01" and web_tmp(1) = '1' and wea_tmp(1) = '0' and viol_type_tmp = "10") or (seq = "01" and WRITE_MODE_A /= "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST") or (seq = "01" and WRITE_MODE_A = "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST" and web_tmp(1) = '1') or (seq = "11" and WRITE_MODE_A = "WRITE_FIRST" and web_tmp(1) /= '1')) then
17661
 
17662
                     doa_ltmp(15 downto 8) := mem(prcd_tmp_addra_dly_depth)(15 downto 8);
17663
                     dopa_ltmp(1) := memp(prcd_tmp_addra_dly_depth)(1);
17664
                     prcd_x_buf (wr_mode_a_tmp, 15, 8, 1, doa_ltmp, doa_tmp, dopa_ltmp, dopa_tmp);
17665
 
17666
                   end if;
17667
 
17668
                   if ((web_tmp(2) = '1' and wea_tmp(2) = '1') or (seq = "01" and web_tmp(2) = '1' and wea_tmp(2) = '0' and viol_type_tmp = "10") or (seq = "01" and WRITE_MODE_A /= "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST") or (seq = "01" and WRITE_MODE_A = "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST" and web_tmp(2) = '1') or (seq = "11" and WRITE_MODE_A = "WRITE_FIRST" and web_tmp(2) /= '1')) then
17669
 
17670
                     doa_ltmp(23 downto 16) := mem(prcd_tmp_addra_dly_depth)(23 downto 16);
17671
                     dopa_ltmp(2) := memp(prcd_tmp_addra_dly_depth)(2);
17672
                     prcd_x_buf (wr_mode_a_tmp, 23, 16, 2, doa_ltmp, doa_tmp, dopa_ltmp, dopa_tmp);
17673
 
17674
                   end if;
17675
 
17676
                   if ((web_tmp(3) = '1' and wea_tmp(3) = '1') or (seq = "01" and web_tmp(3) = '1' and wea_tmp(3) = '0' and viol_type_tmp = "10") or (seq = "01" and WRITE_MODE_A /= "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST") or (seq = "01" and WRITE_MODE_A = "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST" and web_tmp(3) = '1') or (seq = "11" and WRITE_MODE_A = "WRITE_FIRST" and web_tmp(3) /= '1')) then
17677
 
17678
                     doa_ltmp(31 downto 24) := mem(prcd_tmp_addra_dly_depth)(31 downto 24);
17679
                     dopa_ltmp(3) := memp(prcd_tmp_addra_dly_depth)(3);
17680
                     prcd_x_buf (wr_mode_a_tmp, 31, 24, 3, doa_ltmp, doa_tmp, dopa_ltmp, dopa_tmp);
17681
 
17682
                   end if;
17683
 
17684
                   if ((web_tmp(4) = '1' and wea_tmp(4) = '1') or (seq = "01" and web_tmp(4) = '1' and wea_tmp(4) = '0' and viol_type_tmp = "10") or (seq = "01" and WRITE_MODE_A /= "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST") or (seq = "01" and WRITE_MODE_A = "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST" and web_tmp(4) = '1') or (seq = "11" and WRITE_MODE_A = "WRITE_FIRST" and web_tmp(4) /= '1')) then
17685
 
17686
                     doa_ltmp(39 downto 32) := mem(prcd_tmp_addra_dly_depth)(39 downto 32);
17687
                     dopa_ltmp(4) := memp(prcd_tmp_addra_dly_depth)(4);
17688
                     prcd_x_buf (wr_mode_a_tmp, 39, 32, 4, doa_ltmp, doa_tmp, dopa_ltmp, dopa_tmp);
17689
 
17690
                   end if;
17691
 
17692
                   if ((web_tmp(5) = '1' and wea_tmp(5) = '1') or (seq = "01" and web_tmp(5) = '1' and wea_tmp(5) = '0' and viol_type_tmp = "10") or (seq = "01" and WRITE_MODE_A /= "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST") or (seq = "01" and WRITE_MODE_A = "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST" and web_tmp(5) = '1') or (seq = "11" and WRITE_MODE_A = "WRITE_FIRST" and web_tmp(5) /= '1')) then
17693
 
17694
                     doa_ltmp(47 downto 40) := mem(prcd_tmp_addra_dly_depth)(47 downto 40);
17695
                     dopa_ltmp(5) := memp(prcd_tmp_addra_dly_depth)(5);
17696
                     prcd_x_buf (wr_mode_a_tmp, 47, 40, 5, doa_ltmp, doa_tmp, dopa_ltmp, dopa_tmp);
17697
 
17698
                   end if;
17699
 
17700
                   if ((web_tmp(6) = '1' and wea_tmp(6) = '1') or (seq = "01" and web_tmp(6) = '1' and wea_tmp(6) = '0' and viol_type_tmp = "10") or (seq = "01" and WRITE_MODE_A /= "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST") or (seq = "01" and WRITE_MODE_A = "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST" and web_tmp(6) = '1') or (seq = "11" and WRITE_MODE_A = "WRITE_FIRST" and web_tmp(6) /= '1')) then
17701
 
17702
                     doa_ltmp(55 downto 48) := mem(prcd_tmp_addra_dly_depth)(55 downto 48);
17703
                     dopa_ltmp(6) := memp(prcd_tmp_addra_dly_depth)(6);
17704
                     prcd_x_buf (wr_mode_a_tmp, 55, 48, 6, doa_ltmp, doa_tmp, dopa_ltmp, dopa_tmp);
17705
 
17706
                   end if;
17707
 
17708
                   if ((web_tmp(7) = '1' and wea_tmp(7) = '1') or (seq = "01" and web_tmp(7) = '1' and wea_tmp(7) = '0' and viol_type_tmp = "10") or (seq = "01" and WRITE_MODE_A /= "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST") or (seq = "01" and WRITE_MODE_A = "READ_FIRST" and WRITE_MODE_B /= "READ_FIRST" and web_tmp(7) = '1') or (seq = "11" and WRITE_MODE_A = "WRITE_FIRST" and web_tmp(7) /= '1')) then
17709
 
17710
                     doa_ltmp(63 downto 56) := mem(prcd_tmp_addra_dly_depth)(63 downto 56);
17711
                     dopa_ltmp(7) := memp(prcd_tmp_addra_dly_depth)(7);
17712
                     prcd_x_buf (wr_mode_a_tmp, 63, 56, 7, doa_ltmp, doa_tmp, dopa_ltmp, dopa_tmp);
17713
 
17714
                   end if;
17715
 
17716
      when others => null;
17717
 
17718
    end case;
17719
 
17720
  end prcd_col_rd_ram_a;
17721
 
17722
 
17723
  procedure prcd_col_rd_ram_b (
17724
    constant viol_type_tmp : in std_logic_vector (1 downto 0);
17725
    constant seq : in std_logic_vector (1 downto 0);
17726
    constant wea_tmp : in std_logic_vector (7 downto 0);
17727
    constant web_tmp : in std_logic_vector (7 downto 0);
17728
    constant addrb_tmp : in std_logic_vector (15 downto 0);
17729
    variable dob_tmp : inout std_logic_vector (63 downto 0);
17730
    variable dopb_tmp : inout std_logic_vector (7 downto 0);
17731
    constant mem : in Two_D_array_type;
17732
    constant memp : in Two_D_parity_array_type;
17733
    constant wr_mode_b_tmp : in std_logic_vector (1 downto 0)
17734
 
17735
    ) is
17736
    variable prcd_tmp_addrb_dly_depth : integer;
17737
    variable prcd_tmp_addrb_dly_width : integer;
17738
    variable junk : std_ulogic;
17739
    variable dob_ltmp : std_logic_vector (63 downto 0);
17740
    variable dopb_ltmp : std_logic_vector (7 downto 0);
17741
 
17742
  begin
17743
 
17744
    dob_ltmp := (others => '0');
17745
    dopb_ltmp := (others => '0');
17746
 
17747
    case rb_width is
17748
 
17749
      when 1 | 2 | 4 => if ((web_tmp(0) = '1' and wea_tmp(0) = '1') or (seq = "01" and wea_tmp(0) = '1' and web_tmp(0) = '0' and viol_type_tmp = "11") or (seq = "01" and WRITE_MODE_B /= "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST") or (seq = "01" and WRITE_MODE_B = "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST" and wea_tmp(0) = '1') or (seq = "11" and WRITE_MODE_B = "WRITE_FIRST" and wea_tmp(0) /= '1')) then
17750
 
17751
                          if (rb_width >= width) then
17752
                            prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto r_addrb_lbit_124));
17753
                            dob_ltmp(rb_width-1 downto 0) := mem(prcd_tmp_addrb_dly_depth);
17754
                          else
17755
                            prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto r_addrb_bit_124 + 1));
17756
                            prcd_tmp_addrb_dly_width := SLV_TO_INT(addrb_tmp(r_addrb_bit_124 downto r_addrb_lbit_124));
17757
                            dob_ltmp(rb_width-1 downto 0) := mem(prcd_tmp_addrb_dly_depth)(((prcd_tmp_addrb_dly_width * rb_width) + rb_width - 1) downto (prcd_tmp_addrb_dly_width * rb_width));
17758
                          end if;
17759
                          prcd_x_buf (wr_mode_b_tmp, 3, 0, 0, dob_ltmp, dob_tmp, dopb_ltmp, dopb_tmp);
17760
 
17761
                        end if;
17762
 
17763
      when 8 => if ((web_tmp(0) = '1' and wea_tmp(0) = '1') or (seq = "01" and wea_tmp(0) = '1' and web_tmp(0) = '0' and viol_type_tmp = "11") or (seq = "01" and WRITE_MODE_B /= "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST") or (seq = "01" and WRITE_MODE_B = "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST" and wea_tmp(0) = '1') or (seq = "11" and WRITE_MODE_B = "WRITE_FIRST" and wea_tmp(0) /= '1')) then
17764
 
17765
                  if (rb_width >= width) then
17766
                    prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto 3));
17767
                    dob_ltmp(7 downto 0) := mem(prcd_tmp_addrb_dly_depth);
17768
                    dopb_ltmp(0) := memp(prcd_tmp_addrb_dly_depth)(0);
17769
                  else
17770
                    prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto r_addrb_bit_8 + 1));
17771
                    prcd_tmp_addrb_dly_width := SLV_TO_INT(addrb_tmp(r_addrb_bit_8 downto 3));
17772
                    dob_ltmp(7 downto 0) := mem(prcd_tmp_addrb_dly_depth)(((prcd_tmp_addrb_dly_width * 8) + 7) downto (prcd_tmp_addrb_dly_width * 8));
17773
                    dopb_ltmp(0) := memp(prcd_tmp_addrb_dly_depth)(prcd_tmp_addrb_dly_width);
17774
                  end if;
17775
                  prcd_x_buf (wr_mode_b_tmp, 7, 0, 0, dob_ltmp, dob_tmp, dopb_ltmp, dopb_tmp);
17776
 
17777
                end if;
17778
 
17779
      when 16 => if ((web_tmp(0) = '1' and wea_tmp(0) = '1') or (seq = "01" and wea_tmp(0) = '1' and web_tmp(0) = '0' and viol_type_tmp = "11") or (seq = "01" and WRITE_MODE_B /= "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST") or (seq = "01" and WRITE_MODE_B = "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST" and wea_tmp(0) = '1') or (seq = "11" and WRITE_MODE_B = "WRITE_FIRST" and wea_tmp(0) /= '1')) then
17780
 
17781
                  if (rb_width >= width) then
17782
                    prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto 4));
17783
                    dob_ltmp(7 downto 0) := mem(prcd_tmp_addrb_dly_depth)(7 downto 0);
17784
                    dopb_ltmp(0) := memp(prcd_tmp_addrb_dly_depth)(0);
17785
                  else
17786
                    prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto r_addrb_bit_16 + 1));
17787
                    prcd_tmp_addrb_dly_width := SLV_TO_INT(addrb_tmp(r_addrb_bit_16 downto 4));
17788
 
17789
                    dob_ltmp(7 downto 0) := mem(prcd_tmp_addrb_dly_depth)(((prcd_tmp_addrb_dly_width * 16) + 7) downto (prcd_tmp_addrb_dly_width * 16));
17790
                    dopb_ltmp(0) := memp(prcd_tmp_addrb_dly_depth)(prcd_tmp_addrb_dly_width * 2);
17791
                  end if;
17792
                  prcd_x_buf (wr_mode_b_tmp, 7, 0, 0, dob_ltmp, dob_tmp, dopb_ltmp, dopb_tmp);
17793
 
17794
                end if;
17795
 
17796
 
17797
                if ((web_tmp(1) = '1' and wea_tmp(1) = '1') or (seq = "01" and wea_tmp(1) = '1' and web_tmp(1) = '0' and viol_type_tmp = "11") or (seq = "01" and WRITE_MODE_B /= "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST") or (seq = "01" and WRITE_MODE_B = "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST" and wea_tmp(1) = '1') or (seq = "11" and WRITE_MODE_B = "WRITE_FIRST" and wea_tmp(1) /= '1')) then
17798
 
17799
                  if (rb_width >= width) then
17800
                    prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto 4));
17801
                    dob_ltmp(15 downto 8) := mem(prcd_tmp_addrb_dly_depth)(15 downto 8);
17802
                    dopb_ltmp(1) := memp(prcd_tmp_addrb_dly_depth)(1);
17803
                  else
17804
                    prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto r_addrb_bit_16 + 1));
17805
                    prcd_tmp_addrb_dly_width := SLV_TO_INT(addrb_tmp(r_addrb_bit_16 downto 4));
17806
 
17807
                    dob_ltmp(15 downto 8) := mem(prcd_tmp_addrb_dly_depth)(((prcd_tmp_addrb_dly_width * 16) + 15) downto ((prcd_tmp_addrb_dly_width * 16) + 8));
17808
                    dopb_ltmp(1) := memp(prcd_tmp_addrb_dly_depth)((prcd_tmp_addrb_dly_width * 2) + 1);
17809
                  end if;
17810
                  prcd_x_buf (wr_mode_b_tmp, 15, 8, 1, dob_ltmp, dob_tmp, dopb_ltmp, dopb_tmp);
17811
 
17812
                end if;
17813
 
17814
      when 32 => if (rb_width >= width) then
17815
 
17816
                   prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto 5));
17817
 
17818
                   if ((web_tmp(0) = '1' and wea_tmp(0) = '1') or (seq = "01" and wea_tmp(0) = '1' and web_tmp(0) = '0' and viol_type_tmp = "11") or (seq = "01" and WRITE_MODE_B /= "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST") or (seq = "01" and WRITE_MODE_B = "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST" and wea_tmp(0) = '1') or (seq = "11" and WRITE_MODE_B = "WRITE_FIRST" and wea_tmp(0) /= '1')) then
17819
 
17820
                     dob_ltmp(7 downto 0) := mem(prcd_tmp_addrb_dly_depth)(7 downto 0);
17821
                     dopb_ltmp(0) := memp(prcd_tmp_addrb_dly_depth)(0);
17822
                     prcd_x_buf (wr_mode_b_tmp, 7, 0, 0, dob_ltmp, dob_tmp, dopb_ltmp, dopb_tmp);
17823
 
17824
                   end if;
17825
 
17826
                   if ((web_tmp(1) = '1' and wea_tmp(1) = '1') or (seq = "01" and wea_tmp(1) = '1' and web_tmp(1) = '0' and viol_type_tmp = "11") or (seq = "01" and WRITE_MODE_B /= "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST") or (seq = "01" and WRITE_MODE_B = "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST" and wea_tmp(1) = '1') or (seq = "11" and WRITE_MODE_B = "WRITE_FIRST" and wea_tmp(1) /= '1')) then
17827
 
17828
                     dob_ltmp(15 downto 8) := mem(prcd_tmp_addrb_dly_depth)(15 downto 8);
17829
                     dopb_ltmp(1) := memp(prcd_tmp_addrb_dly_depth)(1);
17830
                     prcd_x_buf (wr_mode_b_tmp, 15, 8, 1, dob_ltmp, dob_tmp, dopb_ltmp, dopb_tmp);
17831
 
17832
                   end if;
17833
 
17834
                   if ((web_tmp(2) = '1' and wea_tmp(2) = '1') or (seq = "01" and wea_tmp(2) = '1' and web_tmp(2) = '0' and viol_type_tmp = "11") or (seq = "01" and WRITE_MODE_B /= "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST") or (seq = "01" and WRITE_MODE_B = "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST" and wea_tmp(2) = '1') or (seq = "11" and WRITE_MODE_B = "WRITE_FIRST" and wea_tmp(2) /= '1')) then
17835
 
17836
                     dob_ltmp(23 downto 16) := mem(prcd_tmp_addrb_dly_depth)(23 downto 16);
17837
                     dopb_ltmp(2) := memp(prcd_tmp_addrb_dly_depth)(2);
17838
                     prcd_x_buf (wr_mode_b_tmp, 23, 16, 2, dob_ltmp, dob_tmp, dopb_ltmp, dopb_tmp);
17839
 
17840
                   end if;
17841
 
17842
                   if ((web_tmp(3) = '1' and wea_tmp(3) = '1') or (seq = "01" and wea_tmp(3) = '1' and web_tmp(3) = '0' and viol_type_tmp = "11") or (seq = "01" and WRITE_MODE_B /= "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST") or (seq = "01" and WRITE_MODE_B = "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST" and wea_tmp(3) = '1') or (seq = "11" and WRITE_MODE_B = "WRITE_FIRST" and wea_tmp(3) /= '1')) then
17843
 
17844
                     dob_ltmp(31 downto 24) := mem(prcd_tmp_addrb_dly_depth)(31 downto 24);
17845
                     dopb_ltmp(3) := memp(prcd_tmp_addrb_dly_depth)(3);
17846
                     prcd_x_buf (wr_mode_b_tmp, 31, 24, 3, dob_ltmp, dob_tmp, dopb_ltmp, dopb_tmp);
17847
 
17848
                   end if;
17849
 
17850
                end if;
17851
 
17852
      when 64 =>
17853
                   prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto 6));
17854
 
17855
                   if ((web_tmp(0) = '1' and wea_tmp(0) = '1') or (seq = "01" and wea_tmp(0) = '1' and web_tmp(0) = '0' and viol_type_tmp = "11") or (seq = "01" and WRITE_MODE_B /= "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST") or (seq = "01" and WRITE_MODE_B = "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST" and wea_tmp(0) = '1') or (seq = "11" and WRITE_MODE_B = "WRITE_FIRST" and wea_tmp(0) /= '1')) then
17856
 
17857
                     dob_ltmp(7 downto 0) := mem(prcd_tmp_addrb_dly_depth)(7 downto 0);
17858
                     dopb_ltmp(0) := memp(prcd_tmp_addrb_dly_depth)(0);
17859
                     prcd_x_buf (wr_mode_b_tmp, 7, 0, 0, dob_ltmp, dob_tmp, dopb_ltmp, dopb_tmp);
17860
 
17861
                   end if;
17862
 
17863
                   if ((web_tmp(1) = '1' and wea_tmp(1) = '1') or (seq = "01" and wea_tmp(1) = '1' and web_tmp(1) = '0' and viol_type_tmp = "11") or (seq = "01" and WRITE_MODE_B /= "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST") or (seq = "01" and WRITE_MODE_B = "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST" and wea_tmp(1) = '1') or (seq = "11" and WRITE_MODE_B = "WRITE_FIRST" and wea_tmp(1) /= '1')) then
17864
 
17865
                     dob_ltmp(15 downto 8) := mem(prcd_tmp_addrb_dly_depth)(15 downto 8);
17866
                     dopb_ltmp(1) := memp(prcd_tmp_addrb_dly_depth)(1);
17867
                     prcd_x_buf (wr_mode_b_tmp, 15, 8, 1, dob_ltmp, dob_tmp, dopb_ltmp, dopb_tmp);
17868
 
17869
                   end if;
17870
 
17871
                   if ((web_tmp(2) = '1' and wea_tmp(2) = '1') or (seq = "01" and wea_tmp(2) = '1' and web_tmp(2) = '0' and viol_type_tmp = "11") or (seq = "01" and WRITE_MODE_B /= "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST") or (seq = "01" and WRITE_MODE_B = "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST" and wea_tmp(2) = '1') or (seq = "11" and WRITE_MODE_B = "WRITE_FIRST" and wea_tmp(2) /= '1')) then
17872
 
17873
                     dob_ltmp(23 downto 16) := mem(prcd_tmp_addrb_dly_depth)(23 downto 16);
17874
                     dopb_ltmp(2) := memp(prcd_tmp_addrb_dly_depth)(2);
17875
                     prcd_x_buf (wr_mode_b_tmp, 23, 16, 2, dob_ltmp, dob_tmp, dopb_ltmp, dopb_tmp);
17876
 
17877
                   end if;
17878
 
17879
                   if ((web_tmp(3) = '1' and wea_tmp(3) = '1') or (seq = "01" and wea_tmp(3) = '1' and web_tmp(3) = '0' and viol_type_tmp = "11") or (seq = "01" and WRITE_MODE_B /= "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST") or (seq = "01" and WRITE_MODE_B = "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST" and wea_tmp(3) = '1') or (seq = "11" and WRITE_MODE_B = "WRITE_FIRST" and wea_tmp(3) /= '1')) then
17880
 
17881
                     dob_ltmp(31 downto 24) := mem(prcd_tmp_addrb_dly_depth)(31 downto 24);
17882
                     dopb_ltmp(3) := memp(prcd_tmp_addrb_dly_depth)(3);
17883
                     prcd_x_buf (wr_mode_b_tmp, 31, 24, 3, dob_ltmp, dob_tmp, dopb_ltmp, dopb_tmp);
17884
 
17885
                   end if;
17886
 
17887
                   if ((web_tmp(4) = '1' and wea_tmp(4) = '1') or (seq = "01" and wea_tmp(4) = '1' and web_tmp(4) = '0' and viol_type_tmp = "11") or (seq = "01" and WRITE_MODE_B /= "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST") or (seq = "01" and WRITE_MODE_B = "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST" and wea_tmp(4) = '1') or (seq = "11" and WRITE_MODE_B = "WRITE_FIRST" and wea_tmp(4) /= '1')) then
17888
 
17889
                     dob_ltmp(39 downto 32) := mem(prcd_tmp_addrb_dly_depth)(39 downto 32);
17890
                     dopb_ltmp(4) := memp(prcd_tmp_addrb_dly_depth)(4);
17891
                     prcd_x_buf (wr_mode_b_tmp, 39, 32, 4, dob_ltmp, dob_tmp, dopb_ltmp, dopb_tmp);
17892
 
17893
                   end if;
17894
 
17895
                   if ((web_tmp(5) = '1' and wea_tmp(5) = '1') or (seq = "01" and wea_tmp(5) = '1' and web_tmp(5) = '0' and viol_type_tmp = "11") or (seq = "01" and WRITE_MODE_B /= "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST") or (seq = "01" and WRITE_MODE_B = "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST" and wea_tmp(5) = '1') or (seq = "11" and WRITE_MODE_B = "WRITE_FIRST" and wea_tmp(5) /= '1')) then
17896
 
17897
                     dob_ltmp(47 downto 40) := mem(prcd_tmp_addrb_dly_depth)(47 downto 40);
17898
                     dopb_ltmp(5) := memp(prcd_tmp_addrb_dly_depth)(5);
17899
                     prcd_x_buf (wr_mode_b_tmp, 47, 40, 5, dob_ltmp, dob_tmp, dopb_ltmp, dopb_tmp);
17900
 
17901
                   end if;
17902
 
17903
                   if ((web_tmp(6) = '1' and wea_tmp(6) = '1') or (seq = "01" and wea_tmp(6) = '1' and web_tmp(6) = '0' and viol_type_tmp = "11") or (seq = "01" and WRITE_MODE_B /= "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST") or (seq = "01" and WRITE_MODE_B = "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST" and wea_tmp(6) = '1') or (seq = "11" and WRITE_MODE_B = "WRITE_FIRST" and wea_tmp(6) /= '1')) then
17904
 
17905
                     dob_ltmp(55 downto 48) := mem(prcd_tmp_addrb_dly_depth)(55 downto 48);
17906
                     dopb_ltmp(6) := memp(prcd_tmp_addrb_dly_depth)(6);
17907
                     prcd_x_buf (wr_mode_b_tmp, 55, 48, 6, dob_ltmp, dob_tmp, dopb_ltmp, dopb_tmp);
17908
 
17909
                   end if;
17910
 
17911
                   if ((web_tmp(7) = '1' and wea_tmp(7) = '1') or (seq = "01" and wea_tmp(7) = '1' and web_tmp(7) = '0' and viol_type_tmp = "11") or (seq = "01" and WRITE_MODE_B /= "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST") or (seq = "01" and WRITE_MODE_B = "READ_FIRST" and WRITE_MODE_A /= "READ_FIRST" and wea_tmp(7) = '1') or (seq = "11" and WRITE_MODE_B = "WRITE_FIRST" and wea_tmp(7) /= '1')) then
17912
 
17913
                     dob_ltmp(63 downto 56) := mem(prcd_tmp_addrb_dly_depth)(63 downto 56);
17914
                     dopb_ltmp(7) := memp(prcd_tmp_addrb_dly_depth)(7);
17915
                     prcd_x_buf (wr_mode_b_tmp, 63, 56, 7, dob_ltmp, dob_tmp, dopb_ltmp, dopb_tmp);
17916
 
17917
                   end if;
17918
 
17919
      when others => null;
17920
 
17921
    end case;
17922
 
17923
  end prcd_col_rd_ram_b;
17924
 
17925
 
17926
  procedure prcd_wr_ram_a (
17927
    constant wea_tmp : in std_logic_vector (7 downto 0);
17928
    constant dia_tmp : in std_logic_vector (63 downto 0);
17929
    constant dipa_tmp : in std_logic_vector (7 downto 0);
17930
    constant addra_tmp : in std_logic_vector (15 downto 0);
17931
    variable mem : inout Two_D_array_type;
17932
    variable memp : inout Two_D_parity_array_type;
17933
    constant syndrome_tmp : in std_logic_vector (7 downto 0)
17934
    ) is
17935
    variable prcd_tmp_addra_dly_depth : integer;
17936
    variable prcd_tmp_addra_dly_width : integer;
17937
    variable junk : std_ulogic;
17938
 
17939
  begin
17940
 
17941
    case wa_width is
17942
 
17943
      when 1 | 2 | 4 =>
17944
                          if (wa_width >= width) then
17945
                            prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto w_addra_lbit_124));
17946
                            prcd_write_ram (wea_tmp(0), dia_tmp(wa_width-1 downto 0), '0', mem(prcd_tmp_addra_dly_depth), junk);
17947
                          else
17948
                            prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto w_addra_bit_124 + 1));
17949
                            prcd_tmp_addra_dly_width := SLV_TO_INT(addra_tmp(w_addra_bit_124 downto w_addra_lbit_124));
17950
                            prcd_write_ram (wea_tmp(0), dia_tmp(wa_width-1 downto 0), '0', mem(prcd_tmp_addra_dly_depth)((prcd_tmp_addra_dly_width * wa_width) + wa_width - 1 downto (prcd_tmp_addra_dly_width * wa_width)), junk);
17951
                          end if;
17952
 
17953
      when 8 =>
17954
                  if (wa_width >= width) then
17955
                    prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto 3));
17956
                    prcd_write_ram (wea_tmp(0), dia_tmp(7 downto 0), dipa_tmp(0), mem(prcd_tmp_addra_dly_depth), memp(prcd_tmp_addra_dly_depth)(0));
17957
                  else
17958
                    prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto w_addra_bit_8 + 1));
17959
                    prcd_tmp_addra_dly_width := SLV_TO_INT(addra_tmp(w_addra_bit_8 downto 3));
17960
                    prcd_write_ram (wea_tmp(0), dia_tmp(7 downto 0), dipa_tmp(0), mem(prcd_tmp_addra_dly_depth)((prcd_tmp_addra_dly_width * 8) + 7 downto (prcd_tmp_addra_dly_width * 8)), memp(prcd_tmp_addra_dly_depth)((prcd_tmp_addra_dly_width)));
17961
                  end if;
17962
 
17963
      when 16 =>
17964
                  if (wa_width >= width) then
17965
                    prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto 4));
17966
                    prcd_write_ram (wea_tmp(0), dia_tmp(7 downto 0), dipa_tmp(0), mem(prcd_tmp_addra_dly_depth)(7 downto 0), memp(prcd_tmp_addra_dly_depth)(0));
17967
                    prcd_write_ram (wea_tmp(1), dia_tmp(15 downto 8), dipa_tmp(1), mem(prcd_tmp_addra_dly_depth)(15 downto 8), memp(prcd_tmp_addra_dly_depth)(1));
17968
                  else
17969
                    prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto w_addra_bit_16 + 1));
17970
                    prcd_tmp_addra_dly_width := SLV_TO_INT(addra_tmp(w_addra_bit_16 downto 4));
17971
                    prcd_write_ram (wea_tmp(0), dia_tmp(7 downto 0), dipa_tmp(0), mem(prcd_tmp_addra_dly_depth)((prcd_tmp_addra_dly_width * 16) + 7 downto (prcd_tmp_addra_dly_width * 16)), memp(prcd_tmp_addra_dly_depth)((prcd_tmp_addra_dly_width * 2)));
17972
                    prcd_write_ram (wea_tmp(1), dia_tmp(15 downto 8), dipa_tmp(1), mem(prcd_tmp_addra_dly_depth)((prcd_tmp_addra_dly_width * 16) + 15 downto (prcd_tmp_addra_dly_width * 16) + 8), memp(prcd_tmp_addra_dly_depth)((prcd_tmp_addra_dly_width * 2) + 1));
17973
                  end if;
17974
 
17975
      when 32 =>
17976
                   prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto 5));
17977
 
17978
                   prcd_write_ram (wea_tmp(0), dia_tmp(7 downto 0), dipa_tmp(0), mem(prcd_tmp_addra_dly_depth)(7 downto 0), memp(prcd_tmp_addra_dly_depth)(0));
17979
                   prcd_write_ram (wea_tmp(1), dia_tmp(15 downto 8), dipa_tmp(1), mem(prcd_tmp_addra_dly_depth)(15 downto 8), memp(prcd_tmp_addra_dly_depth)(1));
17980
                   prcd_write_ram (wea_tmp(2), dia_tmp(23 downto 16), dipa_tmp(2), mem(prcd_tmp_addra_dly_depth)(23 downto 16), memp(prcd_tmp_addra_dly_depth)(2));
17981
                   prcd_write_ram (wea_tmp(3), dia_tmp(31 downto 24), dipa_tmp(3), mem(prcd_tmp_addra_dly_depth)(31 downto 24), memp(prcd_tmp_addra_dly_depth)(3));
17982
 
17983
      when 64 => if (syndrome_tmp /= "00000000" and syndrome_tmp(7) = '1' and EN_ECC_SCRUB = TRUE) then
17984
 
17985
                   prcd_tmp_addra_dly_depth := SLV_TO_INT(addra_tmp(14 downto 6));
17986
                   prcd_write_ram ('1', dia_tmp(7 downto 0), dipa_tmp(0), mem(prcd_tmp_addra_dly_depth)(7 downto 0), memp(prcd_tmp_addra_dly_depth)(0));
17987
                   prcd_write_ram ('1', dia_tmp(15 downto 8), dipa_tmp(1), mem(prcd_tmp_addra_dly_depth)(15 downto 8), memp(prcd_tmp_addra_dly_depth)(1));
17988
                   prcd_write_ram ('1', dia_tmp(23 downto 16), dipa_tmp(2), mem(prcd_tmp_addra_dly_depth)(23 downto 16), memp(prcd_tmp_addra_dly_depth)(2));
17989
                   prcd_write_ram ('1', dia_tmp(31 downto 24), dipa_tmp(3), mem(prcd_tmp_addra_dly_depth)(31 downto 24), memp(prcd_tmp_addra_dly_depth)(3));
17990
                   prcd_write_ram ('1', dia_tmp(39 downto 32), dipa_tmp(4), mem(prcd_tmp_addra_dly_depth)(39 downto 32), memp(prcd_tmp_addra_dly_depth)(4));
17991
                   prcd_write_ram ('1', dia_tmp(47 downto 40), dipa_tmp(5), mem(prcd_tmp_addra_dly_depth)(47 downto 40), memp(prcd_tmp_addra_dly_depth)(5));
17992
                   prcd_write_ram ('1', dia_tmp(55 downto 48), dipa_tmp(6), mem(prcd_tmp_addra_dly_depth)(55 downto 48), memp(prcd_tmp_addra_dly_depth)(6));
17993
                   prcd_write_ram ('1', dia_tmp(63 downto 56), dipa_tmp(7), mem(prcd_tmp_addra_dly_depth)(63 downto 56), memp(prcd_tmp_addra_dly_depth)(7));
17994
 
17995
                 end if;
17996
 
17997
      when others => null;
17998
 
17999
    end case;
18000
 
18001
  end prcd_wr_ram_a;
18002
 
18003
 
18004
  procedure prcd_wr_ram_b (
18005
    constant web_tmp : in std_logic_vector (7 downto 0);
18006
    constant dib_tmp : in std_logic_vector (63 downto 0);
18007
    constant dipb_tmp : in std_logic_vector (7 downto 0);
18008
    constant addrb_tmp : in std_logic_vector (15 downto 0);
18009
    variable mem : inout Two_D_array_type;
18010
    variable memp : inout Two_D_parity_array_type
18011
    ) is
18012
    variable prcd_tmp_addrb_dly_depth : integer;
18013
    variable prcd_tmp_addrb_dly_width : integer;
18014
    variable junk : std_ulogic;
18015
 
18016
  begin
18017
 
18018
    case wb_width is
18019
 
18020
      when 1 | 2 | 4 =>
18021
                          if (wb_width >= width) then
18022
                            prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto w_addrb_lbit_124));
18023
                            prcd_write_ram (web_tmp(0), dib_tmp(wb_width-1 downto 0), '0', mem(prcd_tmp_addrb_dly_depth), junk);
18024
                          else
18025
                            prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto w_addrb_bit_124 + 1));
18026
                            prcd_tmp_addrb_dly_width := SLV_TO_INT(addrb_tmp(w_addrb_bit_124 downto w_addrb_lbit_124));
18027
                            prcd_write_ram (web_tmp(0), dib_tmp(wb_width-1 downto 0), '0', mem(prcd_tmp_addrb_dly_depth)((prcd_tmp_addrb_dly_width * wb_width) + wb_width - 1 downto (prcd_tmp_addrb_dly_width * wb_width)), junk);
18028
                          end if;
18029
 
18030
      when 8 =>
18031
                  if (wb_width >= width) then
18032
                    prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto 3));
18033
                    prcd_write_ram (web_tmp(0), dib_tmp(7 downto 0), dipb_tmp(0), mem(prcd_tmp_addrb_dly_depth), memp(prcd_tmp_addrb_dly_depth)(0));
18034
                  else
18035
                    prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto w_addrb_bit_8 + 1));
18036
                    prcd_tmp_addrb_dly_width := SLV_TO_INT(addrb_tmp(w_addrb_bit_8 downto 3));
18037
                    prcd_write_ram (web_tmp(0), dib_tmp(7 downto 0), dipb_tmp(0), mem(prcd_tmp_addrb_dly_depth)((prcd_tmp_addrb_dly_width * 8) + 7 downto (prcd_tmp_addrb_dly_width * 8)), memp(prcd_tmp_addrb_dly_depth)((prcd_tmp_addrb_dly_width)));
18038
                  end if;
18039
 
18040
      when 16 =>
18041
                  if (wb_width >= width) then
18042
                    prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto 4));
18043
                    prcd_write_ram (web_tmp(0), dib_tmp(7 downto 0), dipb_tmp(0), mem(prcd_tmp_addrb_dly_depth)(7 downto 0), memp(prcd_tmp_addrb_dly_depth)(0));
18044
                    prcd_write_ram (web_tmp(1), dib_tmp(15 downto 8), dipb_tmp(1), mem(prcd_tmp_addrb_dly_depth)(15 downto 8), memp(prcd_tmp_addrb_dly_depth)(1));
18045
                  else
18046
                    prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto w_addrb_bit_16 + 1));
18047
                    prcd_tmp_addrb_dly_width := SLV_TO_INT(addrb_tmp(w_addrb_bit_16 downto 4));
18048
                    prcd_write_ram (web_tmp(0), dib_tmp(7 downto 0), dipb_tmp(0), mem(prcd_tmp_addrb_dly_depth)((prcd_tmp_addrb_dly_width * 16) + 7 downto (prcd_tmp_addrb_dly_width * 16)), memp(prcd_tmp_addrb_dly_depth)((prcd_tmp_addrb_dly_width * 2)));
18049
                    prcd_write_ram (web_tmp(1), dib_tmp(15 downto 8), dipb_tmp(1), mem(prcd_tmp_addrb_dly_depth)((prcd_tmp_addrb_dly_width * 16) + 15 downto (prcd_tmp_addrb_dly_width * 16) + 8), memp(prcd_tmp_addrb_dly_depth)((prcd_tmp_addrb_dly_width * 2) + 1));
18050
                  end if;
18051
 
18052
      when 32 =>
18053
                   prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto 5));
18054
                   prcd_write_ram (web_tmp(0), dib_tmp(7 downto 0), dipb_tmp(0), mem(prcd_tmp_addrb_dly_depth)(7 downto 0), memp(prcd_tmp_addrb_dly_depth)(0));
18055
                   prcd_write_ram (web_tmp(1), dib_tmp(15 downto 8), dipb_tmp(1), mem(prcd_tmp_addrb_dly_depth)(15 downto 8), memp(prcd_tmp_addrb_dly_depth)(1));
18056
                   prcd_write_ram (web_tmp(2), dib_tmp(23 downto 16), dipb_tmp(2), mem(prcd_tmp_addrb_dly_depth)(23 downto 16), memp(prcd_tmp_addrb_dly_depth)(2));
18057
                   prcd_write_ram (web_tmp(3), dib_tmp(31 downto 24), dipb_tmp(3), mem(prcd_tmp_addrb_dly_depth)(31 downto 24), memp(prcd_tmp_addrb_dly_depth)(3));
18058
 
18059
      when 64 =>
18060
                   prcd_tmp_addrb_dly_depth := SLV_TO_INT(addrb_tmp(14 downto 6));
18061
                   prcd_write_ram (web_tmp(0), dib_tmp(7 downto 0), dipb_tmp(0), mem(prcd_tmp_addrb_dly_depth)(7 downto 0), memp(prcd_tmp_addrb_dly_depth)(0));
18062
                   prcd_write_ram (web_tmp(1), dib_tmp(15 downto 8), dipb_tmp(1), mem(prcd_tmp_addrb_dly_depth)(15 downto 8), memp(prcd_tmp_addrb_dly_depth)(1));
18063
                   prcd_write_ram (web_tmp(2), dib_tmp(23 downto 16), dipb_tmp(2), mem(prcd_tmp_addrb_dly_depth)(23 downto 16), memp(prcd_tmp_addrb_dly_depth)(2));
18064
                   prcd_write_ram (web_tmp(3), dib_tmp(31 downto 24), dipb_tmp(3), mem(prcd_tmp_addrb_dly_depth)(31 downto 24), memp(prcd_tmp_addrb_dly_depth)(3));
18065
                   prcd_write_ram (web_tmp(4), dib_tmp(39 downto 32), dipb_tmp(4), mem(prcd_tmp_addrb_dly_depth)(39 downto 32), memp(prcd_tmp_addrb_dly_depth)(4));
18066
                   prcd_write_ram (web_tmp(5), dib_tmp(47 downto 40), dipb_tmp(5), mem(prcd_tmp_addrb_dly_depth)(47 downto 40), memp(prcd_tmp_addrb_dly_depth)(5));
18067
                   prcd_write_ram (web_tmp(6), dib_tmp(55 downto 48), dipb_tmp(6), mem(prcd_tmp_addrb_dly_depth)(55 downto 48), memp(prcd_tmp_addrb_dly_depth)(6));
18068
                   prcd_write_ram (web_tmp(7), dib_tmp(63 downto 56), dipb_tmp(7), mem(prcd_tmp_addrb_dly_depth)(63 downto 56), memp(prcd_tmp_addrb_dly_depth)(7));
18069
 
18070
      when others => null;
18071
 
18072
    end case;
18073
 
18074
  end prcd_wr_ram_b;
18075
 
18076
 
18077
  procedure prcd_col_ecc_read (
18078
 
18079
    variable do_tmp : inout std_logic_vector (63 downto 0);
18080
    variable dop_tmp : inout std_logic_vector (7 downto 0);
18081
    constant addr_tmp : in std_logic_vector (15 downto 0);
18082
    variable dbiterr_tmp : inout std_logic;
18083
    variable sbiterr_tmp : inout std_logic;
18084
    variable mem : inout Two_D_array_type;
18085
    variable memp : inout Two_D_parity_array_type;
18086
    variable prcd_syndrome : inout std_logic_vector (7 downto 0)
18087
    ) is
18088
 
18089
    variable prcd_ecc_bit_position : std_logic_vector (71 downto 0);
18090
    variable prcd_dopr_ecc : std_logic_vector (7 downto 0);
18091
    variable prcd_di_dly_ecc_corrected : std_logic_vector (63 downto 0);
18092
    variable prcd_dip_dly_ecc_corrected : std_logic_vector (7 downto 0);
18093
    variable prcd_tmp_syndrome_int : integer := 0;
18094
 
18095
  begin
18096
 
18097
    prcd_dopr_ecc := fn_dip_ecc('0', do_tmp, dop_tmp);
18098
 
18099
    prcd_syndrome := prcd_dopr_ecc xor dop_tmp;
18100
 
18101
    if (prcd_syndrome /= "00000000") then
18102
 
18103
      if (prcd_syndrome(7) = '1') then  -- dectect single bit error
18104
 
18105
        prcd_ecc_bit_position := do_tmp(63 downto 57) & dop_tmp(6) & do_tmp(56 downto 26) & dop_tmp(5) & do_tmp(25 downto 11) & dop_tmp(4) & do_tmp(10 downto 4) & dop_tmp(3) & do_tmp(3 downto 1) & dop_tmp(2) & do_tmp(0) & dop_tmp(1 downto 0) & dop_tmp(7);
18106
 
18107
        prcd_tmp_syndrome_int := SLV_TO_INT(prcd_syndrome(6 downto 0));
18108
        prcd_ecc_bit_position(prcd_tmp_syndrome_int) := not prcd_ecc_bit_position(prcd_tmp_syndrome_int); -- correct single bit error in the output
18109
 
18110
        prcd_di_dly_ecc_corrected := prcd_ecc_bit_position(71 downto 65) & prcd_ecc_bit_position(63 downto 33) & prcd_ecc_bit_position(31 downto 17) & prcd_ecc_bit_position(15 downto 9) & prcd_ecc_bit_position(7 downto 5) & prcd_ecc_bit_position(3); -- correct single bit error in the memory
18111
 
18112
        do_tmp := prcd_di_dly_ecc_corrected;
18113
 
18114
        prcd_dip_dly_ecc_corrected := prcd_ecc_bit_position(0) & prcd_ecc_bit_position(64) & prcd_ecc_bit_position(32) & prcd_ecc_bit_position(16) & prcd_ecc_bit_position(8) & prcd_ecc_bit_position(4) & prcd_ecc_bit_position(2 downto 1); -- correct single bit error in the parity memory
18115
 
18116
        dop_tmp := prcd_dip_dly_ecc_corrected;
18117
 
18118
        dbiterr_tmp := '0';
18119
        sbiterr_tmp := '1';
18120
 
18121
      elsif (prcd_syndrome(7) = '0') then  -- double bit error
18122
        sbiterr_tmp := '0';
18123
        dbiterr_tmp := '1';
18124
      end if;
18125
    else
18126
      dbiterr_tmp := '0';
18127
      sbiterr_tmp := '0';
18128
    end if;
18129
 
18130
    if (ssra_dly = '1') then  -- ssra reset
18131
      dbiterr_tmp := '0';
18132
      sbiterr_tmp := '0';
18133
    end if;
18134
 
18135
    if (prcd_syndrome /= "00000000" and prcd_syndrome(7) = '1' and EN_ECC_SCRUB = TRUE) then
18136
      prcd_wr_ram_a ("11111111", prcd_di_dly_ecc_corrected, prcd_dip_dly_ecc_corrected, addr_tmp, mem, memp, prcd_syndrome);
18137
    end if;
18138
 
18139
  end prcd_col_ecc_read;
18140
 
18141
 
18142
  begin
18143
 
18144
  ---------------------
18145
  --  INPUT PATH DELAYs
18146
  --------------------
18147
 
18148
    addra_dly            <= ADDRA               after 0 ps;
18149
    addrb_dly            <= ADDRB               after 0 ps;
18150
    cascadeinlata_dly    <= CASCADEINLATA       after 0 ps;
18151
    cascadeinlatb_dly    <= CASCADEINLATB       after 0 ps;
18152
    cascadeinrega_dly    <= CASCADEINREGA       after 0 ps;
18153
    cascadeinregb_dly    <= CASCADEINREGB       after 0 ps;
18154
    clka_dly             <= CLKA                after 0 ps;
18155
    clkb_dly             <= CLKB                after 0 ps;
18156
    dia_dly              <= DIA                 after 0 ps;
18157
    dib_dly              <= DIB                 after 0 ps;
18158
    dipa_dly             <= DIPA                after 0 ps;
18159
    dipb_dly             <= DIPB                after 0 ps;
18160
    ena_dly              <= ENA                 after 0 ps;
18161
    enb_dly              <= ENB                 after 0 ps;
18162
    regcea_dly           <= REGCEA              after 0 ps;
18163
    regceb_dly           <= REGCEB              after 0 ps;
18164
    ssra_dly             <= SSRA                after 0 ps;
18165
    ssrb_dly             <= SSRB                after 0 ps;
18166
    wea_dly              <= WEA                 after 0 ps;
18167
    web_dly              <= WEB                 after 0 ps;
18168
    gsr_dly              <= GSR                 after 0 ps;
18169
    regclka_dly          <= REGCLKA             after 0 ps;
18170
    regclkb_dly          <= REGCLKB             after 0 ps;
18171
 
18172
  --------------------
18173
  --  BEHAVIOR SECTION
18174
  --------------------
18175
 
18176
  prcs_clk: process (clka_dly, clkb_dly, gsr_dly)
18177
 
18178
    variable mem_slv : std_logic_vector(32767 downto 0) := To_StdLogicVector(INIT_7F) &
18179
                                                       To_StdLogicVector(INIT_7E) &
18180
                                                       To_StdLogicVector(INIT_7D) &
18181
                                                       To_StdLogicVector(INIT_7C) &
18182
                                                       To_StdLogicVector(INIT_7B) &
18183
                                                       To_StdLogicVector(INIT_7A) &
18184
                                                       To_StdLogicVector(INIT_79) &
18185
                                                       To_StdLogicVector(INIT_78) &
18186
                                                       To_StdLogicVector(INIT_77) &
18187
                                                       To_StdLogicVector(INIT_76) &
18188
                                                       To_StdLogicVector(INIT_75) &
18189
                                                       To_StdLogicVector(INIT_74) &
18190
                                                       To_StdLogicVector(INIT_73) &
18191
                                                       To_StdLogicVector(INIT_72) &
18192
                                                       To_StdLogicVector(INIT_71) &
18193
                                                       To_StdLogicVector(INIT_70) &
18194
                                                       To_StdLogicVector(INIT_6F) &
18195
                                                       To_StdLogicVector(INIT_6E) &
18196
                                                       To_StdLogicVector(INIT_6D) &
18197
                                                       To_StdLogicVector(INIT_6C) &
18198
                                                       To_StdLogicVector(INIT_6B) &
18199
                                                       To_StdLogicVector(INIT_6A) &
18200
                                                       To_StdLogicVector(INIT_69) &
18201
                                                       To_StdLogicVector(INIT_68) &
18202
                                                       To_StdLogicVector(INIT_67) &
18203
                                                       To_StdLogicVector(INIT_66) &
18204
                                                       To_StdLogicVector(INIT_65) &
18205
                                                       To_StdLogicVector(INIT_64) &
18206
                                                       To_StdLogicVector(INIT_63) &
18207
                                                       To_StdLogicVector(INIT_62) &
18208
                                                       To_StdLogicVector(INIT_61) &
18209
                                                       To_StdLogicVector(INIT_60) &
18210
                                                       To_StdLogicVector(INIT_5F) &
18211
                                                       To_StdLogicVector(INIT_5E) &
18212
                                                       To_StdLogicVector(INIT_5D) &
18213
                                                       To_StdLogicVector(INIT_5C) &
18214
                                                       To_StdLogicVector(INIT_5B) &
18215
                                                       To_StdLogicVector(INIT_5A) &
18216
                                                       To_StdLogicVector(INIT_59) &
18217
                                                       To_StdLogicVector(INIT_58) &
18218
                                                       To_StdLogicVector(INIT_57) &
18219
                                                       To_StdLogicVector(INIT_56) &
18220
                                                       To_StdLogicVector(INIT_55) &
18221
                                                       To_StdLogicVector(INIT_54) &
18222
                                                       To_StdLogicVector(INIT_53) &
18223
                                                       To_StdLogicVector(INIT_52) &
18224
                                                       To_StdLogicVector(INIT_51) &
18225
                                                       To_StdLogicVector(INIT_50) &
18226
                                                       To_StdLogicVector(INIT_4F) &
18227
                                                       To_StdLogicVector(INIT_4E) &
18228
                                                       To_StdLogicVector(INIT_4D) &
18229
                                                       To_StdLogicVector(INIT_4C) &
18230
                                                       To_StdLogicVector(INIT_4B) &
18231
                                                       To_StdLogicVector(INIT_4A) &
18232
                                                       To_StdLogicVector(INIT_49) &
18233
                                                       To_StdLogicVector(INIT_48) &
18234
                                                       To_StdLogicVector(INIT_47) &
18235
                                                       To_StdLogicVector(INIT_46) &
18236
                                                       To_StdLogicVector(INIT_45) &
18237
                                                       To_StdLogicVector(INIT_44) &
18238
                                                       To_StdLogicVector(INIT_43) &
18239
                                                       To_StdLogicVector(INIT_42) &
18240
                                                       To_StdLogicVector(INIT_41) &
18241
                                                       To_StdLogicVector(INIT_40) &
18242
                                                       To_StdLogicVector(INIT_3F) &
18243
                                                       To_StdLogicVector(INIT_3E) &
18244
                                                       To_StdLogicVector(INIT_3D) &
18245
                                                       To_StdLogicVector(INIT_3C) &
18246
                                                       To_StdLogicVector(INIT_3B) &
18247
                                                       To_StdLogicVector(INIT_3A) &
18248
                                                       To_StdLogicVector(INIT_39) &
18249
                                                       To_StdLogicVector(INIT_38) &
18250
                                                       To_StdLogicVector(INIT_37) &
18251
                                                       To_StdLogicVector(INIT_36) &
18252
                                                       To_StdLogicVector(INIT_35) &
18253
                                                       To_StdLogicVector(INIT_34) &
18254
                                                       To_StdLogicVector(INIT_33) &
18255
                                                       To_StdLogicVector(INIT_32) &
18256
                                                       To_StdLogicVector(INIT_31) &
18257
                                                       To_StdLogicVector(INIT_30) &
18258
                                                       To_StdLogicVector(INIT_2F) &
18259
                                                       To_StdLogicVector(INIT_2E) &
18260
                                                       To_StdLogicVector(INIT_2D) &
18261
                                                       To_StdLogicVector(INIT_2C) &
18262
                                                       To_StdLogicVector(INIT_2B) &
18263
                                                       To_StdLogicVector(INIT_2A) &
18264
                                                       To_StdLogicVector(INIT_29) &
18265
                                                       To_StdLogicVector(INIT_28) &
18266
                                                       To_StdLogicVector(INIT_27) &
18267
                                                       To_StdLogicVector(INIT_26) &
18268
                                                       To_StdLogicVector(INIT_25) &
18269
                                                       To_StdLogicVector(INIT_24) &
18270
                                                       To_StdLogicVector(INIT_23) &
18271
                                                       To_StdLogicVector(INIT_22) &
18272
                                                       To_StdLogicVector(INIT_21) &
18273
                                                       To_StdLogicVector(INIT_20) &
18274
                                                       To_StdLogicVector(INIT_1F) &
18275
                                                       To_StdLogicVector(INIT_1E) &
18276
                                                       To_StdLogicVector(INIT_1D) &
18277
                                                       To_StdLogicVector(INIT_1C) &
18278
                                                       To_StdLogicVector(INIT_1B) &
18279
                                                       To_StdLogicVector(INIT_1A) &
18280
                                                       To_StdLogicVector(INIT_19) &
18281
                                                       To_StdLogicVector(INIT_18) &
18282
                                                       To_StdLogicVector(INIT_17) &
18283
                                                       To_StdLogicVector(INIT_16) &
18284
                                                       To_StdLogicVector(INIT_15) &
18285
                                                       To_StdLogicVector(INIT_14) &
18286
                                                       To_StdLogicVector(INIT_13) &
18287
                                                       To_StdLogicVector(INIT_12) &
18288
                                                       To_StdLogicVector(INIT_11) &
18289
                                                       To_StdLogicVector(INIT_10) &
18290
                                                       To_StdLogicVector(INIT_0F) &
18291
                                                       To_StdLogicVector(INIT_0E) &
18292
                                                       To_StdLogicVector(INIT_0D) &
18293
                                                       To_StdLogicVector(INIT_0C) &
18294
                                                       To_StdLogicVector(INIT_0B) &
18295
                                                       To_StdLogicVector(INIT_0A) &
18296
                                                       To_StdLogicVector(INIT_09) &
18297
                                                       To_StdLogicVector(INIT_08) &
18298
                                                       To_StdLogicVector(INIT_07) &
18299
                                                       To_StdLogicVector(INIT_06) &
18300
                                                       To_StdLogicVector(INIT_05) &
18301
                                                       To_StdLogicVector(INIT_04) &
18302
                                                       To_StdLogicVector(INIT_03) &
18303
                                                       To_StdLogicVector(INIT_02) &
18304
                                                       To_StdLogicVector(INIT_01) &
18305
                                                       To_StdLogicVector(INIT_00);
18306
 
18307
    variable memp_slv : std_logic_vector(4095 downto 0) := To_StdLogicVector(INITP_0F) &
18308
                                                       To_StdLogicVector(INITP_0E) &
18309
                                                       To_StdLogicVector(INITP_0D) &
18310
                                                       To_StdLogicVector(INITP_0C) &
18311
                                                       To_StdLogicVector(INITP_0B) &
18312
                                                       To_StdLogicVector(INITP_0A) &
18313
                                                       To_StdLogicVector(INITP_09) &
18314
                                                       To_StdLogicVector(INITP_08) &
18315
                                                       To_StdLogicVector(INITP_07) &
18316
                                                       To_StdLogicVector(INITP_06) &
18317
                                                       To_StdLogicVector(INITP_05) &
18318
                                                       To_StdLogicVector(INITP_04) &
18319
                                                       To_StdLogicVector(INITP_03) &
18320
                                                       To_StdLogicVector(INITP_02) &
18321
                                                       To_StdLogicVector(INITP_01) &
18322
                                                       To_StdLogicVector(INITP_00);
18323
 
18324
    variable mem : Two_D_array_type := slv_to_two_D_array(mem_depth, width, mem_slv);
18325
    variable memp : Two_D_parity_array_type := slv_to_two_D_parity_array(memp_depth, widthp, memp_slv);
18326
    variable tmp_addra_dly_depth : integer;
18327
    variable tmp_addra_dly_width : integer;
18328
    variable tmp_addrb_dly_depth : integer;
18329
    variable tmp_addrb_dly_width : integer;
18330
    variable junk1 : std_logic;
18331
    variable wr_mode_a : std_logic_vector(1 downto 0) := "00";
18332
    variable wr_mode_b : std_logic_vector(1 downto 0) := "00";
18333
    variable tmp_syndrome_int : integer;
18334
    variable doa_buf : std_logic_vector(63 downto 0) := (others => '0');
18335
    variable dob_buf : std_logic_vector(63 downto 0) := (others => '0');
18336
    variable dopa_buf : std_logic_vector(7 downto 0) := (others => '0');
18337
    variable dopb_buf : std_logic_vector(7 downto 0) := (others => '0');
18338
    variable syndrome : std_logic_vector(7 downto 0) := (others => '0');
18339
    variable dopr_ecc : std_logic_vector(7 downto 0) := (others => '0');
18340
    variable dia_dly_ecc_corrected : std_logic_vector(63 downto 0) := (others => '0');
18341
    variable dipa_dly_ecc_corrected : std_logic_vector(7 downto 0) := (others => '0');
18342
    variable dip_ecc : std_logic_vector(7 downto 0) := (others => '0');
18343
    variable dipb_dly_ecc : std_logic_vector(7 downto 0) := (others => '0');
18344
    variable ecc_bit_position : std_logic_vector(71 downto 0) := (others => '0');
18345
    variable addra_dly_15_reg_var : std_logic := '0';
18346
    variable addrb_dly_15_reg_var : std_logic := '0';
18347
    variable addra_dly_15_reg_bram_var : std_logic := '0';
18348
    variable addrb_dly_15_reg_bram_var : std_logic := '0';
18349
    variable FIRST_TIME : boolean := true;
18350
 
18351
    variable curr_time : time := 0 ps;
18352
    variable prev_time : time := 0 ps;
18353
    variable viol_time : integer := 0;
18354
    variable viol_type : std_logic_vector(1 downto 0) := (others => '0');
18355
    variable message : line;
18356
    variable dip_ecc_col : std_logic_vector (7 downto 0) := (others => '0');
18357
    variable dbiterr_out_var : std_ulogic := '0';
18358
    variable sbiterr_out_var : std_ulogic := '0';
18359
 
18360
    variable dia_reg_dly : std_logic_vector(63 downto 0) := (others => '0');
18361
    variable dipa_reg_dly : std_logic_vector(7 downto 0) := (others => '0');
18362
    variable wea_reg_dly : std_logic_vector(7 downto 0) := (others => '0');
18363
    variable addra_reg_dly : std_logic_vector(15 downto 0) := (others => '0');
18364
    variable dib_reg_dly : std_logic_vector(63 downto 0) := (others => '0');
18365
    variable dipb_reg_dly : std_logic_vector(7 downto 0) := (others => '0');
18366
    variable web_reg_dly : std_logic_vector(7 downto 0) := (others => '0');
18367
    variable addrb_reg_dly : std_logic_vector(15 downto 0) := (others => '0');
18368
    variable col_wr_wr_msg : std_ulogic := '1';
18369
    variable col_wra_rdb_msg : std_ulogic := '1';
18370
    variable col_wrb_rda_msg : std_ulogic := '1';
18371
 
18372
 
18373
  begin  -- process prcs_clka
18374
 
18375
    if (FIRST_TIME) then
18376
 
18377
      case READ_WIDTH_A is
18378
        when 0 | 1 | 2 | 4 | 9 | 18 => null;
18379
        when 36 => if (BRAM_SIZE = 18 and BRAM_MODE = "TRUE_DUAL_PORT") then
18380
                       GenericValueCheckMessage
18381
                        (  HeaderMsg            => " Attribute Syntax Error : ",
18382
                           GenericName          => " READ_WIDTH_A ",
18383
                           EntityName           => "/ARAMB36_INTERNAL",
18384
                           GenericValue         => READ_WIDTH_A,
18385
                           Unit                 => "",
18386
                           ExpectedValueMsg     => " The Legal values for this attribute are ",
18387
                           ExpectedGenericValue => " 0, 1, 2, 4, 9 or 18.",
18388
                           TailMsg              => "",
18389
                           MsgSeverity          => failure
18390
                           );
18391
                   end if;
18392
        when 72 => if (BRAM_SIZE = 18) then
18393
                       GenericValueCheckMessage
18394
                        (  HeaderMsg            => " Attribute Syntax Error : ",
18395
                           GenericName          => " READ_WIDTH_A ",
18396
                           EntityName           => "/ARAMB36_INTERNAL",
18397
                           GenericValue         => READ_WIDTH_A,
18398
                           Unit                 => "",
18399
                           ExpectedValueMsg     => " The Legal values for this attribute are ",
18400
                           ExpectedGenericValue => " 0, 1, 2, 4, 9 or 18.",
18401
                           TailMsg              => "",
18402
                           MsgSeverity          => failure
18403
                           );
18404
                   elsif ((BRAM_SIZE = 16 or BRAM_SIZE = 36) and BRAM_MODE = "TRUE_DUAL_PORT") then
18405
                       GenericValueCheckMessage
18406
                        (  HeaderMsg            => " Attribute Syntax Error : ",
18407
                           GenericName          => " READ_WIDTH_A ",
18408
                           EntityName           => "/ARAMB36_INTERNAL",
18409
                           GenericValue         => READ_WIDTH_A,
18410
                           Unit                 => "",
18411
                           ExpectedValueMsg     => " The Legal values for this attribute are ",
18412
                           ExpectedGenericValue => " 0, 1, 2, 4, 9, 18 or 36.",
18413
                           TailMsg              => "",
18414
                           MsgSeverity          => failure
18415
                           );
18416
                   end if;
18417
        when others => if (BRAM_SIZE = 18) then
18418
                         GenericValueCheckMessage
18419
                           (  HeaderMsg            => " Attribute Syntax Error : ",
18420
                              GenericName          => " READ_WIDTH_A ",
18421
                              EntityName           => "/ARAMB36_INTERNAL",
18422
                              GenericValue         => READ_WIDTH_A,
18423
                              Unit                 => "",
18424
                              ExpectedValueMsg     => " The Legal values for this attribute are ",
18425
                              ExpectedGenericValue => " 0, 1, 2, 4, 9 or 18.",
18426
                              TailMsg              => "",
18427
                              MsgSeverity          => failure
18428
                              );
18429
                       elsif (BRAM_SIZE = 16 or BRAM_SIZE = 36) then
18430
                         GenericValueCheckMessage
18431
                           (  HeaderMsg            => " Attribute Syntax Error : ",
18432
                              GenericName          => " READ_WIDTH_A ",
18433
                              EntityName           => "/ARAMB36_INTERNAL",
18434
                              GenericValue         => READ_WIDTH_A,
18435
                              Unit                 => "",
18436
                              ExpectedValueMsg     => " The Legal values for this attribute are ",
18437
                              ExpectedGenericValue => " 0, 1, 2, 4, 9, 18 or 36.",
18438
                              TailMsg              => "",
18439
                              MsgSeverity          => failure
18440
                              );
18441
                       end if;
18442
      end case;
18443
 
18444
 
18445
      case READ_WIDTH_B is
18446
        when 0 | 1 | 2 | 4 | 9 | 18 => null;
18447
        when 36 => if (BRAM_SIZE = 18 and BRAM_MODE = "TRUE_DUAL_PORT") then
18448
                       GenericValueCheckMessage
18449
                        (  HeaderMsg            => " Attribute Syntax Error : ",
18450
                           GenericName          => " READ_WIDTH_B ",
18451
                           EntityName           => "/ARAMB36_INTERNAL",
18452
                           GenericValue         => READ_WIDTH_B,
18453
                           Unit                 => "",
18454
                           ExpectedValueMsg     => " The Legal values for this attribute are ",
18455
                           ExpectedGenericValue => " 0, 1, 2, 4, 9 or 18.",
18456
                           TailMsg              => "",
18457
                           MsgSeverity          => failure
18458
                           );
18459
                   end if;
18460
        when 72 => if (BRAM_SIZE = 18) then
18461
                       GenericValueCheckMessage
18462
                        (  HeaderMsg            => " Attribute Syntax Error : ",
18463
                           GenericName          => " READ_WIDTH_B ",
18464
                           EntityName           => "/ARAMB36_INTERNAL",
18465
                           GenericValue         => READ_WIDTH_B,
18466
                           Unit                 => "",
18467
                           ExpectedValueMsg     => " The Legal values for this attribute are ",
18468
                           ExpectedGenericValue => " 0, 1, 2, 4, 9 or 18.",
18469
                           TailMsg              => "",
18470
                           MsgSeverity          => failure
18471
                           );
18472
                   elsif ((BRAM_SIZE = 16 or BRAM_SIZE = 36) and BRAM_MODE = "TRUE_DUAL_PORT") then
18473
                       GenericValueCheckMessage
18474
                        (  HeaderMsg            => " Attribute Syntax Error : ",
18475
                           GenericName          => " READ_WIDTH_B ",
18476
                           EntityName           => "/ARAMB36_INTERNAL",
18477
                           GenericValue         => READ_WIDTH_B,
18478
                           Unit                 => "",
18479
                           ExpectedValueMsg     => " The Legal values for this attribute are ",
18480
                           ExpectedGenericValue => " 0, 1, 2, 4, 9, 18 or 36.",
18481
                           TailMsg              => "",
18482
                           MsgSeverity          => failure
18483
                           );
18484
                   end if;
18485
        when others => if (BRAM_SIZE = 18) then
18486
                         GenericValueCheckMessage
18487
                           (  HeaderMsg            => " Attribute Syntax Error : ",
18488
                              GenericName          => " READ_WIDTH_B ",
18489
                              EntityName           => "/ARAMB36_INTERNAL",
18490
                              GenericValue         => READ_WIDTH_B,
18491
                              Unit                 => "",
18492
                              ExpectedValueMsg     => " The Legal values for this attribute are ",
18493
                              ExpectedGenericValue => " 0, 1, 2, 4, 9 or 18.",
18494
                              TailMsg              => "",
18495
                              MsgSeverity          => failure
18496
                              );
18497
                       elsif (BRAM_SIZE = 16 or BRAM_SIZE = 36) then
18498
                         GenericValueCheckMessage
18499
                           (  HeaderMsg            => " Attribute Syntax Error : ",
18500
                              GenericName          => " READ_WIDTH_B ",
18501
                              EntityName           => "/ARAMB36_INTERNAL",
18502
                              GenericValue         => READ_WIDTH_B,
18503
                              Unit                 => "",
18504
                              ExpectedValueMsg     => " The Legal values for this attribute are ",
18505
                              ExpectedGenericValue => " 0, 1, 2, 4, 9, 18 or 36.",
18506
                              TailMsg              => "",
18507
                              MsgSeverity          => failure
18508
                              );
18509
                       end if;
18510
      end case;
18511
 
18512
 
18513
      case WRITE_WIDTH_A is
18514
        when 0 | 1 | 2 | 4 | 9 | 18 => null;
18515
        when 36 => if (BRAM_SIZE = 18 and BRAM_MODE = "TRUE_DUAL_PORT") then
18516
                       GenericValueCheckMessage
18517
                        (  HeaderMsg            => " Attribute Syntax Error : ",
18518
                           GenericName          => " WRITE_WIDTH_A ",
18519
                           EntityName           => "/ARAMB36_INTERNAL",
18520
                           GenericValue         => WRITE_WIDTH_A,
18521
                           Unit                 => "",
18522
                           ExpectedValueMsg     => " The Legal values for this attribute are ",
18523
                           ExpectedGenericValue => " 0, 1, 2, 4, 9 or 18.",
18524
                           TailMsg              => "",
18525
                           MsgSeverity          => failure
18526
                           );
18527
                   end if;
18528
        when 72 => if (BRAM_SIZE = 18) then
18529
                       GenericValueCheckMessage
18530
                        (  HeaderMsg            => " Attribute Syntax Error : ",
18531
                           GenericName          => " WRITE_WIDTH_A ",
18532
                           EntityName           => "/ARAMB36_INTERNAL",
18533
                           GenericValue         => WRITE_WIDTH_A,
18534
                           Unit                 => "",
18535
                           ExpectedValueMsg     => " The Legal values for this attribute are ",
18536
                           ExpectedGenericValue => " 0, 1, 2, 4, 9 or 18.",
18537
                           TailMsg              => "",
18538
                           MsgSeverity          => failure
18539
                           );
18540
                   elsif ((BRAM_SIZE = 16 or BRAM_SIZE = 36) and BRAM_MODE = "TRUE_DUAL_PORT") then
18541
                       GenericValueCheckMessage
18542
                        (  HeaderMsg            => " Attribute Syntax Error : ",
18543
                           GenericName          => " WRITE_WIDTH_A ",
18544
                           EntityName           => "/ARAMB36_INTERNAL",
18545
                           GenericValue         => WRITE_WIDTH_A,
18546
                           Unit                 => "",
18547
                           ExpectedValueMsg     => " The Legal values for this attribute are ",
18548
                           ExpectedGenericValue => " 0, 1, 2, 4, 9, 18 or 36.",
18549
                           TailMsg              => "",
18550
                           MsgSeverity          => failure
18551
                           );
18552
                   end if;
18553
        when others => if (BRAM_SIZE = 18) then
18554
                         GenericValueCheckMessage
18555
                           (  HeaderMsg            => " Attribute Syntax Error : ",
18556
                              GenericName          => " WRITE_WIDTH_A ",
18557
                              EntityName           => "/ARAMB36_INTERNAL",
18558
                              GenericValue         => WRITE_WIDTH_A,
18559
                              Unit                 => "",
18560
                              ExpectedValueMsg     => " The Legal values for this attribute are ",
18561
                              ExpectedGenericValue => " 0, 1, 2, 4, 9 or 18.",
18562
                              TailMsg              => "",
18563
                              MsgSeverity          => failure
18564
                              );
18565
                       elsif (BRAM_SIZE = 16 or BRAM_SIZE = 36) then
18566
                         GenericValueCheckMessage
18567
                           (  HeaderMsg            => " Attribute Syntax Error : ",
18568
                              GenericName          => " WRITE_WIDTH_A ",
18569
                              EntityName           => "/ARAMB36_INTERNAL",
18570
                              GenericValue         => WRITE_WIDTH_A,
18571
                              Unit                 => "",
18572
                              ExpectedValueMsg     => " The Legal values for this attribute are ",
18573
                              ExpectedGenericValue => " 0, 1, 2, 4, 9, 18 or 36.",
18574
                              TailMsg              => "",
18575
                              MsgSeverity          => failure
18576
                              );
18577
                       end if;
18578
      end case;
18579
 
18580
 
18581
      case WRITE_WIDTH_B is
18582
        when 0 | 1 | 2 | 4 | 9 | 18 => null;
18583
        when 36 => if (BRAM_SIZE = 18 and BRAM_MODE = "TRUE_DUAL_PORT") then
18584
                       GenericValueCheckMessage
18585
                        (  HeaderMsg            => " Attribute Syntax Error : ",
18586
                           GenericName          => " WRITE_WIDTH_B ",
18587
                           EntityName           => "/ARAMB36_INTERNAL",
18588
                           GenericValue         => WRITE_WIDTH_B,
18589
                           Unit                 => "",
18590
                           ExpectedValueMsg     => " The Legal values for this attribute are ",
18591
                           ExpectedGenericValue => " 0, 1, 2, 4, 9 or 18.",
18592
                           TailMsg              => "",
18593
                           MsgSeverity          => failure
18594
                           );
18595
                   end if;
18596
        when 72 => if (BRAM_SIZE = 18) then
18597
                       GenericValueCheckMessage
18598
                        (  HeaderMsg            => " Attribute Syntax Error : ",
18599
                           GenericName          => " WRITE_WIDTH_B ",
18600
                           EntityName           => "/ARAMB36_INTERNAL",
18601
                           GenericValue         => WRITE_WIDTH_B,
18602
                           Unit                 => "",
18603
                           ExpectedValueMsg     => " The Legal values for this attribute are ",
18604
                           ExpectedGenericValue => " 0, 1, 2, 4, 9 or 18.",
18605
                           TailMsg              => "",
18606
                           MsgSeverity          => failure
18607
                           );
18608
                   elsif ((BRAM_SIZE = 16 or BRAM_SIZE = 36) and BRAM_MODE = "TRUE_DUAL_PORT") then
18609
                       GenericValueCheckMessage
18610
                        (  HeaderMsg            => " Attribute Syntax Error : ",
18611
                           GenericName          => " WRITE_WIDTH_B ",
18612
                           EntityName           => "/ARAMB36_INTERNAL",
18613
                           GenericValue         => WRITE_WIDTH_B,
18614
                           Unit                 => "",
18615
                           ExpectedValueMsg     => " The Legal values for this attribute are ",
18616
                           ExpectedGenericValue => " 0, 1, 2, 4, 9, 18 or 36.",
18617
                           TailMsg              => "",
18618
                           MsgSeverity          => failure
18619
                           );
18620
                   end if;
18621
        when others => if (BRAM_SIZE = 18) then
18622
                         GenericValueCheckMessage
18623
                           (  HeaderMsg            => " Attribute Syntax Error : ",
18624
                              GenericName          => " WRITE_WIDTH_B ",
18625
                              EntityName           => "/ARAMB36_INTERNAL",
18626
                              GenericValue         => WRITE_WIDTH_B,
18627
                              Unit                 => "",
18628
                              ExpectedValueMsg     => " The Legal values for this attribute are ",
18629
                              ExpectedGenericValue => " 0, 1, 2, 4, 9 or 18.",
18630
                              TailMsg              => "",
18631
                              MsgSeverity          => failure
18632
                              );
18633
                       elsif (BRAM_SIZE = 16 or BRAM_SIZE = 36) then
18634
                         GenericValueCheckMessage
18635
                           (  HeaderMsg            => " Attribute Syntax Error : ",
18636
                              GenericName          => " WRITE_WIDTH_B ",
18637
                              EntityName           => "/ARAMB36_INTERNAL",
18638
                              GenericValue         => WRITE_WIDTH_B,
18639
                              Unit                 => "",
18640
                              ExpectedValueMsg     => " The Legal values for this attribute are ",
18641
                              ExpectedGenericValue => " 0, 1, 2, 4, 9, 18 or 36.",
18642
                              TailMsg              => "",
18643
                              MsgSeverity          => failure
18644
                              );
18645
                       end if;
18646
      end case;
18647
 
18648
 
18649
      if (not(EN_ECC_READ = TRUE or EN_ECC_READ = FALSE)) then
18650
 
18651
        GenericValueCheckMessage
18652
          ( HeaderMsg            => " Attribute Syntax Error : ",
18653
            GenericName          => " EN_ECC_READ ",
18654
            EntityName           => "/ARAMB36_INTERNAL",
18655
            GenericValue         => EN_ECC_READ,
18656
            Unit                 => "",
18657
            ExpectedValueMsg     => " The Legal values for this attribute are ",
18658
            ExpectedGenericValue => " TRUE or FALSE ",
18659
            TailMsg              => "",
18660
            MsgSeverity          => failure
18661
            );
18662
      end if;
18663
 
18664
      if (not(EN_ECC_WRITE = TRUE or EN_ECC_WRITE = FALSE)) then
18665
 
18666
        GenericValueCheckMessage
18667
          ( HeaderMsg            => " Attribute Syntax Error : ",
18668
            GenericName          => " EN_ECC_WRITE ",
18669
            EntityName           => "/ARAMB36_INTERNAL",
18670
            GenericValue         => EN_ECC_WRITE,
18671
            Unit                 => "",
18672
            ExpectedValueMsg     => " The Legal values for this attribute are ",
18673
            ExpectedGenericValue => " TRUE or FALSE ",
18674
            TailMsg              => "",
18675
            MsgSeverity          => failure
18676
            );
18677
      end if;
18678
 
18679
      if (EN_ECC_SCRUB = TRUE) then
18680
        assert false
18681
          report "DRC Error : The attribute EN_ECC_SCRUB = TRUE is not supported on ARAMB36_INTERNAL instance."
18682
          severity failure;
18683
      end if;
18684
 
18685
      if (not(EN_ECC_SCRUB = TRUE or EN_ECC_SCRUB = FALSE)) then
18686
 
18687
        GenericValueCheckMessage
18688
          ( HeaderMsg            => " Attribute Syntax Error : ",
18689
            GenericName          => " EN_ECC_SCRUB ",
18690
            EntityName           => "/ARAMB36_INTERNAL",
18691
            GenericValue         => EN_ECC_SCRUB,
18692
            Unit                 => "",
18693
            ExpectedValueMsg     => " The Legal values for this attribute are ",
18694
            ExpectedGenericValue => " TRUE or FALSE ",
18695
            TailMsg              => "",
18696
            MsgSeverity          => failure
18697
            );
18698
      end if;
18699
 
18700
 
18701
      if (EN_ECC_READ = FALSE and EN_ECC_SCRUB = TRUE) then
18702
        assert false
18703
        report "DRC Error : The attribute EN_ECC_SCRUB = TRUE is vaild only if the attribute EN_ECC_READ set to TRUE on ARAMB36_INTERNAL instance."
18704
        severity failure;
18705
      end if;
18706
 
18707
 
18708
      if (READ_WIDTH_A = 0 and READ_WIDTH_B = 0) then
18709
        assert false
18710
        report "Attribute Syntax Error : Attributes READ_WIDTH_A and READ_WIDTH_B on ARAMB36_INTERNAL instance, both can not be 0."
18711
        severity failure;
18712
      end if;
18713
 
18714
 
18715
      if (WRITE_MODE_A = "WRITE_FIRST") then
18716
        wr_mode_a := "00";
18717
      elsif (WRITE_MODE_A = "READ_FIRST") then
18718
        wr_mode_a := "01";
18719
      elsif (WRITE_MODE_A = "NO_CHANGE") then
18720
        wr_mode_a := "10";
18721
      else
18722
        GenericValueCheckMessage
18723
          ( HeaderMsg            => " Attribute Syntax Error : ",
18724
            GenericName          => " WRITE_MODE_A ",
18725
            EntityName           => "/ARAMB36_INTERNAL",
18726
            GenericValue         => WRITE_MODE_A,
18727
            Unit                 => "",
18728
            ExpectedValueMsg     => " The Legal values for this attribute are ",
18729
            ExpectedGenericValue => " WRITE_FIRST, READ_FIRST or NO_CHANGE ",
18730
            TailMsg              => "",
18731
            MsgSeverity          => failure
18732
            );
18733
      end if;
18734
 
18735
      if (WRITE_MODE_B = "WRITE_FIRST") then
18736
        wr_mode_b := "00";
18737
      elsif (WRITE_MODE_B = "READ_FIRST") then
18738
        wr_mode_b := "01";
18739
      elsif (WRITE_MODE_B = "NO_CHANGE") then
18740
        wr_mode_b := "10";
18741
      else
18742
        GenericValueCheckMessage
18743
          ( HeaderMsg            => " Attribute Syntax Error : ",
18744
            GenericName          => " WRITE_MODE_B ",
18745
            EntityName           => "/ARAMB36_INTERNAL",
18746
            GenericValue         => WRITE_MODE_B,
18747
            Unit                 => "",
18748
            ExpectedValueMsg     => " The Legal values for this attribute are ",
18749
            ExpectedGenericValue => " WRITE_FIRST, READ_FIRST or NO_CHANGE ",
18750
            TailMsg              => "",
18751
            MsgSeverity          => failure
18752
            );
18753
      end if;
18754
 
18755
 
18756
      if (RAM_EXTENSION_A = "UPPER") then
18757
        cascade_a <= "11";
18758
      elsif (RAM_EXTENSION_A = "LOWER") then
18759
        cascade_a <= "01";
18760
      elsif (RAM_EXTENSION_A= "NONE") then
18761
        cascade_a <= "00";
18762
      else
18763
        GenericValueCheckMessage
18764
          ( HeaderMsg            => " Attribute Syntax Error : ",
18765
            GenericName          => " RAM_EXTENSION_A ",
18766
            EntityName           => "/ARAMB36_INTERNAL",
18767
            GenericValue         => RAM_EXTENSION_A,
18768
            Unit                 => "",
18769
            ExpectedValueMsg     => " The Legal values for this attribute are ",
18770
            ExpectedGenericValue => " NONE, LOWER or UPPER ",
18771
            TailMsg              => "",
18772
            MsgSeverity          => failure
18773
            );
18774
      end if;
18775
 
18776
 
18777
      if (RAM_EXTENSION_B = "UPPER") then
18778
        cascade_b <= "11";
18779
      elsif (RAM_EXTENSION_B = "LOWER") then
18780
        cascade_b <= "01";
18781
      elsif (RAM_EXTENSION_B= "NONE") then
18782
        cascade_b <= "00";
18783
      else
18784
        GenericValueCheckMessage
18785
          ( HeaderMsg            => " Attribute Syntax Error : ",
18786
            GenericName          => " RAM_EXTENSION_B ",
18787
            EntityName           => "/ARAMB36_INTERNAL",
18788
            GenericValue         => RAM_EXTENSION_A,
18789
            Unit                 => "",
18790
            ExpectedValueMsg     => " The Legal values for this attribute are ",
18791
            ExpectedGenericValue => " NONE, LOWER or UPPER ",
18792
            TailMsg              => "",
18793
            MsgSeverity          => failure
18794
            );
18795
      end if;
18796
 
18797
 
18798
      if( ((RAM_EXTENSION_A = "LOWER") or (RAM_EXTENSION_A = "UPPER")) and (READ_WIDTH_A /= 1)) then
18799
        assert false
18800
          report "Attribute Syntax Error: If RAM_EXTENSION_A is set to either LOWER or UPPER, then READ_WIDTH_A has to be set to 1."
18801
          severity Failure;
18802
      end if;
18803
 
18804
      if( ((RAM_EXTENSION_A = "LOWER") or (RAM_EXTENSION_A = "UPPER")) and (WRITE_WIDTH_A /= 1)) then
18805
        assert false
18806
          report "Attribute Syntax Error: If RAM_EXTENSION_A is set to either LOWER or UPPER, then WRITE_WIDTH_A has to be set to 1."
18807
          severity Failure;
18808
      end if;
18809
 
18810
      if( ((RAM_EXTENSION_B = "LOWER") or (RAM_EXTENSION_B = "UPPER")) and (READ_WIDTH_B /= 1)) then
18811
        assert false
18812
          report "Attribute Syntax Error: If RAM_EXTENSION_B is set to either LOWER or UPPER, then READ_WIDTH_B has to be set to 1."
18813
          severity Failure;
18814
      end if;
18815
 
18816
      if( ((RAM_EXTENSION_B = "LOWER") or (RAM_EXTENSION_B = "UPPER")) and (WRITE_WIDTH_B /= 1)) then
18817
        assert false
18818
          report "Attribute Syntax Error: If RAM_EXTENSION_B is set to either LOWER or UPPER, then WRITE_WIDTH_B has to be set to 1."
18819
          severity Failure;
18820
      end if;
18821
 
18822
 
18823
    end if;
18824
 
18825
 
18826
    if (rising_edge(clka_dly)) then
18827
 
18828
      if (ena_dly = '1') then
18829
        prev_time := curr_time;
18830
        curr_time := now;
18831
        addra_reg_dly := addra_dly;
18832
        wea_reg_dly := wea_dly;
18833
        dia_reg_dly := dia_dly;
18834
        dipa_reg_dly := dipa_dly;
18835
      end if;
18836
 
18837
    end if;
18838
 
18839
    if (rising_edge(clkb_dly)) then
18840
 
18841
      if (enb_dly = '1') then
18842
        prev_time := curr_time;
18843
        curr_time := now;
18844
        addrb_reg_dly := addrb_dly;
18845
        web_reg_dly := web_dly;
18846
        dib_reg_dly := dib_dly;
18847
        dipb_reg_dly := dipb_dly;
18848
      end if;
18849
 
18850
    end if;
18851
 
18852
    if (gsr_dly = '1' or FIRST_TIME) then
18853
 
18854
      doa_out(ra_width-1 downto 0) <= INIT_A_STD(ra_width-1 downto 0);
18855
 
18856
      if (ra_width >= 8) then
18857
        dopa_out(ra_widthp-1 downto 0) <= INIT_A_STD((ra_width+ra_widthp)-1 downto ra_width);
18858
      end if;
18859
 
18860
      dob_out(rb_width-1 downto 0) <= INIT_B_STD(rb_width-1 downto 0);
18861
 
18862
      if (rb_width >= 8) then
18863
        dopb_out(rb_widthp-1 downto 0) <= INIT_B_STD((rb_width+rb_widthp)-1 downto rb_width);
18864
      end if;
18865
 
18866
      dbiterr_out <= '0';
18867
      sbiterr_out <= '0';
18868
 
18869
      FIRST_TIME := false;
18870
 
18871
    elsif (gsr_dly = '0') then
18872
 
18873
      if (rising_edge(clka_dly)) then
18874
       if (cascade_a(1) = '1') then
18875
         addra_dly_15_reg_bram_var := not addra_dly(15);
18876
       else
18877
         addra_dly_15_reg_bram_var := addra_dly(15);
18878
       end if;
18879
      end if;
18880
 
18881
      if (rising_edge(clkb_dly)) then
18882
       if (cascade_b(1) = '1') then
18883
         addrb_dly_15_reg_bram_var := not addrb_dly(15);
18884
       else
18885
         addrb_dly_15_reg_bram_var := addrb_dly(15);
18886
       end if;
18887
      end if;
18888
 
18889
     if (rising_edge(clka_dly) or rising_edge(clkb_dly)) then
18890
 
18891
      if ((cascade_a = "00" or (addra_dly_15_reg_bram_var = '0' and cascade_a /= "00")) or (cascade_b = "00" or (addrb_dly_15_reg_bram_var = '0' and cascade_b /= "00"))) then
18892
 
18893
-------------------------------------------------------------------------------
18894
-- Collision starts
18895
-------------------------------------------------------------------------------
18896
 
18897
       if (SIM_COLLISION_CHECK /= "NONE") then
18898
 
18899
 
18900
        if (curr_time - prev_time = 0 ps) then
18901
          viol_time := 1;
18902
        elsif (curr_time - prev_time <= SETUP_READ_FIRST) then
18903
          viol_time := 2;
18904
        end if;
18905
 
18906
 
18907
        if (ena_dly = '0' or enb_dly = '0') then
18908
          viol_time := 0;
18909
        end if;
18910
 
18911
 
18912
        if ((WRITE_WIDTH_A <= 9 and wea_dly(0) = '0') or (WRITE_WIDTH_A = 18 and wea_dly(1 downto 0) = "00") or ((WRITE_WIDTH_A = 36 or WRITE_WIDTH_A = 72) and wea_dly(3 downto 0) = "0000")) then
18913
          if ((WRITE_WIDTH_B <= 9 and web_dly(0) = '0') or (WRITE_WIDTH_B = 18 and web_dly(1 downto 0) = "00") or (WRITE_WIDTH_B = 36 and web_dly(3 downto 0) = "0000") or (WRITE_WIDTH_B = 72 and web_dly(7 downto 0) = "00000000")) then
18914
            viol_time := 0;
18915
          end if;
18916
        end if;
18917
 
18918
 
18919
        if (viol_time /= 0) then
18920
 
18921
          if (rising_edge(clka_dly) and rising_edge(clkb_dly)) then
18922
            if (addra_dly(14 downto col_addr_lsb) = addrb_dly(14 downto col_addr_lsb)) then
18923
 
18924
              viol_type := "01";
18925
 
18926
              prcd_rd_ram_a (addra_dly, doa_buf, dopa_buf, mem, memp);
18927
              prcd_rd_ram_b (addrb_dly, dob_buf, dopb_buf, mem, memp);
18928
 
18929
              prcd_col_wr_ram_a ("00", web_dly, wea_dly, di_x, di_x(7 downto 0), addrb_dly, addra_dly, mem, memp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
18930
              prcd_col_wr_ram_b ("00", wea_dly, web_dly, di_x, di_x(7 downto 0), addra_dly, addrb_dly, mem, memp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
18931
 
18932
              prcd_col_rd_ram_a (viol_type, "01", web_dly, wea_dly, addra_dly, doa_buf, dopa_buf, mem, memp, wr_mode_a);
18933
              prcd_col_rd_ram_b (viol_type, "01", wea_dly, web_dly, addrb_dly, dob_buf, dopb_buf, mem, memp, wr_mode_b);
18934
 
18935
              prcd_col_wr_ram_a ("10", web_dly, wea_dly, dia_dly, dipa_dly, addrb_dly, addra_dly, mem, memp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
18936
 
18937
              if (BRAM_MODE = "ECC" and EN_ECC_WRITE = TRUE and enb_dly = '1') then
18938
 
18939
                dip_ecc_col := fn_dip_ecc('1', dib_dly, dipb_dly);
18940
                eccparity_out <= dip_ecc_col;
18941
                prcd_col_wr_ram_b ("10", wea_dly, web_dly, dib_dly, dip_ecc_col, addra_dly, addrb_dly, mem, memp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
18942
 
18943
              else
18944
 
18945
                prcd_col_wr_ram_b ("10", wea_dly, web_dly, dib_dly, dipb_dly, addra_dly, addrb_dly, mem, memp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
18946
 
18947
              end if;
18948
 
18949
              if (wr_mode_a /= "01") then
18950
                prcd_col_rd_ram_a (viol_type, "11", web_dly, wea_dly, addra_dly, doa_buf, dopa_buf, mem, memp, wr_mode_a);
18951
              end if;
18952
 
18953
              if (wr_mode_b /= "01") then
18954
                prcd_col_rd_ram_b (viol_type, "11", wea_dly, web_dly, addrb_dly, dob_buf, dopb_buf, mem, memp, wr_mode_b);
18955
              end if;
18956
 
18957
              if (BRAM_MODE = "ECC" and EN_ECC_READ = TRUE) then
18958
                prcd_col_ecc_read (doa_buf, dopa_buf, addra_dly, dbiterr_out_var, sbiterr_out_var, mem, memp, syndrome);
18959
              end if;
18960
 
18961
            else
18962
              viol_time := 0;
18963
 
18964
            end if;
18965
 
18966
          elsif (rising_edge(clka_dly) and  (not(rising_edge(clkb_dly)))) then
18967
            if (addra_dly(14 downto col_addr_lsb) = addrb_dly(14 downto col_addr_lsb)) then
18968
 
18969
              viol_type := "10";
18970
 
18971
              prcd_rd_ram_a (addra_dly, doa_buf, dopa_buf, mem, memp);
18972
 
18973
              prcd_col_wr_ram_a ("00", web_reg_dly, wea_dly, di_x, di_x(7 downto 0), addrb_reg_dly, addra_dly, mem, memp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
18974
              prcd_col_wr_ram_b ("00", wea_dly, web_reg_dly, di_x, di_x(7 downto 0), addra_dly, addrb_reg_dly, mem, memp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
18975
 
18976
              prcd_col_rd_ram_a (viol_type, "01", web_reg_dly, wea_dly, addra_dly, doa_buf, dopa_buf, mem, memp, wr_mode_a);
18977
              prcd_col_rd_ram_b (viol_type, "01", wea_dly, web_reg_dly, addrb_reg_dly, dob_buf, dopb_buf, mem, memp, wr_mode_b);
18978
 
18979
              prcd_col_wr_ram_a ("10", web_reg_dly, wea_dly, dia_dly, dipa_dly, addrb_reg_dly, addra_dly, mem, memp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
18980
 
18981
              if (BRAM_MODE = "ECC" and EN_ECC_WRITE = TRUE and enb_dly = '1') then
18982
 
18983
                dip_ecc_col := fn_dip_ecc('1', dib_reg_dly, dipb_reg_dly);
18984
                eccparity_out <= dip_ecc_col;
18985
                prcd_col_wr_ram_b ("10", wea_dly, web_reg_dly, dib_reg_dly, dip_ecc_col, addra_dly, addrb_reg_dly, mem, memp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
18986
 
18987
              else
18988
 
18989
                prcd_col_wr_ram_b ("10", wea_dly, web_reg_dly, dib_reg_dly, dipb_reg_dly, addra_dly, addrb_reg_dly, mem, memp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
18990
 
18991
              end if;
18992
 
18993
              if (wr_mode_a /= "01") then
18994
                prcd_col_rd_ram_a (viol_type, "11", web_reg_dly, wea_dly, addra_dly, doa_buf, dopa_buf, mem, memp, wr_mode_a);
18995
              end if;
18996
 
18997
              if (wr_mode_b /= "01") then
18998
                prcd_col_rd_ram_b (viol_type, "11", wea_dly, web_reg_dly, addrb_reg_dly, dob_buf, dopb_buf, mem, memp, wr_mode_b);
18999
              end if;
19000
 
19001
              if (BRAM_MODE = "ECC" and EN_ECC_READ = TRUE) then
19002
                prcd_col_ecc_read (doa_buf, dopa_buf, addra_dly, dbiterr_out_var, sbiterr_out_var, mem, memp, syndrome);
19003
              end if;
19004
 
19005
            else
19006
              viol_time := 0;
19007
 
19008
            end if;
19009
 
19010
          elsif ((not(rising_edge(clka_dly))) and rising_edge(clkb_dly)) then
19011
            if (addra_dly(14 downto col_addr_lsb) = addrb_dly(14 downto col_addr_lsb)) then
19012
 
19013
              viol_type := "11";
19014
 
19015
              prcd_rd_ram_b (addrb_dly, dob_buf, dopb_buf, mem, memp);
19016
 
19017
              prcd_col_wr_ram_a ("00", web_dly, wea_reg_dly, di_x, di_x(7 downto 0), addrb_dly, addra_reg_dly, mem, memp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
19018
              prcd_col_wr_ram_b ("00", wea_reg_dly, web_dly, di_x, di_x(7 downto 0), addra_reg_dly, addrb_dly, mem, memp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
19019
 
19020
              prcd_col_rd_ram_a (viol_type, "01", web_dly, wea_reg_dly, addra_reg_dly, doa_buf, dopa_buf, mem, memp, wr_mode_a);
19021
              prcd_col_rd_ram_b (viol_type, "01", wea_reg_dly, web_dly, addrb_dly, dob_buf, dopb_buf, mem, memp, wr_mode_b);
19022
 
19023
              prcd_col_wr_ram_a ("10", web_dly, wea_reg_dly, dia_reg_dly, dipa_reg_dly, addrb_dly, addra_reg_dly, mem, memp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
19024
 
19025
              if (BRAM_MODE = "ECC" and EN_ECC_WRITE = TRUE and enb_dly = '1') then
19026
 
19027
                dip_ecc_col := fn_dip_ecc('1', dib_dly, dipb_dly);
19028
                eccparity_out <= dip_ecc_col;
19029
                prcd_col_wr_ram_b ("10", wea_reg_dly, web_dly, dib_dly, dip_ecc_col, addra_reg_dly, addrb_dly, mem, memp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
19030
 
19031
              else
19032
 
19033
                prcd_col_wr_ram_b ("10", wea_reg_dly, web_dly, dib_dly, dipb_dly, addra_reg_dly, addrb_dly, mem, memp, col_wr_wr_msg, col_wra_rdb_msg, col_wrb_rda_msg);
19034
 
19035
              end if;
19036
 
19037
              if (wr_mode_a /= "01") then
19038
                prcd_col_rd_ram_a (viol_type, "11", web_dly, wea_reg_dly, addra_reg_dly, doa_buf, dopa_buf, mem, memp, wr_mode_a);
19039
              end if;
19040
 
19041
              if (wr_mode_b /= "01") then
19042
                prcd_col_rd_ram_b (viol_type, "11", wea_reg_dly, web_dly, addrb_dly, dob_buf, dopb_buf, mem, memp, wr_mode_b);
19043
              end if;
19044
 
19045
              if (BRAM_MODE = "ECC" and EN_ECC_READ = TRUE) then
19046
                prcd_col_ecc_read (doa_buf, dopa_buf, addra_reg_dly, dbiterr_out_var, sbiterr_out_var, mem, memp, syndrome);
19047
              end if;
19048
 
19049
            else
19050
              viol_time := 0;
19051
 
19052
            end if;
19053
          end if;
19054
 
19055
          if (SIM_COLLISION_CHECK = "WARNING_ONLY") then
19056
            viol_time := 0;
19057
          end if;
19058
 
19059
        end if;
19060
      end if;
19061
-------------------------------------------------------------------------------
19062
-- end collision
19063
-------------------------------------------------------------------------------
19064
 
19065
    end if;
19066
 
19067
-------------------------------------------------------------------------------
19068
-- Port A
19069
-------------------------------------------------------------------------------
19070
    if (rising_edge(clka_dly)) then
19071
 
19072
      if (ssra_dly = '1' and BRAM_MODE = "ECC") then
19073
        assert false
19074
        report "DRC Warning : SET/RESET (SSR) is not supported in ECC mode."
19075
        severity Warning;
19076
      end if;
19077
 
19078
 
19079
      -- registering addra_dly(15) the second time
19080
      if (regcea_dly = '1') then
19081
        addra_dly_15_reg1 <= addra_dly_15_reg_var;
19082
      end if;
19083
 
19084
 
19085
      -- registering addra[15)
19086
      if (ena_dly = '1' and (wr_mode_a /= "10" or wea_dly(0) = '0')) then
19087
        if (cascade_a(1) = '1') then
19088
          addra_dly_15_reg_var :=  not addra_dly(15);
19089
        else
19090
          addra_dly_15_reg_var := addra_dly(15);
19091
        end if;
19092
      end if;
19093
 
19094
 
19095
      addra_dly_15_reg <= addra_dly_15_reg_var;
19096
 
19097
 
19098
      if (gsr_dly = '0' and ena_dly = '1' and (cascade_a = "00" or (addra_dly_15_reg_bram_var = '0' and cascade_a /= "00"))) then
19099
 
19100
        if (ssra_dly = '1' and DOA_REG = 0) then
19101
 
19102
          doa_buf(ra_width-1 downto 0) := SRVAL_A_STD(ra_width-1 downto 0);
19103
          doa_out(ra_width-1 downto 0) <= SRVAL_A_STD(ra_width-1 downto 0);
19104
 
19105
          if (ra_width >= 8) then
19106
            dopa_buf(ra_widthp-1 downto 0) := SRVAL_A_STD((ra_width+ra_widthp)-1 downto ra_width);
19107
            dopa_out(ra_widthp-1 downto 0) <= SRVAL_A_STD((ra_width+ra_widthp)-1 downto ra_width);
19108
          end if;
19109
 
19110
        end if;
19111
 
19112
        if (viol_time = 0) then
19113
          -- read for rf
19114
          if ((wr_mode_a = "01" and (ssra_dly = '0' or DOA_REG = 1)) or (BRAM_MODE = "ECC" and EN_ECC_READ = TRUE)) then
19115
            prcd_rd_ram_a (addra_dly, doa_buf, dopa_buf, mem, memp);
19116
 
19117
          -- ECC decode  -- only port A
19118
            if (BRAM_MODE = "ECC" and EN_ECC_READ = TRUE) then
19119
 
19120
              dopr_ecc := fn_dip_ecc('0', doa_buf, dopa_buf);
19121
 
19122
              syndrome := dopr_ecc xor dopa_buf;
19123
 
19124
              if (syndrome /= "00000000") then
19125
 
19126
                if (syndrome(7) = '1') then  -- dectect single bit error
19127
 
19128
                  ecc_bit_position := doa_buf(63 downto 57) & dopa_buf(6) & doa_buf(56 downto 26) & dopa_buf(5) & doa_buf(25 downto 11) & dopa_buf(4) & doa_buf(10 downto 4) & dopa_buf(3) & doa_buf(3 downto 1) & dopa_buf(2) & doa_buf(0) & dopa_buf(1 downto 0) & dopa_buf(7);
19129
 
19130
                  tmp_syndrome_int := SLV_TO_INT(syndrome(6 downto 0));
19131
                  ecc_bit_position(tmp_syndrome_int) := not ecc_bit_position(tmp_syndrome_int); -- correct single bit error in the output
19132
 
19133
                  dia_dly_ecc_corrected := ecc_bit_position(71 downto 65) & ecc_bit_position(63 downto 33) & ecc_bit_position(31 downto 17) & ecc_bit_position(15 downto 9) & ecc_bit_position(7 downto 5) & ecc_bit_position(3); -- correct single bit error in the memory
19134
 
19135
                  doa_buf := dia_dly_ecc_corrected;
19136
 
19137
                  dipa_dly_ecc_corrected := ecc_bit_position(0) & ecc_bit_position(64) & ecc_bit_position(32) & ecc_bit_position(16) & ecc_bit_position(8) & ecc_bit_position(4) & ecc_bit_position(2 downto 1); -- correct single bit error in the parity memory
19138
 
19139
                  dopa_buf := dipa_dly_ecc_corrected;
19140
 
19141
                  dbiterr_out_var := '0';
19142
                  sbiterr_out_var := '1';
19143
 
19144
                elsif (syndrome(7) = '0') then  -- double bit error
19145
                  sbiterr_out_var := '0';
19146
                  dbiterr_out_var := '1';
19147
                end if;
19148
              else
19149
                dbiterr_out_var := '0';
19150
                sbiterr_out_var := '0';
19151
              end if;
19152
 
19153
              if (ssra_dly = '1') then  -- ssra reset
19154
                dbiterr_out_var := '0';
19155
                sbiterr_out_var := '0';
19156
              end if;
19157
 
19158
            end if;
19159
          end if;
19160
 
19161
 
19162
 
19163
        if (syndrome /= "00000000" and syndrome(7) = '1' and EN_ECC_SCRUB = TRUE) then
19164
          prcd_wr_ram_a ("11111111", dia_dly_ecc_corrected, dipa_dly_ecc_corrected, addra_dly, mem, memp, syndrome);
19165
        else
19166
          prcd_wr_ram_a (wea_dly, dia_dly, dipa_dly, addra_dly, mem, memp, syndrome);
19167
        end if;
19168
 
19169
 
19170
        if ((wr_mode_a /= "01" and (ssra_dly = '0' or DOA_REG = 1)) and (not(BRAM_MODE = "ECC" and EN_ECC_READ = TRUE))) then
19171
          prcd_rd_ram_a (addra_dly, doa_buf, dopa_buf, mem, memp);
19172
        end if;
19173
 
19174
 
19175
        end if;
19176
      end if;
19177
    end if;
19178
 
19179
-------------------------------------------------------------------------------
19180
-- Port B
19181
-------------------------------------------------------------------------------
19182
 
19183
    if (rising_edge(clkb_dly)) then
19184
 
19185
      -- DRC
19186
      if (ssrb_dly = '1' and BRAM_MODE = "ECC") then
19187
        assert false
19188
        report "DRC Warning : SET/RESET (SSR) is not supported in ECC mode."
19189
        severity Warning;
19190
      end if;
19191
 
19192
 
19193
      -- registering addrb_dly(15) the second time
19194
      if (regceb_dly = '1') then
19195
        addrb_dly_15_reg1 <= addrb_dly_15_reg_var;
19196
      end if;
19197
 
19198
 
19199
      -- registering addrb(15)
19200
      if (enb_dly = '1' and (wr_mode_b /= "10" or web_dly(0) = '0' or ssrb_dly = '1')) then
19201
        if (cascade_b(1) = '1') then
19202
          addrb_dly_15_reg_var :=  not addrb_dly(15);
19203
        else
19204
          addrb_dly_15_reg_var := addrb_dly(15);
19205
        end if;
19206
      end if;
19207
 
19208
 
19209
      addrb_dly_15_reg <= addrb_dly_15_reg_var;
19210
 
19211
      if (gsr_dly = '0' and enb_dly = '1' and (cascade_b = "00" or (addrb_dly_15_reg_bram_var = '0' and cascade_b /= "00"))) then
19212
 
19213
        if (ssrb_dly = '1' and DOB_REG = 0) then
19214
 
19215
          dob_buf(rb_width-1 downto 0) := SRVAL_B_STD(rb_width-1 downto 0);
19216
          dob_out(rb_width-1 downto 0) <= SRVAL_B_STD(rb_width-1 downto 0);
19217
 
19218
          if (rb_width >= 8) then
19219
            dopb_buf(rb_widthp-1 downto 0) := SRVAL_B_STD((rb_width+rb_widthp)-1 downto rb_width);
19220
            dopb_out(rb_widthp-1 downto 0) <= SRVAL_B_STD((rb_width+rb_widthp)-1 downto rb_width);
19221
          end if;
19222
 
19223
        end if;
19224
 
19225
        dip_ecc := fn_dip_ecc('1', dib_dly, dipb_dly);
19226
 
19227
        eccparity_out <= dip_ecc;
19228
 
19229
        if (BRAM_MODE = "ECC" and EN_ECC_WRITE = TRUE) then
19230
            dipb_dly_ecc := dip_ecc;
19231
        else
19232
          dipb_dly_ecc := dipb_dly;
19233
        end if;
19234
 
19235
 
19236
        if (viol_time = 0) then
19237
 
19238
          if (wr_mode_b = "01" and (ssrb_dly = '0' or DOB_REG = 1)) then
19239
            prcd_rd_ram_b (addrb_dly, dob_buf, dopb_buf, mem, memp);
19240
          end if;
19241
 
19242
          if (BRAM_MODE = "ECC" and EN_ECC_WRITE = TRUE) then
19243
            prcd_wr_ram_b (web_dly, dib_dly, dipb_dly_ecc, addrb_dly, mem, memp);
19244
          else
19245
            prcd_wr_ram_b (web_dly, dib_dly, dipb_dly, addrb_dly, mem, memp);
19246
          end if;
19247
 
19248
 
19249
          if (wr_mode_b /= "01" and (ssrb_dly = '0' or DOB_REG = 1)) then
19250
            prcd_rd_ram_b (addrb_dly, dob_buf, dopb_buf, mem, memp);
19251
          end if;
19252
 
19253
        end if;
19254
      end if;
19255
    end if;
19256
 
19257
 
19258
    if (ena_dly = '1' and (rising_edge(clka_dly) or viol_time /= 0)) then
19259
      if ((ssra_dly = '0' or DOA_REG = 1) and (wr_mode_a /= "10" or (WRITE_WIDTH_A <= 9 and wea_dly(0) = '0') or (WRITE_WIDTH_A = 18 and wea_dly(1 downto 0) = "00") or ((WRITE_WIDTH_A = 36 or WRITE_WIDTH_A = 72) and wea_dly(3 downto 0) = "0000"))) then
19260
 
19261
        -- Virtex4 feature
19262
        if (wr_mode_a = "00" and BRAM_SIZE = 16) then
19263
 
19264
          if ((WRITE_WIDTH_A = 18 and not(wea_dly(1 downto 0) = "00" or wea_dly(1 downto 0) = "11")) or (WRITE_WIDTH_A = 36 and not(wea_dly(3 downto 0) = "0000" or wea_dly(3 downto 0) = "1111"))) then
19265
 
19266
            if (WRITE_WIDTH_A /= READ_WIDTH_A) then
19267
 
19268
              doa_buf(ra_width-1 downto 0) := di_x(ra_width-1 downto 0);
19269
 
19270
              if (READ_WIDTH_A >= 9) then
19271
                dopa_buf(ra_widthp-1 downto 0) := di_x(ra_widthp-1 downto 0);
19272
 
19273
              end if;
19274
 
19275
              Write ( Message, STRING'(" Functional warning at simulation time "));
19276
              Write ( Message, STRING'("( "));
19277
              Write ( Message, now);
19278
              Write ( Message, STRING'(") : "));
19279
              Write ( Message, STRING'("ARAMB36_INTERNAL "));
19280
              Write ( Message, STRING'("( "));
19281
              Write ( Message, STRING'(ARAMB36_INTERNAL'path_name));
19282
              Write ( Message, STRING'(") "));
19283
              Write ( Message, STRING'(" port A is in WRITE_FIRST mode with parameter WRITE_WIDTH_A = "));
19284
              Write ( Message, INTEGER'(WRITE_WIDTH_A));
19285
              Write ( Message, STRING'(", which is different from READ_WIDTH_A = "));
19286
              Write ( Message, INTEGER'(READ_WIDTH_A));
19287
              Write ( Message, STRING'(". The write will be successful however the read value of all bits on port A"));
19288
              Write ( Message, STRING'(" is unknown until the next CLKA cycle and all bits of WEA is set to all 1s or 0s. "));
19289
              Write ( Message, LF );
19290
              ASSERT FALSE REPORT Message.ALL SEVERITY warning;
19291
              DEALLOCATE (Message);
19292
 
19293
            elsif (WRITE_WIDTH_A = 18) then
19294
 
19295
              for i in 0 to 1 loop
19296
 
19297
                if (wea_dly(i) = '0') then
19298
                  doa_buf(((8*(i+1))-1) downto 8*i) := di_x(((8*(i+1))-1) downto 8*i);
19299
                  dopa_buf(i downto i) := di_x(i downto i);
19300
                end if;
19301
 
19302
              end loop;
19303
 
19304
              Write ( Message, STRING'(" Functional warning at simulation time "));
19305
              Write ( Message, STRING'("( "));
19306
              Write ( Message, now);
19307
              Write ( Message, STRING'(") : "));
19308
              Write ( Message, STRING'("ARAMB36_INTERNAL "));
19309
              Write ( Message, STRING'("( "));
19310
              Write ( Message, STRING'(ARAMB36_INTERNAL'path_name));
19311
              Write ( Message, STRING'(") "));
19312
              Write ( Message, STRING'(" port A is in WRITE_FIRST mode. The write will be successful,"));
19313
              Write ( Message, STRING'(" however DOA shows only the enabled newly written byte(s)."));
19314
              Write ( Message, STRING'(" The other byte values on DOA are unknown until the next CLKA cycle and"));
19315
              Write ( Message, STRING'(" all bits of WEA is set to all 1s or 0s. "));
19316
              Write ( Message, LF );
19317
              ASSERT FALSE REPORT Message.ALL SEVERITY warning;
19318
              DEALLOCATE (Message);
19319
 
19320
            elsif (WRITE_WIDTH_A = 36) then
19321
 
19322
              for i in 0 to 3 loop
19323
 
19324
                if (wea_dly(i) = '0') then
19325
                  doa_buf(((8*(i+1))-1) downto 8*i) := di_x(((8*(i+1))-1) downto 8*i);
19326
                  dopa_buf(i downto i) := di_x(i downto i);
19327
                end if;
19328
 
19329
              end loop;
19330
 
19331
              Write ( Message, STRING'(" Functional warning at simulation time "));
19332
              Write ( Message, STRING'("( "));
19333
              Write ( Message, now);
19334
              Write ( Message, STRING'(") : "));
19335
              Write ( Message, STRING'("ARAMB36_INTERNAL "));
19336
              Write ( Message, STRING'("( "));
19337
              Write ( Message, STRING'(ARAMB36_INTERNAL'path_name));
19338
              Write ( Message, STRING'(") "));
19339
              Write ( Message, STRING'(" port A is in WRITE_FIRST mode. The write will be successful,"));
19340
              Write ( Message, STRING'(" however DOA shows only the enabled newly written byte(s)."));
19341
              Write ( Message, STRING'(" The other byte values on DOA are unknown until the next CLKA cycle and"));
19342
              Write ( Message, STRING'(" all bits of WEA is set to all 1s or 0s. "));
19343
              Write ( Message, LF );
19344
              ASSERT FALSE REPORT Message.ALL SEVERITY warning;
19345
              DEALLOCATE (Message);
19346
 
19347
            end if;
19348
 
19349
          end if;
19350
        end if;
19351
 
19352
        doa_out <= doa_buf;
19353
        dopa_out <= dopa_buf;
19354
      end if;
19355
    end if;
19356
 
19357
    if (enb_dly = '1' and (rising_edge(clkb_dly) or viol_time /= 0)) then
19358
      if ((ssrb_dly = '0' or DOB_REG = 1) and (wr_mode_b /= "10" or (WRITE_WIDTH_B <= 9 and web_dly(0) = '0') or (WRITE_WIDTH_B = 18 and web_dly(1 downto 0) = "00") or (WRITE_WIDTH_B = 36 and web_dly(3 downto 0) = "0000") or (WRITE_WIDTH_B = 72 and web_dly(7 downto 0) = "00000000"))) then
19359
 
19360
        -- Virtex4 feature
19361
        if (wr_mode_b = "00" and BRAM_SIZE = 16) then
19362
 
19363
          if ((WRITE_WIDTH_B = 18 and not(web_dly(1 downto 0) = "00" or web_dly(1 downto 0) = "11")) or (WRITE_WIDTH_B = 36 and not(web_dly(3 downto 0) = "0000" or web_dly(3 downto 0) = "1111"))) then
19364
 
19365
            if (WRITE_WIDTH_B /= READ_WIDTH_B) then
19366
 
19367
              dob_buf(rb_width-1 downto 0) := di_x(rb_width-1 downto 0);
19368
 
19369
              if (READ_WIDTH_B >= 9) then
19370
                dopb_buf(rb_widthp-1 downto 0) := di_x(rb_widthp-1 downto 0);
19371
 
19372
              end if;
19373
 
19374
              Write ( Message, STRING'(" Functional warning at simulation time "));
19375
              Write ( Message, STRING'("( "));
19376
              Write ( Message, now);
19377
              Write ( Message, STRING'(") : "));
19378
              Write ( Message, STRING'("ARAMB36_INTERNAL "));
19379
              Write ( Message, STRING'("( "));
19380
              Write ( Message, STRING'(ARAMB36_INTERNAL'path_name));
19381
              Write ( Message, STRING'(") "));
19382
              Write ( Message, STRING'(" port B is in WRITE_FIRST mode with parameter WRITE_WIDTH_B = "));
19383
              Write ( Message, INTEGER'(WRITE_WIDTH_B));
19384
              Write ( Message, STRING'(", which is different from READ_WIDTH_B = "));
19385
              Write ( Message, INTEGER'(READ_WIDTH_B));
19386
              Write ( Message, STRING'(". The write will be successful however the read value of all bits on port B"));
19387
              Write ( Message, STRING'(" is unknown until the next CLKB cycle and all bits of WEB is set to all 1s or 0s. "));
19388
              Write ( Message, LF );
19389
              ASSERT FALSE REPORT Message.ALL SEVERITY warning;
19390
              DEALLOCATE (Message);
19391
 
19392
            elsif (WRITE_WIDTH_B = 18) then
19393
 
19394
              for i in 0 to 1 loop
19395
 
19396
                if (web_dly(i) = '0') then
19397
                  dob_buf(((8*(i+1))-1) downto 8*i) := di_x(((8*(i+1))-1) downto 8*i);
19398
                  dopb_buf(i downto i) := di_x(i downto i);
19399
                end if;
19400
 
19401
              end loop;
19402
 
19403
              Write ( Message, STRING'(" Functional warning at simulation time "));
19404
              Write ( Message, STRING'("( "));
19405
              Write ( Message, now);
19406
              Write ( Message, STRING'(") : "));
19407
              Write ( Message, STRING'("ARAMB36_INTERNAL "));
19408
              Write ( Message, STRING'("( "));
19409
              Write ( Message, STRING'(ARAMB36_INTERNAL'path_name));
19410
              Write ( Message, STRING'(") "));
19411
              Write ( Message, STRING'(" port B is in WRITE_FIRST mode. The write will be successful,"));
19412
              Write ( Message, STRING'(" however DOB shows only the enabled newly written byte(s)."));
19413
              Write ( Message, STRING'(" The other byte values on DOB are unknown until the next CLKB cycle and"));
19414
              Write ( Message, STRING'(" all bits of WEB is set to all 1s or 0s. "));
19415
              Write ( Message, LF );
19416
              ASSERT FALSE REPORT Message.ALL SEVERITY warning;
19417
              DEALLOCATE (Message);
19418
 
19419
            elsif (WRITE_WIDTH_B = 36) then
19420
 
19421
              for i in 0 to 3 loop
19422
 
19423
                if (web_dly(i) = '0') then
19424
                  dob_buf(((8*(i+1))-1) downto 8*i) := di_x(((8*(i+1))-1) downto 8*i);
19425
                  dopb_buf(i downto i) := di_x(i downto i);
19426
                end if;
19427
 
19428
              end loop;
19429
 
19430
              Write ( Message, STRING'(" Functional warning at simulation time "));
19431
              Write ( Message, STRING'("( "));
19432
              Write ( Message, now);
19433
              Write ( Message, STRING'(") : "));
19434
              Write ( Message, STRING'("ARAMB36_INTERNAL "));
19435
              Write ( Message, STRING'("( "));
19436
              Write ( Message, STRING'(ARAMB36_INTERNAL'path_name));
19437
              Write ( Message, STRING'(") "));
19438
              Write ( Message, STRING'(" port B is in WRITE_FIRST mode. The write will be successful,"));
19439
              Write ( Message, STRING'(" however DOB shows only the enabled newly written byte(s)."));
19440
              Write ( Message, STRING'(" The other byte values on DOB are unknown until the next CLKB cycle and"));
19441
              Write ( Message, STRING'(" all bits of WEB is set to all 1s or 0s. "));
19442
              Write ( Message, LF );
19443
              ASSERT FALSE REPORT Message.ALL SEVERITY warning;
19444
              DEALLOCATE (Message);
19445
 
19446
            end if;
19447
 
19448
          end if;
19449
        end if;
19450
 
19451
        dob_out <= dob_buf;
19452
        dopb_out <= dopb_buf;
19453
      end if;
19454
    end if;
19455
 
19456
    viol_time := 0;
19457
    viol_type := "00";
19458
    col_wr_wr_msg := '1';
19459
    col_wra_rdb_msg := '1';
19460
    col_wrb_rda_msg := '1';
19461
    dbiterr_out <= dbiterr_out_var;
19462
    sbiterr_out <= sbiterr_out_var;
19463
 
19464
   end if;
19465
  end if;
19466
 
19467
  end process prcs_clk;
19468
 
19469
 
19470
  outreg_clka: process (regclka_dly, gsr_dly)
19471
    variable FIRST_TIME : boolean := true;
19472
 
19473
  begin  -- process outreg_clka
19474
 
19475
    if (rising_edge(regclka_dly) or rising_edge(gsr_dly) or FIRST_TIME) then
19476
 
19477
      if (DOA_REG = 1) then
19478
 
19479
        if (gsr_dly = '1' or FIRST_TIME) then
19480
 
19481
          dbiterr_outreg <= '0';
19482
          sbiterr_outreg <= '0';
19483
 
19484
          doa_outreg(ra_width-1 downto 0) <= INIT_A_STD(ra_width-1 downto 0);
19485
 
19486
          if (ra_width >= 8) then
19487
            dopa_outreg(ra_widthp-1 downto 0) <= INIT_A_STD((ra_width+ra_widthp)-1 downto ra_width);
19488
          end if;
19489
 
19490
          FIRST_TIME := false;
19491
 
19492
        elsif (gsr_dly = '0') then
19493
 
19494
          dbiterr_outreg <= dbiterr_out;
19495
          sbiterr_outreg <= sbiterr_out;
19496
 
19497
          if (regcea_dly = '1') then
19498
            if (ssra_dly = '1') then
19499
 
19500
              doa_outreg(ra_width-1 downto 0) <= SRVAL_A_STD(ra_width-1 downto 0);
19501
 
19502
              if (ra_width >= 8) then
19503
                dopa_outreg(ra_widthp-1 downto 0) <= SRVAL_A_STD((ra_width+ra_widthp)-1 downto ra_width);
19504
              end if;
19505
 
19506
            elsif (ssra_dly = '0') then
19507
 
19508
              doa_outreg <= doa_out;
19509
              dopa_outreg <= dopa_out;
19510
 
19511
            end if;
19512
          end if;
19513
        end if;
19514
      end if;
19515
 
19516
    end if;
19517
  end process outreg_clka;
19518
 
19519
 
19520
  cascade_a_mux: process (clka_dly, cascadeinlata_dly, addra_dly_15_reg, doa_out, dopa_out)
19521
  begin  -- process cascade_a_mux
19522
 
19523
    if (rising_edge(clka_dly) or cascadeinlata_dly'event or addra_dly_15_reg'event or doa_out'event or dopa_out'event) then
19524
      if (cascade_a(1) = '1' and addra_dly_15_reg = '1') then
19525
        doa_out_mux(0) <= cascadeinlata_dly;
19526
      else
19527
        doa_out_mux <= doa_out;
19528
        dopa_out_mux <= dopa_out;
19529
      end if;
19530
    end if;
19531
 
19532
  end process cascade_a_mux;
19533
 
19534
  cascade_a_muxreg: process (regclka_dly, cascadeinrega_dly, addra_dly_15_reg1, doa_outreg, dopa_outreg)
19535
  begin  -- process cascade_a_muxreg
19536
 
19537
    if (rising_edge(regclka_dly) or cascadeinrega_dly'event or addra_dly_15_reg1'event or doa_outreg'event or dopa_outreg'event) then
19538
      if (cascade_a(1) = '1' and addra_dly_15_reg1 = '1') then
19539
        doa_outreg_mux(0) <= cascadeinrega_dly;
19540
      else
19541
        doa_outreg_mux <= doa_outreg;
19542
        dopa_outreg_mux <= dopa_outreg;
19543
      end if;
19544
    end if;
19545
 
19546
  end process cascade_a_muxreg;
19547
 
19548
 
19549
  outmux_clka: process (doa_out_mux, dopa_out_mux, doa_outreg_mux, dopa_outreg_mux, dbiterr_out, dbiterr_outreg, sbiterr_out, sbiterr_outreg)
19550
  begin  -- process outmux_clka
19551
 
19552
      case DOA_REG is
19553
        when 0 =>
19554
                  dbiterr_out_out <= dbiterr_out;
19555
                  sbiterr_out_out <= sbiterr_out;
19556
                  doa_out_out <= doa_out_mux;
19557
                  dopa_out_out <= dopa_out_mux;
19558
        when 1 =>
19559
                  dbiterr_out_out <= dbiterr_outreg;
19560
                  sbiterr_out_out <= sbiterr_outreg;
19561
                  doa_out_out <= doa_outreg_mux;
19562
                  dopa_out_out <= dopa_outreg_mux;
19563
        when others => assert false
19564
                       report "Attribute Syntax Error: The allowed integer values for DOA_REG are 0 or 1."
19565
                       severity Failure;
19566
      end case;
19567
 
19568
  end process outmux_clka;
19569
 
19570
 
19571
  outreg_clkb: process (regclkb_dly, gsr_dly)
19572
    variable FIRST_TIME : boolean := true;
19573
 
19574
  begin  -- process outreg_clkb
19575
 
19576
    if (rising_edge(regclkb_dly) or rising_edge(gsr_dly) or FIRST_TIME) then
19577
 
19578
      if (DOB_REG = 1) then
19579
 
19580
        if (gsr_dly = '1' or FIRST_TIME) then
19581
          dob_outreg(rb_width-1 downto 0) <= INIT_B_STD(rb_width-1 downto 0);
19582
 
19583
          if (rb_width >= 8) then
19584
            dopb_outreg(rb_widthp-1 downto 0) <= INIT_B_STD((rb_width+rb_widthp)-1 downto rb_width);
19585
          end if;
19586
 
19587
          FIRST_TIME := false;
19588
 
19589
        elsif (gsr_dly = '0') then
19590
 
19591
          if (regceb_dly = '1') then
19592
            if (ssrb_dly = '1') then
19593
 
19594
              dob_outreg(rb_width-1 downto 0) <= SRVAL_B_STD(rb_width-1 downto 0);
19595
 
19596
              if (rb_width >= 8) then
19597
                dopb_outreg(rb_widthp-1 downto 0) <= SRVAL_B_STD((rb_width+rb_widthp)-1 downto rb_width);
19598
              end if;
19599
 
19600
            elsif (ssrb_dly = '0') then
19601
 
19602
              dob_outreg <= dob_out;
19603
              dopb_outreg <= dopb_out;
19604
 
19605
            end if;
19606
          end if;
19607
        end if;
19608
      end if;
19609
 
19610
    end if;
19611
  end process outreg_clkb;
19612
 
19613
 
19614
  cascade_b_mux: process (clkb_dly, cascadeinlatb_dly, addrb_dly_15_reg, dob_out, dopb_out)
19615
  begin  -- process cascade_b_mux
19616
 
19617
    if (rising_edge(clkb_dly) or cascadeinlatb_dly'event or addrb_dly_15_reg'event or dob_out'event or dopb_out'event) then
19618
      if (cascade_b(1) = '1' and addrb_dly_15_reg = '1') then
19619
        dob_out_mux(0) <= cascadeinlatb_dly;
19620
      else
19621
        dob_out_mux <= dob_out;
19622
        dopb_out_mux <= dopb_out;
19623
      end if;
19624
    end if;
19625
 
19626
  end process cascade_b_mux;
19627
 
19628
  cascade_b_muxreg: process (regclkb_dly, cascadeinregb_dly, addrb_dly_15_reg1, dob_outreg, dopb_outreg)
19629
  begin  -- process cascade_b_muxreg
19630
 
19631
    if (rising_edge(regclkb_dly) or cascadeinregb_dly'event or addrb_dly_15_reg1'event or dob_outreg'event or dopb_outreg'event) then
19632
      if (cascade_b(1) = '1' and addrb_dly_15_reg1 = '1') then
19633
        dob_outreg_mux(0) <= cascadeinregb_dly;
19634
      else
19635
        dob_outreg_mux <= dob_outreg;
19636
        dopb_outreg_mux <= dopb_outreg;
19637
      end if;
19638
    end if;
19639
 
19640
  end process cascade_b_muxreg;
19641
 
19642
 
19643
  outmux_clkb: process (dob_out_mux, dopb_out_mux, dob_outreg_mux, dopb_outreg_mux)
19644
  begin  -- process outmux_clkb
19645
 
19646
      case DOB_REG is
19647
        when 0 =>
19648
                  dob_out_out <= dob_out_mux;
19649
                  dopb_out_out <= dopb_out_mux;
19650
        when 1 =>
19651
                  dob_out_out <= dob_outreg_mux;
19652
                  dopb_out_out <= dopb_outreg_mux;
19653
        when others => assert false
19654
                       report "Attribute Syntax Error: The allowed integer values for DOB_REG are 0 or 1."
19655
                       severity Failure;
19656
      end case;
19657
 
19658
  end process outmux_clkb;
19659
 
19660
 
19661
  prcs_output: process (doa_out_out, dopa_out_out, dob_out_out, dopb_out_out, eccparity_out,
19662
                        dbiterr_out_out, sbiterr_out_out, doa_out_mux(0), dob_out_mux(0),
19663
                        doa_outreg_mux(0), dob_outreg_mux(0))
19664
  begin  -- process prcs_output
19665
 
19666
    DOA <= doa_out_out;
19667
    DOPA <= dopa_out_out;
19668
    DOB <= dob_out_out;
19669
    DOPB <= dopb_out_out;
19670
    ECCPARITY <= eccparity_out;
19671
    DBITERR <= dbiterr_out_out;
19672
    SBITERR <= sbiterr_out_out;
19673
    CASCADEOUTLATA <= doa_out_mux(0);
19674
    CASCADEOUTLATB <= dob_out_mux(0);
19675
    CASCADEOUTREGA <= doa_outreg_mux(0);
19676
    CASCADEOUTREGB <= dob_outreg_mux(0);
19677
 
19678
  end process prcs_output;
19679
 
19680
 
19681
end ARAMB36_INTERNAL_V;
19682
 
19683
library IEEE;
19684
use IEEE.STD_LOGIC_1164.all;
19685
 
19686
library STD;
19687
use STD.TEXTIO.all;
19688
 
19689
library unisim;
19690
use unisim.vpkg.all;
19691
 
19692
entity RAMB16 is
19693
 
19694
  generic (
19695
 
19696
    DOA_REG : integer := 0 ;
19697
    DOB_REG : integer := 0 ;
19698
 
19699
    INIT_00 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19700
    INIT_01 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19701
    INIT_02 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19702
    INIT_03 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19703
    INIT_04 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19704
    INIT_05 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19705
    INIT_06 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19706
    INIT_07 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19707
    INIT_08 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19708
    INIT_09 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19709
    INIT_0A : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19710
    INIT_0B : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19711
    INIT_0C : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19712
    INIT_0D : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19713
    INIT_0E : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19714
    INIT_0F : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19715
    INIT_10 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19716
    INIT_11 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19717
    INIT_12 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19718
    INIT_13 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19719
    INIT_14 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19720
    INIT_15 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19721
    INIT_16 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19722
    INIT_17 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19723
    INIT_18 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19724
    INIT_19 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19725
    INIT_1A : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19726
    INIT_1B : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19727
    INIT_1C : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19728
    INIT_1D : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19729
    INIT_1E : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19730
    INIT_1F : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19731
    INIT_20 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19732
    INIT_21 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19733
    INIT_22 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19734
    INIT_23 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19735
    INIT_24 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19736
    INIT_25 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19737
    INIT_26 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19738
    INIT_27 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19739
    INIT_28 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19740
    INIT_29 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19741
    INIT_2A : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19742
    INIT_2B : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19743
    INIT_2C : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19744
    INIT_2D : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19745
    INIT_2E : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19746
    INIT_2F : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19747
    INIT_30 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19748
    INIT_31 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19749
    INIT_32 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19750
    INIT_33 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19751
    INIT_34 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19752
    INIT_35 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19753
    INIT_36 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19754
    INIT_37 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19755
    INIT_38 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19756
    INIT_39 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19757
    INIT_3A : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19758
    INIT_3B : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19759
    INIT_3C : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19760
    INIT_3D : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19761
    INIT_3E : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19762
    INIT_3F : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19763
 
19764
    INIT_A : bit_vector := X"000000000";
19765
    INIT_B : bit_vector := X"000000000";
19766
 
19767
    INITP_00 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19768
    INITP_01 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19769
    INITP_02 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19770
    INITP_03 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19771
    INITP_04 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19772
    INITP_05 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19773
    INITP_06 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19774
    INITP_07 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19775
 
19776
    INVERT_CLK_DOA_REG : boolean := false;
19777
    INVERT_CLK_DOB_REG : boolean := false;
19778
 
19779
    RAM_EXTENSION_A : string := "NONE";
19780
    RAM_EXTENSION_B : string := "NONE";
19781
 
19782
    READ_WIDTH_A : integer := 0;
19783
    READ_WIDTH_B : integer := 0;
19784
 
19785
 
19786
    SIM_COLLISION_CHECK : string := "ALL";
19787
 
19788
    SRVAL_A  : bit_vector := X"000000000";
19789
    SRVAL_B  : bit_vector := X"000000000";
19790
 
19791
    WRITE_MODE_A : string := "WRITE_FIRST";
19792
    WRITE_MODE_B : string := "WRITE_FIRST";
19793
 
19794
    WRITE_WIDTH_A : integer := 0;
19795
    WRITE_WIDTH_B : integer := 0
19796
    );
19797
 
19798
  port(
19799
    CASCADEOUTA  : out  std_ulogic;
19800
    CASCADEOUTB  : out  std_ulogic;
19801
    DOA          : out std_logic_vector (31 downto 0);
19802
    DOB          : out std_logic_vector (31 downto 0);
19803
    DOPA         : out std_logic_vector (3 downto 0);
19804
    DOPB         : out std_logic_vector (3 downto 0);
19805
 
19806
    ADDRA        : in  std_logic_vector (14 downto 0);
19807
    ADDRB        : in  std_logic_vector (14 downto 0);
19808
    CASCADEINA   : in  std_ulogic;
19809
    CASCADEINB   : in  std_ulogic;
19810
    CLKA         : in  std_ulogic;
19811
    CLKB         : in  std_ulogic;
19812
    DIA          : in  std_logic_vector (31 downto 0);
19813
    DIB          : in  std_logic_vector (31 downto 0);
19814
    DIPA         : in  std_logic_vector (3 downto 0);
19815
    DIPB         : in  std_logic_vector (3 downto 0);
19816
    ENA          : in  std_ulogic;
19817
    ENB          : in  std_ulogic;
19818
    REGCEA       : in  std_ulogic;
19819
    REGCEB       : in  std_ulogic;
19820
    SSRA         : in  std_ulogic;
19821
    SSRB         : in  std_ulogic;
19822
    WEA          : in  std_logic_vector (3 downto 0);
19823
    WEB          : in  std_logic_vector (3 downto 0)
19824
    );
19825
 
19826
end RAMB16;
19827
 
19828
architecture RAMB16_V of RAMB16 is
19829
 
19830
  component ARAMB36_INTERNAL
19831
        generic
19832
        (
19833
          BRAM_MODE : string := "TRUE_DUAL_PORT";
19834
          BRAM_SIZE : integer := 36;
19835
          DOA_REG : integer := 0;
19836
          DOB_REG : integer := 0;
19837
          INIT_A : bit_vector := X"000000000000000000";
19838
          INIT_B : bit_vector := X"000000000000000000";
19839
          RAM_EXTENSION_A : string := "NONE";
19840
          RAM_EXTENSION_B : string := "NONE";
19841
          READ_WIDTH_A : integer := 0;
19842
          READ_WIDTH_B : integer := 0;
19843
          SIM_COLLISION_CHECK : string := "ALL";
19844
          SRVAL_A : bit_vector := X"000000000000000000";
19845
          SRVAL_B : bit_vector := X"000000000000000000";
19846
          WRITE_MODE_A : string := "WRITE_FIRST";
19847
          WRITE_MODE_B : string := "WRITE_FIRST";
19848
          WRITE_WIDTH_A : integer := 0;
19849
          WRITE_WIDTH_B : integer := 0;
19850
          EN_ECC_READ : boolean := FALSE;
19851
          EN_ECC_SCRUB : boolean := FALSE;
19852
          EN_ECC_WRITE : boolean := FALSE;
19853
 
19854
          INIT_00 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19855
          INIT_01 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19856
          INIT_02 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19857
          INIT_03 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19858
          INIT_04 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19859
          INIT_05 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19860
          INIT_06 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19861
          INIT_07 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19862
          INIT_08 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19863
          INIT_09 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19864
          INIT_0A : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19865
          INIT_0B : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19866
          INIT_0C : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19867
          INIT_0D : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19868
          INIT_0E : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19869
          INIT_0F : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19870
          INIT_10 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19871
          INIT_11 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19872
          INIT_12 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19873
          INIT_13 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19874
          INIT_14 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19875
          INIT_15 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19876
          INIT_16 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19877
          INIT_17 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19878
          INIT_18 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19879
          INIT_19 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19880
          INIT_1A : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19881
          INIT_1B : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19882
          INIT_1C : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19883
          INIT_1D : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19884
          INIT_1E : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19885
          INIT_1F : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19886
          INIT_20 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19887
          INIT_21 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19888
          INIT_22 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19889
          INIT_23 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19890
          INIT_24 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19891
          INIT_25 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19892
          INIT_26 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19893
          INIT_27 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19894
          INIT_28 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19895
          INIT_29 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19896
          INIT_2A : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19897
          INIT_2B : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19898
          INIT_2C : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19899
          INIT_2D : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19900
          INIT_2E : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19901
          INIT_2F : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19902
          INIT_30 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19903
          INIT_31 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19904
          INIT_32 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19905
          INIT_33 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19906
          INIT_34 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19907
          INIT_35 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19908
          INIT_36 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19909
          INIT_37 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19910
          INIT_38 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19911
          INIT_39 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19912
          INIT_3A : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19913
          INIT_3B : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19914
          INIT_3C : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19915
          INIT_3D : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19916
          INIT_3E : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19917
          INIT_3F : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19918
          INIT_40 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19919
          INIT_41 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19920
          INIT_42 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19921
          INIT_43 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19922
          INIT_44 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19923
          INIT_45 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19924
          INIT_46 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19925
          INIT_47 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19926
          INIT_48 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19927
          INIT_49 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19928
          INIT_4A : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19929
          INIT_4B : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19930
          INIT_4C : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19931
          INIT_4D : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19932
          INIT_4E : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19933
          INIT_4F : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19934
          INIT_50 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19935
          INIT_51 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19936
          INIT_52 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19937
          INIT_53 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19938
          INIT_54 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19939
          INIT_55 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19940
          INIT_56 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19941
          INIT_57 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19942
          INIT_58 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19943
          INIT_59 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19944
          INIT_5A : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19945
          INIT_5B : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19946
          INIT_5C : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19947
          INIT_5D : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19948
          INIT_5E : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19949
          INIT_5F : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19950
          INIT_60 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19951
          INIT_61 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19952
          INIT_62 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19953
          INIT_63 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19954
          INIT_64 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19955
          INIT_65 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19956
          INIT_66 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19957
          INIT_67 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19958
          INIT_68 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19959
          INIT_69 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19960
          INIT_6A : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19961
          INIT_6B : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19962
          INIT_6C : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19963
          INIT_6D : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19964
          INIT_6E : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19965
          INIT_6F : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19966
          INIT_70 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19967
          INIT_71 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19968
          INIT_72 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19969
          INIT_73 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19970
          INIT_74 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19971
          INIT_75 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19972
          INIT_76 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19973
          INIT_77 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19974
          INIT_78 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19975
          INIT_79 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19976
          INIT_7A : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19977
          INIT_7B : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19978
          INIT_7C : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19979
          INIT_7D : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19980
          INIT_7E : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19981
          INIT_7F : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19982
          INITP_00 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19983
          INITP_01 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19984
          INITP_02 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19985
          INITP_03 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19986
          INITP_04 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19987
          INITP_05 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19988
          INITP_06 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19989
          INITP_07 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19990
          INITP_08 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19991
          INITP_09 : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19992
          INITP_0A : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19993
          INITP_0B : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19994
          INITP_0C : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19995
          INITP_0D : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19996
          INITP_0E : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000";
19997
          INITP_0F : bit_vector := X"0000000000000000000000000000000000000000000000000000000000000000"
19998
           );
19999
        port
20000
        (
20001
          CASCADEOUTLATA : out std_ulogic;
20002
          CASCADEOUTLATB : out std_ulogic;
20003
          CASCADEOUTREGA : out std_ulogic;
20004
          CASCADEOUTREGB : out std_ulogic;
20005
          DBITERR : out std_ulogic;
20006
          DOA : out std_logic_vector(63 downto 0);
20007
          DOB : out std_logic_vector(63 downto 0);
20008
          DOPA : out std_logic_vector(7 downto 0);
20009
          DOPB : out std_logic_vector(7 downto 0);
20010
          ECCPARITY : out std_logic_vector(7 downto 0);
20011
          SBITERR : out std_ulogic;
20012
 
20013
          ADDRA : in std_logic_vector(15 downto 0);
20014
          ADDRB : in std_logic_vector(15 downto 0);
20015
          CASCADEINLATA : in std_ulogic;
20016
          CASCADEINLATB : in std_ulogic;
20017
          CASCADEINREGA : in std_ulogic;
20018
          CASCADEINREGB : in std_ulogic;
20019
          CLKA : in std_ulogic;
20020
          CLKB : in std_ulogic;
20021
          DIA : in std_logic_vector(63 downto 0);
20022
          DIB : in std_logic_vector(63 downto 0);
20023
          DIPA : in std_logic_vector(7 downto 0);
20024
          DIPB : in std_logic_vector(7 downto 0);
20025
          ENA : in std_ulogic;
20026
          ENB : in std_ulogic;
20027
          REGCEA : in std_ulogic;
20028
          REGCEB : in std_ulogic;
20029
          REGCLKA : in std_ulogic;
20030
          REGCLKB : in std_ulogic;
20031
          SSRA : in std_ulogic;
20032
          SSRB : in std_ulogic;
20033
          WEA : in std_logic_vector(7 downto 0);
20034
          WEB : in std_logic_vector(7 downto 0)
20035
        );
20036
  end component;
20037
 
20038
 
20039
  constant SYNC_PATH_DELAY : time := 100 ps;
20040
  signal GND_4 : std_logic_vector(3 downto 0) := (others => '0');
20041
  signal GND_32 : std_logic_vector(31 downto 0) := (others => '0');
20042
  signal OPEN_4 : std_logic_vector(3 downto 0);
20043
  signal OPEN_32 : std_logic_vector(31 downto 0);
20044
  signal doa_dly : std_logic_vector(31 downto 0) :=  (others => '0');
20045
  signal dob_dly : std_logic_vector(31 downto 0) :=  (others => '0');
20046
  signal dopa_dly : std_logic_vector(3 downto 0) :=  (others => '0');
20047
  signal dopb_dly : std_logic_vector(3 downto 0) :=  (others => '0');
20048
  signal cascadeouta_dly : std_ulogic := '0';
20049
  signal cascadeoutb_dly : std_ulogic := '0';
20050
  signal addra_int : std_logic_vector(15 downto 0) := (others => '0');
20051
  signal addrb_int : std_logic_vector(15 downto 0) := (others => '0');
20052
  signal wea_int : std_logic_vector(7 downto 0) := (others => '0');
20053
  signal web_int : std_logic_vector(7 downto 0) := (others => '0');
20054
  signal clka_wire : std_ulogic := '0';
20055
  signal clkb_wire : std_ulogic := '0';
20056
  signal clka_tmp : std_ulogic := '0';
20057
  signal clkb_tmp : std_ulogic := '0';
20058
 
20059
 
20060
begin
20061
 
20062
  prcs_clk: process (CLKA, CLKB)
20063
 
20064
    variable FIRST_TIME : boolean := true;
20065
 
20066
    begin
20067
 
20068
      if (FIRST_TIME) then
20069
 
20070
        if((INVERT_CLK_DOA_REG = true) and (DOA_REG /= 1 )) then
20071
          assert false
20072
            report "Attribute Syntax Error:  When INVERT_CLK_DOA_REG is set to TRUE, then DOA_REG has to be set to 1."
20073
          severity Failure;
20074
        end if;
20075
 
20076
        if((INVERT_CLK_DOB_REG = true) and (DOB_REG /= 1 )) then
20077
          assert false
20078
            report "Attribute Syntax Error:  When INVERT_CLK_DOB_REG is set to TRUE, then DOB_REG has to be set to 1."
20079
          severity Failure;
20080
        end if;
20081
 
20082
        if((INVERT_CLK_DOA_REG /= TRUE) and (INVERT_CLK_DOA_REG /= FALSE)) then
20083
          assert false
20084
            report "Attribute Syntax Error : The allowed boolean values for INVERT_CLK_DOA_REG are TRUE or FALSE"
20085
          severity Failure;
20086
        end if;
20087
 
20088
        if((INVERT_CLK_DOB_REG /= TRUE) and (INVERT_CLK_DOB_REG /= FALSE)) then
20089
          assert false
20090
            report "Attribute Syntax Error : The allowed boolean values for INVERT_CLK_DOB_REG are TRUE or FALSE"
20091
          severity Failure;
20092
        end if;
20093
 
20094
        FIRST_TIME := false;
20095
 
20096
      end if;
20097
 
20098
 
20099
      if (CLKA'event) then
20100
 
20101
        if (DOA_REG = 1 and INVERT_CLK_DOA_REG = TRUE) then
20102
          clka_wire <= not CLKA;
20103
        else
20104
          clka_wire <= CLKA;
20105
        end if;
20106
 
20107
        clka_tmp <= CLKA;
20108
 
20109
      end if;
20110
 
20111
 
20112
      if (CLKB'event) then
20113
 
20114
        if (DOB_REG = 1 and INVERT_CLK_DOB_REG = TRUE) then
20115
          clkb_wire <= not CLKB;
20116
        else
20117
          clkb_wire <= CLKB;
20118
        end if;
20119
 
20120
        clkb_tmp <= CLKB;
20121
 
20122
      end if;
20123
 
20124
 
20125
    end process prcs_clk;
20126
 
20127
 
20128
  addra_int <= ADDRA(14) & '0' & ADDRA(13 downto 0);
20129
  addrb_int <= ADDRB(14) & '0' & ADDRB(13 downto 0);
20130
  wea_int <= WEA & WEA;
20131
  web_int <= WEB & WEB;
20132
 
20133
 
20134
RAMB16_inst : ARAMB36_INTERNAL
20135
        generic map (
20136
 
20137
                DOA_REG => DOA_REG,
20138
                DOB_REG => DOB_REG,
20139
                INIT_A  => INIT_A,
20140
                INIT_B  => INIT_B,
20141
 
20142
                INIT_00 => INIT_00,
20143
                INIT_01 => INIT_01,
20144
                INIT_02 => INIT_02,
20145
                INIT_03 => INIT_03,
20146
                INIT_04 => INIT_04,
20147
                INIT_05 => INIT_05,
20148
                INIT_06 => INIT_06,
20149
                INIT_07 => INIT_07,
20150
                INIT_08 => INIT_08,
20151
                INIT_09 => INIT_09,
20152
                INIT_0A => INIT_0A,
20153
                INIT_0B => INIT_0B,
20154
                INIT_0C => INIT_0C,
20155
                INIT_0D => INIT_0D,
20156
                INIT_0E => INIT_0E,
20157
                INIT_0F => INIT_0F,
20158
                INIT_10 => INIT_10,
20159
                INIT_11 => INIT_11,
20160
                INIT_12 => INIT_12,
20161
                INIT_13 => INIT_13,
20162
                INIT_14 => INIT_14,
20163
                INIT_15 => INIT_15,
20164
                INIT_16 => INIT_16,
20165
                INIT_17 => INIT_17,
20166
                INIT_18 => INIT_18,
20167
                INIT_19 => INIT_19,
20168
                INIT_1A => INIT_1A,
20169
                INIT_1B => INIT_1B,
20170
                INIT_1C => INIT_1C,
20171
                INIT_1D => INIT_1D,
20172
                INIT_1E => INIT_1E,
20173
                INIT_1F => INIT_1F,
20174
                INIT_20 => INIT_20,
20175
                INIT_21 => INIT_21,
20176
                INIT_22 => INIT_22,
20177
                INIT_23 => INIT_23,
20178
                INIT_24 => INIT_24,
20179
                INIT_25 => INIT_25,
20180
                INIT_26 => INIT_26,
20181
                INIT_27 => INIT_27,
20182
                INIT_28 => INIT_28,
20183
                INIT_29 => INIT_29,
20184
                INIT_2A => INIT_2A,
20185
                INIT_2B => INIT_2B,
20186
                INIT_2C => INIT_2C,
20187
                INIT_2D => INIT_2D,
20188
                INIT_2E => INIT_2E,
20189
                INIT_2F => INIT_2F,
20190
                INIT_30 => INIT_30,
20191
                INIT_31 => INIT_31,
20192
                INIT_32 => INIT_32,
20193
                INIT_33 => INIT_33,
20194
                INIT_34 => INIT_34,
20195
                INIT_35 => INIT_35,
20196
                INIT_36 => INIT_36,
20197
                INIT_37 => INIT_37,
20198
                INIT_38 => INIT_38,
20199
                INIT_39 => INIT_39,
20200
                INIT_3A => INIT_3A,
20201
                INIT_3B => INIT_3B,
20202
                INIT_3C => INIT_3C,
20203
                INIT_3D => INIT_3D,
20204
                INIT_3E => INIT_3E,
20205
                INIT_3F => INIT_3F,
20206
 
20207
                INITP_00 => INITP_00,
20208
                INITP_01 => INITP_01,
20209
                INITP_02 => INITP_02,
20210
                INITP_03 => INITP_03,
20211
                INITP_04 => INITP_04,
20212
                INITP_05 => INITP_05,
20213
                INITP_06 => INITP_06,
20214
                INITP_07 => INITP_07,
20215
 
20216
                SIM_COLLISION_CHECK => SIM_COLLISION_CHECK,
20217
                SRVAL_A => SRVAL_A,
20218
                SRVAL_B => SRVAL_B,
20219
                WRITE_MODE_A => WRITE_MODE_A,
20220
                WRITE_MODE_B => WRITE_MODE_B,
20221
                BRAM_MODE => "TRUE_DUAL_PORT",
20222
                BRAM_SIZE => 16,
20223
                RAM_EXTENSION_A => RAM_EXTENSION_A,
20224
                RAM_EXTENSION_B => RAM_EXTENSION_B,
20225
                READ_WIDTH_A => READ_WIDTH_A,
20226
                READ_WIDTH_B => READ_WIDTH_B,
20227
                WRITE_WIDTH_A => WRITE_WIDTH_A,
20228
                WRITE_WIDTH_B => WRITE_WIDTH_B
20229
 
20230
                )
20231
        port map (
20232
                ADDRA => addra_int,
20233
                ADDRB => addrb_int,
20234
                CLKA => clka_tmp,
20235
                CLKB => clkb_tmp,
20236
                DIA(31 downto 0)  => DIA,
20237
                DIA(63 downto 32) => GND_32,
20238
                DIB(31 downto 0) => DIB,
20239
                DIB(63 downto 32) => GND_32,
20240
                DIPA(3 downto 0) => DIPA,
20241
                DIPA(7 downto 4) => GND_4,
20242
                DIPB(3 downto 0) => DIPB,
20243
                DIPB(7 downto 4) => GND_4,
20244
                ENA => ENA,
20245
                ENB => ENB,
20246
                SSRA => SSRA,
20247
                SSRB => SSRB,
20248
                WEA => wea_int,
20249
                WEB => web_int,
20250
                DOA(31  downto 0) => doa_dly,
20251
                DOA(63 downto 32) => OPEN_32,
20252
                DOB(31 downto 0) => dob_dly,
20253
                DOB(63 downto 32) => OPEN_32,
20254
                DOPA(3 downto 0) => dopa_dly,
20255
                DOPA(7 downto 4) => OPEN_4,
20256
                DOPB(3 downto 0) => dopb_dly,
20257
                DOPB(7 downto 4) => OPEN_4,
20258
                CASCADEOUTLATA => cascadeouta_dly,
20259
                CASCADEOUTLATB => cascadeoutb_dly,
20260
                CASCADEOUTREGA => open,
20261
                CASCADEOUTREGB => open,
20262
                CASCADEINLATA => CASCADEINA,
20263
                CASCADEINLATB => CASCADEINB,
20264
                CASCADEINREGA => CASCADEINA,
20265
                CASCADEINREGB => CASCADEINB,
20266
                REGCLKA => clka_wire,
20267
                REGCLKB => clkb_wire,
20268
                REGCEA => REGCEA,
20269
                REGCEB => REGCEB
20270
        );
20271
 
20272
 
20273
  prcs_output_wtiming: process (doa_dly, dob_dly, dopa_dly, dopb_dly, cascadeouta_dly, cascadeoutb_dly)
20274
   begin  -- process prcs_output_wtiming
20275
 
20276
     CASCADEOUTA <= cascadeouta_dly after SYNC_PATH_DELAY;
20277
     CASCADEOUTB <= cascadeoutb_dly after SYNC_PATH_DELAY;
20278
     DOA <= doa_dly after SYNC_PATH_DELAY;
20279
     DOPA <= dopa_dly after SYNC_PATH_DELAY;
20280
     DOB <= dob_dly after SYNC_PATH_DELAY;
20281
     DOPB <= dopb_dly after SYNC_PATH_DELAY;
20282
 
20283
   end process prcs_output_wtiming;
20284
 
20285
end RAMB16_V;
20286
 
20287
library IEEE;
20288
use IEEE.STD_LOGIC_1164.all;
20289
 
20290
library UNISIM;
20291
use UNISIM.VPKG.all;
20292
 
20293
entity RAM64X1D is
20294
  generic (
20295
    INIT : bit_vector(63 downto 0) := X"0000000000000000"
20296
    );
20297
 
20298
  port (
20299
    DPO : out std_ulogic;
20300
    SPO : out std_ulogic;
20301
 
20302
    A0    : in std_ulogic;
20303
    A1    : in std_ulogic;
20304
    A2    : in std_ulogic;
20305
    A3    : in std_ulogic;
20306
    A4    : in std_ulogic;
20307
    A5    : in std_ulogic;
20308
    D     : in std_ulogic;
20309
    DPRA0 : in std_ulogic;
20310
    DPRA1 : in std_ulogic;
20311
    DPRA2 : in std_ulogic;
20312
    DPRA3 : in std_ulogic;
20313
    DPRA4 : in std_ulogic;
20314
    DPRA5 : in std_ulogic;
20315
    WCLK  : in std_ulogic;
20316
    WE    : in std_ulogic
20317
    );
20318
end RAM64X1D;
20319
 
20320
architecture RAM64X1D_V of RAM64X1D is
20321
  signal MEM : std_logic_vector( 64 downto 0 ) := ('X' & To_StdLogicVector(INIT) );
20322
 
20323
begin
20324
  VITALReadBehavior   : process(A0, A1, A2, A3, A4, A5, DPRA5, DPRA4, DPRA3, DPRA2, DPRA1, DPRA0, WCLK, MEM)
20325
    variable Index_SP : integer := 64;
20326
    variable Index_DP : integer := 64;
20327
    variable Raddress : std_logic_vector (5 downto 0);
20328
    variable Waddress : std_logic_vector (5 downto 0);
20329
 
20330
  begin
20331
    Waddress := (A5, A4, A3, A2, A1, A0);
20332
    Raddress := (DPRA5, DPRA4, DPRA3, DPRA2, DPRA1, DPRA0);
20333
    Index_SP := SLV_TO_INT(SLV => Waddress);
20334
    Index_DP := SLV_TO_INT(SLV => Raddress);
20335
    SPO <= MEM(Index_SP);
20336
    DPO <= MEM(Index_DP);
20337
  end process VITALReadBehavior;
20338
 
20339
  VITALWriteBehavior  : process(WCLK)
20340
    variable Index_SP : integer := 32;
20341
    variable Index_DP : integer := 32;
20342
    variable Address  : std_logic_vector( 5 downto 0);
20343
 
20344
  begin
20345
    Address  := (A5, A4, A3, A2, A1, A0);
20346
    Index_SP := SLV_TO_INT(SLV => Address );
20347
    if ((WE = '1') and (wclk'event) and (wclk'last_value = '0') and (wclk = '1')) then
20348
      MEM(Index_SP) <= D after 100 ps;
20349
    end if;
20350
  end process VITALWriteBehavior;
20351
end RAM64X1D_V;
20352
 
20353
library IEEE;
20354
use IEEE.STD_LOGIC_1164.all;
20355
 
20356
entity MUXF8 is
20357
  port(
20358
    O : out std_ulogic;
20359
 
20360
    I0 : in std_ulogic;
20361
    I1 : in std_ulogic;
20362
    S  : in std_ulogic
20363
    );
20364
end MUXF8;
20365
 
20366
architecture MUXF8_V of MUXF8 is
20367
begin
20368
  VITALBehavior   : process (I0, I1, S)
20369
  begin
20370
    if (S = '0') then
20371
      O <= I0;
20372
    elsif (S = '1') then
20373
      O <= I1;
20374
    end if;
20375
  end process;
20376
end MUXF8_V;
20377
 
20378
 
20379
 
20380
library IEEE;
20381
use IEEE.STD_LOGIC_1164.all;
20382
 
20383
entity BUF is
20384
  port(
20385
    O : out std_ulogic;
20386
 
20387
    I : in std_ulogic
20388
    );
20389
end BUF;
20390
 
20391
architecture BUF_V of BUF is
20392
begin
20393
  O <= TO_X01(I);
20394
end BUF_V;
20395
 
20396
library IEEE;
20397
use IEEE.STD_LOGIC_1164.all;
20398
 
20399
library unisim;
20400
use unisim.VPKG.all;
20401
use unisim.VCOMPONENTS.all;
20402
 
20403
entity LUT5 is
20404
  generic(
20405
    INIT : bit_vector := X"00000000"
20406
    );
20407
 
20408
  port(
20409
    O : out std_ulogic;
20410
 
20411
    I0 : in std_ulogic;
20412
    I1 : in std_ulogic;
20413
    I2 : in std_ulogic;
20414
    I3 : in std_ulogic;
20415
    I4 : in std_ulogic
20416
    );
20417
end LUT5;
20418
 
20419
architecture LUT5_V of LUT5 is
20420
 
20421
function lut6_mux8 (d :  std_logic_vector(7 downto 0); s : std_logic_vector(2 downto 0))
20422
                    return std_logic is
20423
 
20424
       variable lut6_mux8_o : std_logic;
20425
       function lut4_mux4f (df :  std_logic_vector(3 downto 0); sf : std_logic_vector(1 downto 0) )
20426
                    return std_logic is
20427
 
20428
            variable lut4_mux4_f : std_logic;
20429
       begin
20430
 
20431
            if (((sf(1) xor sf(0)) = '1')  or  ((sf(1) xor sf(0)) = '0')) then
20432
                lut4_mux4_f := df(SLV_TO_INT(sf));
20433
            elsif ((df(0) xor df(1)) = '0' and (df(2) xor df(3)) = '0'
20434
                    and (df(0) xor df(2)) = '0') then
20435
                lut4_mux4_f := df(0);
20436
            elsif ((sf(1) = '0') and (df(0) = df(1))) then
20437
                lut4_mux4_f := df(0);
20438
            elsif ((sf(1) = '1') and (df(2) = df(3))) then
20439
                lut4_mux4_f := df(2);
20440
            elsif ((sf(0) = '0') and (df(0) = df(2))) then
20441
                lut4_mux4_f := df(0);
20442
            elsif ((sf(0) = '1') and (df(1) = df(3))) then
20443
                lut4_mux4_f := df(1);
20444
            else
20445
                lut4_mux4_f := 'X';
20446
           end if;
20447
 
20448
           return (lut4_mux4_f);
20449
 
20450
       end function lut4_mux4f;
20451
  begin
20452
 
20453
    if ((s(2) xor s(1) xor s(0)) = '1' or (s(2) xor s(1) xor s(0)) = '0') then
20454
       lut6_mux8_o := d(SLV_TO_INT(s));
20455
    else
20456
       lut6_mux8_o := lut4_mux4f(('0' & '0' & lut4_mux4f(d(7 downto 4), s(1 downto 0)) &
20457
            lut4_mux4f(d(3 downto 0), s(1 downto 0))), ('0' & s(2)));
20458
    end if;
20459
 
20460
      return (lut6_mux8_o);
20461
 
20462
  end function lut6_mux8;
20463
 
20464
function lut4_mux4 (d :  std_logic_vector(3 downto 0); s : std_logic_vector(1 downto 0) )
20465
                    return std_logic is
20466
 
20467
       variable lut4_mux4_o : std_logic;
20468
  begin
20469
 
20470
       if (((s(1) xor s(0)) = '1')  or  ((s(1) xor s(0)) = '0')) then
20471
           lut4_mux4_o := d(SLV_TO_INT(s));
20472
       elsif ((d(0) xor d(1)) = '0' and (d(2) xor d(3)) = '0'
20473
                    and (d(0) xor d(2)) = '0') then
20474
           lut4_mux4_o := d(0);
20475
       elsif ((s(1) = '0') and (d(0) = d(1))) then
20476
           lut4_mux4_o := d(0);
20477
       elsif ((s(1) = '1') and (d(2) = d(3))) then
20478
           lut4_mux4_o := d(2);
20479
       elsif ((s(0) = '0') and (d(0) = d(2))) then
20480
           lut4_mux4_o := d(0);
20481
       elsif ((s(0) = '1') and (d(1) = d(3))) then
20482
           lut4_mux4_o := d(1);
20483
       else
20484
           lut4_mux4_o := 'X';
20485
      end if;
20486
 
20487
      return (lut4_mux4_o);
20488
 
20489
  end function lut4_mux4;
20490
 
20491
    constant INIT_reg : std_logic_vector(31 downto 0) := To_StdLogicVector(INIT);
20492
begin
20493
 
20494
  lut_p   : process (I0, I1, I2, I3, I4)
20495
    variable I_reg : std_logic_vector(4 downto 0);
20496
  begin
20497
 
20498
    I_reg := TO_STDLOGICVECTOR(I4 & I3 &  I2 & I1 & I0);
20499
 
20500
    if ((I4 xor I3 xor I2 xor I1 xor I0) = '1' or (I4 xor I3 xor I2 xor I1 xor I0) = '0') then
20501
       O <= INIT_reg(SLV_TO_INT(I_reg));
20502
    else
20503
 
20504
       O <=  lut4_mux4 (
20505
           (lut6_mux8 ( INIT_reg(31 downto 24), I_reg(2 downto 0)) &
20506
            lut6_mux8 ( INIT_reg(23 downto 16), I_reg(2 downto 0)) &
20507
            lut6_mux8 ( INIT_reg(15 downto 8), I_reg(2 downto 0)) &
20508
            lut6_mux8 ( INIT_reg(7 downto 0), I_reg(2 downto 0))),
20509
                        I_reg(4 downto 3));
20510
 
20511
    end if;
20512
  end process;
20513
end LUT5_V;
20514
 
20515
library IEEE;
20516
use IEEE.STD_LOGIC_1164.all;
20517
 
20518
library unisim;
20519
use unisim.VPKG.all;
20520
use unisim.VCOMPONENTS.all;
20521
 
20522
entity LUT5_L is
20523
  generic(
20524
    INIT : bit_vector := X"00000000"
20525
    );
20526
 
20527
  port(
20528
    LO : out std_ulogic;
20529
 
20530
    I0 : in std_ulogic;
20531
    I1 : in std_ulogic;
20532
    I2 : in std_ulogic;
20533
    I3 : in std_ulogic;
20534
    I4 : in std_ulogic
20535
    );
20536
end LUT5_L;
20537
 
20538
architecture LUT5_L_V of LUT5_L is
20539
 
20540
function lut6_mux8 (d :  std_logic_vector(7 downto 0); s : std_logic_vector(2 downto 0))
20541
                    return std_logic is
20542
 
20543
       variable lut6_mux8_o : std_logic;
20544
       function lut4_mux4f (df :  std_logic_vector(3 downto 0); sf : std_logic_vector(1 downto 0) )
20545
                    return std_logic is
20546
 
20547
            variable lut4_mux4_f : std_logic;
20548
       begin
20549
 
20550
            if (((sf(1) xor sf(0)) = '1')  or  ((sf(1) xor sf(0)) = '0')) then
20551
                lut4_mux4_f := df(SLV_TO_INT(sf));
20552
            elsif ((df(0) xor df(1)) = '0' and (df(2) xor df(3)) = '0'
20553
                    and (df(0) xor df(2)) = '0') then
20554
                lut4_mux4_f := df(0);
20555
            elsif ((sf(1) = '0') and (df(0) = df(1))) then
20556
                lut4_mux4_f := df(0);
20557
            elsif ((sf(1) = '1') and (df(2) = df(3))) then
20558
                lut4_mux4_f := df(2);
20559
            elsif ((sf(0) = '0') and (df(0) = df(2))) then
20560
                lut4_mux4_f := df(0);
20561
            elsif ((sf(0) = '1') and (df(1) = df(3))) then
20562
                lut4_mux4_f := df(1);
20563
            else
20564
                lut4_mux4_f := 'X';
20565
           end if;
20566
 
20567
           return (lut4_mux4_f);
20568
 
20569
       end function lut4_mux4f;
20570
  begin
20571
 
20572
    if ((s(2) xor s(1) xor s(0)) = '1' or (s(2) xor s(1) xor s(0)) = '0') then
20573
       lut6_mux8_o := d(SLV_TO_INT(s));
20574
    else
20575
       lut6_mux8_o := lut4_mux4f(('0' & '0' & lut4_mux4f(d(7 downto 4), s(1 downto 0)) &
20576
            lut4_mux4f(d(3 downto 0), s(1 downto 0))), ('0' & s(2)));
20577
    end if;
20578
 
20579
      return (lut6_mux8_o);
20580
 
20581
  end function lut6_mux8;
20582
 
20583
function lut4_mux4 (d :  std_logic_vector(3 downto 0); s : std_logic_vector(1 downto 0) )
20584
                    return std_logic is
20585
 
20586
       variable lut4_mux4_o : std_logic;
20587
  begin
20588
 
20589
       if (((s(1) xor s(0)) = '1')  or  ((s(1) xor s(0)) = '0')) then
20590
           lut4_mux4_o := d(SLV_TO_INT(s));
20591
       elsif ((d(0) xor d(1)) = '0' and (d(2) xor d(3)) = '0'
20592
                    and (d(0) xor d(2)) = '0') then
20593
           lut4_mux4_o := d(0);
20594
       elsif ((s(1) = '0') and (d(0) = d(1))) then
20595
           lut4_mux4_o := d(0);
20596
       elsif ((s(1) = '1') and (d(2) = d(3))) then
20597
           lut4_mux4_o := d(2);
20598
       elsif ((s(0) = '0') and (d(0) = d(2))) then
20599
           lut4_mux4_o := d(0);
20600
       elsif ((s(0) = '1') and (d(1) = d(3))) then
20601
           lut4_mux4_o := d(1);
20602
       else
20603
           lut4_mux4_o := 'X';
20604
      end if;
20605
 
20606
      return (lut4_mux4_o);
20607
 
20608
  end function lut4_mux4;
20609
 
20610
    constant INIT_reg : std_logic_vector(31 downto 0) := To_StdLogicVector(INIT);
20611
begin
20612
 
20613
  lut_p   : process (I0, I1, I2, I3, I4)
20614
    variable INIT_reg : std_logic_vector(31 downto 0) := To_StdLogicVector(INIT);
20615
    variable I_reg : std_logic_vector(4 downto 0);
20616
  begin
20617
 
20618
    I_reg := TO_STDLOGICVECTOR(I4 & I3 &  I2 & I1 & I0);
20619
 
20620
    if ((I4 xor I3 xor I2 xor I1 xor I0) = '1' or (I4 xor I3 xor I2 xor I1 xor I0) = '0') then
20621
       LO <= INIT_reg(SLV_TO_INT(I_reg));
20622
    else
20623
 
20624
       LO <=  lut4_mux4 (
20625
           (lut6_mux8 ( INIT_reg(31 downto 24), I_reg(2 downto 0)) &
20626
            lut6_mux8 ( INIT_reg(23 downto 16), I_reg(2 downto 0)) &
20627
            lut6_mux8 ( INIT_reg(15 downto 8), I_reg(2 downto 0)) &
20628
            lut6_mux8 ( INIT_reg(7 downto 0), I_reg(2 downto 0))),
20629
                        I_reg(4 downto 3));
20630
 
20631
    end if;
20632
  end process;
20633
end LUT5_L_V;
20634
 
20635
 
20636
library IEEE;
20637
use IEEE.STD_LOGIC_1164.all;
20638
 
20639
library unisim;
20640
use unisim.VPKG.all;
20641
use unisim.VCOMPONENTS.all;
20642
 
20643
entity LUT6 is
20644
  generic(
20645
     INIT : bit_vector := X"0000000000000000"
20646
    );
20647
 
20648
  port(
20649
    O : out std_ulogic;
20650
 
20651
    I0 : in std_ulogic;
20652
    I1 : in std_ulogic;
20653
    I2 : in std_ulogic;
20654
    I3 : in std_ulogic;
20655
    I4 : in std_ulogic;
20656
    I5 : in std_ulogic
20657
    );
20658
end LUT6;
20659
 
20660
architecture LUT6_V of LUT6 is
20661
 
20662
function lut6_mux8 (d :  std_logic_vector(7 downto 0); s : std_logic_vector(2  downto 0) )
20663
                    return std_logic is
20664
       variable lut6_mux8_o : std_logic;
20665
       function lut4_mux4f (df :  std_logic_vector(3 downto 0); sf : std_logic_vector(1 downto 0) )
20666
                    return std_logic is
20667
 
20668
            variable lut4_mux4_f : std_logic;
20669
       begin
20670
 
20671
            if (((sf(1) xor sf(0)) = '1')  or  ((sf(1) xor sf(0)) = '0')) then
20672
                lut4_mux4_f := df(SLV_TO_INT(sf));
20673
            elsif ((df(0) xor df(1)) = '0' and (df(2) xor df(3)) = '0'
20674
                    and (df(0) xor df(2)) = '0') then
20675
                lut4_mux4_f := df(0);
20676
            elsif ((sf(1) = '0') and (df(0) = df(1))) then
20677
                lut4_mux4_f := df(0);
20678
            elsif ((sf(1) = '1') and (df(2) = df(3))) then
20679
                lut4_mux4_f := df(2);
20680
            elsif ((sf(0) = '0') and (df(0) = df(2))) then
20681
                lut4_mux4_f := df(0);
20682
            elsif ((sf(0) = '1') and (df(1) = df(3))) then
20683
                lut4_mux4_f := df(1);
20684
            else
20685
                lut4_mux4_f := 'X';
20686
           end if;
20687
 
20688
           return (lut4_mux4_f);
20689
 
20690
       end function lut4_mux4f;
20691
  begin
20692
 
20693
   if ((s(2) xor s(1) xor s(0)) = '1' or (s(2) xor s(1) xor s(0)) = '0') then
20694
       lut6_mux8_o := d(SLV_TO_INT(s));
20695
    else
20696
       lut6_mux8_o := lut4_mux4f(('0' & '0' & lut4_mux4f(d(7 downto 4), s(1 downto 0)) &
20697
            lut4_mux4f(d(3 downto 0), s(1 downto 0))), ('0' & s(2)));
20698
    end if;
20699
 
20700
      return (lut6_mux8_o);
20701
 
20702
  end function lut6_mux8;
20703
 
20704
    constant INIT_reg : std_logic_vector(63 downto 0) := To_StdLogicVector(INIT);
20705
begin
20706
 
20707
  lut_p   : process (I0, I1, I2, I3, I4, I5)
20708
    variable I_reg : std_logic_vector(5 downto 0);
20709
  begin
20710
 
20711
    I_reg := TO_STDLOGICVECTOR(I5 & I4 & I3 &  I2 & I1 & I0);
20712
 
20713
    if ((I5 xor I4 xor I3 xor I2 xor I1 xor I0) = '1' or (I5 xor I4 xor I3 xor I2 xor I1 xor I0) = '0') then
20714
       O <= INIT_reg(SLV_TO_INT(I_reg));
20715
    else
20716
 
20717
       O <=  lut6_mux8 (
20718
               (lut6_mux8 ( INIT_reg(63 downto 56), I_reg(2 downto 0)) &
20719
                lut6_mux8 ( INIT_reg(55 downto 48), I_reg(2 downto 0)) &
20720
                lut6_mux8 ( INIT_reg(47 downto 40), I_reg(2 downto 0)) &
20721
                lut6_mux8 ( INIT_reg(39 downto 32), I_reg(2 downto 0)) &
20722
                lut6_mux8 ( INIT_reg(31 downto 24), I_reg(2 downto 0)) &
20723
                lut6_mux8 ( INIT_reg(23 downto 16), I_reg(2 downto 0)) &
20724
                lut6_mux8 ( INIT_reg(15 downto 8), I_reg(2 downto 0)) &
20725
                lut6_mux8 ( INIT_reg(7 downto 0), I_reg(2 downto 0))),
20726
                        I_reg(5 downto 3));
20727
 
20728
    end if;
20729
  end process;
20730
end LUT6_V;
20731
 
20732
 
20733
library IEEE;
20734
use IEEE.STD_LOGIC_1164.all;
20735
 
20736
library unisim;
20737
use unisim.VPKG.all;
20738
use unisim.VCOMPONENTS.all;
20739
 
20740
entity LUT6_L is
20741
  generic(
20742
      INIT : bit_vector := X"0000000000000000"
20743
     );
20744
 
20745
  port(
20746
    LO : out std_ulogic;
20747
 
20748
    I0 : in std_ulogic;
20749
    I1 : in std_ulogic;
20750
    I2 : in std_ulogic;
20751
    I3 : in std_ulogic;
20752
    I4 : in std_ulogic;
20753
    I5 : in std_ulogic
20754
    );
20755
end LUT6_L;
20756
 
20757
architecture LUT6_L_V of LUT6_L is
20758
 
20759
function lut6_mux8 (d :  std_logic_vector(7 downto 0); s : std_logic_vector(2  downto 0) )
20760
                    return std_logic is
20761
       variable lut6_mux8_o : std_logic;
20762
       function lut4_mux4f (df :  std_logic_vector(3 downto 0); sf : std_logic_vector(1 downto 0) )
20763
                    return std_logic is
20764
 
20765
            variable lut4_mux4_f : std_logic;
20766
       begin
20767
 
20768
            if (((sf(1) xor sf(0)) = '1')  or  ((sf(1) xor sf(0)) = '0')) then
20769
                lut4_mux4_f := df(SLV_TO_INT(sf));
20770
            elsif ((df(0) xor df(1)) = '0' and (df(2) xor df(3)) = '0'
20771
                    and (df(0) xor df(2)) = '0') then
20772
                lut4_mux4_f := df(0);
20773
            elsif ((sf(1) = '0') and (df(0) = df(1))) then
20774
                lut4_mux4_f := df(0);
20775
            elsif ((sf(1) = '1') and (df(2) = df(3))) then
20776
                lut4_mux4_f := df(2);
20777
            elsif ((sf(0) = '0') and (df(0) = df(2))) then
20778
                lut4_mux4_f := df(0);
20779
            elsif ((sf(0) = '1') and (df(1) = df(3))) then
20780
                lut4_mux4_f := df(1);
20781
            else
20782
                lut4_mux4_f := 'X';
20783
           end if;
20784
 
20785
           return (lut4_mux4_f);
20786
 
20787
       end function lut4_mux4f;
20788
 
20789
  begin
20790
 
20791
   if ((s(2) xor s(1) xor s(0)) = '1' or (s(2) xor s(1) xor s(0)) = '0') then
20792
       lut6_mux8_o := d(SLV_TO_INT(s));
20793
    else
20794
       lut6_mux8_o := lut4_mux4f(('0' & '0' & lut4_mux4f(d(7 downto 4), s(1 downto 0)) &
20795
            lut4_mux4f(d(3 downto 0), s(1 downto 0))), ('0' & s(2)));
20796
    end if;
20797
 
20798
      return (lut6_mux8_o);
20799
 
20800
  end function lut6_mux8;
20801
 
20802
    constant INIT_reg : std_logic_vector(63 downto 0) := To_StdLogicVector(INIT);
20803
begin
20804
 
20805
  lut_p   : process (I0, I1, I2, I3, I4, I5)
20806
    variable I_reg : std_logic_vector(5 downto 0);
20807
  begin
20808
 
20809
    I_reg := TO_STDLOGICVECTOR(I5 & I4 & I3 &  I2 & I1 & I0);
20810
 
20811
    if ((I5 xor I4 xor I3 xor I2 xor I1 xor I0) = '1' or (I5 xor I4 xor I3 xor I2 xor I1 xor I0) = '0') then
20812
       LO <= INIT_reg(SLV_TO_INT(I_reg));
20813
    else
20814
 
20815
       LO <=  lut6_mux8 (
20816
               (lut6_mux8 ( INIT_reg(63 downto 56), I_reg(2 downto 0)) &
20817
                lut6_mux8 ( INIT_reg(55 downto 48), I_reg(2 downto 0)) &
20818
                lut6_mux8 ( INIT_reg(47 downto 40), I_reg(2 downto 0)) &
20819
                lut6_mux8 ( INIT_reg(39 downto 32), I_reg(2 downto 0)) &
20820
                lut6_mux8 ( INIT_reg(31 downto 24), I_reg(2 downto 0)) &
20821
                lut6_mux8 ( INIT_reg(23 downto 16), I_reg(2 downto 0)) &
20822
                lut6_mux8 ( INIT_reg(15 downto 8), I_reg(2 downto 0)) &
20823
                lut6_mux8 ( INIT_reg(7 downto 0), I_reg(2 downto 0))),
20824
                        I_reg(5 downto 3));
20825
 
20826
    end if;
20827
  end process;
20828
end LUT6_L_V;
20829
 
20830
library IEEE;
20831
use IEEE.STD_LOGIC_1164.all;
20832
 
20833
library UNISIM;
20834
use UNISIM.VPKG.all;
20835
 
20836
entity RAM128X1S is
20837
 
20838
  generic (
20839
    INIT : bit_vector(127 downto 0) := X"00000000000000000000000000000000"
20840
    );
20841
 
20842
  port (
20843
    O : out std_ulogic;
20844
 
20845
    A0   : in std_ulogic;
20846
    A1   : in std_ulogic;
20847
    A2   : in std_ulogic;
20848
    A3   : in std_ulogic;
20849
    A4   : in std_ulogic;
20850
    A5   : in std_ulogic;
20851
    A6   : in std_ulogic;
20852
    D    : in std_ulogic;
20853
    WCLK : in std_ulogic;
20854
    WE   : in std_ulogic
20855
    );
20856
end RAM128X1S;
20857
 
20858
architecture RAM128X1S_V of RAM128X1S is
20859
  signal MEM : std_logic_vector( 128 downto 0 ) := ('X' & To_StdLogicVector(INIT) );
20860
 
20861
begin
20862
  VITALReadBehavior  : process(A0, A1, A2, A3, A4, A5, A6, MEM)
20863
    Variable Index   : integer    := 128;
20864
    variable Address : std_logic_vector( 6 downto 0);
20865
 
20866
  begin
20867
    Address := (A6, A5, A4, A3, A2, A1, A0);
20868
    Index   := SLV_TO_INT(SLV => Address);
20869
    O <= MEM(Index);
20870
 
20871
  end process VITALReadBehavior;
20872
 
20873
  VITALWriteBehavior : process(WCLK)
20874
    Variable Index   : integer := 128;
20875
    variable Address : std_logic_vector (6 downto 0);
20876
 
20877
  begin
20878
    if (rising_edge(WCLK)) then
20879
      if (WE = '1') then
20880
        Address := (A6, A5, A4, A3, A2, A1, A0);
20881
        Index   := SLV_TO_INT(SLV => Address);
20882
        MEM(Index) <= D after 100 ps;
20883
      end if;
20884
    end if;
20885
  end process VITALWriteBehavior;
20886
end RAM128X1S_V;
20887
 
20888
library IEEE;
20889
use IEEE.STD_LOGIC_1164.all;
20890
 
20891
library UNISIM;
20892
use UNISIM.VPKG.all;
20893
 
20894
entity SRLC16E is
20895
 
20896
  generic (
20897
       INIT : bit_vector := X"0000"
20898
  );
20899
 
20900
  port (
20901
        Q   : out STD_ULOGIC;
20902
        Q15 : out STD_ULOGIC;
20903
 
20904
        A0  : in STD_ULOGIC;
20905
        A1  : in STD_ULOGIC;
20906
        A2  : in STD_ULOGIC;
20907
        A3  : in STD_ULOGIC;
20908
        CE  : in STD_ULOGIC;
20909
        CLK : in STD_ULOGIC;
20910
        D   : in STD_ULOGIC
20911
       );
20912
end SRLC16E;
20913
 
20914
architecture SRLC16E_V of SRLC16E is
20915
  signal SHIFT_REG : std_logic_vector (16 downto 0) := ('X' & To_StdLogicVector(INIT));
20916
begin
20917
  VITALReadBehavior : process(A0, A1, A2, A3, SHIFT_REG)
20918
 
20919
    variable VALID_ADDR : boolean := FALSE;
20920
    variable LENGTH : integer;
20921
    variable ADDR : std_logic_vector(3 downto 0);
20922
 
20923
  begin
20924
 
20925
    ADDR := (A3, A2, A1, A0);
20926
    VALID_ADDR := ADDR_IS_VALID(SLV => ADDR);
20927
 
20928
    if (VALID_ADDR) then
20929
        LENGTH := SLV_TO_INT(SLV => ADDR);
20930
    else
20931
        LENGTH := 16;
20932
    end if;
20933
    Q <= SHIFT_REG(LENGTH);
20934
    Q15 <= SHIFT_REG(15);
20935
 
20936
  end process VITALReadBehavior;
20937
 
20938
  VITALWriteBehavior : process
20939
 
20940
    variable FIRST_TIME : boolean := TRUE;
20941
 
20942
  begin
20943
 
20944
    if (FIRST_TIME) then
20945
        wait until ((CE = '1' or CE = '0') and
20946
                   (CLK'last_value = '0' or CLK'last_value = '1') and
20947
                   (CLK = '0' or CLK = '1'));
20948
        FIRST_TIME := FALSE;
20949
    end if;
20950
 
20951
    if (CLK'event AND CLK'last_value = '0') then
20952
      if (CLK = '1') then
20953
        if (CE = '1') then
20954
          for I in 15 downto 1 loop
20955
            SHIFT_REG(I) <= SHIFT_REG(I-1) after 100 ps;
20956
          end loop;
20957
          SHIFT_REG(0) <= D after 100 ps;
20958
        elsif (CE = 'X') then
20959
          SHIFT_REG <= (others => 'X') after 100 ps;
20960
        end if;
20961
      elsif (CLK = 'X') then
20962
        if (CE /= '0') then
20963
          SHIFT_REG <= (others => 'X') after 100 ps;
20964
        end if;
20965
      end if;
20966
    elsif (CLK'event AND CLK'last_value = 'X') then
20967
      if (CLK = '1') then
20968
        if (CE /= '0') then
20969
          SHIFT_REG <= (others => 'X') after 100 ps;
20970
        end if;
20971
      end if;
20972
    end if;
20973
 
20974
    wait on CLK;
20975
 
20976
  end process VITALWriteBehavior;
20977
end SRLC16E_V;
20978
 
20979
library IEEE;
20980
use IEEE.STD_LOGIC_1164.all;
20981
 
20982
entity LD_1 is
20983
  generic(
20984
    INIT : bit := '0'
20985
    );
20986
 
20987
  port(
20988
    Q : out std_ulogic := '0';
20989
 
20990
    D : in std_ulogic;
20991
    G : in std_ulogic
20992
    );
20993
end LD_1;
20994
 
20995
architecture LD_1_V of LD_1 is
20996
begin
20997
  VITALBehavior : process(D, G)
20998
   begin
20999
     if (G = '0') then
21000
       Q <= D after 100 ps;
21001
     end if;
21002
  end process;
21003
end LD_1_V;
21004
 
21005
 
21006
-- pragma translate_on
21007
 

powered by: WebSVN 2.1.0

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