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 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 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
use work.common_pkg.all;
20
 
21
entity program_ram is
22
        generic(
23
                THROTTLE: boolean
24
        );
25
        port(
26
                clk_i: in std_logic;
27
                rst_i: in std_logic;
28
 
29
                wbs_cyc_i: in std_logic;
30
                wbs_stb_i: in std_logic;
31
                wbs_we_i: in std_logic;
32
                wbs_sel_i: in std_logic_vector(3 downto 0);
33
                wbs_ack_o: out std_logic;
34
                wbs_adr_i: in std_logic_vector(27 downto 2);
35
                wbs_dat_i: in std_logic_vector(31 downto 0);
36
                wbs_dat_o: out std_logic_vector(31 downto 0);
37
 
38
                lli_re_i: in std_logic;
39
                lli_adr_i: in std_logic_vector(29 downto 0);
40
                lli_dat_o: out std_logic_vector(31 downto 0);
41
                lli_busy_o: out std_logic
42
        );
43
end entity;
44
 
45
architecture rtl of program_ram is
46
 
47
signal ram_a_we: std_logic_vector(3 downto 0);
48
signal ram_a_rdata: std_logic_vector(31 downto 0);
49
 
50
signal ram_b_re: std_logic;
51
signal ram_b_rdata: std_logic_vector(31 downto 0);
52
 
53
signal ack_write: std_logic;
54
signal ack_read: std_logic;
55
 
56
signal prbs: std_logic;
57
signal lli_busy: std_logic:='0';
58
 
59
begin
60
 
61
-- The total memory size is 16384 words, i.e. 64K bytes
62
 
63
gen_dprams: for i in 3 downto 0 generate
64
        generic_dpram_inst: entity work.generic_dpram(rtl)
65
                generic map(
66
                        DATA_WIDTH=>8,
67
                        ADDR_WIDTH=>14,
68
                        SIZE=>16384,
69
                        MODE=>"DONTCARE"
70
                )
71
                port map(
72
                        clka_i=>clk_i,
73
                        cea_i=>'1',
74
                        wea_i=>ram_a_we(i),
75
                        addra_i=>wbs_adr_i(15 downto 2),
76
                        da_i=>wbs_dat_i(i*8+7 downto i*8),
77
                        da_o=>ram_a_rdata(i*8+7 downto i*8),
78
 
79
                        clkb_i=>clk_i,
80
                        ceb_i=>ram_b_re,
81
                        addrb_i=>lli_adr_i(13 downto 0),
82
                        db_o=>ram_b_rdata(i*8+7 downto i*8)
83
                );
84
end generate;
85
 
86
-- WISHBONE interface
87
 
88
gen_ram_a_we: for i in 3 downto 0 generate
89
        ram_a_we(i)<='1' when wbs_cyc_i='1' and wbs_stb_i='1' and wbs_we_i='1'
90
                and wbs_sel_i(i)='1' and wbs_adr_i(27 downto 16)="000000000000" else '0';
91
end generate;
92
 
93
process (clk_i) is
94
begin
95
        if rising_edge(clk_i) then
96
                ack_read<=wbs_cyc_i and wbs_stb_i and not wbs_we_i and not ack_read;
97
        end if;
98
end process;
99
 
100
ack_write<=wbs_cyc_i and wbs_stb_i and wbs_we_i;
101
 
102
wbs_ack_o<=ack_read or ack_write;
103
wbs_dat_o<=ram_a_rdata;
104
 
105
-- Low Latency Interface (with optional pseudo-random throttling)
106
 
107
process (clk_i) is
108
begin
109
        if rising_edge(clk_i) then
110
                assert lli_re_i='0' or lli_adr_i(lli_adr_i'high downto 14)=X"0000"
111
                        report "Attempted to fetch instruction from a non-existent address 0x"&
112
                                hex_string(lli_adr_i&"00")
113
                        severity failure;
114
        end if;
115
end process;
116
 
117
gen_throttling: if THROTTLE generate
118
        throttle_inst: entity work.scrambler(rtl)
119
                generic map(TAP1=>9,TAP2=>11)
120
                port map(clk_i=>clk_i,rst_i=>rst_i,ce_i=>'1',d_o=>prbs);
121
end generate;
122
 
123
gen_no_throttling: if not THROTTLE generate
124
        prbs<='0';
125
end generate;
126
 
127
process (clk_i) is
128
begin
129
        if rising_edge(clk_i) then
130
                if rst_i='1' then
131
                        lli_busy<='0';
132
                elsif prbs='1' and lli_re_i='1' then
133
                        lli_busy<='1';
134
                elsif prbs='0' then
135
                        lli_busy<='0';
136
                end if;
137
        end if;
138
end process;
139
 
140
ram_b_re<=lli_re_i and not lli_busy;
141
 
142
lli_busy_o<=lli_busy;
143
lli_dat_o<=ram_b_rdata when lli_busy='0' else (others=>'-');
144
 
145
end architecture;

powered by: WebSVN 2.1.0

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