File: handshake.vhd

package info (click to toggle)
bladerf 0.2017.12~rc1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 14,620 kB
  • sloc: ansic: 50,123; vhdl: 12,873; python: 1,062; tcl: 1,060; xml: 1,017; makefile: 657; sh: 589; csh: 18; cpp: 9
file content (76 lines) | stat: -rw-r--r-- 2,243 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
library ieee ;
    use ieee.std_logic_1164.all ;

entity handshake is
  generic (
    DATA_WIDTH      :       positive        := 32
  ) ;
  port (
    source_reset    :   in  std_logic ;
    source_clock    :   in  std_logic ;
    source_data     :   in  std_logic_vector(DATA_WIDTH-1 downto 0) ;

    dest_reset      :   in  std_logic ;
    dest_clock      :   in  std_logic ;
    dest_data       :   out std_logic_vector(DATA_WIDTH-1 downto 0) ;
    dest_req        :   in  std_logic ;
    dest_ack        :   out std_logic
  ) ;
end entity ;

architecture arch of handshake is

    -- Holding flops for bus at the request time
    signal source_holding   :   std_logic_vector(source_data'range) ;

    -- Source req and ack signals
    signal source_req       :   std_logic ;
    signal source_ack       :   std_logic ;

    -- Synchronization signal for destination
    signal dest_ack_sync    :   std_logic ;

begin

    U_sync_req : entity work.synchronizer
      generic map (
        RESET_LEVEL     =>  '0'
      ) port map (
        reset           =>  source_reset,
        clock           =>  source_clock,
        async           =>  dest_req,
        sync            =>  source_req
      ) ;

    dest_ack <= dest_ack_sync ;
    U_sync_ack : entity work.synchronizer
      generic map (
        RESET_LEVEL     =>  '0'
      ) port map (
        reset           =>  dest_reset,
        clock           =>  dest_clock,
        async           =>  source_ack,
        sync            =>  dest_ack_sync
      ) ;

    dest_data <= source_holding ;
    grab_source : process(source_reset, source_clock)
        variable prev_req : std_logic := '0' ;
    begin
        if( source_reset = '1' ) then
            source_holding <= (others =>'0') ;
            source_ack <= '0' ;
            prev_req := '0' ;
        elsif( rising_edge(source_clock) ) then
            if( prev_req = '0' and source_req = '1' and source_ack = '0' ) then
                source_holding <= source_data ;
                source_ack <= '1' ;
            elsif( source_req = '0' and source_ack = '1' ) then
                source_ack <= '0' ;
            end if ;
            prev_req := source_req ;
        end if ;
    end process ;

end architecture ;