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

Subversion Repositories lxp32

[/] [lxp32/] [trunk/] [verify/] [icache/] [src/] [tb/] [ram_model.vhd] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 ring0_mipt
---------------------------------------------------------------------
2
-- RAM model
3
--
4
-- Part of the LXP32 instruction cache testbench
5
--
6
-- Copyright (c) 2016 by Alex I. Kuznetsov
7
--
8
-- Simulates RAM controller which provides WISHBONE registered
9
-- feedback interface.
10
---------------------------------------------------------------------
11
 
12
library ieee;
13
use ieee.std_logic_1164.all;
14
use ieee.numeric_std.all;
15
 
16
use work.common_pkg.all;
17
use work.tb_pkg.all;
18
 
19
entity ram_model is
20
        port(
21
                clk_i: in std_logic;
22
 
23
                wbm_cyc_i: in std_logic;
24
                wbm_stb_i: in std_logic;
25
                wbm_cti_i: in std_logic_vector(2 downto 0);
26
                wbm_bte_i: in std_logic_vector(1 downto 0);
27
                wbm_ack_o: out std_logic;
28
                wbm_adr_i: in std_logic_vector(29 downto 0);
29
                wbm_dat_o: out std_logic_vector(31 downto 0)
30
        );
31
end entity;
32
 
33
architecture sim of ram_model is
34
 
35
signal ack: std_logic:='0';
36
signal cycle: std_logic:='0';
37
 
38
begin
39
 
40
wbm_ack_o<=ack;
41
 
42
process (clk_i) is
43
begin
44
        if rising_edge(clk_i) then
45
                if wbm_cyc_i='1' and wbm_stb_i='1' and wbm_cti_i="010" and wbm_bte_i="00" then
46
                        cycle<='1';
47
                elsif wbm_cyc_i='0' or (wbm_cyc_i='1' and wbm_stb_i='1' and (wbm_cti_i/="010" or wbm_bte_i/="00")) then
48
                        cycle<='0';
49
                end if;
50
        end if;
51
end process;
52
 
53
process is
54
        variable rng_state: rng_state_type;
55
        variable delay: integer;
56
begin
57
        wait until rising_edge(clk_i) and wbm_cyc_i='1' and wbm_stb_i='1';
58
        ack<='0';
59
 
60
-- Random delay before the first beat
61
        if cycle='0' then
62
                rand(rng_state,0,3,delay);
63
                if delay>0 then
64
                        for i in 1 to delay loop
65
                                wait until rising_edge(clk_i) and wbm_cyc_i='1' and wbm_stb_i='1';
66
                        end loop;
67
                end if;
68
        end if;
69
 
70
        if ack='0' then
71
                wbm_dat_o<=("00"&wbm_adr_i) xor xor_constant;
72
                ack<='1';
73
        elsif wbm_cti_i="010" and wbm_bte_i="00" then
74
                wbm_dat_o<=("00"&std_logic_vector(unsigned(wbm_adr_i)+1)) xor xor_constant;
75
                ack<='1';
76
        end if;
77
end process;
78
 
79
end architecture;

powered by: WebSVN 2.1.0

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