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

Subversion Repositories lateq

[/] [lateq/] [trunk/] [hdl_various_types/] [src/] [lateq_pkg.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 wzab
-------------------------------------------------------------------------------
2
-- Title      : lateq_pkg package
3
-- Project    : 
4
-------------------------------------------------------------------------------
5
-- File       : lateq_pkg.vhd
6
-- Author     : Wojciech M. Zabolotny ( wzab01<at>gmail.com )
7
-- Company    :
8
-- License    : BSD
9
-- Created    : 2013-11-01
10
-- Last update: 2015-09-24
11
-- Platform   : 
12
-- Standard   : VHDL'93/02
13
-------------------------------------------------------------------------------
14
-- Description: Package with definitions needed to create the hierarhical
15
--              block for finding the maximum element
16
-------------------------------------------------------------------------------
17
-- Copyright (c) 2015
18
-------------------------------------------------------------------------------
19
-- Revisions  :
20
-- Date        Version  Author  Description
21
-- 2013-11-01  1.0      WZab    Created
22
-------------------------------------------------------------------------------
23
 
24
library ieee;
25
use ieee.std_logic_1164.all;
26
use ieee.numeric_std.all;
27
use std.textio.all;
28
 
29
library work;
30
 
31
package lateq_pkg is
32
 
33
  -- pragma translate_off
34
 
35
  file f_lat_rep : text is out "/tmp/latrep.txt";
36
  file f_leq_mode : text is in "/tmp/lateq_mode.txt";
37
 
38
  -- Function reading the simulation mode
39
  function lateq_mode_read
40
    return integer;
41
 
42
  constant C_LATEQ_MODE     : integer   :=  lateq_mode_read;
43
 
44
  -- Constant defining the maximum value of the time marker
45
  constant C_LATEQ_MRK_MAX  : integer     := 1000000;
46
  -- Type used to keep the time marker
47
  subtype T_LATEQ_MRK is integer range -1 to C_LATEQ_MRK_MAX;
48
  constant C_LATEQ_MRK_INIT : T_LATEQ_MRK := -1;
49
 
50
 
51
 
52
  -- Function used to increase the time marker
53
  function lateq_mrk_incr (
54
    constant v : T_LATEQ_MRK)
55
    return T_LATEQ_MRK;
56
 
57
  -- Function for comparison of time markers
58
  function lateq_mrk_cmp (
59
    constant v1, v2 : T_LATEQ_MRK)
60
    return integer;
61
 
62
  -- Function converting time marker to string (for reports)
63
  function lateq_mrk_to_str (
64
    constant v1 : T_LATEQ_MRK)
65
    return string;
66
 
67
  -- Function reporting the delay for analyzis
68
  procedure lateq_report_delay (
69
    constant s1     :    string;
70
    constant i1, i2 : in integer);
71
 
72
  -- Function marking the end of reports from single block
73
  procedure lateq_report_end (
74
    constant s1 : string);
75
  -- pragma translate_on
76
 
77
end package lateq_pkg;
78
 
79
package body lateq_pkg is
80
 
81
-- pragma translate_off
82
 
83
  function lateq_mode_read
84
    return integer is
85
    variable rl : line;
86
    variable res : integer;
87
    begin
88
      readline(f_leq_mode,rl);
89
      read(rl,res);
90
      return res;
91
    end function lateq_mode_read;
92
 
93
  -- For long simulations we must "wrap" the time
94
  -- marker.
95
  function lateq_mrk_incr (
96
    constant v : T_LATEQ_MRK)
97
    return T_LATEQ_MRK is
98
    variable res : T_LATEQ_MRK;
99
  begin
100
    if v < C_LATEQ_MRK_MAX-1 then
101
      res := v+1;
102
    else
103
      res := 0;
104
    end if;
105
    return res;
106
  end function lateq_mrk_incr;
107
 
108
  -- For wrapped time markers we must perform mathematical
109
  -- operations in a special way
110
  function lateq_mrk_cmp (
111
    constant v1, v2 : T_LATEQ_MRK)
112
    return integer is
113
    variable res : integer;
114
  begin  -- function "-"
115
    res := v1-v2;
116
    -- Now correct effects of wrapping
117
    if res > C_LATEQ_MRK_MAX/2 then
118
      res := res - C_LATEQ_MRK_MAX;
119
    end if;
120
    if res < -(C_LATEQ_MRK_MAX/2) then
121
      res := res + C_LATEQ_MRK_MAX;
122
    end if;
123
    return res;
124
  end function lateq_mrk_cmp;
125
 
126
  function lateq_mrk_to_str (
127
    constant v1 : T_LATEQ_MRK)
128
    return string is
129
  begin
130
    return integer'image(v1);
131
  end function lateq_mrk_to_str;
132
 
133
 
134
  procedure lateq_report_delay (
135
    constant s1     :    string;
136
    constant i1, i2 : in integer) is
137
    variable wl : line;
138
  begin
139
    write(wl, s1 & string'(","));
140
    write(wl, integer'image(i1));
141
    write(wl, string'(","));
142
    write(wl, integer'image(i2));
143
    writeline(f_lat_rep, wl);
144
  end procedure lateq_report_delay;
145
 
146
  procedure lateq_report_end (
147
    constant s1 : string) is
148
    variable wl : line;
149
  begin
150
    write(wl, s1 & string'(",end"));
151
    writeline(f_lat_rep, wl);
152
  end procedure lateq_report_end;
153
  -- pragma translate_on 
154
 
155
 
156
end package body lateq_pkg;

powered by: WebSVN 2.1.0

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