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

Subversion Repositories common_components

[/] [common_components/] [trunk/] [common_spulse.vhd] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 danv
-------------------------------------------------------------------------------
2
--
3 4 danv
-- Copyright 2020
4 3 danv
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
5
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
6 4 danv
-- 
7
-- Licensed under the Apache License, Version 2.0 (the "License");
8
-- you may not use this file except in compliance with the License.
9
-- You may obtain a copy of the License at
10
-- 
11
--     http://www.apache.org/licenses/LICENSE-2.0
12
-- 
13
-- Unless required by applicable law or agreed to in writing, software
14
-- distributed under the License is distributed on an "AS IS" BASIS,
15
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
-- See the License for the specific language governing permissions and
17
-- limitations under the License.
18 3 danv
--
19
-------------------------------------------------------------------------------
20
 
21
-- Purpose: Get in_pulse from in_clk to out_pulse in the out_clk domain.
22
-- Description:
23
--   The in_pulse is captured in the in_clk domain and then transfered to the
24
--   out_clk domain. The out_pulse is also only one cycle wide and transfered
25
--   back to the in_clk domain to serve as an acknowledge signal to ensure
26
--   that the in_pulse was recognized also in case the in_clk is faster than
27
--   the out_clk. The in_busy is active during the entire transfer. Hence the
28
--   rate of pulses that can be transfered is limited by g_delay_len and by
29
--   the out_clk rate.
30
 
31
LIBRARY IEEE, common_pkg_lib;
32
USE IEEE.std_logic_1164.ALL;
33
USE common_pkg_lib.common_pkg.ALL;
34
 
35
ENTITY common_spulse IS
36
  GENERIC (
37
    g_delay_len : NATURAL := c_meta_delay_len
38
  );
39
  PORT (
40
    in_rst       : IN  STD_LOGIC := '0';
41
    in_clk       : IN  STD_LOGIC;
42
    in_clken     : IN  STD_LOGIC := '1';
43
    in_pulse     : IN  STD_LOGIC;
44
    in_busy      : OUT STD_LOGIC;
45
    out_rst      : IN  STD_LOGIC := '0';
46
    out_clk      : IN  STD_LOGIC;
47
    out_clken    : IN  STD_LOGIC := '1';
48
    out_pulse    : OUT STD_LOGIC
49
  );
50
END;
51
 
52
ARCHITECTURE rtl OF common_spulse IS
53
 
54
  SIGNAL in_level       : STD_LOGIC;
55
  SIGNAL meta_level     : STD_LOGIC_VECTOR(0 TO g_delay_len-1);
56
  SIGNAL out_level      : STD_LOGIC;
57
  SIGNAL prev_out_level : STD_LOGIC;
58
  SIGNAL meta_ack       : STD_LOGIC_VECTOR(0 TO g_delay_len-1);
59
  SIGNAL pulse_ack      : STD_LOGIC;
60
  SIGNAL nxt_out_pulse  : STD_LOGIC;
61
 
62
BEGIN
63
 
64
  capture_in_pulse : ENTITY work.common_switch
65
  PORT MAP (
66
    clk         => in_clk,
67
    clken       => in_clken,
68
    rst         => in_rst,
69
    switch_high => in_pulse,
70
    switch_low  => pulse_ack,
71
    out_level   => in_level
72
  );
73
 
74
  in_busy <= in_level OR pulse_ack;
75
 
76
  p_out_clk : PROCESS(out_rst, out_clk)
77
  BEGIN
78
    IF out_rst='1' THEN
79
      meta_level     <= (OTHERS=>'0');
80
      out_level      <= '0';
81
      prev_out_level <= '0';
82
      out_pulse      <= '0';
83
    ELSIF RISING_EDGE(out_clk) THEN
84
      IF out_clken='1' THEN
85
        meta_level     <= in_level & meta_level(0 TO meta_level'HIGH-1);
86
        out_level      <= meta_level(meta_level'HIGH);
87
        prev_out_level <= out_level;
88
        out_pulse      <= nxt_out_pulse;
89
      END IF;
90
    END IF;
91
  END PROCESS;
92
 
93
  p_in_clk : PROCESS(in_rst, in_clk)
94
  BEGIN
95
    IF in_rst='1' THEN
96
      meta_ack  <= (OTHERS=>'0');
97
      pulse_ack <= '0';
98
    ELSIF RISING_EDGE(in_clk) THEN
99
      IF in_clken='1' THEN
100
        meta_ack  <= out_level & meta_ack(0 TO meta_ack'HIGH-1);
101
        pulse_ack <= meta_ack(meta_ack'HIGH);
102
      END IF;
103
    END IF;
104
  END PROCESS;
105
 
106
  nxt_out_pulse <= out_level AND NOT prev_out_level;
107
 
108
END rtl;

powered by: WebSVN 2.1.0

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