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

Subversion Repositories System09

[/] [System09/] [rev_86/] [rtl/] [VHDL/] [quadcpu09.vhd] - Blame information for rev 203

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

Line No. Rev Author Line
1 65 davidgb
--===========================================================================----
2
--
3
--  S Y N T H E Z I A B L E    unicpu09.vhd - Quad core 6809 processor
4
--
5
--===========================================================================----
6
--
7
--  This core adheres to the GNU public license  
8
--
9
-- File name      : quadcpu09.vhd
10
--
11
-- Purpose        : Top level file for quad Core 6809 compatible system on a chip
12
--                  Designed with Xilinx XC3S1000 Spartan 3 FPGA.
13
--                  Implemented With Digilent Xilinx Starter FPGA board,
14
--
15
-- Dependencies   : ieee.Std_Logic_1164
16
--                  ieee.std_logic_unsigned
17
--                  ieee.std_logic_arith
18
--                  ieee.numeric_std
19
--
20
-- Uses           : 
21
--                  unicpu09  (unicpu09.vhd)     6809 CPU core  module
22
-- 
23
-- Author         : John E. Kent      
24
--                  dilbert57@opencores.org      
25
--
26
--===========================================================================----
27
--
28
-- Revision History:
29
--
30
--===========================================================================--
31
-- Version 0.1 - 20 March 2003
32
--
33
--===========================================================================--
34
 
35
library ieee;
36
   use ieee.std_logic_1164.all;
37
   use IEEE.STD_LOGIC_ARITH.ALL;
38
   use IEEE.STD_LOGIC_UNSIGNED.ALL;
39
   use ieee.numeric_std.all;
40
library unisim;
41
        use unisim.vcomponents.all;
42
library work;
43
   use work.bit_funcs.all;
44
 
45
entity quadcpu09 is
46
  port (
47
         clk      :     in  std_logic;
48
    rst      : in  std_logic;
49
    rw       :  out std_logic;
50
    vma      :  out std_logic;
51
    address  : out std_logic_vector(19 downto 0);
52
    data_in  : in        std_logic_vector(7 downto 0);
53
         data_out : out std_logic_vector(7 downto 0);
54
         halt     : in  std_logic;
55
         hold     : in  std_logic;
56
         irq      : in  std_logic;
57
         nmi      : in  std_logic;
58
         firq     : in  std_logic
59
  );
60
end entity;
61
 
62
-------------------------------------------------------------------------------
63
-- Architecture for System09
64
-------------------------------------------------------------------------------
65
architecture RTL of quadcpu09 is
66
 
67
  constant CPU_MAX    : integer :=  4;
68
  constant ADDR_WIDTH : integer := 20;
69
  constant DATA_WIDTH : integer :=  8;
70
 
71
  type addr_type  is std_logic_vector(ADDR_WIDTH-1 downto 0);
72
  type data_type  is std_logic_vector(DATA_WIDTH-1 downto 0);
73
  type cpu_type   is std_logic_vector(   CPU_MAX-1 downto 0);
74
  type addr_array is array(0 to (CPU_MAX-1)) of addr_type;
75
  type data_array is array(0 to (CPU_MAX-1)) of data_type;
76
 
77
  -- CPU Interface signals
78
  signal cpu_rw       : cpu_type;
79
  signal cpu_vma      : cpu_type;
80
  signal cpu_addr     : addr_array;
81
  signal cpu_id       : data_array;
82
  signal cpu_halt     : cpu_type;
83
  signal cpu_hold     : cpu_type;
84
  signal cpu_irq      : cpu_type;
85
  signal cpu_nmi      : cpu_type;
86
  signal cpu_firq     : cpu_type;
87
  signal mem_rw       : std_logic;
88
  signal mem_vma      : std_logic;
89
  signal mem_addr     : addr_type;
90
  signal mem_dati     : data_type;
91
  signal mem_dato     : data_array;
92
 
93
  --
94
  -- priority encoder
95
  --
96
  signal pri_rot      : std_logic;                                   -- rotate the priority 
97
  signal pri_cnt      : std_logic_vector( log2(CPU_MAX)-1 downto 0);     -- priority rotation counter
98
  signal pri_mux      : std_logic_vector( (CPU_MAX-1) downto 0);     -- rotated bus request
99
  signal pri_enc      : std_logic_vector( log2(CPU_MAX)-1 downto 0);     -- encoded rotated bus request
100
  signal pri_req      : std_logic;                                                                                              -- encoded bus request valid
101
 
102
 
103
component my_unicpu09
104
  generic(
105
  );
106
 
107
  port(
108
         clk      :     in  std_logic;
109
    rst      : in  std_logic;
110
         --
111
         -- cpu side signals
112
         --
113
    rw       : out std_logic;
114
    vma      : out std_logic;
115
    addr     : out addr_type;
116
    cpu_id   : in  data_type;
117
         --
118
         -- memory side signals
119
         --
120
    mem_rw   : in  std_logic;
121
    mem_vma  :  in  std_logic;
122
    mem_addr : in  addr_type;
123
    mem_dati : in        data_type;
124
         mem_dato : out data_type;
125
         --
126
         -- controls
127
         --
128
         halt     : in  std_logic;
129
         hold     : in  std_logic;
130
         irq      : in  std_logic;
131
         nmi      : in  std_logic;
132
         firq     : in  std_logic
133
    );
134
end component;
135
 
136
 
137
begin
138
  -----------------------------------------------------------------------------
139
  -- Instantiation of internal components
140
  -----------------------------------------------------------------------------
141
 
142
my_unicpu09_0 : unicpu09
143
port map (
144
         clk         => clk,
145
    rst       => rst,
146
    rw       => cpu_rw(0),
147
    vma       => cpu_vma(0),
148
    addr      => cpu_addr(0),
149
    id        => "00000000",
150
         --
151
         -- memory side signals
152
         --
153
    mem_rw    => mem_rw,
154
    mem_vma   => mem_vma,
155
    mem_addr  => mem_addr,
156
    mem_dati  => mem_dati,
157
         mem_dato  => mem_dato(0),
158
    --
159
         -- cpu controls
160
         --
161
         halt      => cpu_halt(0),
162
         hold      => cpu_hold(0),
163
         irq       => cpu_irq(0),
164
         nmi       => cpu_nmi(0),
165
         firq      => cpu_firq(0)
166
    );
167
 
168
my_unicpu09_1 : unicpu09
169
port map (
170
         clk         => clk,
171
    rst       => rst,
172
    rw       => cpu_rw(1),
173
    vma       => cpu_vma(1),
174
    addr      => cpu_addr(1),
175
    id        => "00010000",
176
         --
177
         -- memory side signals
178
         --
179
    mem_rw    => mem_rw,
180
    mem_vma   => mem_vma,
181
    mem_addr  => mem_addr,
182
    mem_dati  => mem_dati,
183
         mem_dato  => mem_dato(1),
184
    --
185
         -- cpu controls
186
         --
187
         halt      => cpu_halt(1),
188
         hold      => cpu_hold(1),
189
         irq       => cpu_irq(1),
190
         nmi       => cpu_nmi(1),
191
         firq      => cpu_firq(1)
192
    );
193
 
194
my_unicpu09_2 : unicpu09
195
port map (
196
         clk         => clk,
197
    rst       => rst,
198
    rw       => cpu_rw(2),
199
    vma       => cpu_vma(2),
200
    addr      => cpu_addr(2),
201
    id        => "00100000"
202
         --
203
         -- memory side signals
204
         --
205
    mem_rw    => mem_rw,
206
    mem_vma   => mem_vma,
207
    mem_addr  => mem_addr,
208
    mem_dati  => mem_dati,
209
         mem_dato  => mem_dato(2),
210
    --
211
         -- cpu controls
212
         --
213
         halt      => cpu_halt(2),
214
         hold      => cpu_hold(2),
215
         irq       => cpu_irq(2),
216
         nmi       => cpu_nmi(2),
217
         firq      => cpu_firq(2)
218
    );
219
 
220
my_unicpu09_3 : unicpu09
221
port map (
222
         clk         => clk,
223
    rst       => rst,
224
    rw       => cpu_rw(3),
225
    vma       => cpu_vma(3),
226
    addr      => cpu_addr(3),
227
    id        => "00110000",
228
         --
229
         -- memory side signals
230
         --
231
    mem_rw    => mem_rw,
232
    mem_vma   => mem_vma,
233
    mem_addr  => mem_addr,
234
    mem_dati  => mem_dati,
235
         mem_dato  => mem_dato(3),
236
    --
237
         -- cpu controls
238
         --
239
         halt      => cpu_halt(3),
240
         hold      => cpu_hold(3),
241
         irq       => cpu_irq(3),
242
         nmi       => cpu_nmi(3),
243
         firq      => cpu_firq(3)
244
    );
245
 
246
--
247
-- Rotating priority
248
--
249
my_pri_rotate : process( rst, clk )
250
variable cpu_count : integer := 0;
251
begin
252
  if rst = '1' then
253
    pri_cnt <= (others=>0);
254
  if falling_edge(clk) then
255
    if pri_rot = '1' then
256
      pri_cnt <= pri_cnt + 1;
257
    end if;
258
  end if;
259
end process;
260
 
261
--
262
-- Rotate VMA request
263
--
264
my_pri_mux : process( pri_cnt )
265
begin
266
  case pri_cnt is
267
  when "00" =>
268
    pri_mux <= cpu_vma(3 downto 0);
269
  when "01" =>
270
    pri_mux <= cpu_vma(2 downto 0) & cpu_vma(3);
271
  when "10" =>
272
    pri_mux <= cpu_vma(1 downto 0) & cpu_vma(3 downto 2);
273
  when "11" =>
274
    pri_mux <= cpu_vma(0)          & cpu_vma(3 downto 1);
275
  when other =>
276
    null;
277
  end case;
278
end process;
279
 
280
--
281
-- Priority Encode Rotated VMA Request
282
--
283
my_pri_encoder : process( pri_mux )
284
variable enc_bits : integer := 0;
285
variable cpu_bits : integer := 0;
286
begin
287
    for cpu_bits in 0 to (CPU_MAX-1) loop
288
      pri_req := pri_req or pri_mux(cpu_bits);
289
    end loop;
290
 
291
    for enc_bits in 0 to log2(CPU_MAX)-1 loop
292
           pri_enc(enc_bits) <= '0';
293
      for cpu_bits in 0 to (CPU_MAX-1) loop
294
                  if (cpu_bits and pow2(enc_bits)) /= 0 then
295
               pri_enc(enc_bits) <= pri_enc(enc_bits) or pri_mux(cpu_bits);
296
        end if;
297
      end loop;
298
         end loop;
299
end process;
300
 
301
--
302
-- Grant highest priority requesting processor access to the bus
303
--
304
my_bus_grant : process( rst, clk )
305
begin
306
 
307
end process;
308
 
309
--
310
-- Hold processor until bus cycle acknowledged
311
--
312
my_hold_machine : process( rst, clk )
313
variable cpu_bits : integer := 0;
314
begin
315
  for cpu_bits in 0 to (CPU_MAX-1) loop
316
    if rst = '1' then
317
           cpu_hold( cpu_bits ) <= '0';
318
    elsif rising_edge( clk ) then
319
      cpu_hold( cpu_bits ) <= cpu_vma( cpu_bits ) and (not cpu_ack( cpu_bits ));
320
    end if;
321
  end loop;
322
end process;
323
 
324
end architecture;

powered by: WebSVN 2.1.0

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