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

Subversion Repositories lateq

[/] [lateq/] [trunk/] [hdl_various_types/] [src/] [lateq_pkg.vhd] - Rev 2

Compare with Previous | Blame | View Log

-------------------------------------------------------------------------------
-- Title      : lateq_pkg package
-- Project    : 
-------------------------------------------------------------------------------
-- File       : lateq_pkg.vhd
-- Author     : Wojciech M. Zabolotny ( wzab01<at>gmail.com )
-- Company    :
-- License    : BSD
-- Created    : 2013-11-01
-- Last update: 2015-09-24
-- Platform   : 
-- Standard   : VHDL'93/02
-------------------------------------------------------------------------------
-- Description: Package with definitions needed to create the hierarhical
--              block for finding the maximum element
-------------------------------------------------------------------------------
-- Copyright (c) 2015
-------------------------------------------------------------------------------
-- Revisions  :
-- Date        Version  Author  Description
-- 2013-11-01  1.0      WZab    Created
-------------------------------------------------------------------------------
 
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use std.textio.all;
 
library work;
 
package lateq_pkg is
 
  -- pragma translate_off
 
  file f_lat_rep : text is out "/tmp/latrep.txt";
  file f_leq_mode : text is in "/tmp/lateq_mode.txt";
 
  -- Function reading the simulation mode
  function lateq_mode_read 
    return integer;
 
  constant C_LATEQ_MODE     : integer   :=  lateq_mode_read;
 
  -- Constant defining the maximum value of the time marker
  constant C_LATEQ_MRK_MAX  : integer     := 1000000;
  -- Type used to keep the time marker
  subtype T_LATEQ_MRK is integer range -1 to C_LATEQ_MRK_MAX;
  constant C_LATEQ_MRK_INIT : T_LATEQ_MRK := -1;
 
 
 
  -- Function used to increase the time marker
  function lateq_mrk_incr (
    constant v : T_LATEQ_MRK)
    return T_LATEQ_MRK;
 
  -- Function for comparison of time markers
  function lateq_mrk_cmp (
    constant v1, v2 : T_LATEQ_MRK)
    return integer;
 
  -- Function converting time marker to string (for reports)
  function lateq_mrk_to_str (
    constant v1 : T_LATEQ_MRK)
    return string;
 
  -- Function reporting the delay for analyzis
  procedure lateq_report_delay (
    constant s1     :    string;
    constant i1, i2 : in integer);
 
  -- Function marking the end of reports from single block
  procedure lateq_report_end (
    constant s1 : string);
  -- pragma translate_on
 
end package lateq_pkg;
 
package body lateq_pkg is
 
-- pragma translate_off
 
  function lateq_mode_read
    return integer is
    variable rl : line;
    variable res : integer;
    begin
      readline(f_leq_mode,rl);
      read(rl,res);
      return res;
    end function lateq_mode_read;
 
  -- For long simulations we must "wrap" the time
  -- marker.
  function lateq_mrk_incr (
    constant v : T_LATEQ_MRK)
    return T_LATEQ_MRK is
    variable res : T_LATEQ_MRK;
  begin
    if v < C_LATEQ_MRK_MAX-1 then
      res := v+1;
    else
      res := 0;
    end if;
    return res;
  end function lateq_mrk_incr;
 
  -- For wrapped time markers we must perform mathematical
  -- operations in a special way
  function lateq_mrk_cmp (
    constant v1, v2 : T_LATEQ_MRK)
    return integer is
    variable res : integer;
  begin  -- function "-"
    res := v1-v2;
    -- Now correct effects of wrapping
    if res > C_LATEQ_MRK_MAX/2 then
      res := res - C_LATEQ_MRK_MAX;
    end if;
    if res < -(C_LATEQ_MRK_MAX/2) then
      res := res + C_LATEQ_MRK_MAX;
    end if;
    return res;
  end function lateq_mrk_cmp;
 
  function lateq_mrk_to_str (
    constant v1 : T_LATEQ_MRK)
    return string is
  begin
    return integer'image(v1);
  end function lateq_mrk_to_str;
 
 
  procedure lateq_report_delay (
    constant s1     :    string;
    constant i1, i2 : in integer) is
    variable wl : line;
  begin
    write(wl, s1 & string'(","));
    write(wl, integer'image(i1));
    write(wl, string'(","));
    write(wl, integer'image(i2));
    writeline(f_lat_rep, wl);
  end procedure lateq_report_delay;
 
  procedure lateq_report_end (
    constant s1 : string) is
    variable wl : line;
  begin
    write(wl, s1 & string'(",end"));
    writeline(f_lat_rep, wl);
  end procedure lateq_report_end;
  -- pragma translate_on 
 
 
end package body lateq_pkg;
 

Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

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