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

Subversion Repositories xucpu

[/] [xucpu/] [trunk/] [VHDL/] [uCtrl/] [ROM1.vhdl] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 lcdsgmtr
-- Copyright 2015, Jürgen Defurne
2
--
3
-- This file is part of the Experimental Unstable CPU System.
4
--
5
-- The Experimental Unstable CPU System Is free software: you can redistribute
6
-- it and/or modify it under the terms of the GNU Lesser General Public License
7
-- as published by the Free Software Foundation, either version 3 of the
8
-- License, or (at your option) any later version.
9
--
10
-- The Experimental Unstable CPU System is distributed in the hope that it will
11
-- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
12
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
13
-- General Public License for more details.
14
--
15
-- You should have received a copy of the GNU Lesser General Public License
16
-- along with Experimental Unstable CPU System. If not, see
17
-- http://www.gnu.org/licenses/lgpl.txt.
18
 
19
 
20
LIBRARY ieee;
21
USE ieee.std_logic_1164.ALL;
22
USE ieee.numeric_std.ALL;
23
 
24
PACKAGE rom_parts IS
25
 
26
  COMPONENT rom_in_pr IS
27
 
28
    GENERIC (
29
      w_data : NATURAL RANGE 1 TO 48 := 16;
30
      w_addr : NATURAL RANGE 6 TO 14 := 10);
31
    PORT (
32
      clk : IN  STD_LOGIC;
33
      a1  : IN  STD_LOGIC_VECTOR(w_addr - 1 DOWNTO 0);   -- ROM address
34
      q1  : OUT STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0));  -- ROM output
35
 
36
  END COMPONENT rom_in_pr;
37
 
38
  COMPONENT rom_db_pr IS
39
 
40
    GENERIC (
41
      w_data : NATURAL RANGE 1 TO 48 := 16;
42
      w_addr : NATURAL RANGE 6 TO 14 := 10);
43
    PORT (
44
      clk : IN  STD_LOGIC;
45
      a1  : IN  STD_LOGIC_VECTOR(w_addr - 1 DOWNTO 0);   -- ROM address
46
      q1  : OUT STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0));  -- ROM output
47
 
48
  END COMPONENT rom_db_pr;
49
 
50
  COMPONENT rom_out_pr IS
51
 
52
    GENERIC (
53
      w_data : NATURAL RANGE 1 TO 48 := 16;
54
      w_addr : NATURAL RANGE 6 TO 14 := 10);
55
    PORT (
56
      clk : IN  STD_LOGIC;
57
      a1  : IN  STD_LOGIC_VECTOR(w_addr - 1 DOWNTO 0);   -- ROM address
58
      q1  : OUT STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0));  -- ROM output
59
 
60
  END COMPONENT rom_out_pr;
61
 
62
END PACKAGE rom_parts;
63
 
64
-------------------------------------------------------------------------------
65
 
66
LIBRARY ieee;
67
USE ieee.std_logic_1164.ALL;
68
USE ieee.numeric_std.ALL;
69
 
70
ENTITY rom_in_pr IS
71
 
72
  GENERIC (
73
    w_data : NATURAL RANGE 1 TO 48 := 16;
74
    w_addr : NATURAL RANGE 6 TO 14 := 10);
75
  PORT (
76
    clk : IN  STD_LOGIC;
77
    a1  : IN  STD_LOGIC_VECTOR(w_addr - 1 DOWNTO 0);   -- ROM address
78
    q1  : OUT STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0));  -- ROM output
79
 
80
END rom_in_pr;
81
 
82
ARCHITECTURE Behavioral OF rom_in_pr IS
83
 
84
  TYPE rom_array IS ARRAY(0 TO (2**w_addr) - 1) OF STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0);
85
 
86
  SIGNAL rom : rom_array := (
87
    STD_LOGIC_VECTOR(to_unsigned(0, w_data)),
88
    STD_LOGIC_VECTOR(to_unsigned(1, w_data)),
89
    STD_LOGIC_VECTOR(to_unsigned(2, w_data)),
90
    STD_LOGIC_VECTOR(to_unsigned(4, w_data)),
91
    STD_LOGIC_VECTOR(to_unsigned(8, w_data)),
92
    STD_LOGIC_VECTOR(to_unsigned(16, w_data)),
93
    STD_LOGIC_VECTOR(to_unsigned(32, w_data)),
94
    STD_LOGIC_VECTOR(to_unsigned(64, w_data)),
95
    STD_LOGIC_VECTOR(to_unsigned(128, w_data)),
96
    STD_LOGIC_VECTOR(to_unsigned(256, w_data)),
97
    STD_LOGIC_VECTOR(to_unsigned(512, w_data)),
98
    OTHERS => STD_LOGIC_VECTOR(to_unsigned(255, w_data)));
99
 
100
  SIGNAL a1_reg : STD_LOGIC_VECTOR(w_addr - 1 DOWNTO 0);
101
 
102
BEGIN  -- Behavioral
103
 
104
  -- purpose: Try to describe a proper block ram without needing to instantiate a BRAM
105
  -- type   : sequential
106
  -- inputs : clk, a1
107
  -- outputs: q1
108
  MP1 : PROCESS (clk)
109
  BEGIN  -- PROCESS MP1
110
    IF rising_edge(clk) THEN            -- rising clock edge
111
 
112
      a1_reg <= a1;
113
 
114
    END IF;
115
  END PROCESS MP1;
116
 
117
  q1 <= rom(to_integer(UNSIGNED(a1_reg)));
118
 
119
END Behavioral;
120
 
121
-------------------------------------------------------------------------------
122
 
123
LIBRARY ieee;
124
USE ieee.std_logic_1164.ALL;
125
USE ieee.numeric_std.ALL;
126
 
127
ENTITY rom_db_pr IS
128
 
129
  GENERIC (
130
    w_data : NATURAL RANGE 1 TO 48 := 16;
131
    w_addr : NATURAL RANGE 6 TO 14 := 10);
132
  PORT (
133
    clk : IN  STD_LOGIC;
134
    a1  : IN  STD_LOGIC_VECTOR(w_addr - 1 DOWNTO 0);   -- ROM address
135
    q1  : OUT STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0));  -- ROM output
136
 
137
END rom_db_pr;
138
 
139
ARCHITECTURE Behavioral OF rom_db_pr IS
140
 
141
  TYPE rom_array IS ARRAY(0 TO (2**w_addr) - 1) OF STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0);
142
 
143
  SIGNAL rom : rom_array := (
144
    STD_LOGIC_VECTOR(to_unsigned(0, w_data)),
145
    STD_LOGIC_VECTOR(to_unsigned(1, w_data)),
146
    STD_LOGIC_VECTOR(to_unsigned(2, w_data)),
147
    STD_LOGIC_VECTOR(to_unsigned(4, w_data)),
148
    STD_LOGIC_VECTOR(to_unsigned(8, w_data)),
149
    STD_LOGIC_VECTOR(to_unsigned(16, w_data)),
150
    STD_LOGIC_VECTOR(to_unsigned(32, w_data)),
151
    STD_LOGIC_VECTOR(to_unsigned(64, w_data)),
152
    STD_LOGIC_VECTOR(to_unsigned(128, w_data)),
153
    STD_LOGIC_VECTOR(to_unsigned(256, w_data)),
154
    STD_LOGIC_VECTOR(to_unsigned(512, w_data)),
155
    OTHERS => STD_LOGIC_VECTOR(to_unsigned(255, w_data)));
156
 
157
  SIGNAL a1_reg : STD_LOGIC_VECTOR(w_addr - 1 DOWNTO 0);
158
  SIGNAL q1_reg : STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0);
159
 
160
BEGIN  -- Behavioral
161
 
162
  -- purpose: Try to describe a proper block ram without needing to instantiate a BRAM
163
  -- type   : sequential
164
  -- inputs : clk, a1
165
  -- outputs: q1
166
  MP1 : PROCESS (clk)
167
  BEGIN  -- PROCESS MP1
168
    IF rising_edge(clk) THEN            -- rising clock edge
169
 
170
      a1_reg <= a1;
171
      q1_reg <= rom(to_integer(UNSIGNED(a1_reg)));
172
 
173
 
174
    END IF;
175
  END PROCESS MP1;
176
 
177
  q1 <= q1_reg;
178
 
179
END Behavioral;
180
 
181
-------------------------------------------------------------------------------
182
 
183
LIBRARY ieee;
184
USE ieee.std_logic_1164.ALL;
185
USE ieee.numeric_std.ALL;
186
 
187
ENTITY rom_out_pr IS
188
 
189
  GENERIC (
190
    w_data : NATURAL RANGE 1 TO 48 := 16;
191
    w_addr : NATURAL RANGE 6 TO 14 := 10);
192
  PORT (
193
    clk : IN  STD_LOGIC;
194
    a1  : IN  STD_LOGIC_VECTOR(w_addr - 1 DOWNTO 0);   -- ROM address
195
    q1  : OUT STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0));  -- ROM output
196
 
197
END rom_out_pr;
198
 
199
ARCHITECTURE Behavioral OF rom_out_pr IS
200
 
201
  TYPE rom_array IS ARRAY(0 TO (2**w_addr) - 1) OF STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0);
202
 
203
  SIGNAL rom : rom_array := (
204
    STD_LOGIC_VECTOR(to_unsigned(0, w_data)),
205
    STD_LOGIC_VECTOR(to_unsigned(1, w_data)),
206
    STD_LOGIC_VECTOR(to_unsigned(2, w_data)),
207
    STD_LOGIC_VECTOR(to_unsigned(4, w_data)),
208
    STD_LOGIC_VECTOR(to_unsigned(8, w_data)),
209
    STD_LOGIC_VECTOR(to_unsigned(16, w_data)),
210
    STD_LOGIC_VECTOR(to_unsigned(32, w_data)),
211
    STD_LOGIC_VECTOR(to_unsigned(64, w_data)),
212
    STD_LOGIC_VECTOR(to_unsigned(128, w_data)),
213
    STD_LOGIC_VECTOR(to_unsigned(256, w_data)),
214
    STD_LOGIC_VECTOR(to_unsigned(512, w_data)),
215
    OTHERS => STD_LOGIC_VECTOR(to_unsigned(255, w_data)));
216
 
217
  SIGNAL q1_reg : STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0);
218
 
219
BEGIN  -- Behavioral
220
 
221
  -- purpose: Try to describe a proper block ram without needing to instantiate a BRAM
222
  -- type   : sequential
223
  -- inputs : clk, a1
224
  -- outputs: q1
225
  MP1 : PROCESS (clk)
226
  BEGIN  -- PROCESS MP1
227
    IF rising_edge(clk) THEN            -- rising clock edge
228
 
229
      q1_reg <= rom(to_integer(UNSIGNED(a1)));
230
 
231
    END IF;
232
  END PROCESS MP1;
233
 
234
  q1 <= q1_reg;
235
 
236
END Behavioral;

powered by: WebSVN 2.1.0

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