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

Subversion Repositories lxp32

[/] [lxp32/] [trunk/] [rtl/] [lxp32_scratchpad.vhd] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 ring0_mipt
---------------------------------------------------------------------
2
-- Scratchpad
3
--
4
-- Part of the LXP32 CPU
5
--
6
-- Copyright (c) 2016 by Alex I. Kuznetsov
7
--
8
-- LXP32 register file implemented as a RAM block. Since we need
9
-- to read two registers simultaneously, the memory is duplicated.
10
---------------------------------------------------------------------
11
 
12
library ieee;
13
use ieee.std_logic_1164.all;
14
 
15
entity lxp32_scratchpad is
16
        port(
17
                clk_i: in std_logic;
18
 
19
                raddr1_i: in std_logic_vector(7 downto 0);
20
                rdata1_o: out std_logic_vector(31 downto 0);
21
                raddr2_i: in std_logic_vector(7 downto 0);
22
                rdata2_o: out std_logic_vector(31 downto 0);
23
 
24
                waddr_i: in std_logic_vector(7 downto 0);
25
                we_i: in std_logic;
26
                wdata_i: in std_logic_vector(31 downto 0)
27
        );
28
end entity;
29
 
30
architecture rtl of lxp32_scratchpad is
31
 
32
signal wdata_reg: std_logic_vector(wdata_i'range);
33
signal ram1_rdata: std_logic_vector(31 downto 0);
34
signal ram2_rdata: std_logic_vector(31 downto 0);
35
 
36
signal ram1_collision: std_logic;
37
signal ram2_collision: std_logic;
38
 
39
begin
40
 
41
-- RAM 1
42
 
43
ram_inst1: entity work.lxp32_ram256x32(rtl)
44
        port map(
45
                clk_i=>clk_i,
46
 
47
                we_i=>we_i,
48
                waddr_i=>waddr_i,
49
                wdata_i=>wdata_i,
50
 
51
                re_i=>'1',
52
                raddr_i=>raddr1_i,
53
                rdata_o=>ram1_rdata
54
        );
55
 
56
-- RAM 2
57
 
58
ram_inst2: entity work.lxp32_ram256x32(rtl)
59
        port map(
60
                clk_i=>clk_i,
61
 
62
                we_i=>we_i,
63
                waddr_i=>waddr_i,
64
                wdata_i=>wdata_i,
65
 
66
                re_i=>'1',
67
                raddr_i=>raddr2_i,
68
                rdata_o=>ram2_rdata
69
        );
70
 
71
-- Read/write collision detection
72
 
73
process (clk_i) is
74
begin
75
        if rising_edge(clk_i) then
76
                wdata_reg<=wdata_i;
77
                if waddr_i=raddr1_i and we_i='1' then
78
                        ram1_collision<='1';
79
                else
80
                        ram1_collision<='0';
81
                end if;
82
                if waddr_i=raddr2_i and we_i='1' then
83
                        ram2_collision<='1';
84
                else
85
                        ram2_collision<='0';
86
                end if;
87
        end if;
88
end process;
89
 
90
rdata1_o<=ram1_rdata when ram1_collision='0' else wdata_reg;
91
rdata2_o<=ram2_rdata when ram2_collision='0' else wdata_reg;
92
 
93
end architecture;

powered by: WebSVN 2.1.0

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