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

Subversion Repositories ccsds_rxtxsoc

[/] [ccsds_rxtxsoc/] [trunk/] [ccsds_rxtx_clock_divider.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 zguig52
-------------------------------
2
---- Project: EurySPACE CCSDS RX/TX with wishbone interface
3
---- Design Name: ccsds_rxtx_clock_divider
4
---- Version: 1.0.0
5
---- Description:
6
---- Generate output clock = input clock / divider
7
-------------------------------
8
---- Author(s):
9
---- Guillaume REMBERT
10
-------------------------------
11
---- Licence:
12
---- MIT
13
-------------------------------
14
---- Changes list:
15
---- 2016/11/05: initial release
16
-------------------------------
17
 
18
-- libraries used
19
library ieee;
20
use ieee.std_logic_1164.all;
21
 
22
--=============================================================================
23
-- Entity declaration for ccsds_tx / unitary tx clock generator inputs and outputs
24
--=============================================================================
25
entity ccsds_rxtx_clock_divider is
26
  generic(
27
    constant CCSDS_RXTX_CLOCK_DIVIDER: integer range 1 to 4096
28
  );
29
  port(
30
    -- inputs
31
    clk_i: in std_logic;
32
    rst_i: in std_logic;
33
    -- outputs
34
    clk_o: out std_logic
35
  );
36
end ccsds_rxtx_clock_divider;
37
 
38
--=============================================================================
39
-- architecture declaration / internal components and connections
40
--=============================================================================
41
architecture structure of ccsds_rxtx_clock_divider is
42
-- internal constants
43
-- internal variable signals
44
-- components instanciation and mapping
45
  begin
46
-- presynthesis checks
47
          CHKCLKDIV0: if (CCSDS_RXTX_CLOCK_DIVIDER mod 2 /= 0) and (CCSDS_RXTX_CLOCK_DIVIDER /= 1) generate
48
                  process
49
                  begin
50
                          report "ERROR: CLOCK DIVIDER MUST BE A MULTIPLE OF 2 OR 1" severity failure;
51
                          wait;
52
                  end process;
53
          end generate CHKCLKDIV0;
54
-- internal processing
55
  CLOCKDIVIDER1P: if (CCSDS_RXTX_CLOCK_DIVIDER = 1) generate
56
    clk_o <= clk_i and (not rst_i);
57
  end generate CLOCKDIVIDER1P;
58
  CLOCKDIVIDERNP: if (CCSDS_RXTX_CLOCK_DIVIDER /= 1) generate
59
    --=============================================================================
60
    -- Begin of clockdividerp
61
    -- Clock divider
62
    --=============================================================================
63
    -- read: rst_i
64
    -- write: clk_o
65
    -- r/w:
66
    CLOCKDIVIDERP : process (clk_i, rst_i)
67
    -- variables instantiation
68
    variable counter: integer range 0 to CCSDS_RXTX_CLOCK_DIVIDER/2-1 := CCSDS_RXTX_CLOCK_DIVIDER/2-1;
69
    variable clock_state: std_logic := '1';
70
    begin
71
      if (rst_i = '1') then
72
        clk_o <= '0';
73
        clock_state := '1';
74
        counter := CCSDS_RXTX_CLOCK_DIVIDER/2-1;
75
      else
76
        -- on each clock rising edge
77
        if rising_edge(clk_i) then
78
          clk_o <= clock_state;
79
          if (counter = 0) then
80
            clock_state := clock_state xor '1';
81
            counter := CCSDS_RXTX_CLOCK_DIVIDER/2-1;
82
          else
83
            counter := counter-1;
84
          end if;
85
        end if;
86
      end if;
87
    end process;
88
  end generate CLOCKDIVIDERNP;
89
end structure;

powered by: WebSVN 2.1.0

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