Debian Codegraph @

hdl/fpga/ip/nuand/synthesis/handshake.vhd

raw
1 library ieee ;
2 use ieee.std_logic_1164.all ;
3
4 entity handshake is
5 generic (
6 DATA_WIDTH : positive := 32
7 ) ;
8 port (
9 source_reset : in std_logic ;
10 source_clock : in std_logic ;
11 source_data : in std_logic_vector(DATA_WIDTH-1 downto 0) ;
12
13 dest_reset : in std_logic ;
14 dest_clock : in std_logic ;
15 dest_data : out std_logic_vector(DATA_WIDTH-1 downto 0) ;
16 dest_req : in std_logic ;
17 dest_ack : out std_logic
18 ) ;
19 end entity ;
20
21 architecture arch of handshake is
22
23 -- Holding flops for bus at the request time
24 signal source_holding : std_logic_vector(source_data'range) ;
25
26 -- Source req and ack signals
27 signal source_req : std_logic ;
28 signal source_ack : std_logic ;
29
30 -- Synchronization signal for destination
31 signal dest_ack_sync : std_logic ;
32
33 begin
34
35 U_sync_req : entity work.synchronizer
36 generic map (
37 RESET_LEVEL => '0'
38 ) port map (
39 reset => source_reset,
40 clock => source_clock,
41 async => dest_req,
42 sync => source_req
43 ) ;
44
45 dest_ack <= dest_ack_sync ;
46 U_sync_ack : entity work.synchronizer
47 generic map (
48 RESET_LEVEL => '0'
49 ) port map (
50 reset => dest_reset,
51 clock => dest_clock,
52 async => source_ack,
53 sync => dest_ack_sync
54 ) ;
55
56 dest_data <= source_holding ;
57 grab_source : process(source_reset, source_clock)
58 variable prev_req : std_logic := '0' ;
59 begin
60 if( source_reset = '1' ) then
61 source_holding <= (others =>'0') ;
62 source_ack <= '0' ;
63 prev_req := '0' ;
64 elsif( rising_edge(source_clock) ) then
65 if( prev_req = '0' and source_req = '1' and source_ack = '0' ) then
66 source_holding <= source_data ;
67 source_ack <= '1' ;
68 elsif( source_req = '0' and source_ack = '1' ) then
69 source_ack <= '0' ;
70 end if ;
71 prev_req := source_req ;
72 end if ;
73 end process ;
74
75 end architecture ;
76