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

Subversion Repositories the_wizardry_project

[/] [the_wizardry_project/] [trunk/] [Wizardry/] [VHDL/] [Wizardry Top Level/] [Address Generation/] [JOP/] [scio_min.vhd] - Blame information for rev 22

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 22 mcwaccent
--
2
--
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
--      scio_min.vhd
24
--
25
--      io devices for minimal configuration
26
--      only counter, wd and serial line, alle io pins are tri statet
27
--
28
--
29
--      io address mapping:
30
--
31
--      IO Base is 0xffffff80 for 'fast' constants (bipush)
32
--
33
--              0x00 0-3                system clock counter, us counter, timer int, wd bit
34
--              0x10 0-1                uart (download)
35
--
36
--      status word in uarts:
37
--              0        uart transmit data register empty
38
--              1       uart read data register full
39
--
40
--
41
--      todo:
42
--
43
--
44
--      2003-07-09      created
45
--      2005-08-27      ignore ncts on uart
46
--      2005-11-30      changed to SimpCon
47
--      2007-03-17      use records
48
--
49
--
50
 
51
 
52
Library IEEE;
53
use IEEE.std_logic_1164.all;
54
use ieee.numeric_std.all;
55
 
56
use work.jop_types.all;
57
use work.sc_pack.all;
58
use work.jop_config.all;
59
 
60
entity scio is
61
generic (cpu_id : integer := 0; cpu_cnt : integer := 1);
62
port (
63
        clk             : in std_logic;
64
        reset   : in std_logic;
65
 
66
--
67
--      SimpCon IO interface
68
--
69
        sc_io_out               : in sc_out_type;
70
        sc_io_in                : out sc_in_type;
71
 
72
--
73
--      Interrupts from IO devices
74
--
75
        irq_in                  : out irq_bcf_type;
76
        irq_out                 : in irq_ack_type;
77
        exc_req                 : in exception_type;
78
 
79
--  Control Signals from JOP
80
--      configuration_trigger : out std_logic_vector(7 downto 0);
81
        eRCP_trigger_reg : out std_logic;
82
 
83
-- CMP
84
 
85
        sync_out : in sync_out_type := NO_SYNC;
86
        sync_in  : out sync_in_type;
87
 
88
-- serial interface
89
 
90
        txd                     : out std_logic;
91
        rxd                     : in std_logic;
92
        ncts            : in std_logic;
93
        nrts            : out std_logic;
94
 
95
-- watch dog
96
 
97
        wd                      : out std_logic;
98
 
99
-- core i/o pins
100
        l                       : inout std_logic_vector(20 downto 1);
101
        r                       : inout std_logic_vector(20 downto 1);
102
        t                       : inout std_logic_vector(6 downto 1);
103
        b                       : inout std_logic_vector(10 downto 1);
104
 
105
-- remove the comment for RAM access counting
106
-- ram_cnt      : in std_logic
107
 
108
-- Wizardry Interface
109
        ack_i : in std_logic;
110
        err_i : in std_logic;
111
        dat_i : in std_logic_vector(31 downto 0);
112
        cyc_o : out std_logic;
113
        stb_o : out std_logic;
114
        we_o : out std_logic;
115
        dat_o : out std_logic_vector(31 downto 0);
116
        adr_o : out std_logic_Vector(21 downto 0);
117
        lock_o : out std_logic;
118
--      id_o : out std_logic_Vector(4 downto 0);
119
        priority_o : out std_logic_Vector(7 downto 0)
120
);
121
end scio;
122
 
123
 
124
architecture rtl of scio is
125
 
126
        constant SLAVE_CNT : integer := 3;
127
        -- SLAVE_CNT <= 2**DECODE_BITS
128
        -- take care of USB address 0x20!
129
        constant DECODE_BITS : integer := 2;
130
        -- number of bits that can be used inside the slave
131
        constant SLAVE_ADDR_BITS : integer := 4;
132
 
133
        type slave_bit is array(0 to SLAVE_CNT-1) of std_logic;
134
        signal sc_rd, sc_wr             : slave_bit;
135
 
136
        type slave_dout is array(0 to SLAVE_CNT-1) of std_logic_vector(31 downto 0);
137
        signal sc_dout                  : slave_dout;
138
 
139
        type slave_rdy_cnt is array(0 to SLAVE_CNT-1) of unsigned(1 downto 0);
140
        signal sc_rdy_cnt               : slave_rdy_cnt;
141
 
142
        signal sel, sel_reg             : integer range 0 to 2**DECODE_BITS-1;
143
 
144
        -- remove the comment for RAM access counting 
145
        -- signal ram_count : std_logic;
146
 
147
begin
148
 
149
--
150
--      unused and input pins tri state
151
--
152
        l <= (others => 'Z');
153
        r <= (others => 'Z');
154
        t <= (others => 'Z');
155
        b <= (others => 'Z');
156
 
157
        assert SLAVE_CNT <= 2**DECODE_BITS report "Wrong constant in scio";
158
 
159
        sel <= to_integer(unsigned(sc_io_out.address(SLAVE_ADDR_BITS+DECODE_BITS-1 downto SLAVE_ADDR_BITS)));
160
 
161
        -- What happens when sel_reg > SLAVE_CNT-1??
162
        sc_io_in.rd_data <= sc_dout(sel_reg);
163
        sc_io_in.rdy_cnt <= sc_rdy_cnt(sel_reg);
164
 
165
        -- default for unused USB device
166
--      sc_dout(2) <= (others => '0');
167
--      sc_rdy_cnt(2) <= (others => '0');
168
 
169
        --
170
        -- Connect SLAVE_CNT simple test slaves
171
        --
172
        gsl: for i in 0 to SLAVE_CNT-1 generate
173
 
174
                sc_rd(i) <= sc_io_out.rd when i=sel else '0';
175
                sc_wr(i) <= sc_io_out.wr when i=sel else '0';
176
 
177
        end generate;
178
 
179
        --
180
        --      Register read and write mux selector
181
        --
182
        process(clk, reset)
183
        begin
184
                if (reset='1') then
185
                        sel_reg <= 0;
186
                elsif rising_edge(clk) then
187
                        if sc_io_out.rd='1' or sc_io_out.wr='1' then
188
                                sel_reg <= sel;
189
                        end if;
190
                end if;
191
        end process;
192
 
193
        cmp_sys: entity work.sc_sys generic map (
194
                        addr_bits => SLAVE_ADDR_BITS,
195
                        clk_freq => clk_freq,
196
                        cpu_id => cpu_id,
197
                        cpu_cnt => cpu_cnt
198
                )
199
                port map(
200
                        clk => clk,
201
                        reset => reset,
202
 
203
                        address => sc_io_out.address(SLAVE_ADDR_BITS-1 downto 0),
204
                        wr_data => sc_io_out.wr_data,
205
                        rd => sc_rd(0),
206
                        wr => sc_wr(0),
207
                        rd_data => sc_dout(0),
208
                        rdy_cnt => sc_rdy_cnt(0),
209
 
210
                        irq_in => irq_in,
211
                        irq_out => irq_out,
212
                        exc_req => exc_req,
213
 
214
                        sync_out => sync_out,
215
                        sync_in => sync_in,
216
 
217
                        wd => wd
218
                        -- remove the comment for RAM access counting
219
                        -- ram_count => ram_count
220
                );
221
 
222
        -- remove the comment for RAM access counting
223
        -- ram_count <= ram_cnt;
224
 
225
        cmp_ua: entity work.sc_uart generic map (
226
                        addr_bits => SLAVE_ADDR_BITS,
227
                        clk_freq => clk_freq,
228
                        baud_rate => 115200,
229
                        txf_depth => 2,
230
                        txf_thres => 1,
231
                        rxf_depth => 2,
232
                        rxf_thres => 1
233
                )
234
                port map(
235
                        clk => clk,
236
                        reset => reset,
237
 
238
                        address => sc_io_out.address(SLAVE_ADDR_BITS-1 downto 0),
239
                        wr_data => sc_io_out.wr_data,
240
                        rd => sc_rd(1),
241
                        wr => sc_wr(1),
242
                        rd_data => sc_dout(1),
243
                        rdy_cnt => sc_rdy_cnt(1),
244
 
245
                        txd      => txd,
246
                        rxd      => rxd,
247
                        ncts => '0',
248
                        nrts => nrts
249
        );
250
 
251
        cmp_wiz: entity work.sc_wizardry
252
                generic map(addr_bits => SLAVE_ADDR_BITS)
253
        port MAP(
254
                clk     => clk,
255
                reset   => reset,
256
 
257
        -- SimpCon interface
258
 
259
                address         => sc_io_out.address(SLAVE_ADDR_BITS-1 downto 0),
260
                wr_data         => sc_io_out.wr_data,
261
                rd => sc_rd(2),
262
                wr      => sc_wr(2),
263
                rd_data => sc_dout(2),
264
                rdy_cnt => sc_rdy_cnt(2),
265
 
266
                --  Control Signals from JOP
267
--              configuration_trigger => configuration_trigger,
268
                eRCP_trigger_reg => eRCP_trigger_reg,
269
 
270
        --Wizardry Interface
271
                ack_i => ack_i,
272
                err_i => err_i,
273
                dat_i => dat_i,
274
                cyc_o => cyc_o,
275
                stb_o => stb_o,
276
                we_o => we_o,
277
                dat_o => dat_o,
278
                adr_o => adr_o,
279
                lock_o => lock_o,
280
--              id_o => id_o,
281
                priority_o => priority_o
282
        );
283
 
284
end rtl;

powered by: WebSVN 2.1.0

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