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

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [rtl/] [gnsslib/] [sync/] [reclk.vhd] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 sergeykhbr
-----------------------------------------------------------------------------
2
-- Package:     fse_v2
3
-- File:        reclk.vhd
4
-- Author:      Sergey Khabarov - sergeykhbr@gmail.com
5
-- Description: Reclocking from ADC clock domain into FSE clock domain
6
------------------------------------------------------------------------------
7
 
8
library ieee;
9
use ieee.std_logic_1164.all;
10
library commonlib;
11
use commonlib.types_common.all;
12
 
13
entity Reclk is
14
port (
15
  nrst       : in std_logic;
16
  clk_bus    : in std_logic;
17
  clk_adc    : in std_logic;
18
  i_I        : in std_logic_vector(1 downto 0);
19
  i_Q        : in std_logic_vector(1 downto 0);
20
  i_ms_pulse : in std_logic;
21
  i_pps      : in std_logic;
22
  o_I        : out std_logic_vector(1 downto 0);
23
  o_Q        : out std_logic_vector(1 downto 0);
24
  o_ms_pulse : out std_logic;
25
  o_pps      : out std_logic;
26
  o_valid    : out std_logic
27
);
28
end;
29
 
30
architecture rtl of Reclk is
31
 
32
  type regadctype is record
33
      flag : std_logic;
34
      I        : std_logic_vector(1 downto 0);
35
      Q        : std_logic_vector(1 downto 0);
36
      ms_pulse : std_logic;
37
      pps      : std_logic;
38
  end record;
39
 
40
 
41
  type regtype is record
42
      flag     : std_logic;
43
      I        : std_logic_vector(1 downto 0);
44
      Q        : std_logic_vector(1 downto 0);
45
      ms_pulse : std_logic;
46
      pps      : std_logic;
47
      valid    : std_logic;
48
  end record;
49
 
50
  signal ra : regadctype;
51
  signal r, rin : regtype;
52
 
53
begin
54
 
55
  adcproc : process (clk_adc)
56
  begin
57
     if rising_edge(clk_adc) then
58
        if nrst = '0' then
59
           ra.flag <= '0';
60
           ra.I <= (others => '0');
61
           ra.Q <= (others => '0');
62
           ra.ms_pulse <= '0';
63
           ra.pps <= '0';
64
        else
65
           ra.flag <= not ra.flag;
66
           ra.I <= i_I;
67
           ra.Q <= i_Q;
68
           ra.ms_pulse <= i_ms_pulse;
69
           ra.pps <= i_pps;
70
        end if;
71
     end if;
72
  end process;
73
 
74
  comb : process (nrst, ra, r)
75
    variable v : regtype;
76
  begin
77
 
78
    v := r;
79
    v.valid := '0';
80
    v.ms_pulse := '0';
81
    v.pps := '0';
82
 
83
    if r.flag /= ra.flag then
84
       v.flag := ra.flag;
85
       v.valid := '1';
86
       v.I := ra.I;
87
       v.Q := ra.Q;
88
       v.ms_pulse := ra.ms_pulse;
89
       v.pps := ra.pps;
90
    end if;
91
 
92
    -- Reset all
93
    if nrst = '0' then
94
      v.flag := '0';
95
      v.I := (others => '0');
96
      v.Q := (others => '0');
97
      v.ms_pulse := '0';
98
      v.pps := '0';
99
    end if;
100
 
101
    rin <= v;
102
  end process;
103
 
104
  o_I <= r.I;
105
  o_Q <= r.Q;
106
  o_ms_pulse <= r.ms_pulse;
107
  o_pps <= r.pps;
108
  o_valid <= r.valid;
109
 
110
  regs : process(clk_bus)
111
  begin
112
    if rising_edge(clk_bus) then
113
      r <= rin;
114
    end if;
115
  end process;
116
 
117
end;
118
 
119
 

powered by: WebSVN 2.1.0

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