xref: /Universal-ctags/Units/parser-vhdl.r/vhdl-process.d/input.vhd (revision e4754670a75a57a7c1f88c1e35a5af438820b26a)
1--
2-- Taken from rtl/riverlib/core/stacktrbuf.vhd of https://github.com/sergeykhbr/riscv_vhdl
3--
4-----------------------------------------------------------------------------
5--! @file
6--! @copyright Copyright 2017 GNSS Sensor Ltd. All right reserved.
7--! @author    Sergey Khabarov - sergeykhbr@gmail.com
8--! @brief     Stack trace buffer on hardware level.
9------------------------------------------------------------------------------
10
11library ieee;
12use ieee.std_logic_1164.all;
13library commonlib;
14use commonlib.types_common.all;
15
16entity StackTraceBuffer is
17  generic (
18    abits : integer := 5;
19    dbits : integer := 64
20  );
21  port (
22    i_clk   : in std_logic;
23    i_raddr : in std_logic_vector(abits-1 downto 0);
24    o_rdata : out std_logic_vector(dbits-1 downto 0);
25    i_we    : in std_logic;
26    i_waddr : in std_logic_vector(abits-1 downto 0);
27    i_wdata : in std_logic_vector(dbits-1 downto 0)
28  );
29end;
30
31architecture arch_StackTraceBuffer of StackTraceBuffer is
32
33  type ram_type is array ((2**abits)-1 downto 0) of std_logic_vector (dbits-1 downto 0);
34  signal stackbuf    : ram_type;
35  signal raddr       : std_logic_vector(abits-1 downto 0);
36
37begin
38
39  -- registers:
40  regs : process(i_clk) begin
41    if rising_edge(i_clk) then
42      if i_we = '1' then
43        stackbuf(conv_integer(i_waddr)) <= i_wdata;
44      end if;
45      raddr <= i_raddr;
46    end if;
47  end process;
48
49  o_rdata <= stackbuf(conv_integer(raddr));
50
51end;
52