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

Subversion Repositories mips_enhanced

[/] [mips_enhanced/] [trunk/] [grlib-gpl-1.0.19-b3188/] [lib/] [gleichmann/] [clockgen/] [clockgenerator_ea.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dimamali
--------------------------------------------------------------------------------
2
-- Project     : Sandbox
3
-- Module      : ClockGenerator
4
-- File        : ClockGenerator.vhd
5
-- Description : Generate the clocks for the AudioCodec.
6
--------------------------------------------------------------------------------
7
-- Author       : Andreas Voggeneder
8
-- Organisation : FH-Hagenberg
9
-- Department   : Hardware/Software Systems Engineering
10
-- Language     : VHDL'87
11
--------------------------------------------------------------------------------
12
-- Copyright (c) 2003 by Andreas Voggeneder
13
--------------------------------------------------------------------------------
14
library ieee;
15
use ieee.std_logic_1164.all;
16
use ieee.numeric_std.all;
17
--use work.CodecGlobal.all;
18
 
19
entity ClockGenerator is
20
 
21
  port (
22
    Clk     : in  std_ulogic;
23
    Reset   : in  std_ulogic;
24
    oMCLK   : out std_ulogic; -- 12 MHz
25
    oBCLK   : out std_ulogic; -- I2S bit clk
26
    oSCLK   : out std_ulogic; -- SPI Data Clk
27
    oLRCOUT : out std_ulogic);
28
 
29
end ClockGenerator;
30
 
31
architecture rtl of ClockGenerator is
32
 
33
  constant cResetActive : std_ulogic := '0';
34
 
35
begin  -- rtl
36
 
37
  createclock : process (Clk, Reset)
38
--    variable cntMCLK        : std_ulogic;            -- counter MCLK
39
    variable cntBCLK        : std_ulogic;            -- counter BCLK
40
    variable cntLRC         : unsigned(5 downto 0);  -- counter LRC
41
    variable internalMCLK   : std_ulogic;
42
    variable internalBCLK   : std_ulogic;
43
    variable internalSCLK   : std_ulogic; --_vector(1 downto 0);
44
    variable internalLRCOUT : std_ulogic;
45
  begin  -- process createclock
46
    if Reset = cResetActive then                     -- asynchronous reset
47
      internalMCLK   := '0';
48
      internalBCLK   := '0';
49
      internalSCLK   := '0';  --"00";
50
      internalLRCOUT := '1';
51
--      cntMCLK        := '0';
52
      cntBCLK        := '0';
53
      cntLRC         := (others => '0');
54
    elsif Clk'event and Clk = '1' then               -- rising clock edge
55
      internalSCLK := not (internalSCLK);
56
--      internalSCLK := std_ulogic_vector(unsigned(internalSCLK)+1);
57
--        if (cntMCLK = '1') then
58
--          cntMCLK      := '0';
59
          internalMCLK := not internalMCLK;       -- 25/2
60
          if (internalMCLK = '1') then
61
          -- == 25/2
62
            if (cntBCLK = '1') then
63
            -- == 25/4
64
              internalBCLK := not internalBCLK; --25/8
65
              cntBCLK      := '0';
66
              if (internalBCLK = '0') then
67
                if (cntLRC = "100001") then -- 33
68
                  internalLRCOUT := not internalLRCOUT;
69
                  cntLRC         := (others => '0');
70
                else
71
                  cntLRC := cntLRC + 1;
72
                end if;
73
              end if;
74
            else
75
              cntBCLK := '1';
76
            end if;
77
          end if;
78
--        else
79
--          cntMCLK := '1';
80
--        end if;
81
 
82
    end if;
83
    oMCLK   <= internalMCLK;
84
    oBCLK   <= internalBCLK;
85
    oSCLK   <= internalSCLK;  --(1);
86
    oLRCOUT <= internalLRCOUT;
87
  end process createclock;
88
 
89
end rtl;
90
 
91
-- 44,1kHz: Fs=44100
92
-- MCLK = 256*Fs = 11.2896 MHz. Gewählt 12.5 MHz
93
-- BCLK = Fs*2*32 = 2.82 MHz. Gewählt 3.125 MHz
94
-- => Fs real = 48.8 kHz
95
 

powered by: WebSVN 2.1.0

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