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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.6/] [rtl/] [vlib/] [genlib/] [clkdivce.vhd] - Blame information for rev 24

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 wfjm
-- $Id: clkdivce.vhd 418 2011-10-23 20:11:40Z mueller $
2 2 wfjm
--
3 13 wfjm
-- Copyright 2007-2011 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4 2 wfjm
--
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:    clkgen - syn
16
-- Description:    Generate usec and msec enable signals
17
--
18
-- Dependencies:   -
19
-- Test bench:     -
20
-- Target Devices: generic
21 13 wfjm
-- Tool versions:  xst 8.2, 9.1, 9.2, 12.1, 13.1; ghdl 0.18-0.29
22 2 wfjm
-- Revision History: 
23
-- Date        Rev  Version    Comment
24 13 wfjm
-- 2011-10-22   418   1.0.3  now numeric_std clean
25 2 wfjm
-- 2008-01-20   112   1.0.2  rename clkgen->clkdivce; remove SYS_CLK port
26
-- 2007-10-12    88   1.0.1  avoid ieee.std_logic_unsigned, use cast to unsigned
27
-- 2007-06-30    62   1.0    Initial version 
28
------------------------------------------------------------------------------
29
 
30
library ieee;
31
use ieee.std_logic_1164.all;
32 13 wfjm
use ieee.numeric_std.all;
33 2 wfjm
 
34
use work.slvtypes.all;
35
 
36
entity clkdivce is                      -- generate usec/msec ce pulses
37
  generic (
38
    CDUWIDTH : positive := 6;           -- usec clock divider width
39
    USECDIV : positive :=  50;          -- divider ratio for usec pulse
40
    MSECDIV : positive := 1000);        -- divider ratio for msec pulse
41
  port (
42
    CLK     : in slbit;                 -- input clock
43
    CE_USEC : out slbit;                -- usec pulse
44
    CE_MSEC : out slbit                 -- msec pulse
45
  );
46
end clkdivce;
47
 
48
 
49
architecture syn of clkdivce is
50
 
51
  type regs_type is record
52
    ucnt : slv(CDUWIDTH-1 downto 0);    -- usec clock divider counter
53
    mcnt : slv10;                       -- msec clock divider counter
54
    usec : slbit;                       -- usec pulse
55
    msec : slbit;                       -- msec pulse
56
  end record regs_type;
57
 
58
  constant regs_init : regs_type := (
59 13 wfjm
    slv(to_unsigned(USECDIV-1,CDUWIDTH)),
60
    slv(to_unsigned(MSECDIV-1,10)),
61 2 wfjm
    '0','0'
62
  );
63
 
64
  signal R_REGS : regs_type := regs_init;  -- state registers
65
  signal N_REGS : regs_type := regs_init;  -- next value state regs
66
 
67
begin
68
 
69
  assert USECDIV <= 2**CDUWIDTH and MSECDIV <= 1024
70
    report "assert(USECDIV <= 2**CDUWIDTH and MSECDIV <= 1024): " &
71
           "USECDIV too large for given CDUWIDTH or MSECDIV>1024"
72
    severity FAILURE;
73
 
74
  proc_regs: process (CLK)
75
  begin
76
 
77 13 wfjm
    if rising_edge(CLK) then
78 2 wfjm
      R_REGS <= N_REGS;
79
    end if;
80
 
81
  end process proc_regs;
82
 
83
  proc_next: process (R_REGS)
84
 
85
    variable r : regs_type := regs_init;
86
    variable n : regs_type := regs_init;
87
 
88
  begin
89
 
90
    r := R_REGS;
91
    n := R_REGS;
92
 
93
    n.usec := '0';
94
    n.msec := '0';
95
 
96 13 wfjm
    n.ucnt := slv(unsigned(r.ucnt) - 1);
97 2 wfjm
    if unsigned(r.ucnt) = 0 then
98
      n.usec := '1';
99 13 wfjm
      n.ucnt := slv(to_unsigned(USECDIV-1,CDUWIDTH));
100
      n.mcnt := slv(unsigned(r.mcnt) - 1);
101 2 wfjm
      if unsigned(r.mcnt) = 0 then
102
        n.msec := '1';
103 13 wfjm
        n.mcnt := slv(to_unsigned(MSECDIV-1,10));
104 2 wfjm
      end if;
105
    end if;
106
 
107
    N_REGS <= n;
108
 
109
    CE_USEC <= r.usec;
110
    CE_MSEC <= r.msec;
111
 
112
  end process proc_next;
113
 
114
 
115
end syn;

powered by: WebSVN 2.1.0

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