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

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [VHDL/] [o8_ram_1k.vhd] - Blame information for rev 223

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 194 jshamlet
-- Copyright (c)2013, 2020 Jeremy Seth Henry
2 174 jshamlet
-- All rights reserved.
3
--
4
-- Redistribution and use in source and binary forms, with or without
5
-- modification, are permitted provided that the following conditions are met:
6
--     * Redistributions of source code must retain the above copyright
7
--       notice, this list of conditions and the following disclaimer.
8
--     * Redistributions in binary form must reproduce the above copyright
9
--       notice, this list of conditions and the following disclaimer in the
10
--       documentation and/or other materials provided with the distribution,
11
--       where applicable (as part of a user interface, debugging port, etc.)
12
--
13
-- THIS SOFTWARE IS PROVIDED BY JEREMY SETH HENRY ``AS IS'' AND ANY
14
-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
-- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16
-- DISCLAIMED. IN NO EVENT SHALL JEREMY SETH HENRY BE LIABLE FOR ANY
17
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 194 jshamlet
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 174 jshamlet
--
24
-- VHDL Units :  o8_ram_1k
25
-- Description:  Provides a wrapper layer for a 1kx8 RAM model
26
 
27
library ieee;
28
use ieee.std_logic_1164.all;
29
use ieee.std_logic_unsigned.all;
30
use ieee.std_logic_arith.all;
31
 
32
library work;
33
  use work.open8_pkg.all;
34
 
35
entity o8_ram_1k is
36
generic(
37 217 jshamlet
  Reset_Level                : std_logic;
38
  Address                    : ADDRESS_TYPE
39 174 jshamlet
);
40
port(
41 217 jshamlet
  Clock                      : in  std_logic;
42
  Reset                      : in  std_logic;
43 174 jshamlet
  --
44 223 jshamlet
  Open8_Bus                  : in  OPEN8_BUS_TYPE;
45 217 jshamlet
  Rd_Data                    : out DATA_TYPE
46 174 jshamlet
);
47
end entity;
48
 
49
architecture behave of o8_ram_1k is
50
 
51 217 jshamlet
  constant User_Addr         : std_logic_vector(15 downto 10)
52
                               := Address(15 downto 10);
53 223 jshamlet
  alias Comp_Addr            is Open8_Bus.Address(15 downto 10);
54
  alias RAM_Addr             is Open8_Bus.Address(9 downto 0);
55 174 jshamlet
 
56 217 jshamlet
  signal Addr_Match          : std_logic := '0';
57
  signal Wr_En               : std_logic := '0';
58
  signal Rd_En               : std_logic := '0';
59
  signal Rd_Data_i           : DATA_TYPE := OPEN8_NULLBUS;
60 174 jshamlet
 
61
begin
62
 
63
  -- This decode needs to happen immediately, to give the RAM a chance to
64
  --  do the lookup before we have to set Rd_Data
65 217 jshamlet
  Addr_Match                 <= '1' when Comp_Addr = User_Addr else '0';
66 223 jshamlet
  Wr_En                      <= Addr_Match and Open8_Bus.Wr_En;
67 174 jshamlet
 
68
  -- Note that this RAM should be created without an output FF (unregistered Q)
69
  U_RAM : entity work.ram_1k_core
70
  port map(
71 217 jshamlet
    address                  => RAM_Addr,
72
    clock                    => Clock,
73 223 jshamlet
    data                     => Open8_Bus.Wr_Data,
74 217 jshamlet
    wren                     => Wr_En,
75
    q                        => Rd_Data_i
76 174 jshamlet
  );
77
 
78
  RAM_proc: process( Reset, Clock )
79
  begin
80
    if( Reset = Reset_Level )then
81 217 jshamlet
      Rd_En                  <= '0';
82
      Rd_Data                <= OPEN8_NULLBUS;
83 174 jshamlet
    elsif( rising_edge(Clock) )then
84 223 jshamlet
      Rd_En                  <= Addr_Match and Open8_Bus.Rd_En;
85 217 jshamlet
      Rd_Data                <= OPEN8_NULLBUS;
86 174 jshamlet
      if( Rd_En = '1' )then
87 217 jshamlet
        Rd_Data              <= Rd_Data_i;
88 174 jshamlet
      end if;
89
    end if;
90
  end process;
91
 
92
end architecture;

powered by: WebSVN 2.1.0

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