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

Subversion Repositories simpcon

[/] [simpcon/] [trunk/] [vhdl/] [sc_test_top.vhd] - Blame information for rev 29

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 8 martin
--
2 29 martin
--
3
--  This file is a part of JOP, the Java Optimized Processor
4
--
5
--  Copyright (C) 2001-2008, Martin Schoeberl (martin@jopdesign.com)
6
--
7
--  This program is free software: you can redistribute it and/or modify
8
--  it under the terms of the GNU General Public License as published by
9
--  the Free Software Foundation, either version 3 of the License, or
10
--  (at your option) any later version.
11
--
12
--  This program is distributed in the hope that it will be useful,
13
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
--  GNU General Public License for more details.
16
--
17
--  You should have received a copy of the GNU General Public License
18
--  along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
--
20
 
21
 
22
--
23 8 martin
--      scio_test_top.vhd
24
--
25
--      The top level to test SimpCon IO devices.
26
--      Do the address decoding here for the various slaves.
27
--      
28
--      Author: Martin Schoeberl        martin@jopdesign.com
29
--
30
--
31
--      2005-11-30      first version with two simple test slaves
32
--
33
--
34
--
35
 
36
 
37
library ieee;
38
use ieee.std_logic_1164.all;
39
use ieee.numeric_std.all;
40
 
41
use work.jop_types.all;
42
 
43
entity scio is
44
generic (addr_bits : integer);
45
 
46
port (
47
        clk             : in std_logic;
48
        reset   : in std_logic;
49
 
50
-- SimpCon interface
51
 
52
        address         : in std_logic_vector(addr_bits-1 downto 0);
53
        wr_data         : in std_logic_vector(31 downto 0);
54
        rd, wr          : in std_logic;
55
        rd_data         : out std_logic_vector(31 downto 0);
56
        rdy_cnt         : out unsigned(1 downto 0)
57
 
58
);
59
end scio;
60
 
61
architecture rtl of scio is
62
 
63 9 martin
        constant SLAVE_CNT : integer := 4;
64
        -- SLAVE_CNT <= 2**DECODE_BITS
65
        constant DECODE_BITS : integer := 2;
66
        -- number of bits that can be used inside the slave
67 8 martin
        constant SLAVE_ADDR_BITS : integer := 4;
68
 
69
        type slave_bit is array(0 to SLAVE_CNT-1) of std_logic;
70
        signal sc_rd, sc_wr             : slave_bit;
71
 
72
        type slave_dout is array(0 to SLAVE_CNT-1) of std_logic_vector(31 downto 0);
73
        signal sc_dout                  : slave_dout;
74
 
75
        type slave_rdy_cnt is array(0 to SLAVE_CNT-1) of unsigned(1 downto 0);
76
        signal sc_rdy_cnt               : slave_rdy_cnt;
77
 
78 9 martin
        signal sel, sel_reg             : integer range 0 to 2**DECODE_BITS-1;
79 8 martin
 
80
begin
81
 
82 9 martin
        assert SLAVE_CNT <= 2**DECODE_BITS report "Wrong constant in scio";
83
 
84
        sel <= to_integer(unsigned(address(SLAVE_ADDR_BITS+DECODE_BITS-1 downto SLAVE_ADDR_BITS)));
85
 
86
        -- What happens when sel_reg > SLAVE_CNT-1??
87
        rd_data <= sc_dout(sel_reg);
88
        rdy_cnt <= sc_rdy_cnt(sel_reg);
89
 
90 8 martin
        --
91 9 martin
        -- Connect SLAVE_CNT simple test slaves
92 8 martin
        --
93
        gsl: for i in 0 to SLAVE_CNT-1 generate
94 9 martin
 
95
                sc_rd(i) <= rd when i=sel else '0';
96
                sc_wr(i) <= wr when i=sel else '0';
97
 
98
                scsl: entity work.sc_test_slave
99 8 martin
                        generic map (
100
                                -- shall we use less address bits inside the slaves?
101
                                addr_bits => SLAVE_ADDR_BITS
102
                        )
103
                        port map (
104
                                clk => clk,
105
                                reset => reset,
106
 
107
                                address => address(SLAVE_ADDR_BITS-1 downto 0),
108
                                wr_data => wr_data,
109
                                rd => sc_rd(i),
110
                                wr => sc_wr(i),
111
                                rd_data => sc_dout(i),
112
                                rdy_cnt => sc_rdy_cnt(i)
113
                );
114
        end generate;
115
 
116 9 martin
        --
117
        --      Register read mux selector
118
        --
119
        process(clk, reset)
120
        begin
121
                if (reset='1') then
122
                        sel_reg <= 0;
123
                elsif rising_edge(clk) then
124
                        if rd='1' then
125
                                sel_reg <= sel;
126
                        end if;
127 8 martin
                end if;
128 9 martin
        end process;
129 8 martin
 
130
 
131
end rtl;

powered by: WebSVN 2.1.0

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