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

Subversion Repositories simpcon

[/] [simpcon/] [trunk/] [vhdl/] [scio_min.vhd] - Blame information for rev 26

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 martin
--
2
--      scio_min.vhd
3
--
4
--      io devices for minimal configuration
5
--      only counter, wd and serial line, alle io pins are tri statet
6
--
7
--
8
--      io address mapping:
9
--
10
--      IO Base is 0xffffff80 for 'fast' constants (bipush)
11
--
12
--              0x00 0-3                system clock counter, us counter, timer int, wd bit
13
--              0x10 0-1                uart (download)
14
--
15
--      status word in uarts:
16
--              0        uart transmit data register empty
17
--              1       uart read data register full
18
--
19
--
20
--      todo:
21
--
22
--
23
--      2003-07-09      created
24
--      2005-08-27      ignore ncts on uart
25
--      2005-11-30      changed to SimpCon
26 18 martin
--      2007-03-17      use records
27 16 martin
--
28
--
29
 
30
 
31
Library IEEE;
32
use IEEE.std_logic_1164.all;
33
use ieee.numeric_std.all;
34
 
35
use work.jop_types.all;
36 18 martin
use work.sc_pack.all;
37
use work.jop_config.all;
38 16 martin
 
39
entity scio is
40 20 martin
generic (cpu_id : integer := 0);
41 16 martin
port (
42
        clk             : in std_logic;
43
        reset   : in std_logic;
44
 
45 18 martin
--
46
--      SimpCon IO interface
47
--
48
        sc_io_out               : in sc_io_out_type;
49
        sc_io_in                : out sc_in_type;
50 16 martin
 
51 18 martin
--
52
--      Interrupts from IO devices
53
--
54
        irq_in                  : out irq_in_type;
55
        exc_req                 : in exception_type;
56 16 martin
 
57 20 martin
-- CMP
58
 
59
        sync_out : in sync_out_type := NO_SYNC;
60
        sync_in  : out sync_in_type;
61
 
62 16 martin
-- serial interface
63
 
64
        txd                     : out std_logic;
65
        rxd                     : in std_logic;
66
        ncts            : in std_logic;
67
        nrts            : out std_logic;
68
 
69
-- watch dog
70
 
71
        wd                      : out std_logic;
72
 
73
-- core i/o pins
74
        l                       : inout std_logic_vector(20 downto 1);
75
        r                       : inout std_logic_vector(20 downto 1);
76
        t                       : inout std_logic_vector(6 downto 1);
77
        b                       : inout std_logic_vector(10 downto 1)
78
);
79
end scio;
80
 
81
 
82
architecture rtl of scio is
83
 
84 20 martin
        constant SLAVE_CNT : integer := 3;
85 16 martin
        -- SLAVE_CNT <= 2**DECODE_BITS
86
        -- take care of USB address 0x20!
87
        constant DECODE_BITS : integer := 2;
88
        -- number of bits that can be used inside the slave
89
        constant SLAVE_ADDR_BITS : integer := 4;
90
 
91
        type slave_bit is array(0 to SLAVE_CNT-1) of std_logic;
92
        signal sc_rd, sc_wr             : slave_bit;
93
 
94
        type slave_dout is array(0 to SLAVE_CNT-1) of std_logic_vector(31 downto 0);
95
        signal sc_dout                  : slave_dout;
96
 
97
        type slave_rdy_cnt is array(0 to SLAVE_CNT-1) of unsigned(1 downto 0);
98
        signal sc_rdy_cnt               : slave_rdy_cnt;
99
 
100
        signal sel, sel_reg             : integer range 0 to 2**DECODE_BITS-1;
101
 
102
begin
103
 
104
--
105
--      unused and input pins tri state
106
--
107
        l <= (others => 'Z');
108
        r <= (others => 'Z');
109
        t <= (others => 'Z');
110
        b <= (others => 'Z');
111
 
112
        assert SLAVE_CNT <= 2**DECODE_BITS report "Wrong constant in scio";
113
 
114 18 martin
        sel <= to_integer(unsigned(sc_io_out.address(SLAVE_ADDR_BITS+DECODE_BITS-1 downto SLAVE_ADDR_BITS)));
115 16 martin
 
116
        -- What happens when sel_reg > SLAVE_CNT-1??
117 18 martin
        sc_io_in.rd_data <= sc_dout(sel_reg);
118
        sc_io_in.rdy_cnt <= sc_rdy_cnt(sel_reg);
119 16 martin
 
120 20 martin
        -- default for unused USB device
121
        sc_dout(2) <= (others => '0');
122
        sc_rdy_cnt(2) <= (others => '0');
123
 
124 16 martin
        --
125
        -- Connect SLAVE_CNT simple test slaves
126
        --
127
        gsl: for i in 0 to SLAVE_CNT-1 generate
128
 
129 18 martin
                sc_rd(i) <= sc_io_out.rd when i=sel else '0';
130
                sc_wr(i) <= sc_io_out.wr when i=sel else '0';
131 16 martin
 
132
        end generate;
133
 
134
        --
135
        --      Register read mux selector
136
        --
137
        process(clk, reset)
138
        begin
139
                if (reset='1') then
140
                        sel_reg <= 0;
141
                elsif rising_edge(clk) then
142 18 martin
                        if sc_io_out.rd='1' then
143 16 martin
                                sel_reg <= sel;
144
                        end if;
145
                end if;
146
        end process;
147
 
148 20 martin
        cmp_sys: entity work.sc_sys generic map (
149 16 martin
                        addr_bits => SLAVE_ADDR_BITS,
150 20 martin
                        clk_freq => clk_freq,
151
                        cpu_id => cpu_id
152 16 martin
                )
153
                port map(
154
                        clk => clk,
155
                        reset => reset,
156
 
157 18 martin
                        address => sc_io_out.address(SLAVE_ADDR_BITS-1 downto 0),
158
                        wr_data => sc_io_out.wr_data,
159 16 martin
                        rd => sc_rd(0),
160
                        wr => sc_wr(0),
161
                        rd_data => sc_dout(0),
162
                        rdy_cnt => sc_rdy_cnt(0),
163
 
164 18 martin
                        irq_in => irq_in,
165
                        exc_req => exc_req,
166
 
167 20 martin
                        sync_out => sync_out,
168
                        sync_in => sync_in,
169
 
170 16 martin
                        wd => wd
171
                );
172
 
173
        cmp_ua: entity work.sc_uart generic map (
174
                        addr_bits => SLAVE_ADDR_BITS,
175
                        clk_freq => clk_freq,
176
                        baud_rate => 115200,
177
                        txf_depth => 2,
178
                        txf_thres => 1,
179
                        rxf_depth => 2,
180
                        rxf_thres => 1
181
                )
182
                port map(
183
                        clk => clk,
184
                        reset => reset,
185
 
186 18 martin
                        address => sc_io_out.address(SLAVE_ADDR_BITS-1 downto 0),
187
                        wr_data => sc_io_out.wr_data,
188 16 martin
                        rd => sc_rd(1),
189
                        wr => sc_wr(1),
190
                        rd_data => sc_dout(1),
191
                        rdy_cnt => sc_rdy_cnt(1),
192
 
193
                        txd      => txd,
194
                        rxd      => rxd,
195
                        ncts => '0',
196
                        nrts => nrts
197
        );
198
 
199
end rtl;

powered by: WebSVN 2.1.0

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