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

Subversion Repositories rv01_riscv_core

[/] [rv01_riscv_core/] [trunk/] [VHDL/] [RV01_plic_gway.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 madsilicon
-----------------------------------------------------------------
2
--                                                             --
3
-----------------------------------------------------------------
4
--                                                             --
5
-- Copyright (C) 2016 Stefano Tonello                          --
6
--                                                             --
7
-- This source file may be used and distributed without        --
8
-- restriction provided that this copyright statement is not   --
9
-- removed from the file and that any derivative work contains --
10
-- the original copyright notice and the associated disclaimer.--
11
--                                                             --
12
-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY         --
13
-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   --
14
-- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   --
15
-- FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      --
16
-- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         --
17
-- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    --
18
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   --
19
-- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        --
20
-- BUSINESS REQERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  --
21
-- LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  --
22
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  --
23
-- OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         --
24
-- POSSIBILITY OF SUCH DAMAGE.                                 --
25
--                                                             --
26
-----------------------------------------------------------------
27
 
28
---------------------------------------------------------------
29
-- RV01 PLIC gateway
30
---------------------------------------------------------------
31
 
32
library IEEE;
33
use IEEE.std_logic_1164.all;
34
use IEEE.numeric_std.all;
35
 
36
library work;
37
use work.RV01_PLIC_PKG.all;
38
 
39
entity RV01_PLIC_GWAY is
40
  generic(
41
    TRIG_TYPE : PLIC_TRIG_TYPE := LEVEL;
42
    REQ_MAXCNT : natural := 16
43
  );
44
  port(
45
    CLK_i : in std_logic;
46
    RST_i : in std_logic;
47
    REQ_i : in std_logic;
48
    IS_i : in std_logic;
49
 
50
    IP_o : out std_logic
51
  );
52
end RV01_PLIC_GWAY;
53
 
54
architecture ARC of RV01_PLIC_GWAY is
55
 
56
  signal IP,IP_q : std_logic;
57
  signal REQ,REQ_q,REQ_EDGE : std_logic;
58
  signal REQ_CNT_q : natural range 0 to REQ_MAXCNT-1;
59
 
60
begin
61
 
62
  GL: if(TRIG_TYPE = LEVEL) generate
63
 
64
  process(IP_q,REQ_i,IS_i)
65
  begin
66
    if(IP_q = '0') then
67
      -- Set pending request register 
68
      IP <= REQ_i;
69
    elsif(IS_i = '1' and REQ_i = '0') then
70
      -- Pending request has been serviced,
71
      -- and there's no new request:
72
      -- clear pending request register 
73
      IP <= '0';
74
    else
75
      IP <= IP_q;
76
    end if;
77
  end process;
78
 
79
  end generate;
80
 
81
  GE: if(TRIG_TYPE = EDGE) generate
82
 
83
  -- REQ_i edge detector
84
 
85
  process(CLK_i)
86
  begin
87
    if(CLK_i = '1' and CLK_i'event) then
88
      if(RST_i = '1') then
89
        REQ_q <= '0';
90
      else
91
        REQ_q <= REQ_i;
92
      end if;
93
    end if;
94
  end process;
95
 
96
  REQ_EDGE <= REQ_i and REQ_q;
97
 
98
  -- Pending request counter
99
 
100
  process(CLK_i)
101
  begin
102
    if(CLK_i = '1' and CLK_i'event) then
103
      if(RST_i = '1') then
104
        REQ_CNT_q <= 0;
105
      elsif(REQ_EDGE = '1' and REQ_CNT_q < REQ_MAXCNT and IS_i = '0') then
106
        -- There's a new request and pending 
107
        -- one has not been serviced: increment count.
108
        REQ_CNT_q <= REQ_CNT_q + 1;
109
      elsif(REQ_EDGE = '0' and REQ_CNT_q > 0 and IS_i = '1') then
110
        -- There's no new request and pending one has
111
        -- ben serviced: decrement count.
112
        REQ_CNT_q <= REQ_CNT_q - 1;
113
      end if;
114
    end if;
115
  end process;
116
 
117
  IP <= '1' when (REQ_CNT_q > 0) else '0';
118
 
119
  end generate;
120
 
121
  -- Pending request register
122
 
123
  process(CLK_i)
124
  begin
125
    if(CLK_i = '1' and CLK_i'event) then
126
      if(RST_i = '1') then
127
        IP_q <= '0';
128
      else
129
        IP_q <= IP;
130
      end if;
131
    end if;
132
  end process;
133
 
134
  IP_o <= IP_q;
135
 
136
end ARC;

powered by: WebSVN 2.1.0

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