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

Subversion Repositories w11

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

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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