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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.5/] [rtl/] [vlib/] [simlib/] [simclk.vhd] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 wfjm
-- $Id: simclk.vhd 314 2010-07-09 17:38:41Z mueller $
2
--
3
-- Copyright 2007-2008 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4
--
5
-- This program is free software; you may redistribute and/or modify it under
6
-- the terms of the GNU General Public License as published by the Free
7
-- Software Foundation, either version 2, or at your option any later version.
8
--
9
-- This program is distributed in the hope that it will be useful, but
10
-- WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
11
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
-- for complete details.
13
--
14
------------------------------------------------------------------------------
15
-- Module Name:    simclk - sim
16
-- Description:    Clock generator for test benches
17
--
18
-- Dependencies:   -
19
-- Test bench:     -
20
-- Target Devices: generic
21
-- Tool versions:  xst 8.1, 8.2, 9.1, 9.2; ghdl 0.18-0.25
22
-- Revision History: 
23
-- Date         Rev Version  Comment
24
-- 2008-03-24   129   1.0.2  CLK_CYCLE now 31 bits
25
-- 2007-10-12    88   1.0.1  avoid ieee.std_logic_unsigned, use cast to unsigned
26
-- 2007-08-10    72   1.0    Initial version 
27
------------------------------------------------------------------------------
28
 
29
library ieee;
30
use ieee.std_logic_1164.all;
31
use ieee.std_logic_arith.all;
32
use work.slvtypes.all;
33
 
34
entity simclk is                      -- test bench clock generator
35
  generic (
36
    PERIOD : time := 20 ns;           -- clock period
37
    OFFSET : time := 200 ns);         -- clock offset (first up transition)
38
  port (
39
    CLK  : out slbit;                 -- clock
40
    CLK_CYCLE  : out slv31;           -- clock cycle number
41
    CLK_STOP : in slbit               -- clock stop trigger
42
  );
43
end entity simclk;
44
 
45
architecture sim of simclk is
46
begin
47
 
48
  clk_proc: process
49
    constant clock_halfperiod : time := PERIOD/2;
50
    variable icycle : slv31 := (others=>'0');
51
  begin
52
 
53
    CLK <= '0';
54
    CLK_CYCLE <= (others=>'0');
55
    wait for OFFSET;
56
 
57
    clk_loop: loop
58
      CLK <= '1';
59
      wait for 0 ns;                    -- make a delta cycle so that clock
60
      icycle := unsigned(icycle) + 1;   -- cycle number is updated after the 
61
      CLK_CYCLE <= icycle;              -- clock transition. all edge triggered
62
                                        -- proc's will thus read old value.
63
      wait for clock_halfperiod;
64
      CLK <= '0';
65
      wait for clock_halfperiod;
66
      exit clk_loop when CLK_STOP = '1';
67
    end loop;
68
 
69
    CLK <= '1';                         -- final clock cycle for clk_sim
70
    wait for clock_halfperiod;
71
    CLK <= '0';
72
    wait for clock_halfperiod;
73
 
74
    wait;                               -- endless wait, simulator will stop
75
 
76
  end process;
77
 
78
end sim;

powered by: WebSVN 2.1.0

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