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

Subversion Repositories risc5x

[/] [risc5x/] [trunk/] [risc5x_xil.vhd] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 mikej
--
2
-- Risc5x
3
-- www.OpenCores.Org - November 2001
4
--
5
--
6
-- This library is free software; you can distribute it and/or modify it
7
-- under the terms of the GNU Lesser General Public License as published
8
-- by the Free Software Foundation; either version 2.1 of the License, or
9
-- (at your option) any later version.
10
--
11
-- This library is distributed in the hope that it will be useful, but
12
-- WITHOUT ANY WARRANTY; without even the implied warranty of
13
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
-- See the GNU Lesser General Public License for more details.
15
--
16
-- A RISC CPU core.
17
--
18
-- (c) Mike Johnson 2001. All Rights Reserved.
19
-- mikej@opencores.org for support or any other issues.
20
--
21
-- Revision list
22
--
23
-- version 1.0 initial opencores release
24
--
25
 
26
-- Top level design for a Xilinx FPGA with a CPU core and some program block ram.
27
 
28
use work.pkg_risc5x.all;
29
use work.pkg_xilinx_prims.all;
30
library ieee;
31
  use ieee.std_logic_1164.all;
32
  use ieee.std_logic_arith.all;
33
  use ieee.std_logic_unsigned.all;
34
 
35
entity RISC5X_XIL is
36
  port (
37
    I_PRAM_ADDR       : in  std_logic_vector(10 downto 0);
38
    I_PRAM_DIN        : in  std_logic_vector(11 downto 0);
39
    O_PRAM_DOUT       : out std_logic_vector(11 downto 0);
40
    I_PRAM_WE         : in  std_logic;
41
    I_PRAM_ENA        : in  std_logic;
42
    PRAM_CLK          : in  std_logic;
43
    --
44
    IO_PORTA_IO       : inout std_logic_vector(7 downto 0);
45
    IO_PORTB_IO       : inout std_logic_vector(7 downto 0);
46
    IO_PORTC_IO       : inout std_logic_vector(7 downto 0);
47
 
48
    O_DEBUG_W         : out std_logic_vector(7 downto 0);
49
    O_DEBUG_PC        : out std_logic_vector(10 downto 0);
50
    O_DEBUG_INST      : out std_logic_vector(11 downto 0);
51
    O_DEBUG_STATUS    : out std_logic_vector(7 downto 0);
52
 
53
    RESET             : in  std_logic;
54
    CLK               : in  std_logic
55
    );
56
end;
57
 
58
architecture RTL of RISC5X_XIL is
59
  signal porta_in        : std_logic_vector(7 downto 0);
60
  signal porta_out       : std_logic_vector(7 downto 0);
61
  signal porta_oe_l      : std_logic_vector(7 downto 0);
62
 
63
  signal portb_in        : std_logic_vector(7 downto 0);
64
  signal portb_out       : std_logic_vector(7 downto 0);
65
  signal portb_oe_l      : std_logic_vector(7 downto 0);
66
 
67
  signal portc_in        : std_logic_vector(7 downto 0);
68
  signal portc_out       : std_logic_vector(7 downto 0);
69
  signal portc_oe_l      : std_logic_vector(7 downto 0);
70
 
71
  signal paddr           : std_logic_vector(10 downto 0);
72
  signal pdata           : std_logic_vector(11 downto 0);
73
  signal pram_addr       : std_logic_vector(10 downto 0);
74
  signal pram_din        : std_logic_vector(11 downto 0);
75
  signal pram_dout       : std_logic_vector(11 downto 0);
76
  signal pram_we         : std_logic;
77
  signal pram_ena        : std_logic;
78
 
79
  signal debug_w         : std_logic_vector(7 downto 0);
80
  signal debug_pc        : std_logic_vector(10 downto 0);
81
  signal debug_inst      : std_logic_vector(11 downto 0);
82
  signal debug_status    : std_logic_vector(7 downto 0);
83
 
84
  signal doa_temp        : std_logic_vector(11 downto 0);
85
  signal dob_temp        : std_logic_vector(11 downto 0);
86
 
87
  component CPU is
88
    port (
89
      PADDR           : out std_logic_vector(10 downto 0);
90
      PDATA           : in  std_logic_vector(11 downto 0);
91
 
92
      PORTA_IN        : in    std_logic_vector(7 downto 0);
93
      PORTA_OUT       : out   std_logic_vector(7 downto 0);
94
      PORTA_OE_L      : out   std_logic_vector(7 downto 0);
95
 
96
      PORTB_IN        : in    std_logic_vector(7 downto 0);
97
      PORTB_OUT       : out   std_logic_vector(7 downto 0);
98
      PORTB_OE_L      : out   std_logic_vector(7 downto 0);
99
 
100
      PORTC_IN        : in    std_logic_vector(7 downto 0);
101
      PORTC_OUT       : out   std_logic_vector(7 downto 0);
102
      PORTC_OE_L      : out   std_logic_vector(7 downto 0);
103
 
104
      DEBUG_W         : out std_logic_vector(7 downto 0);
105
      DEBUG_PC        : out std_logic_vector(10 downto 0);
106
      DEBUG_INST      : out std_logic_vector(11 downto 0);
107
      DEBUG_STATUS    : out std_logic_vector(7 downto 0);
108
 
109
      RESET           : in  std_logic;
110
      CLK             : in  std_logic
111
      );
112
  end component;
113
 
114
begin
115
  u0 : CPU
116
    port map (
117
      PADDR           => paddr,
118
      PDATA           => pdata,
119
 
120
      PORTA_IN        => porta_in,
121
      PORTA_OUT       => porta_out,
122
      PORTA_OE_L      => porta_oe_l,
123
 
124
      PORTB_IN        => portb_in,
125
      PORTB_OUT       => portb_out,
126
      PORTB_OE_L      => portb_oe_l,
127
 
128
      PORTC_IN        => portc_in,
129
      PORTC_OUT       => portc_out,
130
      PORTC_OE_L      => portc_oe_l,
131
 
132
     -- DEBUG_W         => debug_w,
133
     -- DEBUG_PC        => debug_pc,
134
     -- DEBUG_INST      => debug_inst,
135
     -- DEBUG_STATUS    => debug_status,
136
 
137
      RESET           => RESET,
138
      CLK             => CLK
139
      );
140
 
141
  p_drive_ports_out_comb : process(porta_out,porta_oe_l,portb_out,portb_oe_l,portc_out,portc_oe_l)
142
  begin
143
    for i in 0 to 7 loop
144
      if (porta_oe_l(i) = '0') then
145
        IO_PORTA_IO(i) <= porta_out(i);
146
      else
147
        IO_PORTA_IO(i) <= 'Z';
148
      end if;
149
 
150
      if (portb_oe_l(i) = '0') then
151
        IO_PORTB_IO(i) <= portb_out(i);
152
      else
153
        IO_PORTB_IO(i) <= 'Z';
154
      end if;
155
 
156
      if (portc_oe_l(i) = '0') then
157
        IO_PORTC_IO(i) <= portc_out(i);
158
      else
159
        IO_PORTC_IO(i) <= 'Z';
160
      end if;
161
    end loop;
162
  end process;
163
 
164
  p_drive_ports_in_comb : process(IO_PORTA_IO,IO_PORTB_IO,IO_PORTC_IO)
165
  begin
166
    porta_in <= IO_PORTA_IO;
167
    portb_in <= IO_PORTB_IO;
168
    portc_in <= IO_PORTC_IO;
169
  end process;
170
 
171
  prams : for i in 0 to 5 generate
172
    attribute INIT_00 of inst : label is "0000000000000000000000000000000000000000000000000000000000000000";
173
    attribute INIT_01 of inst : label is "0000000000000000000000000000000000000000000000000000000000000000";
174
    attribute INIT_02 of inst : label is "0000000000000000000000000000000000000000000000000000000000000000";
175
    attribute INIT_03 of inst : label is "0000000000000000000000000000000000000000000000000000000000000000";
176
    attribute INIT_04 of inst : label is "0000000000000000000000000000000000000000000000000000000000000000";
177
    attribute INIT_05 of inst : label is "0000000000000000000000000000000000000000000000000000000000000000";
178
    attribute INIT_06 of inst : label is "0000000000000000000000000000000000000000000000000000000000000000";
179
    attribute INIT_07 of inst : label is "0000000000000000000000000000000000000000000000000000000000000000";
180
    attribute INIT_08 of inst : label is "0000000000000000000000000000000000000000000000000000000000000000";
181
    attribute INIT_09 of inst : label is "0000000000000000000000000000000000000000000000000000000000000000";
182
    attribute INIT_0A of inst : label is "0000000000000000000000000000000000000000000000000000000000000000";
183
    attribute INIT_0B of inst : label is "0000000000000000000000000000000000000000000000000000000000000000";
184
    attribute INIT_0C of inst : label is "0000000000000000000000000000000000000000000000000000000000000000";
185
    attribute INIT_0D of inst : label is "0000000000000000000000000000000000000000000000000000000000000000";
186
    attribute INIT_0E of inst : label is "0000000000000000000000000000000000000000000000000000000000000000";
187
    attribute INIT_0F of inst : label is "0000000000000000000000000000000000000000000000000000000000000000";
188
  begin
189
  inst : ramb4_s2_s2
190
    port map (
191
      dob   => pdata(i*2 +1 downto i*2),
192
      dib   => "00",
193
      addrb => paddr,
194
      web   => '0',
195
      enb   => '1',
196
      rstb  => '0',
197
      clkb  => CLK,
198
 
199
      doa   => pram_dout(i*2 +1 downto i*2),
200
      dia   => pram_din(i*2 +1 downto i*2),
201
      addra => pram_addr,
202
      wea   => pram_we,
203
      ena   => pram_ena,
204
      rsta  => '0',
205
      clka  => PRAM_CLK
206
      );
207
  end generate;
208
 
209
  --p_debug : process
210
  --begin
211
  --  wait until CLK'event and (CLK = '1');
212
  --  O_DEBUG_W         <= debug_w;
213
  --  O_DEBUG_PC        <= debug_pc;
214
  --  O_DEBUG_INST      <= debug_inst;
215
  --  O_DEBUG_STATUS    <= debug_status;
216
  --end process;
217
 
218
  p_pram : process
219
  begin
220
    wait until PRAM_CLK'event and (PRAM_CLK = '1');
221
    pram_addr   <= I_PRAM_ADDR;
222
    pram_din    <= I_PRAM_DIN;
223
    O_PRAM_DOUT <= pram_dout;
224
    pram_we     <= I_PRAM_WE;
225
    pram_ena    <= I_PRAM_ENA;
226
  end process;
227
end RTL;
228
 

powered by: WebSVN 2.1.0

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