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

Subversion Repositories kvcordic

[/] [kvcordic/] [trunk/] [sim/] [rtl_sim/] [vhdl/] [std_logic_textio.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 kavi
-- --------------------------------------------------------------------
2
--
3
--   Title     :  std_logic_textio
4
--   Library   :  This package shall be compiled into a library 
5
--             :  symbolically named IEEE.
6
--             :  
7
--   Developers:  Adapted by IEEE P1164 Working Group from
8
--             :  source donated by Synopsys, Inc.
9
--             :
10
--   Purpose   :  This packages defines procedures for reading and writing
11
--             :  standard-logic scalars and vectors in binary, hexadecimal
12
--             :  and octal format.
13
--             : 
14
--   Limitation:  None.
15
--             :  
16
--   Note      :  No declarations or definitions shall be included in,
17
--             :  or excluded from this package. The "package declaration" 
18
--             :  defines the procedures of std_logic_textio.
19
--             :  The std_logic_textio package body shall be 
20
--             :  considered the formal definition of the semantics of 
21
--             :  this package, except that where a procedure issues an
22
--             :  assertion violation, the standard does not specify the
23
--             :  required behavior in response to the erroneous condition.
24
--             :  Tool developers may choose to implement the package body
25
--             :  in the most efficient manner available to them.
26
--             :
27
-- --------------------------------------------------------------------
28
--
29
-- Copyright (c) 1990, 1991, 1992 by Synopsys, Inc.  All rights reserved.
30
-- 
31
-- This source file may be used and distributed without restriction 
32
-- provided that this copyright statement is not removed from the file 
33
-- and that any derivative work contains this copyright notice.
34
--
35
-- --------------------------------------------------------------------
36
 
37
use STD.textio.all;
38
library IEEE;
39
use IEEE.std_logic_1164.all;
40
 
41
package STD_LOGIC_TEXTIO is
42
 
43
    -- Read and Write procedures for STD_ULOGIC and STD_ULOGIC_VECTOR
44
 
45
    procedure READ (L: inout LINE;  VALUE: out STD_ULOGIC;         GOOD: out BOOLEAN);
46
    procedure READ (L: inout LINE;  VALUE: out STD_ULOGIC);
47
 
48
    procedure READ (L: inout LINE;  VALUE: out STD_ULOGIC_VECTOR;  GOOD: out BOOLEAN);
49
    procedure READ (L: inout LINE;  VALUE: out STD_ULOGIC_VECTOR);
50
 
51
    procedure WRITE (L: inout LINE;  VALUE: in STD_ULOGIC;
52
                     JUSTIFIED: in SIDE := RIGHT;  FIELD: in WIDTH := 0);
53
 
54
    procedure WRITE (L: inout LINE;  VALUE: in STD_ULOGIC_VECTOR;
55
                     JUSTIFIED: in SIDE := RIGHT;  FIELD: in WIDTH := 0);
56
 
57
    -- Read and Write procedures for STD_LOGIC_VECTOR
58
 
59
    procedure READ (L: inout LINE;  VALUE: out STD_LOGIC_VECTOR;   GOOD: out BOOLEAN);
60
    procedure READ (L: inout LINE;  VALUE: out STD_LOGIC_VECTOR);
61
 
62
    procedure WRITE (L: inout LINE;  VALUE: in STD_LOGIC_VECTOR;
63
                     JUSTIFIED: in SIDE := RIGHT;  FIELD: in WIDTH := 0);
64
 
65
    -- Read and Write procedures for Hex values
66
 
67
    procedure HREAD (L: inout LINE;  VALUE: out STD_ULOGIC_VECTOR;  GOOD : out BOOLEAN);
68
    procedure HREAD (L: inout LINE;  VALUE: out STD_ULOGIC_VECTOR);
69
 
70
    procedure HWRITE (L: inout LINE;  VALUE: in STD_ULOGIC_VECTOR;
71
                      JUSTIFIED: in SIDE := RIGHT;  FIELD:in WIDTH := 0);
72
 
73
    procedure HREAD (L: inout LINE;  VALUE: out STD_LOGIC_VECTOR;   GOOD: out BOOLEAN);
74
    procedure HREAD (L: inout LINE;  VALUE: out STD_LOGIC_VECTOR);
75
 
76
    procedure HWRITE (L: inout LINE;  VALUE: in STD_LOGIC_VECTOR;
77
                      JUSTIFIED: in SIDE := RIGHT;  FIELD: in WIDTH := 0);
78
 
79
    -- Read and Write procedures for Octal values
80
 
81
    procedure OREAD (L: inout LINE;  VALUE: out STD_ULOGIC_VECTOR;  GOOD: out BOOLEAN);
82
    procedure OREAD (L: inout LINE;  VALUE: out STD_ULOGIC_VECTOR);
83
 
84
    procedure OWRITE (L: inout LINE;  VALUE: in STD_ULOGIC_VECTOR;
85
                      JUSTIFIED:in SIDE := RIGHT;  FIELD:in WIDTH := 0);
86
 
87
    procedure OREAD (L: inout LINE;  VALUE: out STD_LOGIC_VECTOR;   GOOD: out BOOLEAN);
88
    procedure OREAD (L: inout LINE;  VALUE: out STD_LOGIC_VECTOR);
89
 
90
    procedure OWRITE (L: inout LINE;  VALUE: in STD_LOGIC_VECTOR;
91
                      JUSTIFIED:in SIDE := RIGHT;  FIELD:in WIDTH := 0);
92
 
93
end STD_LOGIC_TEXTIO;
94
 
95
 
96
package body STD_LOGIC_TEXTIO is
97
 
98
    -- Type and constant definitions used to map STD_ULOGIC values 
99
    -- into/from character values.
100
 
101
    type MVL9plus is ('U', 'X', '0', '1', 'Z', 'W', 'L', 'H', '-', ERROR);
102
    type char_indexed_by_MVL9 is array (STD_ULOGIC) of character;
103
    type MVL9_indexed_by_char is array (character) of STD_ULOGIC;
104
    type MVL9plus_indexed_by_char is array (character) of MVL9plus;
105
 
106
    constant MVL9_to_char: char_indexed_by_MVL9 := "UX01ZWLH-";
107
    constant char_to_MVL9: MVL9_indexed_by_char :=
108
        ('U' => 'U', 'X' => 'X', '0' => '0', '1' => '1', 'Z' => 'Z',
109
         'W' => 'W', 'L' => 'L', 'H' => 'H', '-' => '-', others => 'U');
110
    constant char_to_MVL9plus: MVL9plus_indexed_by_char :=
111
        ('U' => 'U', 'X' => 'X', '0' => '0', '1' => '1', 'Z' => 'Z',
112
         'W' => 'W', 'L' => 'L', 'H' => 'H', '-' => '-', others => ERROR);
113
 
114
    constant NBSP : character := character'val(160);
115
 
116
    -- Read and Write procedures for STD_ULOGIC and STD_ULOGIC_VECTOR
117
 
118
    procedure READ (L: inout LINE;  VALUE: out STD_ULOGIC;  GOOD: out BOOLEAN) is
119
        variable c: character;
120
        variable readOk: BOOLEAN;
121
    begin
122
        loop                      -- skip white space
123
            read(l, c, readOk);   -- but also exit on a bad read
124
            exit when (readOk = FALSE) or ((c /= ' ') and (c /= NBSP) and (c /= HT));
125
        end loop;
126
 
127
        if not readOk then
128
            good := FALSE;
129
        else
130
            if char_to_MVL9plus(c) = ERROR then
131
                value := 'U';
132
                good := FALSE;
133
            else
134
                value := char_to_MVL9(c);
135
                good := TRUE;
136
            end if;
137
        end if;
138
    end READ;
139
 
140
 
141
    procedure READ (L: inout LINE;  VALUE: out STD_ULOGIC_VECTOR;  GOOD: out BOOLEAN) is
142
        variable m:  STD_ULOGIC;
143
        variable c:  character;
144
        variable s:  string(1 to value'length-1);
145
        variable mv: STD_ULOGIC_VECTOR(0 to value'length-1);
146
        constant allU: STD_ULOGIC_VECTOR(0 to value'length-1)
147
                         := (others => 'U');
148
        variable readOk: BOOLEAN;
149
 
150
    begin
151
        loop                    -- skip white space
152
            read(l, c, readOk);
153
            exit when (readOk = FALSE) or ((c /= ' ') and (c /= NBSP) and (c /= HT));
154
        end loop;
155
 
156
        -- Bail out if there was a bad read
157
        if not readOk then
158
            good := FALSE;
159
            return;
160
        end if;
161
 
162
        if char_to_MVL9plus(c) = ERROR then
163
            value := allU;
164
            good := FALSE;
165
            return;
166
        end if;
167
 
168
        read(l, s, readOk);
169
        -- Bail out if there was a bad read
170
        if not readOk then
171
            good := FALSE;
172
            return;
173
        end if;
174
 
175
        for i in 1 to value'length-1 loop
176
            if char_to_MVL9plus(s(i)) = ERROR then
177
                value := allU;
178
                good := FALSE;
179
                return;
180
            end if;
181
        end loop;
182
 
183
        mv(0) := char_to_MVL9(c);
184
        for i in 1 to value'length-1 loop
185
            mv(i) := char_to_MVL9(s(i));
186
        end loop;
187
        value := mv;
188
        good := TRUE;
189
    end READ;
190
 
191
 
192
    procedure READ (L: inout LINE;  VALUE: out STD_ULOGIC) is
193
        variable c: character;
194
    begin
195
        loop                    -- skip white space
196
            read(l, c);
197
            exit when (c /= ' ') and (c /= NBSP) and (c /= HT);
198
        end loop;
199
 
200
        if char_to_MVL9plus(c) = ERROR then
201
            value := 'U';
202
            assert FALSE report "READ(STD_ULOGIC) Error: Character '" &
203
                                c & "' read, expected STD_ULOGIC literal.";
204
        else
205
            value := char_to_MVL9(c);
206
        end if;
207
    end READ;
208
 
209
 
210
    procedure READ (L: inout LINE;  VALUE: out STD_ULOGIC_VECTOR) is
211
        variable m: STD_ULOGIC;
212
        variable c: character;
213
        variable s: string(1 to value'length-1);
214
        variable mv: STD_ULOGIC_VECTOR(0 to value'length-1);
215
        constant allU: STD_ULOGIC_VECTOR(0 to value'length-1)
216
                 := (others => 'U');
217
    begin
218
        loop                     -- skip white space
219
            read(l, c);
220
            exit when (c /= ' ') and (c /= NBSP) and (c /= HT);
221
        end loop;
222
 
223
        if char_to_MVL9plus(c) = ERROR then
224
            value := allU;
225
            assert FALSE report
226
                "READ(STD_ULOGIC_VECTOR) Error: Character '" &
227
                c & "' read, expected STD_ULOGIC literal.";
228
            return;
229
        end if;
230
 
231
        read(l, s);
232
        for i in 1 to value'length-1 loop
233
            if char_to_MVL9plus(s(i)) = ERROR then
234
                value := allU;
235
                assert FALSE report
236
                    "READ(STD_ULOGIC_VECTOR) Error: Character '" &
237
                    s(i) & "' read, expected STD_ULOGIC literal.";
238
                return;
239
            end if;
240
        end loop;
241
 
242
        mv(0) := char_to_MVL9(c);
243
        for i in 1 to value'length-1 loop
244
            mv(i) := char_to_MVL9(s(i));
245
        end loop;
246
        value := mv;
247
    end READ;
248
 
249
 
250
    procedure WRITE (L: inout LINE;  VALUE: in STD_ULOGIC;
251
                     JUSTIFIED: in SIDE := RIGHT;  FIELD: in WIDTH := 0) is
252
    begin
253
        write(l, MVL9_to_char(value), justified, field);
254
    end WRITE;
255
 
256
 
257
    procedure WRITE (L: inout LINE;  VALUE: in STD_ULOGIC_VECTOR;
258
                     JUSTIFIED: in SIDE := RIGHT;  FIELD: in WIDTH := 0) is
259
        variable s: string(1 to value'length);
260
        variable m: STD_ULOGIC_VECTOR(1 to value'length) := value;
261
    begin
262
        for i in 1 to value'length loop
263
            s(i) := MVL9_to_char(m(i));
264
        end loop;
265
        write(l, s, justified, field);
266
    end WRITE;
267
 
268
 
269
    -- Read and Write procedures for STD_LOGIC_VECTOR
270
 
271
    procedure READ (L: inout LINE;  VALUE: out STD_LOGIC_VECTOR;  GOOD: out BOOLEAN) is
272
        variable tmp: STD_ULOGIC_VECTOR(VALUE'length-1 downto 0);
273
    begin
274
        READ(L, tmp, GOOD);
275
        VALUE := STD_LOGIC_VECTOR(tmp);
276
    end READ;
277
 
278
 
279
    procedure READ (L: inout LINE;  VALUE: out STD_LOGIC_VECTOR) is
280
        variable tmp: STD_ULOGIC_VECTOR(VALUE'length-1 downto 0);
281
    begin
282
        READ(L, tmp);
283
        VALUE := STD_LOGIC_VECTOR(tmp);
284
    end READ;
285
 
286
 
287
    procedure WRITE (L: inout LINE;  VALUE: in STD_LOGIC_VECTOR;
288
                     JUSTIFIED: in SIDE := RIGHT;  FIELD: in WIDTH := 0) is
289
    begin
290
        WRITE(L, STD_ULOGIC_VECTOR(VALUE), JUSTIFIED, FIELD);
291
    end WRITE;
292
 
293
 
294
    -- Hex Read and Write procedures for STD_ULOGIC_VECTOR.
295
 
296
    procedure Char2QuadBits (C: Character;
297
                             RESULT: out std_ulogic_vector(3 downto 0);
298
                             GOOD: out Boolean;
299
                             ISSUE_ERROR: in Boolean) is
300
    begin
301
        case c is
302
            when '0' => result := x"0"; good := TRUE;
303
            when '1' => result := x"1"; good := TRUE;
304
            when '2' => result := x"2"; good := TRUE;
305
            when '3' => result := x"3"; good := TRUE;
306
            when '4' => result := x"4"; good := TRUE;
307
            when '5' => result := x"5"; good := TRUE;
308
            when '6' => result := x"6"; good := TRUE;
309
            when '7' => result := x"7"; good := TRUE;
310
            when '8' => result := x"8"; good := TRUE;
311
            when '9' => result := x"9"; good := TRUE;
312
            when 'A' | 'a' => result := x"A"; good := TRUE;
313
            when 'B' | 'b' => result := x"B"; good := TRUE;
314
            when 'C' | 'c' => result := x"C"; good := TRUE;
315
            when 'D' | 'd' => result := x"D"; good := TRUE;
316
            when 'E' | 'e' => result := x"E"; good := TRUE;
317
            when 'F' | 'f' => result := x"F"; good := TRUE;
318
            when 'Z' => result := "ZZZZ"; good := TRUE;
319
            when 'X' => result := "XXXX"; good := TRUE;
320
            when others =>
321
               if ISSUE_ERROR then
322
                   assert FALSE report
323
                       "HREAD Error: Read a '" & c &
324
                       "', expected a Hex character (0-F).";
325
               end if;
326
               good := FALSE;
327
        end case;
328
    end;
329
 
330
 
331
    procedure HREAD (L: inout LINE;  VALUE: out STD_ULOGIC_VECTOR;  GOOD: out BOOLEAN) is
332
        variable ok: boolean;
333
        variable c:  character;
334
        constant ne: integer := value'length/4;
335
        variable sv: std_ulogic_vector(0 to value'length-1);
336
        variable s:  string(1 to ne-1);
337
    begin
338
        if value'length mod 4 /= 0 then
339
            good := FALSE;
340
            return;
341
        end if;
342
 
343
        loop                    -- skip white space
344
            read(l, c, ok);
345
            exit when (ok = FALSE) or (c = LF) or (c = CR) or ((c /= ' ') and (c /= NBSP) and (c /= HT));
346
--            exit when (ok = FALSE) or ((c /= ' ') and (c /= NBSP) and (c /= HT));
347
        end loop;
348
 
349
        -- Bail out if there was a bad read
350
        if not ok then
351
            good := FALSE;
352
            return;
353
        end if;
354
 
355
        Char2QuadBits(c, sv(0 to 3), ok, FALSE);
356
        if not ok then
357
            good := FALSE;
358
            return;
359
        end if;
360
 
361
        read(L, s, ok);
362
        if not ok then
363
            good := FALSE;
364
            return;
365
        end if;
366
 
367
        for i in 1 to ne-1 loop
368
            Char2QuadBits(s(i), sv(4*i to 4*i+3), ok, FALSE);
369
            if not ok then
370
                good := FALSE;
371
                return;
372
            end if;
373
        end loop;
374
        good := TRUE;
375
        value := sv;
376
    end HREAD;
377
 
378
 
379
    procedure HREAD (L: inout LINE;  VALUE: out STD_ULOGIC_VECTOR)  is
380
        variable ok: boolean;
381
        variable c:  character;
382
        constant ne: integer := value'length/4;
383
        variable sv: std_ulogic_vector(0 to value'length-1);
384
        variable s:  string(1 to ne-1);
385
    begin
386
        if value'length mod 4 /= 0 then
387
            assert FALSE report
388
                "HREAD Error: Trying to read vector " &
389
                "with an odd (non multiple of 4) length";
390
            return;
391
        end if;
392
 
393
        loop                    -- skip white space
394
            read(l, c, ok);
395
            exit when (ok = FALSE) or ((c /= ' ') and (c /= NBSP) and (c /= HT));
396
        end loop;
397
 
398
        -- Bail out if there was a bad read
399
        if not ok then
400
            assert FALSE
401
              report "HREAD Error: Failed skipping white space";
402
            return;
403
        end if;
404
 
405
        Char2QuadBits(c, sv(0 to 3), ok, TRUE);
406
        if not ok then
407
            return;
408
        end if;
409
 
410
        read(L, s, ok);
411
        if not ok then
412
            assert FALSE
413
                report "HREAD Error: Failed to read the STRING";
414
            return;
415
        end if;
416
 
417
        for i in 1 to ne-1 loop
418
            Char2QuadBits(s(i), sv(4*i to 4*i+3), ok, TRUE);
419
            if not ok then
420
                return;
421
            end if;
422
        end loop;
423
        value := sv;
424
    end HREAD;
425
 
426
 
427
    procedure HWRITE (L: inout LINE;  VALUE: in STD_ULOGIC_VECTOR;
428
                      JUSTIFIED: in SIDE := RIGHT;  FIELD: in WIDTH := 0) is
429
        variable quad: std_ulogic_vector(0 to 3);
430
        constant ne:   integer := value'length/4;
431
        variable sv:   std_ulogic_vector(0 to value'length-1) := value;
432
        variable s:    string(1 to ne);
433
    begin
434
        if value'length mod 4 /= 0 then
435
            assert FALSE report
436
                "HWRITE Error: Trying to read vector " &
437
                "with an odd (non multiple of 4) length";
438
            return;
439
        end if;
440
 
441
        for i in 0 to ne-1 loop
442
            quad := To_X01Z(sv(4*i to 4*i+3));
443
            case quad is
444
                when x"0" => s(i+1) := '0';
445
                when x"1" => s(i+1) := '1';
446
                when x"2" => s(i+1) := '2';
447
                when x"3" => s(i+1) := '3';
448
                when x"4" => s(i+1) := '4';
449
                when x"5" => s(i+1) := '5';
450
                when x"6" => s(i+1) := '6';
451
                when x"7" => s(i+1) := '7';
452
                when x"8" => s(i+1) := '8';
453
                when x"9" => s(i+1) := '9';
454
                when x"A" => s(i+1) := 'A';
455
                when x"B" => s(i+1) := 'B';
456
                when x"C" => s(i+1) := 'C';
457
                when x"D" => s(i+1) := 'D';
458
                when x"E" => s(i+1) := 'E';
459
                when x"F" => s(i+1) := 'F';
460
                when others =>
461
                    if (quad = "ZZZZ") then
462
                       s(i+1) := 'Z';
463
                    else
464
                       s(i+1) := 'X';
465
                    end if;
466
            end case;
467
        end loop;
468
        write(L, s, JUSTIFIED, FIELD);
469
    end HWRITE;
470
 
471
 
472
    -- Octal Read and Write procedures for STD_ULOGIC_VECTOR.
473
 
474
    procedure Char2TriBits (C: Character;
475
                            RESULT: out std_ulogic_vector(2 downto 0);
476
                            GOOD: out Boolean;
477
                            ISSUE_ERROR: in Boolean) is
478
    begin
479
        case c is
480
            when '0' => result := o"0"; good := TRUE;
481
            when '1' => result := o"1"; good := TRUE;
482
            when '2' => result := o"2"; good := TRUE;
483
            when '3' => result := o"3"; good := TRUE;
484
            when '4' => result := o"4"; good := TRUE;
485
            when '5' => result := o"5"; good := TRUE;
486
            when '6' => result := o"6"; good := TRUE;
487
            when '7' => result := o"7"; good := TRUE;
488
            when 'Z' => result := "ZZZ"; good := TRUE;
489
            when 'X' => result := "XXX"; good := TRUE;
490
           when others =>
491
               if ISSUE_ERROR then
492
                   assert FALSE report
493
                       "OREAD Error: Read a '" & c &
494
                       "', expected an Octal character (0-7).";
495
               end if;
496
               good := FALSE;
497
        end case;
498
    end;
499
 
500
 
501
    procedure OREAD (L: inout LINE;  VALUE: out STD_ULOGIC_VECTOR;  GOOD: out BOOLEAN) is
502
        variable ok: boolean;
503
        variable c:  character;
504
        constant ne: integer := value'length/3;
505
        variable sv: std_ulogic_vector(0 to value'length-1);
506
        variable s:  string(1 to ne-1);
507
    begin
508
        if value'length mod 3 /= 0 then
509
            good := FALSE;
510
            return;
511
        end if;
512
 
513
        loop                    -- skip white space
514
            read(l, c, ok);
515
            exit when (ok = FALSE) or ((c /= ' ') and (c /= NBSP) and (c /= HT));
516
        end loop;
517
 
518
        -- Bail out if there was a bad read
519
        if not ok then
520
            good := FALSE;
521
            return;
522
        end if;
523
 
524
        Char2TriBits(c, sv(0 to 2), ok, FALSE);
525
        if not ok then
526
            good := FALSE;
527
            return;
528
        end if;
529
 
530
        read(L, s, ok);
531
        if not ok then
532
            good := FALSE;
533
            return;
534
        end if;
535
 
536
        for i in 1 to ne-1 loop
537
            Char2TriBits(s(i), sv(3*i to 3*i+2), ok, FALSE);
538
            if not ok then
539
                good := FALSE;
540
                return;
541
            end if;
542
        end loop;
543
        good := TRUE;
544
        value := sv;
545
    end OREAD;
546
 
547
 
548
    procedure OREAD (L: inout LINE;  VALUE: out STD_ULOGIC_VECTOR)  is
549
        variable c: character;
550
        variable ok: boolean;
551
        constant ne: integer := value'length/3;
552
        variable sv: std_ulogic_vector(0 to value'length-1);
553
        variable s: string(1 to ne-1);
554
    begin
555
        if value'length mod 3 /= 0 then
556
            assert FALSE report
557
                "OREAD Error: Trying to read vector " &
558
                "with an odd (non multiple of 3) length";
559
            return;
560
        end if;
561
 
562
        loop                    -- skip white space
563
            read(l, c, ok);
564
            exit when (ok = FALSE) or ((c /= ' ') and (c /= NBSP) and (c /= HT));
565
        end loop;
566
 
567
        -- Bail out if there was a bad read
568
        if not ok then
569
            assert FALSE
570
              report "OREAD Error: Failed skipping white space";
571
            return;
572
        end if;
573
 
574
        Char2TriBits(c, sv(0 to 2), ok, TRUE);
575
        if not ok then
576
            return;
577
        end if;
578
 
579
        read(L, s, ok);
580
        if not ok then
581
            assert FALSE
582
                report "OREAD Error: Failed to read the STRING";
583
            return;
584
        end if;
585
 
586
        for i in 1 to ne-1 loop
587
            Char2TriBits(s(i), sv(3*i to 3*i+2), ok, TRUE);
588
            if not ok then
589
                return;
590
            end if;
591
        end loop;
592
        value := sv;
593
    end OREAD;
594
 
595
 
596
    procedure OWRITE (L: inout LINE;  VALUE: in STD_ULOGIC_VECTOR;
597
                      JUSTIFIED: in SIDE := RIGHT;  FIELD: in WIDTH := 0) is
598
        variable tri: std_ulogic_vector(0 to 2);
599
        constant ne:  integer := value'length/3;
600
        variable sv:  std_ulogic_vector(0 to value'length-1) := value;
601
        variable s:   string(1 to ne);
602
    begin
603
        if value'length mod 3 /= 0 then
604
            assert FALSE report
605
                "OWRITE Error: Trying to read vector " &
606
                "with an odd (non multiple of 3) length";
607
            return;
608
        end if;
609
 
610
        for i in 0 to ne-1 loop
611
            tri := To_X01Z(sv(3*i to 3*i+2));
612
            case tri is
613
                when o"0" => s(i+1) := '0';
614
                when o"1" => s(i+1) := '1';
615
                when o"2" => s(i+1) := '2';
616
                when o"3" => s(i+1) := '3';
617
                when o"4" => s(i+1) := '4';
618
                when o"5" => s(i+1) := '5';
619
                when o"6" => s(i+1) := '6';
620
                when o"7" => s(i+1) := '7';
621
                when others =>
622
                    if (tri = "ZZZ") then
623
                       s(i+1) := 'Z';
624
                    else
625
                       s(i+1) := 'X';
626
                    end if;
627
            end case;
628
        end loop;
629
        write(L, s, JUSTIFIED, FIELD);
630
    end OWRITE;
631
 
632
 
633
    -- Hex Read and Write procedures for STD_LOGIC_VECTOR
634
 
635
    procedure HREAD (L: inout LINE;  VALUE: out STD_LOGIC_VECTOR;  GOOD: out BOOLEAN) is
636
        variable tmp: STD_ULOGIC_VECTOR(VALUE'length-1 downto 0);
637
    begin
638
        HREAD(L, tmp, GOOD);
639
        VALUE := STD_LOGIC_VECTOR(tmp);
640
    end HREAD;
641
 
642
 
643
    procedure HREAD (L: inout LINE;  VALUE: out STD_LOGIC_VECTOR) is
644
        variable tmp: STD_ULOGIC_VECTOR(VALUE'length-1 downto 0);
645
    begin
646
        HREAD(L, tmp);
647
        VALUE := STD_LOGIC_VECTOR(tmp);
648
    end HREAD;
649
 
650
 
651
    procedure HWRITE (L: inout LINE;  VALUE: in STD_LOGIC_VECTOR;
652
                      JUSTIFIED: in SIDE := RIGHT;  FIELD: in WIDTH := 0) is
653
    begin
654
        HWRITE(L, STD_ULOGIC_VECTOR(VALUE), JUSTIFIED, FIELD);
655
    end HWRITE;
656
 
657
 
658
    -- Octal Read and Write procedures for STD_LOGIC_VECTOR
659
 
660
    procedure OREAD (L: inout LINE;  VALUE: out STD_LOGIC_VECTOR;  GOOD: out BOOLEAN) is
661
        variable tmp: STD_ULOGIC_VECTOR(VALUE'length-1 downto 0);
662
    begin
663
        OREAD(L, tmp, GOOD);
664
        VALUE := STD_LOGIC_VECTOR(tmp);
665
    end OREAD;
666
 
667
    procedure OREAD (L: inout LINE;  VALUE: out STD_LOGIC_VECTOR) is
668
        variable tmp: STD_ULOGIC_VECTOR(VALUE'length-1 downto 0);
669
    begin
670
        OREAD(L, tmp);
671
        VALUE := STD_LOGIC_VECTOR(tmp);
672
    end OREAD;
673
 
674
 
675
    procedure OWRITE (L: inout LINE;  VALUE: in STD_LOGIC_VECTOR;
676
                      JUSTIFIED: in SIDE := RIGHT;  FIELD: in WIDTH := 0) is
677
    begin
678
        OWRITE(L, STD_ULOGIC_VECTOR(VALUE), JUSTIFIED, FIELD);
679
    end OWRITE;
680
 
681
 
682
end STD_LOGIC_TEXTIO;

powered by: WebSVN 2.1.0

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