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

Subversion Repositories pdp1

[/] [pdp1/] [trunk/] [rtl/] [vhdl/] [flagcross.vhd] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 yannv
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer: 
4
-- 
5
-- Create Date:    16:16:44 03/07/2009 
6
-- Design Name: 
7
-- Module Name:    flagcross - Behavioral 
8
-- Project Name: 
9
-- Target Devices: 
10
-- Tool versions: 
11
-- Description:         Module to send a flag (1-cycle high pulse) from one clock domain to another.
12
--                                              Intended to work both fast to slow and slow to fast, but fast to slow may give
13
--                                              a single pulse for several incoming.
14
--                              Extension: add a register transfer, enabled by flag.
15
--
16
-- Dependencies: 
17
--
18
-- Revision: 
19
-- Revision 0.01 - File Created
20
-- Additional Comments: 
21
--
22
----------------------------------------------------------------------------------
23
library IEEE;
24
use IEEE.STD_LOGIC_1164.ALL;
25
 
26
---- Uncomment the following library declaration if instantiating
27
---- any Xilinx primitives in this code.
28
--library UNISIM;
29
--use UNISIM.VComponents.all;
30
 
31
entity flagcross is
32
  generic ( width : integer := 0 );
33
  Port ( ClkA : in  STD_LOGIC;
34
         ClkB : in  STD_LOGIC;
35
         FastClk : in STD_LOGIC;
36
         A : in  STD_LOGIC;
37
         B : out  STD_LOGIC := '0';
38
         A_reg : in STD_LOGIC_VECTOR(0 to width-1) := (others => '0');
39
         B_reg : out STD_LOGIC_VECTOR(0 to width-1));
40
end flagcross;
41
 
42
architecture Behavioral of flagcross is
43
  signal toggle_a, old_a0, old_a1, seen_a, toggle_b : std_logic := '0';
44
  signal reg : std_logic_vector(0 to width-1);
45
begin
46
  process(ClkA)
47
  begin
48
    if rising_edge(ClkA) then
49
      if A='1' then
50
        toggle_a <= not toggle_a;
51
        reg <= A_reg;
52
      end if;
53
    end if;
54
  end process;
55
 
56
  process(FastClk)
57
  begin
58
    if rising_edge(FastClk) then
59
      if width>0 then
60
        old_a0 <= toggle_a;             -- make sure reg can settle
61
        old_a1 <= old_a0;
62
      else
63
        old_a1 <= toggle_a;
64
      end if;
65
      if old_a1/=toggle_a then
66
        seen_a <= not toggle_b;
67
      end if;
68
    end if;
69
  end process;
70
 
71
  process(ClkB)
72
  begin
73
    if rising_edge(ClkB) then
74
      if seen_a/=toggle_b then
75
        B <= '1';
76
        B_reg <= reg;
77
        toggle_b <= not toggle_b;
78
      else
79
        B <= '0';
80
      end if;
81
    end if;
82
  end process;
83
end Behavioral;
84
 

powered by: WebSVN 2.1.0

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