-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathavm_pause.vhd
76 lines (65 loc) · 2.63 KB
/
avm_pause.vhd
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
-- This module inserts empty wait cycles into an Avalon Memory Map stream.
-- The throughput is 1 - 1/G_PAUSE.
-- So a value of 4 results in a 75% throughput.
--
-- Created by Michael Jørgensen in 2022 (mjoergen.github.io/HyperRAM).
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity avm_pause is
generic (
G_PAUSE : natural;
G_ADDRESS_SIZE : integer; -- Number of bits
G_DATA_SIZE : integer -- Number of bits
);
port (
clk_i : in std_logic;
rst_i : in std_logic;
s_avm_write_i : in std_logic;
s_avm_read_i : in std_logic;
s_avm_address_i : in std_logic_vector(G_ADDRESS_SIZE-1 downto 0);
s_avm_writedata_i : in std_logic_vector(G_DATA_SIZE-1 downto 0);
s_avm_byteenable_i : in std_logic_vector(G_DATA_SIZE/8-1 downto 0);
s_avm_burstcount_i : in std_logic_vector(7 downto 0);
s_avm_readdata_o : out std_logic_vector(G_DATA_SIZE-1 downto 0);
s_avm_readdatavalid_o : out std_logic;
s_avm_waitrequest_o : out std_logic;
m_avm_write_o : out std_logic;
m_avm_read_o : out std_logic;
m_avm_address_o : out std_logic_vector(G_ADDRESS_SIZE-1 downto 0);
m_avm_writedata_o : out std_logic_vector(G_DATA_SIZE-1 downto 0);
m_avm_byteenable_o : out std_logic_vector(G_DATA_SIZE/8-1 downto 0);
m_avm_burstcount_o : out std_logic_vector(7 downto 0);
m_avm_readdata_i : in std_logic_vector(G_DATA_SIZE-1 downto 0);
m_avm_readdatavalid_i : in std_logic;
m_avm_waitrequest_i : in std_logic
);
end entity avm_pause;
architecture synthesis of avm_pause is
signal cnt : natural range 0 to G_PAUSE;
signal allow : std_logic;
begin
p_cnt : process (clk_i)
begin
if rising_edge(clk_i) then
if G_PAUSE > 0 then
if m_avm_waitrequest_i = '0' then
cnt <= (cnt + 1) mod G_PAUSE;
end if;
end if;
if rst_i = '1' then
cnt <= 0;
end if;
end if;
end process p_cnt;
allow <= '1' when cnt /= 0 or G_PAUSE = 0 else '0';
m_avm_write_o <= s_avm_write_i and allow;
m_avm_read_o <= s_avm_read_i and allow;
m_avm_address_o <= s_avm_address_i;
m_avm_writedata_o <= s_avm_writedata_i;
m_avm_byteenable_o <= s_avm_byteenable_i;
m_avm_burstcount_o <= s_avm_burstcount_i;
s_avm_readdata_o <= m_avm_readdata_i;
s_avm_readdatavalid_o <= m_avm_readdatavalid_i;
s_avm_waitrequest_o <= m_avm_waitrequest_i or not allow;
end architecture synthesis;