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

Subversion Repositories t400

[/] [t400/] [trunk/] [rtl/] [vhdl/] [t400_clkgen.vhd] - Blame information for rev 179

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 arniml
-------------------------------------------------------------------------------
2
--
3
-- The clock generation unit.
4
-- PHI1 clock and input/output clock enables are generated here.
5
--
6 179 arniml
-- $Id: t400_clkgen.vhd 179 2009-04-01 19:48:38Z arniml $
7 2 arniml
--
8
-- Copyright (c) 2006 Arnim Laeuger (arniml@opencores.org)
9
--
10
-- All rights reserved
11
--
12
-- Redistribution and use in source and synthezised forms, with or without
13
-- modification, are permitted provided that the following conditions are met:
14
--
15
-- Redistributions of source code must retain the above copyright notice,
16
-- this list of conditions and the following disclaimer.
17
--
18
-- Redistributions in synthesized form must reproduce the above copyright
19
-- notice, this list of conditions and the following disclaimer in the
20
-- documentation and/or other materials provided with the distribution.
21
--
22
-- Neither the name of the author nor the names of other contributors may
23
-- be used to endorse or promote products derived from this software without
24
-- specific prior written permission.
25
--
26
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
28
-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29
-- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
30
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36
-- POSSIBILITY OF SUCH DAMAGE.
37
--
38
-- Please report bugs to the author, but before you do so, please
39
-- make sure that this is not a derivative work and that
40
-- you have the latest version of this file.
41
--
42
-- The latest version of this file can be found at:
43
--      http://www.opencores.org/cvsweb.shtml/t400/
44
--
45
-------------------------------------------------------------------------------
46
 
47
library ieee;
48
use ieee.std_logic_1164.all;
49
 
50
use work.t400_opt_pack.all;
51
 
52
entity t400_clkgen is
53
 
54
  generic (
55
    opt_ck_div_g : integer := t400_opt_ck_div_16_c
56
  );
57
  port (
58
    -- System Interface -------------------------------------------------------
59
    ck_i      : in  std_logic;
60
    ck_en_i   : in  boolean;
61
    por_i     : in  boolean;
62
    -- Clock Interface --------------------------------------------------------
63
    phi1_o    : out std_logic;
64
    out_en_o  : out boolean;
65
    in_en_o   : out boolean;
66
    icyc_en_o : out boolean
67
  );
68
 
69
end t400_clkgen;
70
 
71
 
72
library ieee;
73
use ieee.numeric_std.all;
74
 
75
architecture rtl of t400_clkgen is
76
 
77
  subtype  ck_div_t       is unsigned(5 downto 0);
78
  type     ck_div_a_t     is array(natural range t400_opt_ck_div_32_c
79
                                   downto        t400_opt_ck_div_4_c) of
80
                             ck_div_t;
81
  -- reload values for the CK dividing counter
82
  constant ck_div_a_c     : ck_div_a_t := (
83
    t400_opt_ck_div_32_c  => to_unsigned(31, ck_div_t'length),
84
    t400_opt_ck_div_16_c  => to_unsigned(15, ck_div_t'length),
85
    t400_opt_ck_div_8_c   => to_unsigned( 7, ck_div_t'length),
86
    t400_opt_ck_div_4_c   => to_unsigned( 3, ck_div_t'length));
87
 
88
  signal   ck_div_cnt_q   : ck_div_t;
89
  signal   ck_div_zero_s,
90
           ck_div_half_s  : boolean;
91
  signal   phi1_q         : std_logic;
92
 
93
begin
94
 
95
  -----------------------------------------------------------------------------
96
  -- Process ck_div
97
  --
98
  -- Purpose:
99
  --   Divide the incoming clock on ck_i and generate the derived clock
100
  --   enable for the core.
101
  --
102
  ck_div: process (ck_i, por_i)
103
  begin
104
    if por_i then
105
      ck_div_cnt_q <= ck_div_a_c(opt_ck_div_g);
106
      phi1_q       <= '0';
107
 
108
    elsif ck_i'event and ck_i = '1' then
109
      if ck_en_i then
110
        if ck_div_zero_s then
111
          ck_div_cnt_q <= ck_div_a_c(opt_ck_div_g);
112
          phi1_q       <= '0';
113
        else
114
          ck_div_cnt_q <= ck_div_cnt_q - 1;
115
 
116
          if ck_div_half_s then
117
            phi1_q     <= '1';
118
          end if;
119
        end if;
120
      end if;
121
    end if;
122
 
123
  end process ck_div;
124
  --
125
  ck_div_zero_s <= ck_div_cnt_q = 0;
126
  ck_div_half_s <= ck_div_cnt_q = SHIFT_RIGHT(ck_div_a_c(opt_ck_div_g), 1) + 1;
127
  --
128
  -----------------------------------------------------------------------------
129
 
130
 
131
  -----------------------------------------------------------------------------
132
  -- Output mapping
133
  -----------------------------------------------------------------------------
134
  phi1_o    <= phi1_q;
135
  -- Instruction cycle enable
136
  icyc_en_o <= ck_en_i and ck_div_zero_s;
137
  -- Output update enable
138
  out_en_o  <= ck_en_i and ck_div_zero_s;
139
  -- Input sample enable
140
  in_en_o   <= ck_en_i and ck_div_half_s;
141
 
142
end rtl;

powered by: WebSVN 2.1.0

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