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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.74/] [rtl/] [vlib/] [cdclib/] [cdc_pulse.vhd] - Blame information for rev 38

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 36 wfjm
-- $Id: cdc_pulse.vhd 774 2016-06-12 17:08:47Z mueller $
2 16 wfjm
--
3 36 wfjm
-- Copyright 2011-2016 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4 16 wfjm
--
5
-- This program is free software; you may redistribute and/or modify it under
6
-- the terms of the GNU General Public License as published by the Free
7
-- Software Foundation, either version 2, or at your option any later version.
8
--
9
-- This program is distributed in the hope that it will be useful, but
10
-- WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
11
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
-- for complete details.
13
-- 
14
------------------------------------------------------------------------------
15
-- Module Name:    cdc_pulse - syn
16 36 wfjm
-- Description:    clock domain crossing for a pulse
17 16 wfjm
--
18
-- Dependencies:   -
19
-- Test bench:     -
20
-- Target Devices: generic
21 36 wfjm
-- Tool versions:  xst 13.1-14.7; viv 2015.4-2016.2; ghdl 0.29-0.33
22 16 wfjm
-- Revision History: 
23
-- Date         Rev Version    Comment
24 36 wfjm
-- 2016-06-11   774   1.2      add INIT generic
25
-- 2016-03-29   756   1.1      rename regs; add ASYNC_REG attributes
26 16 wfjm
-- 2011-11-09   422   1.0      Initial version
27
-- 
28
------------------------------------------------------------------------------
29
 
30
library ieee;
31
use ieee.std_logic_1164.all;
32
 
33
use work.slvtypes.all;
34
 
35
entity cdc_pulse is                     -- clock domain cross for pulse
36
  generic (
37
    POUT_SINGLE : boolean := false;     -- if true: single cycle pout
38 36 wfjm
    BUSY_WACK : boolean := false;       -- if true: busy waits for ack
39
    INIT : slbit := '0');               -- initial state
40 16 wfjm
  port (
41 36 wfjm
    CLKM : in slbit;                    -- M|clock master
42 16 wfjm
    RESET : in slbit := '0';            -- M|reset
43 36 wfjm
    CLKS : in slbit;                    -- S|clock slave
44 16 wfjm
    PIN : in slbit;                     -- M|pulse in
45
    BUSY : out slbit;                   -- M|busy
46
    POUT : out slbit                    -- S|pulse out
47
  );
48
end entity cdc_pulse;
49
 
50
 
51
architecture syn of cdc_pulse is
52
 
53 36 wfjm
  signal RM_REQ    : slbit := INIT;     -- request active
54
  signal RS_REQ_S0 : slbit := INIT;     -- request: CLKM->CLKS
55
  signal RS_REQ_S1 : slbit := INIT;     -- request: CLKS->CLKS
56
  signal RM_ACK_S0 : slbit := '0';      -- acknowledge: CLKS->CLKM
57
  signal RM_ACK_S1 : slbit := '0';      -- acknowledge: CLKM->CLKM
58 16 wfjm
 
59 36 wfjm
  attribute ASYNC_REG: string;
60
 
61
  attribute ASYNC_REG of RS_REQ_S0   : signal is "true";
62
  attribute ASYNC_REG of RS_REQ_S1   : signal is "true";
63
  attribute ASYNC_REG of RM_ACK_S0   : signal is "true";
64
  attribute ASYNC_REG of RM_ACK_S1   : signal is "true";
65
 
66 16 wfjm
begin
67
 
68
  proc_master: process (CLKM)
69
  begin
70
    if rising_edge(CLKM) then
71
      if RESET = '1' then
72 36 wfjm
        RM_REQ <= '0';
73 16 wfjm
      else
74
        if PIN = '1' then
75 36 wfjm
          RM_REQ <= '1';
76
        elsif RM_ACK_S1 = '1' then
77
          RM_REQ <= '0';
78 16 wfjm
        end if;
79
      end if;
80 36 wfjm
      RM_ACK_S0 <= RS_REQ_S1;           -- synch 0: CLKS->CLKM
81
      RM_ACK_S1 <= RM_ACK_S0;           -- synch 1: CLKM
82 16 wfjm
    end if;
83
  end process proc_master;
84
 
85
  proc_slave: process (CLKS)
86
  begin
87
    if rising_edge(CLKS) then
88 36 wfjm
      RS_REQ_S0 <= RM_REQ;              -- synch 0: CLKM->CLKS
89
      RS_REQ_S1 <= RS_REQ_S0;           -- synch 1: CLKS
90 16 wfjm
    end if;
91
  end process proc_slave;
92
 
93 36 wfjm
  -- Note: no pulse at startup when  POUT_SINGLE=true, INIT=1 and PIN=1 initially
94 16 wfjm
  SINGLE1: if POUT_SINGLE = true generate
95 36 wfjm
    signal RS_ACK_1 : slbit := INIT;
96
    signal RS_POUT  : slbit := '0';
97 16 wfjm
  begin
98
    proc_pout: process (CLKS)
99
    begin
100
      if rising_edge(CLKS) then
101 36 wfjm
        RS_ACK_1 <= RS_REQ_S1;
102
        if RS_REQ_S1='1' and RS_ACK_1='0' then
103
          RS_POUT <= '1';
104 16 wfjm
        else
105 36 wfjm
          RS_POUT <= '0';
106 16 wfjm
        end if;
107
      end if;
108
    end process proc_pout;
109 36 wfjm
    POUT <= RS_POUT;
110 16 wfjm
  end generate SINGLE1;
111
 
112
  SINGLE0: if POUT_SINGLE = false generate
113
  begin
114 36 wfjm
    POUT <= RS_REQ_S1;
115 16 wfjm
  end generate SINGLE0;
116
 
117
  BUSY1: if BUSY_WACK = true generate
118
  begin
119 36 wfjm
    BUSY <= RM_REQ or RM_ACK_S1;
120 16 wfjm
  end generate BUSY1;
121
 
122
  BUSY0: if BUSY_WACK = false generate
123
  begin
124 36 wfjm
    BUSY <= RM_REQ;
125 16 wfjm
  end generate BUSY0;
126
 
127
end syn;
128
 

powered by: WebSVN 2.1.0

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