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

Subversion Repositories tinyvliw8

[/] [tinyvliw8/] [trunk/] [src/] [vhdl/] [sysArch.vhd] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 steckol
-------------------------------------------------------------------------------
2
--
3
-- Design:  tinyVLIW8 soft-core processor
4
-- Author:  Oliver Stecklina <stecklina@ihp-microelectronics.com>
5
-- Date:    24.10.2013 
6
-- File:    sysArch.vhd
7
--
8
-------------------------------------------------------------------------------
9
--
10
-- Description : TinyVLIW8 system architecture includes processor core and
11
--               GPIO, timer, and SPI periperals
12
--
13
-------------------------------------------------------------------------------
14
--
15
--    Copyright (C) 2015 IHP GmbH, Frankfurt (Oder), Germany
16
--
17
-- This code is free software. It is licensed under the EUPL, Version 1.1
18
-- or - as soon they will be approved by the European Commission - subsequent
19
-- versions of the EUPL (the "License").
20
-- You may redistribute this code and/or modify it under the terms of this
21
-- License.
22
-- You may not use this work except in compliance with the License.
23
-- You may obtain a copy of the License at:
24
--
25
-- http://joinup.ec.europa.eu/software/page/eupl/licence-eupl
26
--
27
-- Unless required by applicable law or agreed to in writing, software
28
-- distributed under the License is distributed on an "AS IS" basis,
29
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30
-- See the License for the specific language governing permissions and
31
-- limitations under the License.
32
--
33
-------------------------------------------------------------------------------
34
 
35 4 steckol
library ieee;
36
use ieee.std_logic_1164.all;
37
use ieee.std_logic_arith.all;
38
 
39
entity sysArch is
40
        port (
41
                -- clock input
42
                clk           : in std_logic;
43
 
44
                -- instruction bus
45
                instMemAddr   : out std_logic_vector(10 downto 0);
46
                instMemDataIn : in  std_logic_vector(31 downto 0);
47
                instMemEn_n   : out std_logic;
48
 
49
                -- data bus
50
                dataMemAddr    : out std_logic_vector(7 downto 0);
51
                dataMemDataIn  : in  std_logic_vector(7 downto 0);
52
                dataMemDataOut : out std_logic_vector(7 downto 0);
53
                dataMemEn_n    : out std_logic;
54
                dataMemWr_n    : out std_logic;
55
 
56
                ioAddr    : out std_logic_vector(7 downto 0);
57
                ioDataIn  : in  std_logic_vector(7 downto 0);
58
                ioDataOut : out std_logic_vector(7 downto 0);
59
                ioWrEn_n  : out std_logic;
60
                ioRdEn_n  : out std_logic;
61
 
62 9 steckol
                -- external interrupt handling
63 4 steckol
                irqLine        : in  std_logic;
64
                irqLineAck     : out std_logic;
65
 
66
                -- general purpose IO
67
                gpio_in  : in  std_logic_vector(7 downto 0);
68
                gpio_out : out  std_logic_vector(7 downto 0);
69
                gpio_dir : out  std_logic_vector(7 downto 0);
70
 
71
                spi_clk  : OUT STD_LOGIC;       -- SPI clock
72
                spi_cs   : OUT STD_LOGIC;       -- SPI slave select, active level configurable
73
                spi_mosi : OUT STD_LOGIC;       -- SPI master output, slave input
74
                spi_miso : IN  STD_LOGIC;       -- SPI master input, slave output
75
 
76
                stall_n      : in std_logic;
77
                stalled_n    : out std_logic;
78
 
79
                -- reset input
80
                rst_n        : in std_logic
81
        );
82
end sysArch;
83
 
84
architecture behavior of sysArch is
85
 
86
component SPImaster IS
87 9 steckol
        PORT (
88
                inclk : IN  STD_LOGIC;  -- system clock
89
                rst_n : IN  STD_LOGIC;  -- synchr. system reset, high active
90
                -- processor interface
91
                we_n : IN  STD_LOGIC;   -- write enable, high active
92
                re_n : IN  STD_LOGIC;   -- read  enable, high active
93
                addr : IN  STD_LOGIC_VECTOR(1 DOWNTO 0); -- address from processor
94
                din  : IN  STD_LOGIC_VECTOR(7 DOWNTO 0);-- data from processor
95
                dout : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);-- async. data to processor
96
                intr : OUT STD_LOGIC;   -- interrupt to processor, high active
97
                intra : IN STD_LOGIC;   -- interrupt to processor, high active
98
                -- SPI interface
99
                SCK  : OUT STD_LOGIC;   -- SPI clock
100
                SS   : OUT STD_LOGIC;   -- SPI slave select, active level configurable
101
                MOSI : OUT STD_LOGIC;   -- SPI master output, slave input
102
                MISO : IN  STD_LOGIC    -- SPI master input, slave output
103
        );
104 4 steckol
END component;
105
 
106
component vliwProc
107
        port (
108
                clk            : in  std_logic;
109
 
110
                instMemAddr    : out std_logic_vector(10 downto 0);
111
                instMemDataIn  : in  std_logic_vector(31 downto 0);
112
                instMemEn_n    : out std_logic;
113
 
114
                ioMemAddr    : out std_logic_vector(7 downto 0);
115
                ioMemDataOut : out std_logic_vector(7 downto 0);
116
                ioMemDataIn  : in  std_logic_vector(7 downto 0);
117
                ioMemWr_n    : out std_logic;
118
                ioMemEn_n    : out std_logic;
119
 
120
                -- IO bus
121
                dataMemAddr    : out std_logic_vector(7 downto 0);
122
                dataMemDataOut : out std_logic_vector(7 downto 0);
123
                dataMemDataIn  : in  std_logic_vector(7 downto 0);
124
                dataMemWr_n    : out std_logic;
125
                dataMemEn_n    : out std_logic;
126
 
127
                irqLine        : in  std_logic_vector(4 downto 0);
128
                irqLineAck     : out std_logic_vector(4 downto 0);
129
 
130
                stall_n      : in std_logic;
131
                stalled_n    : out std_logic;
132
 
133
                rst_n        : in std_logic
134
        );
135
end component;
136
 
137
component ioport
138
        port (
139 9 steckol
                cs_n    : IN  STD_LOGIC;                        -- chip select signal
140 4 steckol
 
141 9 steckol
                clk     : IN  STD_LOGIC;
142 4 steckol
 
143 9 steckol
                -- memory interface
144
                mdbwr_n : IN  STD_LOGIC;                    -- write enable signal    
145
                mdb_i   : IN  STD_LOGIC_VECTOR(7 DOWNTO 0); -- data from data bus
146
                mdb_o   : OUT STD_LOGIC_VECTOR(7 DOWNTO 0); -- data to data bus    
147
                mab     : IN  STD_LOGIC_VECTOR(2 downto 0);      -- address registers 
148 4 steckol
 
149 9 steckol
                irq     : out std_logic;
150
                irqAck  : in std_logic;
151
 
152
                -- port interface
153
                PnIN    : IN  STD_LOGIC_VECTOR(7 DOWNTO 0); -- data from pad (gpio in)
154
                PnOUT   : OUT STD_LOGIC_VECTOR(7 DOWNTO 0); -- data to pad (gpio out)
155
                PnOEN   : OUT STD_LOGIC_VECTOR(7 DOWNTO 0); -- port direction (low active)
156
 
157
                rst_n   : IN STD_LOGIC
158
        );
159 4 steckol
end component;
160
 
161
component timer
162
        PORT (
163
                clk       : in std_logic;
164
 
165
                addr      : in std_logic_vector(2 downto 0);        -- register address
166
 
167
                writeEn_n : in  STD_LOGIC;                           -- write enable, low active
168
                readEn_n  : in  STD_LOGIC;                      -- read enable, low active
169
 
170
                dataOut   : OUT std_logic_vector(7 downto 0);    -- data bus for writing register
171
                dataIn    : IN std_logic_vector(7 downto 0);    -- data bus for reading register
172
 
173
                irq       : out std_logic;
174
                irq_ack   : in  std_logic;
175
 
176
                rst_n     : IN  STD_LOGIC                        -- asynchr. reset, low active
177
        );
178
end component;
179
 
180
        signal clk_s   : std_logic;
181
 
182
        signal instAddr_s    : std_logic_vector(10 downto 0);
183
        signal instDataIn_s  : std_logic_vector(31 downto 0);
184
        signal instEn_n_s    : std_logic;
185
 
186
        -- IO bus
187
        signal ioAddr_s    : std_logic_vector(7 downto 0);
188
        signal ioDataOut_s : std_logic_vector(7 downto 0);
189
        signal ioDataIn_s  : std_logic_vector(7 downto 0);
190
        signal ioEn_n_s    : std_logic;
191
        signal ioWr_n_s    : std_logic;
192
 
193
        -- GPIO signals
194
        signal ioDataGpio_s : std_logic_vector(7 downto 0);
195
        signal ioPortEn_n_s : std_logic;
196
        signal ioPortIrq_s  : std_logic;
197
 
198
        --Fir Data bus
199
        signal dataAddr_s   : std_logic_vector(7 downto 0);
200
        signal dataOut_s    : std_logic_vector(7 downto 0);
201
        signal dataIn_s     : std_logic_vector(7 downto 0);
202
        signal dataWr_n_s   : std_logic;
203
        signal dataEn_n_s   : std_logic;
204
 
205
        signal rst_n_s     : std_logic;
206
 
207
        signal stall_n_s   : std_logic;
208
        signal stalled_n_s : std_logic;
209
 
210
        signal irqLine_s        : std_logic_vector(4 downto 0);
211
        signal irqLineAck_s     : std_logic_vector(4 downto 0);
212
 
213
        -- timer signals 
214
        signal timer_irq_s      : std_logic;
215
        signal ioTimerEn_n_s    : std_logic;
216
        signal ioTimerDataOut_s : std_logic_vector(7 downto 0);
217
 
218
        -- spi master signals
219
        signal ioSpiEn_n_s : std_logic;
220
        signal spiIrq_s    : std_logic;
221
        signal ioDataSpi_s : std_logic_vector(7 downto 0);
222
 
223
        -- external io interface
224
        signal ioDataExt_s : std_logic_vector(7 downto 0);
225
        signal ioExtEn_n_s : std_logic;
226
 
227
begin
228
 
229
        clk_s <= clk;
230
 
231
        rst_n_s <= rst_n;
232
 
233
        stall_n_s <= stall_n;
234
        stalled_n <= stalled_n_s;
235
 
236
        irqLineAck <= irqLineAck_s(0);   -- export IRQ 0
237
 
238 9 steckol
        irqLine_s <= ioPortIrq_s & timer_irq_s & '0' & spiIrq_s & irqLine;
239 4 steckol
 
240
        instMemAddr  <= instAddr_s;
241
        instDataIn_s <= instMemDataIn;
242
        instMemEn_n  <= instEn_n_s;
243
 
244
        dataMemAddr    <= dataAddr_s;
245
        dataIn_s       <= dataMemDataIn;
246
        dataMemDataOut <= dataOut_s;
247
        dataMemEn_n    <= dataEn_n_s;
248
        dataMemWr_n    <= dataWr_n_s;
249
 
250
        ioDataIn_s <= ioDataGpio_s     when ioPortEn_n_s = '0' else
251
                      ioTimerDataOut_s when ioTimerEn_n_s = '0' else
252 9 steckol
                                  ioDataSpi_s      when ioSpiEn_n_s = '0' else
253
                                  ioDataExt_s;
254 4 steckol
 
255
        vliwProc_i : vliwProc
256
        port map (
257
                clk            => clk_s,
258
 
259
                instMemAddr    => instAddr_s,
260
                instMemDataIn  => instDataIn_s,
261
                instMemEn_n    => instEn_n_s,
262
 
263
                ioMemAddr      => ioAddr_s,
264
                ioMemDataOut   => ioDataOut_s,
265
                ioMemDataIn    => ioDataIn_s,
266
                ioMemEn_n      => ioEn_n_s,
267
                ioMemWr_n      => ioWr_n_s,
268
 
269
                dataMemAddr    => dataAddr_s,
270
                dataMemDataOut => dataOut_s,
271
                dataMemDataIn  => dataIn_s,
272
                dataMemEn_n    => dataEn_n_s,
273
                dataMemWr_n    => dataWr_n_s,
274
 
275
                irqLine        => irqLine_s,
276
                irqLineAck     => irqLineAck_s,
277
 
278
                stall_n        => stall_n_s,
279
                stalled_n      => stalled_n_s,
280
 
281
                rst_n          => rst_n_s
282
        );
283
 
284
        ioSpiEn_n_s <= ioEn_n_s when ioAddr_s(7 downto 2) = "000101" else
285
                       '1';
286
 
287
        spiMaster_i : SPImaster
288
        port map (
289
                inclk => clk_s,
290 9 steckol
                rst_n => rst_n_s,
291 4 steckol
 
292
                we_n => ioWr_n_s,
293
                re_n => ioSpiEn_n_s,
294
                addr => ioAddr_s(1 downto 0),
295
                din  => ioDataOut_s,
296
                dout => ioDataSpi_s,
297
 
298 9 steckol
                intr  => spiIrq_s,
299 4 steckol
                intra => irqLineAck_s(1),
300
 
301
                SCK  => spi_clk,
302
                SS   => spi_cs,
303
                MOSI => spi_mosi,
304
                MISO => spi_miso
305
        );
306
 
307
        ioPortEn_n_s <= ioEn_n_s when ioAddr_s(7 downto 3) = "00100" else
308
                        '1';
309
 
310
        ioport_i : ioport
311
        port map (
312 9 steckol
                cs_n => ioPortEn_n_s,
313
                clk  => clk_s,
314 4 steckol
 
315 9 steckol
                mdbwr_n => ioWr_n_s,
316
                mdb_i   => ioDataOut_s,
317
                mdb_o   => ioDataGpio_s,
318 4 steckol
                mab     => ioAddr_s(2 downto 0),
319
 
320 9 steckol
                irq    => ioPortIrq_s,
321
                irqAck => irqLineAck_s(4),
322 4 steckol
 
323
                -- port interface
324 9 steckol
                PnIN  => gpio_in,
325
                PnOUT => gpio_out,
326
                PnOEN => gpio_dir,
327 4 steckol
 
328 9 steckol
                rst_n => rst_n_s
329 4 steckol
        );
330
 
331
        ioTimerEn_n_s <= ioEn_n_s when ioAddr_s(7 downto 3) = "00101" else
332
                         '1';
333
 
334
        timer_i : timer
335
        port map (
336
                clk       => clk_s,
337
 
338
                addr      => ioAddr_s(2 downto 0),
339
 
340
                writeEn_n => ioWr_n_s,
341
                readEn_n  => ioTimerEn_n_s,
342
 
343
                dataOut   => ioTimerDataOut_s,
344
                dataIn    => ioDataOut_s,
345
 
346
                irq       => timer_irq_s,
347
                irq_ack   => irqLineAck_s(3),
348
 
349
                rst_n     => rst_n_s
350
        );
351
 
352
        -- external io interface
353 9 steckol
        ioAddr      <= ioAddr_s;
354
        ioDataOut   <= ioDataOut_s;
355 4 steckol
        ioDataExt_s <= ioDataIn;
356 9 steckol
        ioRdEn_n    <= ioEn_n_s;
357
        ioWrEn_n    <= ioWr_n_s;
358 4 steckol
 
359
end behavior;

powered by: WebSVN 2.1.0

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