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

Subversion Repositories simpcon

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

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

Line No. Rev Author Line
1 8 martin
--
2
--      scio_test_top.vhd
3
--
4
--      The top level to test SimpCon IO devices.
5
--      Do the address decoding here for the various slaves.
6
--      
7
--      Author: Martin Schoeberl        martin@jopdesign.com
8
--
9
--
10
--      2005-11-30      first version with two simple test slaves
11
--
12
--
13
--
14
 
15
 
16
library ieee;
17
use ieee.std_logic_1164.all;
18
use ieee.numeric_std.all;
19
 
20
use work.jop_types.all;
21
 
22
entity scio is
23
generic (addr_bits : integer);
24
 
25
port (
26
        clk             : in std_logic;
27
        reset   : in std_logic;
28
 
29
-- SimpCon interface
30
 
31
        address         : in std_logic_vector(addr_bits-1 downto 0);
32
        wr_data         : in std_logic_vector(31 downto 0);
33
        rd, wr          : in std_logic;
34
        rd_data         : out std_logic_vector(31 downto 0);
35
        rdy_cnt         : out unsigned(1 downto 0)
36
 
37
);
38
end scio;
39
 
40
architecture rtl of scio is
41
 
42 9 martin
        constant SLAVE_CNT : integer := 4;
43
        -- SLAVE_CNT <= 2**DECODE_BITS
44
        constant DECODE_BITS : integer := 2;
45
        -- number of bits that can be used inside the slave
46 8 martin
        constant SLAVE_ADDR_BITS : integer := 4;
47
 
48
        type slave_bit is array(0 to SLAVE_CNT-1) of std_logic;
49
        signal sc_rd, sc_wr             : slave_bit;
50
 
51
        type slave_dout is array(0 to SLAVE_CNT-1) of std_logic_vector(31 downto 0);
52
        signal sc_dout                  : slave_dout;
53
 
54
        type slave_rdy_cnt is array(0 to SLAVE_CNT-1) of unsigned(1 downto 0);
55
        signal sc_rdy_cnt               : slave_rdy_cnt;
56
 
57 9 martin
        signal sel, sel_reg             : integer range 0 to 2**DECODE_BITS-1;
58 8 martin
 
59
begin
60
 
61 9 martin
        assert SLAVE_CNT <= 2**DECODE_BITS report "Wrong constant in scio";
62
 
63
        sel <= to_integer(unsigned(address(SLAVE_ADDR_BITS+DECODE_BITS-1 downto SLAVE_ADDR_BITS)));
64
 
65
        -- What happens when sel_reg > SLAVE_CNT-1??
66
        rd_data <= sc_dout(sel_reg);
67
        rdy_cnt <= sc_rdy_cnt(sel_reg);
68
 
69 8 martin
        --
70 9 martin
        -- Connect SLAVE_CNT simple test slaves
71 8 martin
        --
72
        gsl: for i in 0 to SLAVE_CNT-1 generate
73 9 martin
 
74
                sc_rd(i) <= rd when i=sel else '0';
75
                sc_wr(i) <= wr when i=sel else '0';
76
 
77
                scsl: entity work.sc_test_slave
78 8 martin
                        generic map (
79
                                -- shall we use less address bits inside the slaves?
80
                                addr_bits => SLAVE_ADDR_BITS
81
                        )
82
                        port map (
83
                                clk => clk,
84
                                reset => reset,
85
 
86
                                address => address(SLAVE_ADDR_BITS-1 downto 0),
87
                                wr_data => wr_data,
88
                                rd => sc_rd(i),
89
                                wr => sc_wr(i),
90
                                rd_data => sc_dout(i),
91
                                rdy_cnt => sc_rdy_cnt(i)
92
                );
93
        end generate;
94
 
95 9 martin
        --
96
        --      Register read mux selector
97
        --
98
        process(clk, reset)
99
        begin
100
                if (reset='1') then
101
                        sel_reg <= 0;
102
                elsif rising_edge(clk) then
103
                        if rd='1' then
104
                                sel_reg <= sel;
105
                        end if;
106 8 martin
                end if;
107 9 martin
        end process;
108 8 martin
 
109
 
110
end rtl;

powered by: WebSVN 2.1.0

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