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

Subversion Repositories simpcon

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

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
        constant SLAVE_CNT : integer := 2;
43
        constant SLAVE_ADDR_BITS : integer := 4;
44
 
45
        type slave_bit is array(0 to SLAVE_CNT-1) of std_logic;
46
        signal sc_rd, sc_wr             : slave_bit;
47
 
48
        type slave_dout is array(0 to SLAVE_CNT-1) of std_logic_vector(31 downto 0);
49
        signal sc_dout                  : slave_dout;
50
 
51
        type slave_rdy_cnt is array(0 to SLAVE_CNT-1) of unsigned(1 downto 0);
52
        signal sc_rdy_cnt               : slave_rdy_cnt;
53
 
54
        signal rd_mux                   : std_logic;
55
 
56
begin
57
 
58
        --
59
        -- Connect two simple test slaves
60
        --
61
        gsl: for i in 0 to SLAVE_CNT-1 generate
62
                wbsl: entity work.sc_test_slave
63
                        generic map (
64
                                -- shall we use less address bits inside the slaves?
65
                                addr_bits => SLAVE_ADDR_BITS
66
                        )
67
                        port map (
68
                                clk => clk,
69
                                reset => reset,
70
 
71
                                address => address(SLAVE_ADDR_BITS-1 downto 0),
72
                                wr_data => wr_data,
73
                                rd => sc_rd(i),
74
                                wr => sc_wr(i),
75
                                rd_data => sc_dout(i),
76
                                rdy_cnt => sc_rdy_cnt(i)
77
                );
78
        end generate;
79
 
80
 
81
 
82
--
83
--      Address decoding
84
--
85
process(address, rd, wr)
86
begin
87
 
88
        -- How can we formulate this more elegant?
89
        sc_rd(0) <= '0';
90
        sc_wr(0) <= '0';
91
        sc_rd(1) <= '0';
92
        sc_wr(1) <= '0';
93
 
94
        if address(SLAVE_ADDR_BITS)='0' then
95
                sc_rd(0) <= rd;
96
                sc_wr(0) <= wr;
97
        else
98
                sc_rd(1) <= rd;
99
                sc_wr(1) <= wr;
100
        end if;
101
 
102
end process;
103
 
104
--
105
--      Read mux selector
106
--
107
process(clk, reset)
108
begin
109
 
110
        if (reset='1') then
111
                rd_mux <= '0';
112
        elsif rising_edge(clk) then
113
                if rd='1' then
114
                        rd_mux <= address(SLAVE_ADDR_BITS);
115
                end if;
116
        end if;
117
end process;
118
 
119
--
120
--      Read data and rdy_cnt mux
121
--
122
--              Or should we simple or the rdy_cnt values?
123
--
124
process(rd_mux, sc_dout, sc_rdy_cnt)
125
begin
126
 
127
        if rd_mux='0' then
128
                rd_data <= sc_dout(0);
129
                rdy_cnt <= sc_rdy_cnt(0);
130
        else
131
                rd_data <= sc_dout(1);
132
                rdy_cnt <= sc_rdy_cnt(1);
133
        end if;
134
end process;
135
 
136
end rtl;

powered by: WebSVN 2.1.0

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