w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
simclk.vhd
Go to the documentation of this file.
1-- $Id: simclk.vhd 1181 2019-07-08 17:00:50Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2007-2016 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: simclk - sim
7-- Description: Clock generator for test benches
8--
9-- Dependencies: -
10-- Test bench: -
11-- Target Devices: generic
12-- Tool versions: xst 8.2-14.7; viv 2016.2; ghdl 0.18-0.33
13--
14-- Revision History:
15-- Date Rev Version Comment
16-- 2016-09-03 805 2.0.1 CLK_STOP now optional port
17-- 2011-12-23 444 2.0 remove CLK_CYCLE output port
18-- 2011-11-18 427 1.0.3 now numeric_std clean
19-- 2008-03-24 129 1.0.2 CLK_CYCLE now 31 bits
20-- 2007-10-12 88 1.0.1 avoid ieee.std_logic_unsigned, use cast to unsigned
21-- 2007-08-10 72 1.0 Initial version
22------------------------------------------------------------------------------
23
24library ieee;
25use ieee.std_logic_1164.all;
26use work.slvtypes.all;
27
28entity simclk is -- test bench clock generator
29 generic (
30 PERIOD : Delay_length := 20 ns; -- clock period
31 OFFSET : Delay_length := 200 ns); -- clock offset (first up transition)
32 port (
33 CLK : out slbit; -- clock
34 CLK_STOP : in slbit := '0' -- clock stop trigger
35 );
36end entity simclk;
37
38architecture sim of simclk is
39begin
40
41 proc_clk: process
42 constant clock_halfperiod : Delay_length := PERIOD/2;
43 begin
44
45 CLK <= '0';
46 wait for OFFSET;
47
48 clk_loop: loop
49 CLK <= '1';
50 wait for clock_halfperiod;
51 CLK <= '0';
52 wait for PERIOD-clock_halfperiod;
53 exit clk_loop when CLK_STOP = '1';
54 end loop;
55
56 CLK <= '1'; -- final clock cycle for clk_sim
57 wait for clock_halfperiod;
58 CLK <= '0';
59 wait for PERIOD-clock_halfperiod;
60
61 wait; -- endless wait, simulator will stop
62
63 end process proc_clk;
64
65end sim;
out CLK slbit
Definition: simclk.vhd:33
OFFSET Delay_length := 200 ns
Definition: simclk.vhd:31
in CLK_STOP slbit := '0'
Definition: simclk.vhd:35
PERIOD Delay_length := 20 ns
Definition: simclk.vhd:30
std_logic slbit
Definition: slvtypes.vhd:30