Line 1... |
Line 1... |
-- $Id: simlib.vhd 427 2011-11-19 21:04:11Z mueller $
|
-- $Id: simlib.vhd 444 2011-12-25 10:04:58Z mueller $
|
--
|
--
|
-- Copyright 2006-2011 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
-- Copyright 2006-2011 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
--
|
--
|
-- This program is free software; you may redistribute and/or modify it under
|
-- This program is free software; you may redistribute and/or modify it under
|
-- the terms of the GNU General Public License as published by the Free
|
-- the terms of the GNU General Public License as published by the Free
|
Line 20... |
Line 20... |
-- Target Devices: generic
|
-- Target Devices: generic
|
-- Tool versions: xst 8.2, 9.1, 9.2, 12.1, 13.1; ghdl 0.18-0.29
|
-- Tool versions: xst 8.2, 9.1, 9.2, 12.1, 13.1; ghdl 0.18-0.29
|
--
|
--
|
-- Revision History:
|
-- Revision History:
|
-- Date Rev Version Comment
|
-- Date Rev Version Comment
|
|
-- 2011-12-23 444 2.0 drop CLK_CYCLE from simclk,simclkv; use integer for
|
|
-- simclkcnt(CLK_CYCLE),writetimestamp(clkcyc);
|
-- 2011-11-18 427 1.3.8 now numeric_std clean
|
-- 2011-11-18 427 1.3.8 now numeric_std clean
|
-- 2010-12-22 346 1.3.7 rename readcommand -> readdotcomm
|
-- 2010-12-22 346 1.3.7 rename readcommand -> readdotcomm
|
-- 2010-11-13 338 1.3.6 add simclkcnt; xx.x ns time in writetimestamp()
|
-- 2010-11-13 338 1.3.6 add simclkcnt; xx.x ns time in writetimestamp()
|
-- 2008-03-24 129 1.3.5 CLK_CYCLE now 31 bits
|
-- 2008-03-24 129 1.3.5 CLK_CYCLE now 31 bits
|
-- 2008-03-02 121 1.3.4 added readempty (to discard rest of line)
|
-- 2008-03-02 121 1.3.4 added readempty (to discard rest of line)
|
Line 195... |
Line 197... |
field: in width:=0; -- field width
|
field: in width:=0; -- field width
|
base: in integer:= 2); -- default base
|
base: in integer:= 2); -- default base
|
|
|
procedure writetimestamp(
|
procedure writetimestamp(
|
L: inout line;
|
L: inout line;
|
clkcyc: in slv31;
|
clkcyc: in integer;
|
str : in string := null_string);
|
str : in string := null_string);
|
|
|
-- ----------------------------------------------------------------------------
|
-- ----------------------------------------------------------------------------
|
|
|
component simclk is -- test bench clock generator
|
component simclk is -- test bench clock generator
|
generic (
|
generic (
|
PERIOD : time := 20 ns; -- clock period
|
PERIOD : time := 20 ns; -- clock period
|
OFFSET : time := 200 ns); -- clock offset (first up transition)
|
OFFSET : time := 200 ns); -- clock offset (first up transition)
|
port (
|
port (
|
CLK : out slbit; -- clock
|
CLK : out slbit; -- clock
|
CLK_CYCLE : out slv31; -- clock cycle number
|
|
CLK_STOP : in slbit -- clock stop trigger
|
CLK_STOP : in slbit -- clock stop trigger
|
);
|
);
|
end component;
|
end component;
|
|
|
component simclkv is -- test bench clock generator
|
component simclkv is -- test bench clock generator
|
-- with variable periods
|
-- with variable periods
|
port (
|
port (
|
CLK : out slbit; -- clock
|
CLK : out slbit; -- clock
|
CLK_CYCLE : out slv31; -- clock cycle number
|
|
CLK_PERIOD : in time; -- clock period
|
CLK_PERIOD : in time; -- clock period
|
CLK_HOLD : in slbit; -- if 1, hold clocks in 0 state
|
CLK_HOLD : in slbit; -- if 1, hold clocks in 0 state
|
CLK_STOP : in slbit -- clock stop trigger
|
CLK_STOP : in slbit -- clock stop trigger
|
);
|
);
|
end component;
|
end component;
|
|
|
component simclkcnt is -- test bench system clock cycle counter
|
component simclkcnt is -- test bench system clock cycle counter
|
port (
|
port (
|
CLK : in slbit; -- clock
|
CLK : in slbit; -- clock
|
CLK_CYCLE : out slv31 -- clock cycle number
|
CLK_CYCLE : out integer -- clock cycle number
|
);
|
);
|
end component;
|
end component;
|
|
|
end package simlib;
|
end package simlib;
|
|
|
Line 1060... |
Line 1060... |
|
|
-- -------------------------------------
|
-- -------------------------------------
|
|
|
procedure writetimestamp(
|
procedure writetimestamp(
|
L: inout line;
|
L: inout line;
|
clkcyc: in slv31;
|
clkcyc: in integer;
|
str: in string := null_string) is
|
str: in string := null_string) is
|
|
|
variable t_nsec : integer := 0;
|
variable t_nsec : integer := 0;
|
variable t_psec : integer := 0;
|
variable t_psec : integer := 0;
|
variable t_dnsec : integer := 0;
|
variable t_dnsec : integer := 0;
|
Line 1079... |
Line 1079... |
write(L, t_nsec, right, 8);
|
write(L, t_nsec, right, 8);
|
write(L,'.');
|
write(L,'.');
|
write(L, t_dnsec, right, 1);
|
write(L, t_dnsec, right, 1);
|
write(L, string'(" ns"));
|
write(L, string'(" ns"));
|
|
|
write(L, to_integer(unsigned(clkcyc)), right, 7);
|
write(L, clkcyc, right, 7);
|
if str /= null_string then
|
if str /= null_string then
|
write(L, str);
|
write(L, str);
|
end if;
|
end if;
|
|
|
end procedure writetimestamp;
|
end procedure writetimestamp;
|