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

Subversion Repositories pcie_sg_dma

[/] [pcie_sg_dma/] [branches/] [Virtex6/] [ML605_ISE13.3/] [MyUserLogic/] [UserLogic_00/] [top_level_1_PCIe_UserLogic_00_USER_LOGIC/] [sysgen/] [perl_results.vhd] - Blame information for rev 13

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 barabba
 
2
-------------------------------------------------------------------
3
-- System Generator version 13.2 VHDL source file.
4
--
5
-- Copyright(C) 2011 by Xilinx, Inc.  All rights reserved.  This
6
-- text/file contains proprietary, confidential information of Xilinx,
7
-- Inc., is distributed under license from Xilinx, Inc., and may be used,
8
-- copied and/or disclosed only pursuant to the terms of a valid license
9
-- agreement with Xilinx, Inc.  Xilinx hereby grants you a license to use
10
-- this text/file solely for design, simulation, implementation and
11
-- creation of design files limited to Xilinx devices or technologies.
12
-- Use with non-Xilinx devices or technologies is expressly prohibited
13
-- and immediately terminates your license unless covered by a separate
14
-- agreement.
15
--
16
-- Xilinx is providing this design, code, or information "as is" solely
17
-- for use in developing programs and solutions for Xilinx devices.  By
18
-- providing this design, code, or information as one possible
19
-- implementation of this feature, application or standard, Xilinx is
20
-- making no representation that this implementation is free from any
21
-- claims of infringement.  You are responsible for obtaining any rights
22
-- you may require for your implementation.  Xilinx expressly disclaims
23
-- any warranty whatsoever with respect to the adequacy of the
24
-- implementation, including but not limited to warranties of
25
-- merchantability or fitness for a particular purpose.
26
--
27
-- Xilinx products are not intended for use in life support appliances,
28
-- devices, or systems.  Use in such applications is expressly prohibited.
29
--
30
-- Any modifications that are made to the source code are done at the user's
31
-- sole risk and will be unsupported.
32
--
33
-- This copyright and support notice must be retained as part of this
34
-- text at all times.  (c) Copyright 1995-2011 Xilinx, Inc.  All rights
35
-- reserved.
36
-------------------------------------------------------------------
37
library IEEE;
38
use IEEE.std_logic_1164.all;
39
use IEEE.numeric_std.all;
40
package conv_pkg is
41
    constant simulating : boolean := false
42
      -- synopsys translate_off
43
        or true
44
      -- synopsys translate_on
45
    ;
46
    constant xlUnsigned : integer := 1;
47
    constant xlSigned : integer := 2;
48
    constant xlFloat : integer := 3;
49
    constant xlWrap : integer := 1;
50
    constant xlSaturate : integer := 2;
51
    constant xlTruncate : integer := 1;
52
    constant xlRound : integer := 2;
53
    constant xlRoundBanker : integer := 3;
54
    constant xlAddMode : integer := 1;
55
    constant xlSubMode : integer := 2;
56
    attribute black_box : boolean;
57
    attribute syn_black_box : boolean;
58
    attribute fpga_dont_touch: string;
59
    attribute box_type :  string;
60
    attribute keep : string;
61
    attribute syn_keep : boolean;
62
    function std_logic_vector_to_unsigned(inp : std_logic_vector) return unsigned;
63
    function unsigned_to_std_logic_vector(inp : unsigned) return std_logic_vector;
64
    function std_logic_vector_to_signed(inp : std_logic_vector) return signed;
65
    function signed_to_std_logic_vector(inp : signed) return std_logic_vector;
66
    function unsigned_to_signed(inp : unsigned) return signed;
67
    function signed_to_unsigned(inp : signed) return unsigned;
68
    function pos(inp : std_logic_vector; arith : INTEGER) return boolean;
69
    function all_same(inp: std_logic_vector) return boolean;
70
    function all_zeros(inp: std_logic_vector) return boolean;
71
    function is_point_five(inp: std_logic_vector) return boolean;
72
    function all_ones(inp: std_logic_vector) return boolean;
73
    function convert_type (inp : std_logic_vector; old_width, old_bin_pt,
74
                           old_arith, new_width, new_bin_pt, new_arith,
75
                           quantization, overflow : INTEGER)
76
        return std_logic_vector;
77
    function cast (inp : std_logic_vector; old_bin_pt,
78
                   new_width, new_bin_pt, new_arith : INTEGER)
79
        return std_logic_vector;
80
    function shift_division_result(quotient, fraction: std_logic_vector;
81
                                   fraction_width, shift_value, shift_dir: INTEGER)
82
        return std_logic_vector;
83
    function shift_op (inp: std_logic_vector;
84
                       result_width, shift_value, shift_dir: INTEGER)
85
        return std_logic_vector;
86
    function vec_slice (inp : std_logic_vector; upper, lower : INTEGER)
87
        return std_logic_vector;
88
    function s2u_slice (inp : signed; upper, lower : INTEGER)
89
        return unsigned;
90
    function u2u_slice (inp : unsigned; upper, lower : INTEGER)
91
        return unsigned;
92
    function s2s_cast (inp : signed; old_bin_pt,
93
                   new_width, new_bin_pt : INTEGER)
94
        return signed;
95
    function u2s_cast (inp : unsigned; old_bin_pt,
96
                   new_width, new_bin_pt : INTEGER)
97
        return signed;
98
    function s2u_cast (inp : signed; old_bin_pt,
99
                   new_width, new_bin_pt : INTEGER)
100
        return unsigned;
101
    function u2u_cast (inp : unsigned; old_bin_pt,
102
                   new_width, new_bin_pt : INTEGER)
103
        return unsigned;
104
    function u2v_cast (inp : unsigned; old_bin_pt,
105
                   new_width, new_bin_pt : INTEGER)
106
        return std_logic_vector;
107
    function s2v_cast (inp : signed; old_bin_pt,
108
                   new_width, new_bin_pt : INTEGER)
109
        return std_logic_vector;
110
    function trunc (inp : std_logic_vector; old_width, old_bin_pt, old_arith,
111
                    new_width, new_bin_pt, new_arith : INTEGER)
112
        return std_logic_vector;
113
    function round_towards_inf (inp : std_logic_vector; old_width, old_bin_pt,
114
                                old_arith, new_width, new_bin_pt,
115
                                new_arith : INTEGER) return std_logic_vector;
116
    function round_towards_even (inp : std_logic_vector; old_width, old_bin_pt,
117
                                old_arith, new_width, new_bin_pt,
118
                                new_arith : INTEGER) return std_logic_vector;
119
    function max_signed(width : INTEGER) return std_logic_vector;
120
    function min_signed(width : INTEGER) return std_logic_vector;
121
    function saturation_arith(inp:  std_logic_vector;  old_width, old_bin_pt,
122
                              old_arith, new_width, new_bin_pt, new_arith
123
                              : INTEGER) return std_logic_vector;
124
    function wrap_arith(inp:  std_logic_vector;  old_width, old_bin_pt,
125
                        old_arith, new_width, new_bin_pt, new_arith : INTEGER)
126
                        return std_logic_vector;
127
    function fractional_bits(a_bin_pt, b_bin_pt: INTEGER) return INTEGER;
128
    function integer_bits(a_width, a_bin_pt, b_width, b_bin_pt: INTEGER)
129
        return INTEGER;
130
    function sign_ext(inp : std_logic_vector; new_width : INTEGER)
131
        return std_logic_vector;
132
    function zero_ext(inp : std_logic_vector; new_width : INTEGER)
133
        return std_logic_vector;
134
    function zero_ext(inp : std_logic; new_width : INTEGER)
135
        return std_logic_vector;
136
    function extend_MSB(inp : std_logic_vector; new_width, arith : INTEGER)
137
        return std_logic_vector;
138
    function align_input(inp : std_logic_vector; old_width, delta, new_arith,
139
                          new_width: INTEGER)
140
        return std_logic_vector;
141
    function pad_LSB(inp : std_logic_vector; new_width: integer)
142
        return std_logic_vector;
143
    function pad_LSB(inp : std_logic_vector; new_width, arith : integer)
144
        return std_logic_vector;
145
    function max(L, R: INTEGER) return INTEGER;
146
    function min(L, R: INTEGER) return INTEGER;
147
    function "="(left,right: STRING) return boolean;
148
    function boolean_to_signed (inp : boolean; width: integer)
149
        return signed;
150
    function boolean_to_unsigned (inp : boolean; width: integer)
151
        return unsigned;
152
    function boolean_to_vector (inp : boolean)
153
        return std_logic_vector;
154
    function std_logic_to_vector (inp : std_logic)
155
        return std_logic_vector;
156
    function integer_to_std_logic_vector (inp : integer;  width, arith : integer)
157
        return std_logic_vector;
158
    function std_logic_vector_to_integer (inp : std_logic_vector;  arith : integer)
159
        return integer;
160
    function std_logic_to_integer(constant inp : std_logic := '0')
161
        return integer;
162
    function bin_string_element_to_std_logic_vector (inp : string;  width, index : integer)
163
        return std_logic_vector;
164
    function bin_string_to_std_logic_vector (inp : string)
165
        return std_logic_vector;
166
    function hex_string_to_std_logic_vector (inp : string; width : integer)
167
        return std_logic_vector;
168
    function makeZeroBinStr (width : integer) return STRING;
169
    function and_reduce(inp: std_logic_vector) return std_logic;
170
    -- synopsys translate_off
171
    function is_binary_string_invalid (inp : string)
172
        return boolean;
173
    function is_binary_string_undefined (inp : string)
174
        return boolean;
175
    function is_XorU(inp : std_logic_vector)
176
        return boolean;
177
    function to_real(inp : std_logic_vector; bin_pt : integer; arith : integer)
178
        return real;
179
    function std_logic_to_real(inp : std_logic; bin_pt : integer; arith : integer)
180
        return real;
181
    function real_to_std_logic_vector (inp : real;  width, bin_pt, arith : integer)
182
        return std_logic_vector;
183
    function real_string_to_std_logic_vector (inp : string;  width, bin_pt, arith : integer)
184
        return std_logic_vector;
185
    constant display_precision : integer := 20;
186
    function real_to_string (inp : real) return string;
187
    function valid_bin_string(inp : string) return boolean;
188
    function std_logic_vector_to_bin_string(inp : std_logic_vector) return string;
189
    function std_logic_to_bin_string(inp : std_logic) return string;
190
    function std_logic_vector_to_bin_string_w_point(inp : std_logic_vector; bin_pt : integer)
191
        return string;
192
    function real_to_bin_string(inp : real;  width, bin_pt, arith : integer)
193
        return string;
194
    type stdlogic_to_char_t is array(std_logic) of character;
195
    constant to_char : stdlogic_to_char_t := (
196
        'U' => 'U',
197
        'X' => 'X',
198
        '0' => '0',
199
        '1' => '1',
200
        'Z' => 'Z',
201
        'W' => 'W',
202
        'L' => 'L',
203
        'H' => 'H',
204
        '-' => '-');
205
    -- synopsys translate_on
206
end conv_pkg;
207
package body conv_pkg is
208
    function std_logic_vector_to_unsigned(inp : std_logic_vector)
209
        return unsigned
210
    is
211
    begin
212
        return unsigned (inp);
213
    end;
214
    function unsigned_to_std_logic_vector(inp : unsigned)
215
        return std_logic_vector
216
    is
217
    begin
218
        return std_logic_vector(inp);
219
    end;
220
    function std_logic_vector_to_signed(inp : std_logic_vector)
221
        return signed
222
    is
223
    begin
224
        return  signed (inp);
225
    end;
226
    function signed_to_std_logic_vector(inp : signed)
227
        return std_logic_vector
228
    is
229
    begin
230
        return std_logic_vector(inp);
231
    end;
232
    function unsigned_to_signed (inp : unsigned)
233
        return signed
234
    is
235
    begin
236
        return signed(std_logic_vector(inp));
237
    end;
238
    function signed_to_unsigned (inp : signed)
239
        return unsigned
240
    is
241
    begin
242
        return unsigned(std_logic_vector(inp));
243
    end;
244
    function pos(inp : std_logic_vector; arith : INTEGER)
245
        return boolean
246
    is
247
        constant width : integer := inp'length;
248
        variable vec : std_logic_vector(width-1 downto 0);
249
    begin
250
        vec := inp;
251
        if arith = xlUnsigned then
252
            return true;
253
        else
254
            if vec(width-1) = '0' then
255
                return true;
256
            else
257
                return false;
258
            end if;
259
        end if;
260
        return true;
261
    end;
262
    function max_signed(width : INTEGER)
263
        return std_logic_vector
264
    is
265
        variable ones : std_logic_vector(width-2 downto 0);
266
        variable result : std_logic_vector(width-1 downto 0);
267
    begin
268
        ones := (others => '1');
269
        result(width-1) := '0';
270
        result(width-2 downto 0) := ones;
271
        return result;
272
    end;
273
    function min_signed(width : INTEGER)
274
        return std_logic_vector
275
    is
276
        variable zeros : std_logic_vector(width-2 downto 0);
277
        variable result : std_logic_vector(width-1 downto 0);
278
    begin
279
        zeros := (others => '0');
280
        result(width-1) := '1';
281
        result(width-2 downto 0) := zeros;
282
        return result;
283
    end;
284
    function and_reduce(inp: std_logic_vector) return std_logic
285
    is
286
        variable result: std_logic;
287
        constant width : integer := inp'length;
288
        variable vec : std_logic_vector(width-1 downto 0);
289
    begin
290
        vec := inp;
291
        result := vec(0);
292
        if width > 1 then
293
            for i in 1 to width-1 loop
294
                result := result and vec(i);
295
            end loop;
296
        end if;
297
        return result;
298
    end;
299
    function all_same(inp: std_logic_vector) return boolean
300
    is
301
        variable result: boolean;
302
        constant width : integer := inp'length;
303
        variable vec : std_logic_vector(width-1 downto 0);
304
    begin
305
        vec := inp;
306
        result := true;
307
        if width > 0 then
308
            for i in 1 to width-1 loop
309
                if vec(i) /= vec(0) then
310
                    result := false;
311
                end if;
312
            end loop;
313
        end if;
314
        return result;
315
    end;
316
    function all_zeros(inp: std_logic_vector)
317
        return boolean
318
    is
319
        constant width : integer := inp'length;
320
        variable vec : std_logic_vector(width-1 downto 0);
321
        variable zero : std_logic_vector(width-1 downto 0);
322
        variable result : boolean;
323
    begin
324
        zero := (others => '0');
325
        vec := inp;
326
        -- synopsys translate_off
327
        if (is_XorU(vec)) then
328
            return false;
329
        end if;
330
         -- synopsys translate_on
331
        if (std_logic_vector_to_unsigned(vec) = std_logic_vector_to_unsigned(zero)) then
332
            result := true;
333
        else
334
            result := false;
335
        end if;
336
        return result;
337
    end;
338
    function is_point_five(inp: std_logic_vector)
339
        return boolean
340
    is
341
        constant width : integer := inp'length;
342
        variable vec : std_logic_vector(width-1 downto 0);
343
        variable result : boolean;
344
    begin
345
        vec := inp;
346
        -- synopsys translate_off
347
        if (is_XorU(vec)) then
348
            return false;
349
        end if;
350
         -- synopsys translate_on
351
        if (width > 1) then
352
           if ((vec(width-1) = '1') and (all_zeros(vec(width-2 downto 0)) = true)) then
353
               result := true;
354
           else
355
               result := false;
356
           end if;
357
        else
358
           if (vec(width-1) = '1') then
359
               result := true;
360
           else
361
               result := false;
362
           end if;
363
        end if;
364
        return result;
365
    end;
366
    function all_ones(inp: std_logic_vector)
367
        return boolean
368
    is
369
        constant width : integer := inp'length;
370
        variable vec : std_logic_vector(width-1 downto 0);
371
        variable one : std_logic_vector(width-1 downto 0);
372
        variable result : boolean;
373
    begin
374
        one := (others => '1');
375
        vec := inp;
376
        -- synopsys translate_off
377
        if (is_XorU(vec)) then
378
            return false;
379
        end if;
380
         -- synopsys translate_on
381
        if (std_logic_vector_to_unsigned(vec) = std_logic_vector_to_unsigned(one)) then
382
            result := true;
383
        else
384
            result := false;
385
        end if;
386
        return result;
387
    end;
388
    function full_precision_num_width(quantization, overflow, old_width,
389
                                      old_bin_pt, old_arith,
390
                                      new_width, new_bin_pt, new_arith : INTEGER)
391
        return integer
392
    is
393
        variable result : integer;
394
    begin
395
        result := old_width + 2;
396
        return result;
397
    end;
398
    function quantized_num_width(quantization, overflow, old_width, old_bin_pt,
399
                                 old_arith, new_width, new_bin_pt, new_arith
400
                                 : INTEGER)
401
        return integer
402
    is
403
        variable right_of_dp, left_of_dp, result : integer;
404
    begin
405
        right_of_dp := max(new_bin_pt, old_bin_pt);
406
        left_of_dp := max((new_width - new_bin_pt), (old_width - old_bin_pt));
407
        result := (old_width + 2) + (new_bin_pt - old_bin_pt);
408
        return result;
409
    end;
410
    function convert_type (inp : std_logic_vector; old_width, old_bin_pt,
411
                           old_arith, new_width, new_bin_pt, new_arith,
412
                           quantization, overflow : INTEGER)
413
        return std_logic_vector
414
    is
415
        constant fp_width : integer :=
416
            full_precision_num_width(quantization, overflow, old_width,
417
                                     old_bin_pt, old_arith, new_width,
418
                                     new_bin_pt, new_arith);
419
        constant fp_bin_pt : integer := old_bin_pt;
420
        constant fp_arith : integer := old_arith;
421
        variable full_precision_result : std_logic_vector(fp_width-1 downto 0);
422
        constant q_width : integer :=
423
            quantized_num_width(quantization, overflow, old_width, old_bin_pt,
424
                                old_arith, new_width, new_bin_pt, new_arith);
425
        constant q_bin_pt : integer := new_bin_pt;
426
        constant q_arith : integer := old_arith;
427
        variable quantized_result : std_logic_vector(q_width-1 downto 0);
428
        variable result : std_logic_vector(new_width-1 downto 0);
429
    begin
430
        result := (others => '0');
431
        full_precision_result := cast(inp, old_bin_pt, fp_width, fp_bin_pt,
432
                                      fp_arith);
433
        if (quantization = xlRound) then
434
            quantized_result := round_towards_inf(full_precision_result,
435
                                                  fp_width, fp_bin_pt,
436
                                                  fp_arith, q_width, q_bin_pt,
437
                                                  q_arith);
438
        elsif (quantization = xlRoundBanker) then
439
            quantized_result := round_towards_even(full_precision_result,
440
                                                  fp_width, fp_bin_pt,
441
                                                  fp_arith, q_width, q_bin_pt,
442
                                                  q_arith);
443
        else
444
            quantized_result := trunc(full_precision_result, fp_width, fp_bin_pt,
445
                                      fp_arith, q_width, q_bin_pt, q_arith);
446
        end if;
447
        if (overflow = xlSaturate) then
448
            result := saturation_arith(quantized_result, q_width, q_bin_pt,
449
                                       q_arith, new_width, new_bin_pt, new_arith);
450
        else
451
             result := wrap_arith(quantized_result, q_width, q_bin_pt, q_arith,
452
                                  new_width, new_bin_pt, new_arith);
453
        end if;
454
        return result;
455
    end;
456
    function cast (inp : std_logic_vector; old_bin_pt, new_width,
457
                   new_bin_pt, new_arith : INTEGER)
458
        return std_logic_vector
459
    is
460
        constant old_width : integer := inp'length;
461
        constant left_of_dp : integer := (new_width - new_bin_pt)
462
                                         - (old_width - old_bin_pt);
463
        constant right_of_dp : integer := (new_bin_pt - old_bin_pt);
464
        variable vec : std_logic_vector(old_width-1 downto 0);
465
        variable result : std_logic_vector(new_width-1 downto 0);
466
        variable j   : integer;
467
    begin
468
        vec := inp;
469
        for i in new_width-1 downto 0 loop
470
            j := i - right_of_dp;
471
            if ( j > old_width-1) then
472
                if (new_arith = xlUnsigned) then
473
                    result(i) := '0';
474
                else
475
                    result(i) := vec(old_width-1);
476
                end if;
477
            elsif ( j >= 0) then
478
                result(i) := vec(j);
479
            else
480
                result(i) := '0';
481
            end if;
482
        end loop;
483
        return result;
484
    end;
485
    function shift_division_result(quotient, fraction: std_logic_vector;
486
                                   fraction_width, shift_value, shift_dir: INTEGER)
487
        return std_logic_vector
488
    is
489
        constant q_width : integer := quotient'length;
490
        constant f_width : integer := fraction'length;
491
        constant vec_MSB : integer := q_width+f_width-1;
492
        constant result_MSB : integer := q_width+fraction_width-1;
493
        constant result_LSB : integer := vec_MSB-result_MSB;
494
        variable vec : std_logic_vector(vec_MSB downto 0);
495
        variable result : std_logic_vector(result_MSB downto 0);
496
    begin
497
        vec := ( quotient & fraction );
498
        if shift_dir = 1 then
499
            for i in vec_MSB downto 0 loop
500
                if (i < shift_value) then
501
                     vec(i) := '0';
502
                else
503
                    vec(i) := vec(i-shift_value);
504
                end if;
505
            end loop;
506
        else
507
            for i in 0 to vec_MSB loop
508
                if (i > vec_MSB-shift_value) then
509
                    vec(i) := vec(vec_MSB);
510
                else
511
                    vec(i) := vec(i+shift_value);
512
                end if;
513
            end loop;
514
        end if;
515
        result := vec(vec_MSB downto result_LSB);
516
        return result;
517
    end;
518
    function shift_op (inp: std_logic_vector;
519
                       result_width, shift_value, shift_dir: INTEGER)
520
        return std_logic_vector
521
    is
522
        constant inp_width : integer := inp'length;
523
        constant vec_MSB : integer := inp_width-1;
524
        constant result_MSB : integer := result_width-1;
525
        constant result_LSB : integer := vec_MSB-result_MSB;
526
        variable vec : std_logic_vector(vec_MSB downto 0);
527
        variable result : std_logic_vector(result_MSB downto 0);
528
    begin
529
        vec := inp;
530
        if shift_dir = 1 then
531
            for i in vec_MSB downto 0 loop
532
                if (i < shift_value) then
533
                     vec(i) := '0';
534
                else
535
                    vec(i) := vec(i-shift_value);
536
                end if;
537
            end loop;
538
        else
539
            for i in 0 to vec_MSB loop
540
                if (i > vec_MSB-shift_value) then
541
                    vec(i) := vec(vec_MSB);
542
                else
543
                    vec(i) := vec(i+shift_value);
544
                end if;
545
            end loop;
546
        end if;
547
        result := vec(vec_MSB downto result_LSB);
548
        return result;
549
    end;
550
    function vec_slice (inp : std_logic_vector; upper, lower : INTEGER)
551
      return std_logic_vector
552
    is
553
    begin
554
        return inp(upper downto lower);
555
    end;
556
    function s2u_slice (inp : signed; upper, lower : INTEGER)
557
      return unsigned
558
    is
559
    begin
560
        return unsigned(vec_slice(std_logic_vector(inp), upper, lower));
561
    end;
562
    function u2u_slice (inp : unsigned; upper, lower : INTEGER)
563
      return unsigned
564
    is
565
    begin
566
        return unsigned(vec_slice(std_logic_vector(inp), upper, lower));
567
    end;
568
    function s2s_cast (inp : signed; old_bin_pt, new_width, new_bin_pt : INTEGER)
569
        return signed
570
    is
571
    begin
572
        return signed(cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt, xlSigned));
573
    end;
574
    function s2u_cast (inp : signed; old_bin_pt, new_width,
575
                   new_bin_pt : INTEGER)
576
        return unsigned
577
    is
578
    begin
579
        return unsigned(cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt, xlSigned));
580
    end;
581
    function u2s_cast (inp : unsigned; old_bin_pt, new_width,
582
                   new_bin_pt : INTEGER)
583
        return signed
584
    is
585
    begin
586
        return signed(cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt, xlUnsigned));
587
    end;
588
    function u2u_cast (inp : unsigned; old_bin_pt, new_width,
589
                   new_bin_pt : INTEGER)
590
        return unsigned
591
    is
592
    begin
593
        return unsigned(cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt, xlUnsigned));
594
    end;
595
    function u2v_cast (inp : unsigned; old_bin_pt, new_width,
596
                   new_bin_pt : INTEGER)
597
        return std_logic_vector
598
    is
599
    begin
600
        return cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt, xlUnsigned);
601
    end;
602
    function s2v_cast (inp : signed; old_bin_pt, new_width,
603
                   new_bin_pt : INTEGER)
604
        return std_logic_vector
605
    is
606
    begin
607
        return cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt, xlSigned);
608
    end;
609
    function boolean_to_signed (inp : boolean; width : integer)
610
        return signed
611
    is
612
        variable result : signed(width - 1 downto 0);
613
    begin
614
        result := (others => '0');
615
        if inp then
616
          result(0) := '1';
617
        else
618
          result(0) := '0';
619
        end if;
620
        return result;
621
    end;
622
    function boolean_to_unsigned (inp : boolean; width : integer)
623
        return unsigned
624
    is
625
        variable result : unsigned(width - 1 downto 0);
626
    begin
627
        result := (others => '0');
628
        if inp then
629
          result(0) := '1';
630
        else
631
          result(0) := '0';
632
        end if;
633
        return result;
634
    end;
635
    function boolean_to_vector (inp : boolean)
636
        return std_logic_vector
637
    is
638
        variable result : std_logic_vector(1 - 1 downto 0);
639
    begin
640
        result := (others => '0');
641
        if inp then
642
          result(0) := '1';
643
        else
644
          result(0) := '0';
645
        end if;
646
        return result;
647
    end;
648
    function std_logic_to_vector (inp : std_logic)
649
        return std_logic_vector
650
    is
651
        variable result : std_logic_vector(1 - 1 downto 0);
652
    begin
653
        result(0) := inp;
654
        return result;
655
    end;
656
    function trunc (inp : std_logic_vector; old_width, old_bin_pt, old_arith,
657
                                new_width, new_bin_pt, new_arith : INTEGER)
658
        return std_logic_vector
659
    is
660
        constant right_of_dp : integer := (old_bin_pt - new_bin_pt);
661
        variable vec : std_logic_vector(old_width-1 downto 0);
662
        variable result : std_logic_vector(new_width-1 downto 0);
663
    begin
664
        vec := inp;
665
        if right_of_dp >= 0 then
666
            if new_arith = xlUnsigned then
667
                result := zero_ext(vec(old_width-1 downto right_of_dp), new_width);
668
            else
669
                result := sign_ext(vec(old_width-1 downto right_of_dp), new_width);
670
            end if;
671
        else
672
            if new_arith = xlUnsigned then
673
                result := zero_ext(pad_LSB(vec, old_width +
674
                                           abs(right_of_dp)), new_width);
675
            else
676
                result := sign_ext(pad_LSB(vec, old_width +
677
                                           abs(right_of_dp)), new_width);
678
            end if;
679
        end if;
680
        return result;
681
    end;
682
    function round_towards_inf (inp : std_logic_vector; old_width, old_bin_pt,
683
                                old_arith, new_width, new_bin_pt, new_arith
684
                                : INTEGER)
685
        return std_logic_vector
686
    is
687
        constant right_of_dp : integer := (old_bin_pt - new_bin_pt);
688
        constant expected_new_width : integer :=  old_width - right_of_dp  + 1;
689
        variable vec : std_logic_vector(old_width-1 downto 0);
690
        variable one_or_zero : std_logic_vector(new_width-1 downto 0);
691
        variable truncated_val : std_logic_vector(new_width-1 downto 0);
692
        variable result : std_logic_vector(new_width-1 downto 0);
693
    begin
694
        vec := inp;
695
        if right_of_dp >= 0 then
696
            if new_arith = xlUnsigned then
697
                truncated_val := zero_ext(vec(old_width-1 downto right_of_dp),
698
                                          new_width);
699
            else
700
                truncated_val := sign_ext(vec(old_width-1 downto right_of_dp),
701
                                          new_width);
702
            end if;
703
        else
704
            if new_arith = xlUnsigned then
705
                truncated_val := zero_ext(pad_LSB(vec, old_width +
706
                                                  abs(right_of_dp)), new_width);
707
            else
708
                truncated_val := sign_ext(pad_LSB(vec, old_width +
709
                                                  abs(right_of_dp)), new_width);
710
            end if;
711
        end if;
712
        one_or_zero := (others => '0');
713
        if (new_arith = xlSigned) then
714
            if (vec(old_width-1) = '0') then
715
                one_or_zero(0) := '1';
716
            end if;
717
            if (right_of_dp >= 2) and (right_of_dp <= old_width) then
718
                if (all_zeros(vec(right_of_dp-2 downto 0)) = false) then
719
                    one_or_zero(0) := '1';
720
                end if;
721
            end if;
722
            if (right_of_dp >= 1) and (right_of_dp <= old_width) then
723
                if vec(right_of_dp-1) = '0' then
724
                    one_or_zero(0) := '0';
725
                end if;
726
            else
727
                one_or_zero(0) := '0';
728
            end if;
729
        else
730
            if (right_of_dp >= 1) and (right_of_dp <= old_width) then
731
                one_or_zero(0) :=  vec(right_of_dp-1);
732
            end if;
733
        end if;
734
        if new_arith = xlSigned then
735
            result := signed_to_std_logic_vector(std_logic_vector_to_signed(truncated_val) +
736
                                                 std_logic_vector_to_signed(one_or_zero));
737
        else
738
            result := unsigned_to_std_logic_vector(std_logic_vector_to_unsigned(truncated_val) +
739
                                                  std_logic_vector_to_unsigned(one_or_zero));
740
        end if;
741
        return result;
742
    end;
743
    function round_towards_even (inp : std_logic_vector; old_width, old_bin_pt,
744
                                old_arith, new_width, new_bin_pt, new_arith
745
                                : INTEGER)
746
        return std_logic_vector
747
    is
748
        constant right_of_dp : integer := (old_bin_pt - new_bin_pt);
749
        constant expected_new_width : integer :=  old_width - right_of_dp  + 1;
750
        variable vec : std_logic_vector(old_width-1 downto 0);
751
        variable one_or_zero : std_logic_vector(new_width-1 downto 0);
752
        variable truncated_val : std_logic_vector(new_width-1 downto 0);
753
        variable result : std_logic_vector(new_width-1 downto 0);
754
    begin
755
        vec := inp;
756
        if right_of_dp >= 0 then
757
            if new_arith = xlUnsigned then
758
                truncated_val := zero_ext(vec(old_width-1 downto right_of_dp),
759
                                          new_width);
760
            else
761
                truncated_val := sign_ext(vec(old_width-1 downto right_of_dp),
762
                                          new_width);
763
            end if;
764
        else
765
            if new_arith = xlUnsigned then
766
                truncated_val := zero_ext(pad_LSB(vec, old_width +
767
                                                  abs(right_of_dp)), new_width);
768
            else
769
                truncated_val := sign_ext(pad_LSB(vec, old_width +
770
                                                  abs(right_of_dp)), new_width);
771
            end if;
772
        end if;
773
        one_or_zero := (others => '0');
774
        if (right_of_dp >= 1) and (right_of_dp <= old_width) then
775
            if (is_point_five(vec(right_of_dp-1 downto 0)) = false) then
776
                one_or_zero(0) :=  vec(right_of_dp-1);
777
            else
778
                one_or_zero(0) :=  vec(right_of_dp);
779
            end if;
780
        end if;
781
        if new_arith = xlSigned then
782
            result := signed_to_std_logic_vector(std_logic_vector_to_signed(truncated_val) +
783
                                                 std_logic_vector_to_signed(one_or_zero));
784
        else
785
            result := unsigned_to_std_logic_vector(std_logic_vector_to_unsigned(truncated_val) +
786
                                                  std_logic_vector_to_unsigned(one_or_zero));
787
        end if;
788
        return result;
789
    end;
790
    function saturation_arith(inp:  std_logic_vector;  old_width, old_bin_pt,
791
                              old_arith, new_width, new_bin_pt, new_arith
792
                              : INTEGER)
793
        return std_logic_vector
794
    is
795
        constant left_of_dp : integer := (old_width - old_bin_pt) -
796
                                         (new_width - new_bin_pt);
797
        variable vec : std_logic_vector(old_width-1 downto 0);
798
        variable result : std_logic_vector(new_width-1 downto 0);
799
        variable overflow : boolean;
800
    begin
801
        vec := inp;
802
        overflow := true;
803
        result := (others => '0');
804
        if (new_width >= old_width) then
805
            overflow := false;
806
        end if;
807
        if ((old_arith = xlSigned and new_arith = xlSigned) and (old_width > new_width)) then
808
            if all_same(vec(old_width-1 downto new_width-1)) then
809
                overflow := false;
810
            end if;
811
        end if;
812
        if (old_arith = xlSigned and new_arith = xlUnsigned) then
813
            if (old_width > new_width) then
814
                if all_zeros(vec(old_width-1 downto new_width)) then
815
                    overflow := false;
816
                end if;
817
            else
818
                if (old_width = new_width) then
819
                    if (vec(new_width-1) = '0') then
820
                        overflow := false;
821
                    end if;
822
                end if;
823
            end if;
824
        end if;
825
        if (old_arith = xlUnsigned and new_arith = xlUnsigned) then
826
            if (old_width > new_width) then
827
                if all_zeros(vec(old_width-1 downto new_width)) then
828
                    overflow := false;
829
                end if;
830
            else
831
                if (old_width = new_width) then
832
                    overflow := false;
833
                end if;
834
            end if;
835
        end if;
836
        if ((old_arith = xlUnsigned and new_arith = xlSigned) and (old_width > new_width)) then
837
            if all_same(vec(old_width-1 downto new_width-1)) then
838
                overflow := false;
839
            end if;
840
        end if;
841
        if overflow then
842
            if new_arith = xlSigned then
843
                if vec(old_width-1) = '0' then
844
                    result := max_signed(new_width);
845
                else
846
                    result := min_signed(new_width);
847
                end if;
848
            else
849
                if ((old_arith = xlSigned) and vec(old_width-1) = '1') then
850
                    result := (others => '0');
851
                else
852
                    result := (others => '1');
853
                end if;
854
            end if;
855
        else
856
            if (old_arith = xlSigned) and (new_arith = xlUnsigned) then
857
                if (vec(old_width-1) = '1') then
858
                    vec := (others => '0');
859
                end if;
860
            end if;
861
            if new_width <= old_width then
862
                result := vec(new_width-1 downto 0);
863
            else
864
                if new_arith = xlUnsigned then
865
                    result := zero_ext(vec, new_width);
866
                else
867
                    result := sign_ext(vec, new_width);
868
                end if;
869
            end if;
870
        end if;
871
        return result;
872
    end;
873
   function wrap_arith(inp:  std_logic_vector;  old_width, old_bin_pt,
874
                       old_arith, new_width, new_bin_pt, new_arith : INTEGER)
875
        return std_logic_vector
876
    is
877
        variable result : std_logic_vector(new_width-1 downto 0);
878
        variable result_arith : integer;
879
    begin
880
        if (old_arith = xlSigned) and (new_arith = xlUnsigned) then
881
            result_arith := xlSigned;
882
        end if;
883
        result := cast(inp, old_bin_pt, new_width, new_bin_pt, result_arith);
884
        return result;
885
    end;
886
    function fractional_bits(a_bin_pt, b_bin_pt: INTEGER) return INTEGER is
887
    begin
888
        return max(a_bin_pt, b_bin_pt);
889
    end;
890
    function integer_bits(a_width, a_bin_pt, b_width, b_bin_pt: INTEGER)
891
        return INTEGER is
892
    begin
893
        return  max(a_width - a_bin_pt, b_width - b_bin_pt);
894
    end;
895
    function pad_LSB(inp : std_logic_vector; new_width: integer)
896
        return STD_LOGIC_VECTOR
897
    is
898
        constant orig_width : integer := inp'length;
899
        variable vec : std_logic_vector(orig_width-1 downto 0);
900
        variable result : std_logic_vector(new_width-1 downto 0);
901
        variable pos : integer;
902
        constant pad_pos : integer := new_width - orig_width - 1;
903
    begin
904
        vec := inp;
905
        pos := new_width-1;
906
        if (new_width >= orig_width) then
907
            for i in orig_width-1 downto 0 loop
908
                result(pos) := vec(i);
909
                pos := pos - 1;
910
            end loop;
911
            if pad_pos >= 0 then
912
                for i in pad_pos downto 0 loop
913
                    result(i) := '0';
914
                end loop;
915
            end if;
916
        end if;
917
        return result;
918
    end;
919
    function sign_ext(inp : std_logic_vector; new_width : INTEGER)
920
        return std_logic_vector
921
    is
922
        constant old_width : integer := inp'length;
923
        variable vec : std_logic_vector(old_width-1 downto 0);
924
        variable result : std_logic_vector(new_width-1 downto 0);
925
    begin
926
        vec := inp;
927
        if new_width >= old_width then
928
            result(old_width-1 downto 0) := vec;
929
            if new_width-1 >= old_width then
930
                for i in new_width-1 downto old_width loop
931
                    result(i) := vec(old_width-1);
932
                end loop;
933
            end if;
934
        else
935
            result(new_width-1 downto 0) := vec(new_width-1 downto 0);
936
        end if;
937
        return result;
938
    end;
939
    function zero_ext(inp : std_logic_vector; new_width : INTEGER)
940
        return std_logic_vector
941
    is
942
        constant old_width : integer := inp'length;
943
        variable vec : std_logic_vector(old_width-1 downto 0);
944
        variable result : std_logic_vector(new_width-1 downto 0);
945
    begin
946
        vec := inp;
947
        if new_width >= old_width then
948
            result(old_width-1 downto 0) := vec;
949
            if new_width-1 >= old_width then
950
                for i in new_width-1 downto old_width loop
951
                    result(i) := '0';
952
                end loop;
953
            end if;
954
        else
955
            result(new_width-1 downto 0) := vec(new_width-1 downto 0);
956
        end if;
957
        return result;
958
    end;
959
    function zero_ext(inp : std_logic; new_width : INTEGER)
960
        return std_logic_vector
961
    is
962
        variable result : std_logic_vector(new_width-1 downto 0);
963
    begin
964
        result(0) := inp;
965
        for i in new_width-1 downto 1 loop
966
            result(i) := '0';
967
        end loop;
968
        return result;
969
    end;
970
    function extend_MSB(inp : std_logic_vector; new_width, arith : INTEGER)
971
        return std_logic_vector
972
    is
973
        constant orig_width : integer := inp'length;
974
        variable vec : std_logic_vector(orig_width-1 downto 0);
975
        variable result : std_logic_vector(new_width-1 downto 0);
976
    begin
977
        vec := inp;
978
        if arith = xlUnsigned then
979
            result := zero_ext(vec, new_width);
980
        else
981
            result := sign_ext(vec, new_width);
982
        end if;
983
        return result;
984
    end;
985
    function pad_LSB(inp : std_logic_vector; new_width, arith: integer)
986
        return STD_LOGIC_VECTOR
987
    is
988
        constant orig_width : integer := inp'length;
989
        variable vec : std_logic_vector(orig_width-1 downto 0);
990
        variable result : std_logic_vector(new_width-1 downto 0);
991
        variable pos : integer;
992
    begin
993
        vec := inp;
994
        pos := new_width-1;
995
        if (arith = xlUnsigned) then
996
            result(pos) := '0';
997
            pos := pos - 1;
998
        else
999
            result(pos) := vec(orig_width-1);
1000
            pos := pos - 1;
1001
        end if;
1002
        if (new_width >= orig_width) then
1003
            for i in orig_width-1 downto 0 loop
1004
                result(pos) := vec(i);
1005
                pos := pos - 1;
1006
            end loop;
1007
            if pos >= 0 then
1008
                for i in pos downto 0 loop
1009
                    result(i) := '0';
1010
                end loop;
1011
            end if;
1012
        end if;
1013
        return result;
1014
    end;
1015
    function align_input(inp : std_logic_vector; old_width, delta, new_arith,
1016
                         new_width: INTEGER)
1017
        return std_logic_vector
1018
    is
1019
        variable vec : std_logic_vector(old_width-1 downto 0);
1020
        variable padded_inp : std_logic_vector((old_width + delta)-1  downto 0);
1021
        variable result : std_logic_vector(new_width-1 downto 0);
1022
    begin
1023
        vec := inp;
1024
        if delta > 0 then
1025
            padded_inp := pad_LSB(vec, old_width+delta);
1026
            result := extend_MSB(padded_inp, new_width, new_arith);
1027
        else
1028
            result := extend_MSB(vec, new_width, new_arith);
1029
        end if;
1030
        return result;
1031
    end;
1032
    function max(L, R: INTEGER) return INTEGER is
1033
    begin
1034
        if L > R then
1035
            return L;
1036
        else
1037
            return R;
1038
        end if;
1039
    end;
1040
    function min(L, R: INTEGER) return INTEGER is
1041
    begin
1042
        if L < R then
1043
            return L;
1044
        else
1045
            return R;
1046
        end if;
1047
    end;
1048
    function "="(left,right: STRING) return boolean is
1049
    begin
1050
        if (left'length /= right'length) then
1051
            return false;
1052
        else
1053
            test : for i in 1 to left'length loop
1054
                if left(i) /= right(i) then
1055
                    return false;
1056
                end if;
1057
            end loop test;
1058
            return true;
1059
        end if;
1060
    end;
1061
    -- synopsys translate_off
1062
    function is_binary_string_invalid (inp : string)
1063
        return boolean
1064
    is
1065
        variable vec : string(1 to inp'length);
1066
        variable result : boolean;
1067
    begin
1068
        vec := inp;
1069
        result := false;
1070
        for i in 1 to vec'length loop
1071
            if ( vec(i) = 'X' ) then
1072
                result := true;
1073
            end if;
1074
        end loop;
1075
        return result;
1076
    end;
1077
    function is_binary_string_undefined (inp : string)
1078
        return boolean
1079
    is
1080
        variable vec : string(1 to inp'length);
1081
        variable result : boolean;
1082
    begin
1083
        vec := inp;
1084
        result := false;
1085
        for i in 1 to vec'length loop
1086
            if ( vec(i) = 'U' ) then
1087
                result := true;
1088
            end if;
1089
        end loop;
1090
        return result;
1091
    end;
1092
    function is_XorU(inp : std_logic_vector)
1093
        return boolean
1094
    is
1095
        constant width : integer := inp'length;
1096
        variable vec : std_logic_vector(width-1 downto 0);
1097
        variable result : boolean;
1098
    begin
1099
        vec := inp;
1100
        result := false;
1101
        for i in 0 to width-1 loop
1102
            if (vec(i) = 'U') or (vec(i) = 'X') then
1103
                result := true;
1104
            end if;
1105
        end loop;
1106
        return result;
1107
    end;
1108
    function to_real(inp : std_logic_vector; bin_pt : integer; arith : integer)
1109
        return real
1110
    is
1111
        variable  vec : std_logic_vector(inp'length-1 downto 0);
1112
        variable result, shift_val, undefined_real : real;
1113
        variable neg_num : boolean;
1114
    begin
1115
        vec := inp;
1116
        result := 0.0;
1117
        neg_num := false;
1118
        if vec(inp'length-1) = '1' then
1119
            neg_num := true;
1120
        end if;
1121
        for i in 0 to inp'length-1 loop
1122
            if  vec(i) = 'U' or vec(i) = 'X' then
1123
                return undefined_real;
1124
            end if;
1125
            if arith = xlSigned then
1126
                if neg_num then
1127
                    if vec(i) = '0' then
1128
                        result := result + 2.0**i;
1129
                    end if;
1130
                else
1131
                    if vec(i) = '1' then
1132
                        result := result + 2.0**i;
1133
                    end if;
1134
                end if;
1135
            else
1136
                if vec(i) = '1' then
1137
                    result := result + 2.0**i;
1138
                end if;
1139
            end if;
1140
        end loop;
1141
        if arith = xlSigned then
1142
            if neg_num then
1143
                result := result + 1.0;
1144
                result := result * (-1.0);
1145
            end if;
1146
        end if;
1147
        shift_val := 2.0**(-1*bin_pt);
1148
        result := result * shift_val;
1149
        return result;
1150
    end;
1151
    function std_logic_to_real(inp : std_logic; bin_pt : integer; arith : integer)
1152
        return real
1153
    is
1154
        variable result : real := 0.0;
1155
    begin
1156
        if inp = '1' then
1157
            result := 1.0;
1158
        end if;
1159
        if arith = xlSigned then
1160
            assert false
1161
                report "It doesn't make sense to convert a 1 bit number to a signed real.";
1162
        end if;
1163
        return result;
1164
    end;
1165
    -- synopsys translate_on
1166
    function integer_to_std_logic_vector (inp : integer;  width, arith : integer)
1167
        return std_logic_vector
1168
    is
1169
        variable result : std_logic_vector(width-1 downto 0);
1170
        variable unsigned_val : unsigned(width-1 downto 0);
1171
        variable signed_val : signed(width-1 downto 0);
1172
    begin
1173
        if (arith = xlSigned) then
1174
            signed_val := to_signed(inp, width);
1175
            result := signed_to_std_logic_vector(signed_val);
1176
        else
1177
            unsigned_val := to_unsigned(inp, width);
1178
            result := unsigned_to_std_logic_vector(unsigned_val);
1179
        end if;
1180
        return result;
1181
    end;
1182
    function std_logic_vector_to_integer (inp : std_logic_vector;  arith : integer)
1183
        return integer
1184
    is
1185
        constant width : integer := inp'length;
1186
        variable unsigned_val : unsigned(width-1 downto 0);
1187
        variable signed_val : signed(width-1 downto 0);
1188
        variable result : integer;
1189
    begin
1190
        if (arith = xlSigned) then
1191
            signed_val := std_logic_vector_to_signed(inp);
1192
            result := to_integer(signed_val);
1193
        else
1194
            unsigned_val := std_logic_vector_to_unsigned(inp);
1195
            result := to_integer(unsigned_val);
1196
        end if;
1197
        return result;
1198
    end;
1199
    function std_logic_to_integer(constant inp : std_logic := '0')
1200
        return integer
1201
    is
1202
    begin
1203
        if inp = '1' then
1204
            return 1;
1205
        else
1206
            return 0;
1207
        end if;
1208
    end;
1209
    function makeZeroBinStr (width : integer) return STRING is
1210
        variable result : string(1 to width+3);
1211
    begin
1212
        result(1) := '0';
1213
        result(2) := 'b';
1214
        for i in 3 to width+2 loop
1215
            result(i) := '0';
1216
        end loop;
1217
        result(width+3) := '.';
1218
        return result;
1219
    end;
1220
    -- synopsys translate_off
1221
    function real_string_to_std_logic_vector (inp : string;  width, bin_pt, arith : integer)
1222
        return std_logic_vector
1223
    is
1224
        variable result : std_logic_vector(width-1 downto 0);
1225
    begin
1226
        result := (others => '0');
1227
        return result;
1228
    end;
1229
    function real_to_std_logic_vector (inp : real;  width, bin_pt, arith : integer)
1230
        return std_logic_vector
1231
    is
1232
        variable real_val : real;
1233
        variable int_val : integer;
1234
        variable result : std_logic_vector(width-1 downto 0) := (others => '0');
1235
        variable unsigned_val : unsigned(width-1 downto 0) := (others => '0');
1236
        variable signed_val : signed(width-1 downto 0) := (others => '0');
1237
    begin
1238
        real_val := inp;
1239
        int_val := integer(real_val * 2.0**(bin_pt));
1240
        if (arith = xlSigned) then
1241
            signed_val := to_signed(int_val, width);
1242
            result := signed_to_std_logic_vector(signed_val);
1243
        else
1244
            unsigned_val := to_unsigned(int_val, width);
1245
            result := unsigned_to_std_logic_vector(unsigned_val);
1246
        end if;
1247
        return result;
1248
    end;
1249
    -- synopsys translate_on
1250
    function valid_bin_string (inp : string)
1251
        return boolean
1252
    is
1253
        variable vec : string(1 to inp'length);
1254
    begin
1255
        vec := inp;
1256
        if (vec(1) = '0' and vec(2) = 'b') then
1257
            return true;
1258
        else
1259
            return false;
1260
        end if;
1261
    end;
1262
    function hex_string_to_std_logic_vector(inp: string; width : integer)
1263
        return std_logic_vector is
1264
        constant strlen       : integer := inp'LENGTH;
1265
        variable result       : std_logic_vector(width-1 downto 0);
1266
        variable bitval       : std_logic_vector((strlen*4)-1 downto 0);
1267
        variable posn         : integer;
1268
        variable ch           : character;
1269
        variable vec          : string(1 to strlen);
1270
    begin
1271
        vec := inp;
1272
        result := (others => '0');
1273
        posn := (strlen*4)-1;
1274
        for i in 1 to strlen loop
1275
            ch := vec(i);
1276
            case ch is
1277
                when '0' => bitval(posn downto posn-3) := "0000";
1278
                when '1' => bitval(posn downto posn-3) := "0001";
1279
                when '2' => bitval(posn downto posn-3) := "0010";
1280
                when '3' => bitval(posn downto posn-3) := "0011";
1281
                when '4' => bitval(posn downto posn-3) := "0100";
1282
                when '5' => bitval(posn downto posn-3) := "0101";
1283
                when '6' => bitval(posn downto posn-3) := "0110";
1284
                when '7' => bitval(posn downto posn-3) := "0111";
1285
                when '8' => bitval(posn downto posn-3) := "1000";
1286
                when '9' => bitval(posn downto posn-3) := "1001";
1287
                when 'A' | 'a' => bitval(posn downto posn-3) := "1010";
1288
                when 'B' | 'b' => bitval(posn downto posn-3) := "1011";
1289
                when 'C' | 'c' => bitval(posn downto posn-3) := "1100";
1290
                when 'D' | 'd' => bitval(posn downto posn-3) := "1101";
1291
                when 'E' | 'e' => bitval(posn downto posn-3) := "1110";
1292
                when 'F' | 'f' => bitval(posn downto posn-3) := "1111";
1293
                when others => bitval(posn downto posn-3) := "XXXX";
1294
                               -- synopsys translate_off
1295
                               ASSERT false
1296
                                   REPORT "Invalid hex value" SEVERITY ERROR;
1297
                               -- synopsys translate_on
1298
            end case;
1299
            posn := posn - 4;
1300
        end loop;
1301
        if (width <= strlen*4) then
1302
            result :=  bitval(width-1 downto 0);
1303
        else
1304
            result((strlen*4)-1 downto 0) := bitval;
1305
        end if;
1306
        return result;
1307
    end;
1308
    function bin_string_to_std_logic_vector (inp : string)
1309
        return std_logic_vector
1310
    is
1311
        variable pos : integer;
1312
        variable vec : string(1 to inp'length);
1313
        variable result : std_logic_vector(inp'length-1 downto 0);
1314
    begin
1315
        vec := inp;
1316
        pos := inp'length-1;
1317
        result := (others => '0');
1318
        for i in 1 to vec'length loop
1319
            -- synopsys translate_off
1320
            if (pos < 0) and (vec(i) = '0' or vec(i) = '1' or vec(i) = 'X' or vec(i) = 'U')  then
1321
                assert false
1322
                    report "Input string is larger than output std_logic_vector. Truncating output.";
1323
                return result;
1324
            end if;
1325
            -- synopsys translate_on
1326
            if vec(i) = '0' then
1327
                result(pos) := '0';
1328
                pos := pos - 1;
1329
            end if;
1330
            if vec(i) = '1' then
1331
                result(pos) := '1';
1332
                pos := pos - 1;
1333
            end if;
1334
            -- synopsys translate_off
1335
            if (vec(i) = 'X' or vec(i) = 'U') then
1336
                result(pos) := 'U';
1337
                pos := pos - 1;
1338
            end if;
1339
            -- synopsys translate_on
1340
        end loop;
1341
        return result;
1342
    end;
1343
    function bin_string_element_to_std_logic_vector (inp : string;  width, index : integer)
1344
        return std_logic_vector
1345
    is
1346
        constant str_width : integer := width + 4;
1347
        constant inp_len : integer := inp'length;
1348
        constant num_elements : integer := (inp_len + 1)/str_width;
1349
        constant reverse_index : integer := (num_elements-1) - index;
1350
        variable left_pos : integer;
1351
        variable right_pos : integer;
1352
        variable vec : string(1 to inp'length);
1353
        variable result : std_logic_vector(width-1 downto 0);
1354
    begin
1355
        vec := inp;
1356
        result := (others => '0');
1357
        if (reverse_index = 0) and (reverse_index < num_elements) and (inp_len-3 >= width) then
1358
            left_pos := 1;
1359
            right_pos := width + 3;
1360
            result := bin_string_to_std_logic_vector(vec(left_pos to right_pos));
1361
        end if;
1362
        if (reverse_index > 0) and (reverse_index < num_elements) and (inp_len-3 >= width) then
1363
            left_pos := (reverse_index * str_width) + 1;
1364
            right_pos := left_pos + width + 2;
1365
            result := bin_string_to_std_logic_vector(vec(left_pos to right_pos));
1366
        end if;
1367
        return result;
1368
    end;
1369
   -- synopsys translate_off
1370
    function std_logic_vector_to_bin_string(inp : std_logic_vector)
1371
        return string
1372
    is
1373
        variable vec : std_logic_vector(1 to inp'length);
1374
        variable result : string(vec'range);
1375
    begin
1376
        vec := inp;
1377
        for i in vec'range loop
1378
            result(i) := to_char(vec(i));
1379
        end loop;
1380
        return result;
1381
    end;
1382
    function std_logic_to_bin_string(inp : std_logic)
1383
        return string
1384
    is
1385
        variable result : string(1 to 3);
1386
    begin
1387
        result(1) := '0';
1388
        result(2) := 'b';
1389
        result(3) := to_char(inp);
1390
        return result;
1391
    end;
1392
    function std_logic_vector_to_bin_string_w_point(inp : std_logic_vector; bin_pt : integer)
1393
        return string
1394
    is
1395
        variable width : integer := inp'length;
1396
        variable vec : std_logic_vector(width-1 downto 0);
1397
        variable str_pos : integer;
1398
        variable result : string(1 to width+3);
1399
    begin
1400
        vec := inp;
1401
        str_pos := 1;
1402
        result(str_pos) := '0';
1403
        str_pos := 2;
1404
        result(str_pos) := 'b';
1405
        str_pos := 3;
1406
        for i in width-1 downto 0  loop
1407
            if (((width+3) - bin_pt) = str_pos) then
1408
                result(str_pos) := '.';
1409
                str_pos := str_pos + 1;
1410
            end if;
1411
            result(str_pos) := to_char(vec(i));
1412
            str_pos := str_pos + 1;
1413
        end loop;
1414
        if (bin_pt = 0) then
1415
            result(str_pos) := '.';
1416
        end if;
1417
        return result;
1418
    end;
1419
    function real_to_bin_string(inp : real;  width, bin_pt, arith : integer)
1420
        return string
1421
    is
1422
        variable result : string(1 to width);
1423
        variable vec : std_logic_vector(width-1 downto 0);
1424
    begin
1425
        vec := real_to_std_logic_vector(inp, width, bin_pt, arith);
1426
        result := std_logic_vector_to_bin_string(vec);
1427
        return result;
1428
    end;
1429
    function real_to_string (inp : real) return string
1430
    is
1431
        variable result : string(1 to display_precision) := (others => ' ');
1432
    begin
1433
        result(real'image(inp)'range) := real'image(inp);
1434
        return result;
1435
    end;
1436
    -- synopsys translate_on
1437
end conv_pkg;
1438
 
1439
-------------------------------------------------------------------
1440
-- System Generator version 13.2 VHDL source file.
1441
--
1442
-- Copyright(C) 2011 by Xilinx, Inc.  All rights reserved.  This
1443
-- text/file contains proprietary, confidential information of Xilinx,
1444
-- Inc., is distributed under license from Xilinx, Inc., and may be used,
1445
-- copied and/or disclosed only pursuant to the terms of a valid license
1446
-- agreement with Xilinx, Inc.  Xilinx hereby grants you a license to use
1447
-- this text/file solely for design, simulation, implementation and
1448
-- creation of design files limited to Xilinx devices or technologies.
1449
-- Use with non-Xilinx devices or technologies is expressly prohibited
1450
-- and immediately terminates your license unless covered by a separate
1451
-- agreement.
1452
--
1453
-- Xilinx is providing this design, code, or information "as is" solely
1454
-- for use in developing programs and solutions for Xilinx devices.  By
1455
-- providing this design, code, or information as one possible
1456
-- implementation of this feature, application or standard, Xilinx is
1457
-- making no representation that this implementation is free from any
1458
-- claims of infringement.  You are responsible for obtaining any rights
1459
-- you may require for your implementation.  Xilinx expressly disclaims
1460
-- any warranty whatsoever with respect to the adequacy of the
1461
-- implementation, including but not limited to warranties of
1462
-- merchantability or fitness for a particular purpose.
1463
--
1464
-- Xilinx products are not intended for use in life support appliances,
1465
-- devices, or systems.  Use in such applications is expressly prohibited.
1466
--
1467
-- Any modifications that are made to the source code are done at the user's
1468
-- sole risk and will be unsupported.
1469
--
1470
-- This copyright and support notice must be retained as part of this
1471
-- text at all times.  (c) Copyright 1995-2011 Xilinx, Inc.  All rights
1472
-- reserved.
1473
-------------------------------------------------------------------
1474
-- synopsys translate_off
1475
library unisim;
1476
use unisim.vcomponents.all;
1477
-- synopsys translate_on
1478
library IEEE;
1479
use IEEE.std_logic_1164.all;
1480
use work.conv_pkg.all;
1481
entity srl17e is
1482
    generic (width : integer:=16;
1483
             latency : integer :=8);
1484
    port (clk   : in std_logic;
1485
          ce    : in std_logic;
1486
          d     : in std_logic_vector(width-1 downto 0);
1487
          q     : out std_logic_vector(width-1 downto 0));
1488
end srl17e;
1489
architecture structural of srl17e is
1490
    component SRL16E
1491
        port (D   : in STD_ULOGIC;
1492
              CE  : in STD_ULOGIC;
1493
              CLK : in STD_ULOGIC;
1494
              A0  : in STD_ULOGIC;
1495
              A1  : in STD_ULOGIC;
1496
              A2  : in STD_ULOGIC;
1497
              A3  : in STD_ULOGIC;
1498
              Q   : out STD_ULOGIC);
1499
    end component;
1500
    attribute syn_black_box of SRL16E : component is true;
1501
    attribute fpga_dont_touch of SRL16E : component is "true";
1502
    component FDE
1503
        port(
1504
            Q  :        out   STD_ULOGIC;
1505
            D  :        in    STD_ULOGIC;
1506
            C  :        in    STD_ULOGIC;
1507
            CE :        in    STD_ULOGIC);
1508
    end component;
1509
    attribute syn_black_box of FDE : component is true;
1510
    attribute fpga_dont_touch of FDE : component is "true";
1511
    constant a : std_logic_vector(4 downto 0) :=
1512
        integer_to_std_logic_vector(latency-2,5,xlSigned);
1513
    signal d_delayed : std_logic_vector(width-1 downto 0);
1514
    signal srl16_out : std_logic_vector(width-1 downto 0);
1515
begin
1516
    d_delayed <= d after 200 ps;
1517
    reg_array : for i in 0 to width-1 generate
1518
        srl16_used: if latency > 1 generate
1519
            u1 : srl16e port map(clk => clk,
1520
                                 d => d_delayed(i),
1521
                                 q => srl16_out(i),
1522
                                 ce => ce,
1523
                                 a0 => a(0),
1524
                                 a1 => a(1),
1525
                                 a2 => a(2),
1526
                                 a3 => a(3));
1527
        end generate;
1528
        srl16_not_used: if latency <= 1 generate
1529
            srl16_out(i) <= d_delayed(i);
1530
        end generate;
1531
        fde_used: if latency /= 0  generate
1532
            u2 : fde port map(c => clk,
1533
                              d => srl16_out(i),
1534
                              q => q(i),
1535
                              ce => ce);
1536
        end generate;
1537
        fde_not_used: if latency = 0  generate
1538
            q(i) <= srl16_out(i);
1539
        end generate;
1540
    end generate;
1541
 end structural;
1542
library IEEE;
1543
use IEEE.std_logic_1164.all;
1544
use work.conv_pkg.all;
1545
entity synth_reg is
1546
    generic (width           : integer := 8;
1547
             latency         : integer := 1);
1548
    port (i       : in std_logic_vector(width-1 downto 0);
1549
          ce      : in std_logic;
1550
          clr     : in std_logic;
1551
          clk     : in std_logic;
1552
          o       : out std_logic_vector(width-1 downto 0));
1553
end synth_reg;
1554
architecture structural of synth_reg is
1555
    component srl17e
1556
        generic (width : integer:=16;
1557
                 latency : integer :=8);
1558
        port (clk : in std_logic;
1559
              ce  : in std_logic;
1560
              d   : in std_logic_vector(width-1 downto 0);
1561
              q   : out std_logic_vector(width-1 downto 0));
1562
    end component;
1563
    function calc_num_srl17es (latency : integer)
1564
        return integer
1565
    is
1566
        variable remaining_latency : integer;
1567
        variable result : integer;
1568
    begin
1569
        result := latency / 17;
1570
        remaining_latency := latency - (result * 17);
1571
        if (remaining_latency /= 0) then
1572
            result := result + 1;
1573
        end if;
1574
        return result;
1575
    end;
1576
    constant complete_num_srl17es : integer := latency / 17;
1577
    constant num_srl17es : integer := calc_num_srl17es(latency);
1578
    constant remaining_latency : integer := latency - (complete_num_srl17es * 17);
1579
    type register_array is array (num_srl17es downto 0) of
1580
        std_logic_vector(width-1 downto 0);
1581
    signal z : register_array;
1582
begin
1583
    z(0) <= i;
1584
    complete_ones : if complete_num_srl17es > 0 generate
1585
        srl17e_array: for i in 0 to complete_num_srl17es-1 generate
1586
            delay_comp : srl17e
1587
                generic map (width => width,
1588
                             latency => 17)
1589
                port map (clk => clk,
1590
                          ce  => ce,
1591
                          d       => z(i),
1592
                          q       => z(i+1));
1593
        end generate;
1594
    end generate;
1595
    partial_one : if remaining_latency > 0 generate
1596
        last_srl17e : srl17e
1597
            generic map (width => width,
1598
                         latency => remaining_latency)
1599
            port map (clk => clk,
1600
                      ce  => ce,
1601
                      d   => z(num_srl17es-1),
1602
                      q   => z(num_srl17es));
1603
    end generate;
1604
    o <= z(num_srl17es);
1605
end structural;
1606
library IEEE;
1607
use IEEE.std_logic_1164.all;
1608
use work.conv_pkg.all;
1609
entity synth_reg_reg is
1610
    generic (width           : integer := 8;
1611
             latency         : integer := 1);
1612
    port (i       : in std_logic_vector(width-1 downto 0);
1613
          ce      : in std_logic;
1614
          clr     : in std_logic;
1615
          clk     : in std_logic;
1616
          o       : out std_logic_vector(width-1 downto 0));
1617
end synth_reg_reg;
1618
architecture behav of synth_reg_reg is
1619
  type reg_array_type is array (latency-1 downto 0) of std_logic_vector(width -1 downto 0);
1620
  signal reg_bank : reg_array_type := (others => (others => '0'));
1621
  signal reg_bank_in : reg_array_type := (others => (others => '0'));
1622
  attribute syn_allow_retiming : boolean;
1623
  attribute syn_srlstyle : string;
1624
  attribute syn_allow_retiming of reg_bank : signal is true;
1625
  attribute syn_allow_retiming of reg_bank_in : signal is true;
1626
  attribute syn_srlstyle of reg_bank : signal is "registers";
1627
  attribute syn_srlstyle of reg_bank_in : signal is "registers";
1628
begin
1629
  latency_eq_0: if latency = 0 generate
1630
    o <= i;
1631
  end generate latency_eq_0;
1632
  latency_gt_0: if latency >= 1 generate
1633
    o <= reg_bank(latency-1);
1634
    reg_bank_in(0) <= i;
1635
    loop_gen: for idx in latency-2 downto 0 generate
1636
      reg_bank_in(idx+1) <= reg_bank(idx);
1637
    end generate loop_gen;
1638
    sync_loop: for sync_idx in latency-1 downto 0 generate
1639
      sync_proc: process (clk)
1640
      begin
1641
        if clk'event and clk = '1' then
1642
          if clr = '1' then
1643
            reg_bank_in <= (others => (others => '0'));
1644
          elsif ce = '1'  then
1645
            reg_bank(sync_idx) <= reg_bank_in(sync_idx);
1646
          end if;
1647
        end if;
1648
      end process sync_proc;
1649
    end generate sync_loop;
1650
  end generate latency_gt_0;
1651
end behav;
1652
 
1653
-------------------------------------------------------------------
1654
-- System Generator version 13.2 VHDL source file.
1655
--
1656
-- Copyright(C) 2011 by Xilinx, Inc.  All rights reserved.  This
1657
-- text/file contains proprietary, confidential information of Xilinx,
1658
-- Inc., is distributed under license from Xilinx, Inc., and may be used,
1659
-- copied and/or disclosed only pursuant to the terms of a valid license
1660
-- agreement with Xilinx, Inc.  Xilinx hereby grants you a license to use
1661
-- this text/file solely for design, simulation, implementation and
1662
-- creation of design files limited to Xilinx devices or technologies.
1663
-- Use with non-Xilinx devices or technologies is expressly prohibited
1664
-- and immediately terminates your license unless covered by a separate
1665
-- agreement.
1666
--
1667
-- Xilinx is providing this design, code, or information "as is" solely
1668
-- for use in developing programs and solutions for Xilinx devices.  By
1669
-- providing this design, code, or information as one possible
1670
-- implementation of this feature, application or standard, Xilinx is
1671
-- making no representation that this implementation is free from any
1672
-- claims of infringement.  You are responsible for obtaining any rights
1673
-- you may require for your implementation.  Xilinx expressly disclaims
1674
-- any warranty whatsoever with respect to the adequacy of the
1675
-- implementation, including but not limited to warranties of
1676
-- merchantability or fitness for a particular purpose.
1677
--
1678
-- Xilinx products are not intended for use in life support appliances,
1679
-- devices, or systems.  Use in such applications is expressly prohibited.
1680
--
1681
-- Any modifications that are made to the source code are done at the user's
1682
-- sole risk and will be unsupported.
1683
--
1684
-- This copyright and support notice must be retained as part of this
1685
-- text at all times.  (c) Copyright 1995-2011 Xilinx, Inc.  All rights
1686
-- reserved.
1687
-------------------------------------------------------------------
1688
-- synopsys translate_off
1689
library unisim;
1690
use unisim.vcomponents.all;
1691
-- synopsys translate_on
1692
library IEEE;
1693
use IEEE.std_logic_1164.all;
1694
use work.conv_pkg.all;
1695
entity single_reg_w_init is
1696
  generic (
1697
    width: integer := 8;
1698
    init_index: integer := 0;
1699
    init_value: bit_vector := b"0000"
1700
  );
1701
  port (
1702
    i: in std_logic_vector(width - 1 downto 0);
1703
    ce: in std_logic;
1704
    clr: in std_logic;
1705
    clk: in std_logic;
1706
    o: out std_logic_vector(width - 1 downto 0)
1707
  );
1708
end single_reg_w_init;
1709
architecture structural of single_reg_w_init is
1710
  function build_init_const(width: integer;
1711
                            init_index: integer;
1712
                            init_value: bit_vector)
1713
    return std_logic_vector
1714
  is
1715
    variable result: std_logic_vector(width - 1 downto 0);
1716
  begin
1717
    if init_index = 0 then
1718
      result := (others => '0');
1719
    elsif init_index = 1 then
1720
      result := (others => '0');
1721
      result(0) := '1';
1722
    else
1723
      result := to_stdlogicvector(init_value);
1724
    end if;
1725
    return result;
1726
  end;
1727
  component fdre
1728
    port (
1729
      q: out std_ulogic;
1730
      d: in  std_ulogic;
1731
      c: in  std_ulogic;
1732
      ce: in  std_ulogic;
1733
      r: in  std_ulogic
1734
    );
1735
  end component;
1736
  attribute syn_black_box of fdre: component is true;
1737
  attribute fpga_dont_touch of fdre: component is "true";
1738
  component fdse
1739
    port (
1740
      q: out std_ulogic;
1741
      d: in  std_ulogic;
1742
      c: in  std_ulogic;
1743
      ce: in  std_ulogic;
1744
      s: in  std_ulogic
1745
    );
1746
  end component;
1747
  attribute syn_black_box of fdse: component is true;
1748
  attribute fpga_dont_touch of fdse: component is "true";
1749
  constant init_const: std_logic_vector(width - 1 downto 0)
1750
    := build_init_const(width, init_index, init_value);
1751
begin
1752
  fd_prim_array: for index in 0 to width - 1 generate
1753
    bit_is_0: if (init_const(index) = '0') generate
1754
      fdre_comp: fdre
1755
        port map (
1756
          c => clk,
1757
          d => i(index),
1758
          q => o(index),
1759
          ce => ce,
1760
          r => clr
1761
        );
1762
    end generate;
1763
    bit_is_1: if (init_const(index) = '1') generate
1764
      fdse_comp: fdse
1765
        port map (
1766
          c => clk,
1767
          d => i(index),
1768
          q => o(index),
1769
          ce => ce,
1770
          s => clr
1771
        );
1772
    end generate;
1773
  end generate;
1774
end architecture structural;
1775
-- synopsys translate_off
1776
library unisim;
1777
use unisim.vcomponents.all;
1778
-- synopsys translate_on
1779
library IEEE;
1780
use IEEE.std_logic_1164.all;
1781
use work.conv_pkg.all;
1782
entity synth_reg_w_init is
1783
  generic (
1784
    width: integer := 8;
1785
    init_index: integer := 0;
1786
    init_value: bit_vector := b"0000";
1787
    latency: integer := 1
1788
  );
1789
  port (
1790
    i: in std_logic_vector(width - 1 downto 0);
1791
    ce: in std_logic;
1792
    clr: in std_logic;
1793
    clk: in std_logic;
1794
    o: out std_logic_vector(width - 1 downto 0)
1795
  );
1796
end synth_reg_w_init;
1797
architecture structural of synth_reg_w_init is
1798
  component single_reg_w_init
1799
    generic (
1800
      width: integer := 8;
1801
      init_index: integer := 0;
1802
      init_value: bit_vector := b"0000"
1803
    );
1804
    port (
1805
      i: in std_logic_vector(width - 1 downto 0);
1806
      ce: in std_logic;
1807
      clr: in std_logic;
1808
      clk: in std_logic;
1809
      o: out std_logic_vector(width - 1 downto 0)
1810
    );
1811
  end component;
1812
  signal dly_i: std_logic_vector((latency + 1) * width - 1 downto 0);
1813
  signal dly_clr: std_logic;
1814
begin
1815
  latency_eq_0: if (latency = 0) generate
1816
    o <= i;
1817
  end generate;
1818
  latency_gt_0: if (latency >= 1) generate
1819
    dly_i((latency + 1) * width - 1 downto latency * width) <= i
1820
      after 200 ps;
1821
    dly_clr <= clr after 200 ps;
1822
    fd_array: for index in latency downto 1 generate
1823
       reg_comp: single_reg_w_init
1824
          generic map (
1825
            width => width,
1826
            init_index => init_index,
1827
            init_value => init_value
1828
          )
1829
          port map (
1830
            clk => clk,
1831
            i => dly_i((index + 1) * width - 1 downto index * width),
1832
            o => dly_i(index * width - 1 downto (index - 1) * width),
1833
            ce => ce,
1834
            clr => dly_clr
1835
          );
1836
    end generate;
1837
    o <= dly_i(width - 1 downto 0);
1838
  end generate;
1839
end structural;
1840
library IEEE;
1841
use IEEE.std_logic_1164.all;
1842
use IEEE.numeric_std.all;
1843
use work.conv_pkg.all;
1844
 
1845
entity constant_963ed6358a is
1846
  port (
1847
    op : out std_logic_vector((1 - 1) downto 0);
1848
    clk : in std_logic;
1849
    ce : in std_logic;
1850
    clr : in std_logic);
1851
end constant_963ed6358a;
1852
 
1853
 
1854
architecture behavior of constant_963ed6358a is
1855
begin
1856
  op <= "0";
1857
end behavior;
1858
 
1859
library IEEE;
1860
use IEEE.std_logic_1164.all;
1861
use IEEE.numeric_std.all;
1862
use work.conv_pkg.all;
1863
 
1864
entity constant_6293007044 is
1865
  port (
1866
    op : out std_logic_vector((1 - 1) downto 0);
1867
    clk : in std_logic;
1868
    ce : in std_logic;
1869
    clr : in std_logic);
1870
end constant_6293007044;
1871
 
1872
 
1873
architecture behavior of constant_6293007044 is
1874
begin
1875
  op <= "1";
1876
end behavior;
1877
 
1878
library IEEE;
1879
use IEEE.std_logic_1164.all;
1880
use IEEE.numeric_std.all;
1881
use work.conv_pkg.all;
1882
 
1883
entity constant_19562ab42f is
1884
  port (
1885
    op : out std_logic_vector((8 - 1) downto 0);
1886
    clk : in std_logic;
1887
    ce : in std_logic;
1888
    clr : in std_logic);
1889
end constant_19562ab42f;
1890
 
1891
 
1892
architecture behavior of constant_19562ab42f is
1893
begin
1894
  op <= "11111111";
1895
end behavior;
1896
 
1897
 
1898
-------------------------------------------------------------------
1899
-- System Generator version 13.2 VHDL source file.
1900
--
1901
-- Copyright(C) 2011 by Xilinx, Inc.  All rights reserved.  This
1902
-- text/file contains proprietary, confidential information of Xilinx,
1903
-- Inc., is distributed under license from Xilinx, Inc., and may be used,
1904
-- copied and/or disclosed only pursuant to the terms of a valid license
1905
-- agreement with Xilinx, Inc.  Xilinx hereby grants you a license to use
1906
-- this text/file solely for design, simulation, implementation and
1907
-- creation of design files limited to Xilinx devices or technologies.
1908
-- Use with non-Xilinx devices or technologies is expressly prohibited
1909
-- and immediately terminates your license unless covered by a separate
1910
-- agreement.
1911
--
1912
-- Xilinx is providing this design, code, or information "as is" solely
1913
-- for use in developing programs and solutions for Xilinx devices.  By
1914
-- providing this design, code, or information as one possible
1915
-- implementation of this feature, application or standard, Xilinx is
1916
-- making no representation that this implementation is free from any
1917
-- claims of infringement.  You are responsible for obtaining any rights
1918
-- you may require for your implementation.  Xilinx expressly disclaims
1919
-- any warranty whatsoever with respect to the adequacy of the
1920
-- implementation, including but not limited to warranties of
1921
-- merchantability or fitness for a particular purpose.
1922
--
1923
-- Xilinx products are not intended for use in life support appliances,
1924
-- devices, or systems.  Use in such applications is expressly prohibited.
1925
--
1926
-- Any modifications that are made to the source code are done at the user's
1927
-- sole risk and will be unsupported.
1928
--
1929
-- This copyright and support notice must be retained as part of this
1930
-- text at all times.  (c) Copyright 1995-2011 Xilinx, Inc.  All rights
1931
-- reserved.
1932
-------------------------------------------------------------------
1933
library IEEE;
1934
use IEEE.std_logic_1164.all;
1935
use work.conv_pkg.all;
1936
entity convert_func_call is
1937
    generic (
1938
        din_width    : integer := 16;
1939
        din_bin_pt   : integer := 4;
1940
        din_arith    : integer := xlUnsigned;
1941
        dout_width   : integer := 8;
1942
        dout_bin_pt  : integer := 2;
1943
        dout_arith   : integer := xlUnsigned;
1944
        quantization : integer := xlTruncate;
1945
        overflow     : integer := xlWrap);
1946
    port (
1947
        din : in std_logic_vector (din_width-1 downto 0);
1948
        result : out std_logic_vector (dout_width-1 downto 0));
1949
end convert_func_call;
1950
architecture behavior of convert_func_call is
1951
begin
1952
    result <= convert_type(din, din_width, din_bin_pt, din_arith,
1953
                           dout_width, dout_bin_pt, dout_arith,
1954
                           quantization, overflow);
1955
end behavior;
1956
library IEEE;
1957
use IEEE.std_logic_1164.all;
1958
use work.conv_pkg.all;
1959
entity xlconvert is
1960
    generic (
1961
        din_width    : integer := 16;
1962
        din_bin_pt   : integer := 4;
1963
        din_arith    : integer := xlUnsigned;
1964
        dout_width   : integer := 8;
1965
        dout_bin_pt  : integer := 2;
1966
        dout_arith   : integer := xlUnsigned;
1967
        en_width     : integer := 1;
1968
        en_bin_pt    : integer := 0;
1969
        en_arith     : integer := xlUnsigned;
1970
        bool_conversion : integer :=0;
1971
        latency      : integer := 0;
1972
        quantization : integer := xlTruncate;
1973
        overflow     : integer := xlWrap);
1974
    port (
1975
        din : in std_logic_vector (din_width-1 downto 0);
1976
        en  : in std_logic_vector (en_width-1 downto 0);
1977
        ce  : in std_logic;
1978
        clr : in std_logic;
1979
        clk : in std_logic;
1980
        dout : out std_logic_vector (dout_width-1 downto 0));
1981
end xlconvert;
1982
architecture behavior of xlconvert is
1983
    component synth_reg
1984
        generic (width       : integer;
1985
                 latency     : integer);
1986
        port (i       : in std_logic_vector(width-1 downto 0);
1987
              ce      : in std_logic;
1988
              clr     : in std_logic;
1989
              clk     : in std_logic;
1990
              o       : out std_logic_vector(width-1 downto 0));
1991
    end component;
1992
    component convert_func_call
1993
        generic (
1994
            din_width    : integer := 16;
1995
            din_bin_pt   : integer := 4;
1996
            din_arith    : integer := xlUnsigned;
1997
            dout_width   : integer := 8;
1998
            dout_bin_pt  : integer := 2;
1999
            dout_arith   : integer := xlUnsigned;
2000
            quantization : integer := xlTruncate;
2001
            overflow     : integer := xlWrap);
2002
        port (
2003
            din : in std_logic_vector (din_width-1 downto 0);
2004
            result : out std_logic_vector (dout_width-1 downto 0));
2005
    end component;
2006
    -- synopsys translate_off
2007
    -- synopsys translate_on
2008
    signal result : std_logic_vector(dout_width-1 downto 0);
2009
    signal internal_ce : std_logic;
2010
begin
2011
    -- synopsys translate_off
2012
    -- synopsys translate_on
2013
    internal_ce <= ce and en(0);
2014
 
2015
    bool_conversion_generate : if (bool_conversion = 1)
2016
    generate
2017
      result <= din;
2018
    end generate;
2019
    std_conversion_generate : if (bool_conversion = 0)
2020
    generate
2021
      convert : convert_func_call
2022
        generic map (
2023
          din_width   => din_width,
2024
          din_bin_pt  => din_bin_pt,
2025
          din_arith   => din_arith,
2026
          dout_width  => dout_width,
2027
          dout_bin_pt => dout_bin_pt,
2028
          dout_arith  => dout_arith,
2029
          quantization => quantization,
2030
          overflow     => overflow)
2031
        port map (
2032
          din => din,
2033
          result => result);
2034
    end generate;
2035
    latency_test : if (latency > 0) generate
2036
        reg : synth_reg
2037
            generic map (
2038
              width => dout_width,
2039
              latency => latency
2040
            )
2041
            port map (
2042
              i => result,
2043
              ce => internal_ce,
2044
              clr => clr,
2045
              clk => clk,
2046
              o => dout
2047
            );
2048
    end generate;
2049
    latency0 : if (latency = 0)
2050
    generate
2051
        dout <= result;
2052
    end generate latency0;
2053
end  behavior;
2054
 
2055
-------------------------------------------------------------------
2056
-- System Generator version 13.2 VHDL source file.
2057
--
2058
-- Copyright(C) 2011 by Xilinx, Inc.  All rights reserved.  This
2059
-- text/file contains proprietary, confidential information of Xilinx,
2060
-- Inc., is distributed under license from Xilinx, Inc., and may be used,
2061
-- copied and/or disclosed only pursuant to the terms of a valid license
2062
-- agreement with Xilinx, Inc.  Xilinx hereby grants you a license to use
2063
-- this text/file solely for design, simulation, implementation and
2064
-- creation of design files limited to Xilinx devices or technologies.
2065
-- Use with non-Xilinx devices or technologies is expressly prohibited
2066
-- and immediately terminates your license unless covered by a separate
2067
-- agreement.
2068
--
2069
-- Xilinx is providing this design, code, or information "as is" solely
2070
-- for use in developing programs and solutions for Xilinx devices.  By
2071
-- providing this design, code, or information as one possible
2072
-- implementation of this feature, application or standard, Xilinx is
2073
-- making no representation that this implementation is free from any
2074
-- claims of infringement.  You are responsible for obtaining any rights
2075
-- you may require for your implementation.  Xilinx expressly disclaims
2076
-- any warranty whatsoever with respect to the adequacy of the
2077
-- implementation, including but not limited to warranties of
2078
-- merchantability or fitness for a particular purpose.
2079
--
2080
-- Xilinx products are not intended for use in life support appliances,
2081
-- devices, or systems.  Use in such applications is expressly prohibited.
2082
--
2083
-- Any modifications that are made to the source code are done at the user's
2084
-- sole risk and will be unsupported.
2085
--
2086
-- This copyright and support notice must be retained as part of this
2087
-- text at all times.  (c) Copyright 1995-2011 Xilinx, Inc.  All rights
2088
-- reserved.
2089
-------------------------------------------------------------------
2090
-- synopsys translate_off
2091
library XilinxCoreLib;
2092
-- synopsys translate_on
2093
library IEEE;
2094
use IEEE.std_logic_1164.all;
2095
use work.conv_pkg.all;
2096
entity xlcounter_free is
2097
  generic (
2098
    core_name0: string := "";
2099
    op_width: integer := 5;
2100
    op_arith: integer := xlSigned
2101
  );
2102
  port (
2103
    ce: in std_logic;
2104
    clr: in std_logic;
2105
    clk: in std_logic;
2106
    op: out std_logic_vector(op_width - 1 downto 0);
2107
    up: in std_logic_vector(0 downto 0) := (others => '0');
2108
    load: in std_logic_vector(0 downto 0) := (others => '0');
2109
    din: in std_logic_vector(op_width - 1 downto 0) := (others => '0');
2110
    en: in std_logic_vector(0 downto 0);
2111
    rst: in std_logic_vector(0 downto 0)
2112
  );
2113
end xlcounter_free ;
2114
architecture behavior of xlcounter_free is
2115
  component cntr_11_0_341fbb8cfa0e669e
2116
    port (
2117
      clk: in std_logic;
2118
      ce: in std_logic;
2119
      SINIT: in std_logic;
2120
      q: out std_logic_vector(op_width - 1 downto 0)
2121
    );
2122
  end component;
2123
  attribute syn_black_box of cntr_11_0_341fbb8cfa0e669e:
2124
    component is true;
2125
  attribute fpga_dont_touch of cntr_11_0_341fbb8cfa0e669e:
2126
    component is "true";
2127
  attribute box_type of cntr_11_0_341fbb8cfa0e669e:
2128
    component  is "black_box";
2129
-- synopsys translate_off
2130
  constant zeroVec: std_logic_vector(op_width - 1 downto 0) := (others => '0');
2131
  constant oneVec: std_logic_vector(op_width - 1 downto 0) := (others => '1');
2132
  constant zeroStr: string(1 to op_width) :=
2133
    std_logic_vector_to_bin_string(zeroVec);
2134
  constant oneStr: string(1 to op_width) :=
2135
    std_logic_vector_to_bin_string(oneVec);
2136
-- synopsys translate_on
2137
  signal core_sinit: std_logic;
2138
  signal core_ce: std_logic;
2139
  signal op_net: std_logic_vector(op_width - 1 downto 0);
2140
begin
2141
  core_ce <= ce and en(0);
2142
  core_sinit <= (clr or rst(0)) and ce;
2143
  op <= op_net;
2144
  comp0: if ((core_name0 = "cntr_11_0_341fbb8cfa0e669e")) generate
2145
    core_instance0: cntr_11_0_341fbb8cfa0e669e
2146
      port map (
2147
        clk => clk,
2148
        ce => core_ce,
2149
        SINIT => core_sinit,
2150
        q => op_net
2151
      );
2152
  end generate;
2153
end behavior;
2154
library IEEE;
2155
use IEEE.std_logic_1164.all;
2156
use IEEE.numeric_std.all;
2157
use work.conv_pkg.all;
2158
 
2159
entity inverter_e5b38cca3b is
2160
  port (
2161
    ip : in std_logic_vector((1 - 1) downto 0);
2162
    op : out std_logic_vector((1 - 1) downto 0);
2163
    clk : in std_logic;
2164
    ce : in std_logic;
2165
    clr : in std_logic);
2166
end inverter_e5b38cca3b;
2167
 
2168
 
2169
architecture behavior of inverter_e5b38cca3b is
2170
  signal ip_1_26: boolean;
2171
  type array_type_op_mem_22_20 is array (0 to (1 - 1)) of boolean;
2172
  signal op_mem_22_20: array_type_op_mem_22_20 := (
2173
 
2174
  signal op_mem_22_20_front_din: boolean;
2175
  signal op_mem_22_20_back: boolean;
2176
  signal op_mem_22_20_push_front_pop_back_en: std_logic;
2177
  signal internal_ip_12_1_bitnot: boolean;
2178
begin
2179
  ip_1_26 <= ((ip) = "1");
2180
  op_mem_22_20_back <= op_mem_22_20(0);
2181
  proc_op_mem_22_20: process (clk)
2182
  is
2183
    variable i: integer;
2184
  begin
2185
    if (clk'event and (clk = '1')) then
2186
      if ((ce = '1') and (op_mem_22_20_push_front_pop_back_en = '1')) then
2187
        op_mem_22_20(0) <= op_mem_22_20_front_din;
2188
      end if;
2189
    end if;
2190
  end process proc_op_mem_22_20;
2191
  internal_ip_12_1_bitnot <= ((not boolean_to_vector(ip_1_26)) = "1");
2192
  op_mem_22_20_push_front_pop_back_en <= '0';
2193
  op <= boolean_to_vector(internal_ip_12_1_bitnot);
2194
end behavior;
2195
 
2196
library IEEE;
2197
use IEEE.std_logic_1164.all;
2198
use IEEE.numeric_std.all;
2199
use work.conv_pkg.all;
2200
 
2201
entity logical_80f90b97d0 is
2202
  port (
2203
    d0 : in std_logic_vector((1 - 1) downto 0);
2204
    d1 : in std_logic_vector((1 - 1) downto 0);
2205
    y : out std_logic_vector((1 - 1) downto 0);
2206
    clk : in std_logic;
2207
    ce : in std_logic;
2208
    clr : in std_logic);
2209
end logical_80f90b97d0;
2210
 
2211
 
2212
architecture behavior of logical_80f90b97d0 is
2213
  signal d0_1_24: std_logic;
2214
  signal d1_1_27: std_logic;
2215
  signal fully_2_1_bit: std_logic;
2216
begin
2217
  d0_1_24 <= d0(0);
2218
  d1_1_27 <= d1(0);
2219
  fully_2_1_bit <= d0_1_24 and d1_1_27;
2220
  y <= std_logic_to_vector(fully_2_1_bit);
2221
end behavior;
2222
 
2223
 
2224
-------------------------------------------------------------------
2225
-- System Generator version 13.2 VHDL source file.
2226
--
2227
-- Copyright(C) 2011 by Xilinx, Inc.  All rights reserved.  This
2228
-- text/file contains proprietary, confidential information of Xilinx,
2229
-- Inc., is distributed under license from Xilinx, Inc., and may be used,
2230
-- copied and/or disclosed only pursuant to the terms of a valid license
2231
-- agreement with Xilinx, Inc.  Xilinx hereby grants you a license to use
2232
-- this text/file solely for design, simulation, implementation and
2233
-- creation of design files limited to Xilinx devices or technologies.
2234
-- Use with non-Xilinx devices or technologies is expressly prohibited
2235
-- and immediately terminates your license unless covered by a separate
2236
-- agreement.
2237
--
2238
-- Xilinx is providing this design, code, or information "as is" solely
2239
-- for use in developing programs and solutions for Xilinx devices.  By
2240
-- providing this design, code, or information as one possible
2241
-- implementation of this feature, application or standard, Xilinx is
2242
-- making no representation that this implementation is free from any
2243
-- claims of infringement.  You are responsible for obtaining any rights
2244
-- you may require for your implementation.  Xilinx expressly disclaims
2245
-- any warranty whatsoever with respect to the adequacy of the
2246
-- implementation, including but not limited to warranties of
2247
-- merchantability or fitness for a particular purpose.
2248
--
2249
-- Xilinx products are not intended for use in life support appliances,
2250
-- devices, or systems.  Use in such applications is expressly prohibited.
2251
--
2252
-- Any modifications that are made to the source code are done at the user's
2253
-- sole risk and will be unsupported.
2254
--
2255
-- This copyright and support notice must be retained as part of this
2256
-- text at all times.  (c) Copyright 1995-2011 Xilinx, Inc.  All rights
2257
-- reserved.
2258
-------------------------------------------------------------------
2259
library IEEE;
2260
use IEEE.std_logic_1164.all;
2261
use work.conv_pkg.all;
2262
entity xlregister is
2263
   generic (d_width          : integer := 5;
2264
            init_value       : bit_vector := b"00");
2265
   port (d   : in std_logic_vector (d_width-1 downto 0);
2266
         rst : in std_logic_vector(0 downto 0) := "0";
2267
         en  : in std_logic_vector(0 downto 0) := "1";
2268
         ce  : in std_logic;
2269
         clk : in std_logic;
2270
         q   : out std_logic_vector (d_width-1 downto 0));
2271
end xlregister;
2272
architecture behavior of xlregister is
2273
   component synth_reg_w_init
2274
      generic (width      : integer;
2275
               init_index : integer;
2276
               init_value : bit_vector;
2277
               latency    : integer);
2278
      port (i   : in std_logic_vector(width-1 downto 0);
2279
            ce  : in std_logic;
2280
            clr : in std_logic;
2281
            clk : in std_logic;
2282
            o   : out std_logic_vector(width-1 downto 0));
2283
   end component;
2284
   -- synopsys translate_off
2285
   signal real_d, real_q           : real;
2286
   -- synopsys translate_on
2287
   signal internal_clr             : std_logic;
2288
   signal internal_ce              : std_logic;
2289
begin
2290
   internal_clr <= rst(0) and ce;
2291
   internal_ce  <= en(0) and ce;
2292
   synth_reg_inst : synth_reg_w_init
2293
      generic map (width      => d_width,
2294
                   init_index => 2,
2295
                   init_value => init_value,
2296
                   latency    => 1)
2297
      port map (i   => d,
2298
                ce  => internal_ce,
2299
                clr => internal_clr,
2300
                clk => clk,
2301
                o   => q);
2302
end architecture behavior;
2303
 
2304
-------------------------------------------------------------------
2305
-- System Generator version 13.2 VHDL source file.
2306
--
2307
-- Copyright(C) 2011 by Xilinx, Inc.  All rights reserved.  This
2308
-- text/file contains proprietary, confidential information of Xilinx,
2309
-- Inc., is distributed under license from Xilinx, Inc., and may be used,
2310
-- copied and/or disclosed only pursuant to the terms of a valid license
2311
-- agreement with Xilinx, Inc.  Xilinx hereby grants you a license to use
2312
-- this text/file solely for design, simulation, implementation and
2313
-- creation of design files limited to Xilinx devices or technologies.
2314
-- Use with non-Xilinx devices or technologies is expressly prohibited
2315
-- and immediately terminates your license unless covered by a separate
2316
-- agreement.
2317
--
2318
-- Xilinx is providing this design, code, or information "as is" solely
2319
-- for use in developing programs and solutions for Xilinx devices.  By
2320
-- providing this design, code, or information as one possible
2321
-- implementation of this feature, application or standard, Xilinx is
2322
-- making no representation that this implementation is free from any
2323
-- claims of infringement.  You are responsible for obtaining any rights
2324
-- you may require for your implementation.  Xilinx expressly disclaims
2325
-- any warranty whatsoever with respect to the adequacy of the
2326
-- implementation, including but not limited to warranties of
2327
-- merchantability or fitness for a particular purpose.
2328
--
2329
-- Xilinx products are not intended for use in life support appliances,
2330
-- devices, or systems.  Use in such applications is expressly prohibited.
2331
--
2332
-- Any modifications that are made to the source code are done at the user's
2333
-- sole risk and will be unsupported.
2334
--
2335
-- This copyright and support notice must be retained as part of this
2336
-- text at all times.  (c) Copyright 1995-2011 Xilinx, Inc.  All rights
2337
-- reserved.
2338
-------------------------------------------------------------------
2339
library IEEE;
2340
use IEEE.std_logic_1164.all;
2341
entity xlchipscope is
2342
    port (
2343
        trig0 : in std_logic_vector(12-1 downto 0);
2344
        trig1 : in std_logic_vector(64-1 downto 0);
2345
        trig2 : in std_logic_vector(1-1 downto 0);
2346
        trig3 : in std_logic_vector(1-1 downto 0);
2347
        trig4 : in std_logic_vector(1-1 downto 0);
2348
        trig5 : in std_logic_vector(72-1 downto 0);
2349
        trig6 : in std_logic_vector(1-1 downto 0);
2350
        trig7 : in std_logic_vector(15-1 downto 0);
2351
        trig8 : in std_logic_vector(1-1 downto 0);
2352
        trig9 : in std_logic_vector(1-1 downto 0);
2353
        trig10 : in std_logic_vector(15-1 downto 0);
2354
 
2355
 
2356
          ce       : in std_logic;
2357
          clr      : in std_logic;
2358
          clk      : in std_logic);
2359
end xlchipscope;
2360
architecture behavior of xlchipscope is
2361
    attribute syn_noprune : boolean;
2362
    attribute syn_black_box : boolean;
2363
    attribute box_type : string;
2364
    attribute syn_noprune of behavior : architecture is true;
2365
    signal data     : std_logic_vector (184-1 downto 0);
2366
    signal control  : std_logic_vector (35 downto 0);
2367
    component ila_1_05_a_b6735eb4b876dee5
2368
    port (control     : inout std_logic_vector(35 downto 0);
2369
        trig0 : in std_logic_vector(12-1 downto 0);
2370
        trig1 : in std_logic_vector(64-1 downto 0);
2371
        trig2 : in std_logic_vector(1-1 downto 0);
2372
        trig3 : in std_logic_vector(1-1 downto 0);
2373
        trig4 : in std_logic_vector(1-1 downto 0);
2374
        trig5 : in std_logic_vector(72-1 downto 0);
2375
        trig6 : in std_logic_vector(1-1 downto 0);
2376
        trig7 : in std_logic_vector(15-1 downto 0);
2377
        trig8 : in std_logic_vector(1-1 downto 0);
2378
        trig9 : in std_logic_vector(1-1 downto 0);
2379
        trig10 : in std_logic_vector(15-1 downto 0);
2380
 
2381
          clk         : in    std_logic
2382
    );
2383
    end component;
2384
    attribute syn_black_box of ila_1_05_a_b6735eb4b876dee5 : component is TRUE;
2385
    attribute box_type of ila_1_05_a_b6735eb4b876dee5 : component  is "black_box";
2386
    attribute syn_noprune of ila_1_05_a_b6735eb4b876dee5 : component is TRUE;
2387
    component icon_1_06_a_87e2f476e984e565
2388
    port (control0    :  inout std_logic_vector(35 downto 0)
2389
    );
2390
    end component;
2391
    attribute syn_black_box of icon_1_06_a_87e2f476e984e565 : component is TRUE;
2392
    attribute box_type of icon_1_06_a_87e2f476e984e565 : component  is "black_box";
2393
    attribute syn_noprune of icon_1_06_a_87e2f476e984e565 : component is TRUE;
2394
 
2395
begin
2396
 
2397
 i_ila : ila_1_05_a_b6735eb4b876dee5
2398
    port map
2399
    (   control   => control,
2400
        trig0     => trig0,
2401
        trig1     => trig1,
2402
        trig2     => trig2,
2403
        trig3     => trig3,
2404
        trig4     => trig4,
2405
        trig5     => trig5,
2406
        trig6     => trig6,
2407
        trig7     => trig7,
2408
        trig8     => trig8,
2409
        trig9     => trig9,
2410
        trig10     => trig10,
2411
        clk       => clk
2412
    );
2413
  i_icon_for_syn : icon_1_06_a_87e2f476e984e565
2414
    port map
2415
    (
2416
      control0   => control
2417
    );
2418
end architecture behavior;

powered by: WebSVN 2.1.0

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