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

Subversion Repositories lxp32

[/] [lxp32/] [trunk/] [verify/] [lxp32/] [src/] [platform/] [program_ram.vhd] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 ring0_mipt
---------------------------------------------------------------------
2
-- Program RAM
3
--
4
-- Part of the LXP32 test platform
5
--
6
-- Copyright (c) 2016 by Alex I. Kuznetsov
7
--
8
-- Program RAM for the LXP32 test platform. Has two interfaces:
9
-- WISHBONE (for data access) and LLI (for LXP32 instruction bus).
10
-- Optionally performs throttling.
11
--
12
-- Note: regardless of whether this description is synthesizable,
13
-- it was designed exclusively for simulation purposes.
14
---------------------------------------------------------------------
15
 
16
library ieee;
17
use ieee.std_logic_1164.all;
18
 
19
entity program_ram is
20
        generic(
21
                THROTTLE: boolean
22
        );
23
        port(
24
                clk_i: in std_logic;
25
                rst_i: in std_logic;
26
 
27
                wbs_cyc_i: in std_logic;
28
                wbs_stb_i: in std_logic;
29
                wbs_we_i: in std_logic;
30
                wbs_sel_i: in std_logic_vector(3 downto 0);
31
                wbs_ack_o: out std_logic;
32
                wbs_adr_i: in std_logic_vector(27 downto 2);
33
                wbs_dat_i: in std_logic_vector(31 downto 0);
34
                wbs_dat_o: out std_logic_vector(31 downto 0);
35
 
36
                lli_re_i: in std_logic;
37
                lli_adr_i: in std_logic_vector(29 downto 0);
38
                lli_dat_o: out std_logic_vector(31 downto 0);
39
                lli_busy_o: out std_logic
40
        );
41
end entity;
42
 
43
architecture rtl of program_ram is
44
 
45
signal ram_a_we: std_logic_vector(3 downto 0);
46
signal ram_a_rdata: std_logic_vector(31 downto 0);
47
 
48
signal ram_b_re: std_logic;
49
signal ram_b_rdata: std_logic_vector(31 downto 0);
50
 
51
signal ack_write: std_logic;
52
signal ack_read: std_logic;
53
 
54
signal prbs: std_logic;
55
signal lli_busy: std_logic:='0';
56
 
57
begin
58
 
59
-- The total memory size is 16384 words, i.e. 64K bytes
60
 
61
gen_dprams: for i in 3 downto 0 generate
62
        generic_dpram_inst: entity work.generic_dpram(rtl)
63
                generic map(
64
                        DATA_WIDTH=>8,
65
                        ADDR_WIDTH=>14,
66
                        SIZE=>16384,
67
                        MODE=>"DONTCARE"
68
                )
69
                port map(
70
                        clka_i=>clk_i,
71
                        cea_i=>'1',
72
                        wea_i=>ram_a_we(i),
73
                        addra_i=>wbs_adr_i(15 downto 2),
74
                        da_i=>wbs_dat_i(i*8+7 downto i*8),
75
                        da_o=>ram_a_rdata(i*8+7 downto i*8),
76
 
77
                        clkb_i=>clk_i,
78
                        ceb_i=>ram_b_re,
79
                        addrb_i=>lli_adr_i(13 downto 0),
80
                        db_o=>ram_b_rdata(i*8+7 downto i*8)
81
                );
82
end generate;
83
 
84
-- WISHBONE interface
85
 
86
gen_ram_a_we: for i in 3 downto 0 generate
87
        ram_a_we(i)<='1' when wbs_cyc_i='1' and wbs_stb_i='1' and wbs_we_i='1'
88
                and wbs_sel_i(i)='1' and wbs_adr_i(27 downto 16)="000000000000" else '0';
89
end generate;
90
 
91
process (clk_i) is
92
begin
93
        if rising_edge(clk_i) then
94
                ack_read<=wbs_cyc_i and wbs_stb_i and not wbs_we_i;
95
        end if;
96
end process;
97
 
98
ack_write<=wbs_cyc_i and wbs_stb_i and wbs_we_i;
99
 
100
wbs_ack_o<=ack_read or ack_write;
101
wbs_dat_o<=ram_a_rdata;
102
 
103
-- Low Latency Interface (with optional pseudo-random throttling)
104
 
105
gen_throttling: if THROTTLE generate
106
        throttle_inst: entity work.scrambler(rtl)
107
                generic map(TAP1=>9,TAP2=>11)
108
                port map(clk_i=>clk_i,rst_i=>rst_i,ce_i=>'1',d_o=>prbs);
109
end generate;
110
 
111
gen_no_throttling: if not THROTTLE generate
112
        prbs<='0';
113
end generate;
114
 
115
process (clk_i) is
116
begin
117
        if rising_edge(clk_i) then
118
                if rst_i='1' then
119
                        lli_busy<='0';
120
                elsif prbs='1' and lli_re_i='1' then
121
                        lli_busy<='1';
122
                elsif prbs='0' then
123
                        lli_busy<='0';
124
                end if;
125
        end if;
126
end process;
127
 
128
ram_b_re<=lli_re_i and not lli_busy;
129
 
130
lli_busy_o<=lli_busy;
131
lli_dat_o<=ram_b_rdata when lli_busy='0' else (others=>'-');
132
 
133
end architecture;

powered by: WebSVN 2.1.0

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