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

Subversion Repositories cpu_lecture

[/] [cpu_lecture/] [trunk/] [html/] [21_Listing_of_prog_mem.vhd.html] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jsauermann
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2
"http://www.w3.org/TR/html4/strict.dtd">
3
<HTML>
4
<HEAD>
5
<TITLE>html/Listing_of_prog_mem.vhd</TITLE>
6
<META NAME="generator" CONTENT="HTML::TextToHTML v2.46">
7
<LINK REL="stylesheet" TYPE="text/css" HREF="lecture.css">
8
</HEAD>
9
<BODY>
10
<P><table class="ttop"><th class="tpre"><a href="20_Listing_of_prog_mem_content.vhd.html">Previous Lesson</a></th><th class="ttop"><a href="toc.html">Table of Content</a></th><th class="tnxt"><a href="22_Listing_of_reg_16.vhd.html">Next Lesson</a></th></table>
11
<hr>
12
 
13
<H1><A NAME="section_1">21 LISTING OF prog_mem.vhd</A></H1>
14
 
15
<pre class="vhdl">
16
 
17
  1     -------------------------------------------------------------------------------
18
  2     --
19
  3     -- Copyright (C) 2009, 2010 Dr. Juergen Sauermann
20
  4     --
21
  5     --  This code is free software: you can redistribute it and/or modify
22
  6     --  it under the terms of the GNU General Public License as published by
23
  7     --  the Free Software Foundation, either version 3 of the License, or
24
  8     --  (at your option) any later version.
25
  9     --
26
 10     --  This code is distributed in the hope that it will be useful,
27
 11     --  but WITHOUT ANY WARRANTY; without even the implied warranty of
28
 12     --  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29
 13     --  GNU General Public License for more details.
30
 14     --
31
 15     --  You should have received a copy of the GNU General Public License
32
 16     --  along with this code (see the file named COPYING).
33
 17     --  If not, see http://www.gnu.org/licenses/.
34
 18     --
35
 19     -------------------------------------------------------------------------------
36
 20     -------------------------------------------------------------------------------
37
 21     --
38
 22     -- Module Name:    prog_mem - Behavioral
39
 23     -- Create Date:    14:09:04 10/30/2009
40
 24     -- Description:    the program memory of a CPU.
41
 25     --
42
 26     ----------------------------------------------------------------------------------
43
 27     library IEEE;
44
 28     use IEEE.STD_LOGIC_1164.ALL;
45
 29     use IEEE.STD_LOGIC_ARITH.ALL;
46
 30     use IEEE.STD_LOGIC_UNSIGNED.ALL;
47
 31
48
 32     -- the content of the program memory.
49
 33     --
50
 34     use work.prog_mem_content.all;
51
 35
52
 36     entity prog_mem is
53
 37         port (  I_CLK       : in  std_logic;
54
 38
55
 39                 I_WAIT      : in  std_logic;
56
 40                 I_PC        : in  std_logic_vector(15 downto 0); -- word address
57
 41                 I_PM_ADR    : in  std_logic_vector(11 downto 0); -- byte address
58
 42
59
 43                 Q_OPC       : out std_logic_vector(31 downto 0);
60
 44                 Q_PC        : out std_logic_vector(15 downto 0);
61
 45                 Q_PM_DOUT   : out std_logic_vector( 7 downto 0));
62
 46     end prog_mem;
63
 47
64
 48     architecture Behavioral of prog_mem is
65
 49
66
 50     constant zero_256 : bit_vector := X"00000000000000000000000000000000"
67
 51                                     & X"00000000000000000000000000000000";
68
 52
69
 53     component RAMB4_S4_S4
70
 54         generic(INIT_00 : bit_vector := zero_256;
71
 55                 INIT_01 : bit_vector := zero_256;
72
 56                 INIT_02 : bit_vector := zero_256;
73
 57                 INIT_03 : bit_vector := zero_256;
74
 58                 INIT_04 : bit_vector := zero_256;
75
 59                 INIT_05 : bit_vector := zero_256;
76
 60                 INIT_06 : bit_vector := zero_256;
77
 61                 INIT_07 : bit_vector := zero_256;
78
 62                 INIT_08 : bit_vector := zero_256;
79
 63                 INIT_09 : bit_vector := zero_256;
80
 64                 INIT_0A : bit_vector := zero_256;
81
 65                 INIT_0B : bit_vector := zero_256;
82
 66                 INIT_0C : bit_vector := zero_256;
83
 67                 INIT_0D : bit_vector := zero_256;
84
 68                 INIT_0E : bit_vector := zero_256;
85
 69                 INIT_0F : bit_vector := zero_256);
86
 70
87
 71         port(   ADDRA   : in  std_logic_vector(9 downto 0);
88
 72                 ADDRB   : in  std_logic_vector(9 downto 0);
89
 73                 CLKA    : in  std_ulogic;
90
 74                 CLKB    : in  std_ulogic;
91
 75                 DIA     : in  std_logic_vector(3 downto 0);
92
 76                 DIB     : in  std_logic_vector(3 downto 0);
93
 77                 ENA     : in  std_ulogic;
94
 78                 ENB     : in  std_ulogic;
95
 79                 RSTA    : in  std_ulogic;
96
 80                 RSTB    : in  std_ulogic;
97
 81                 WEA     : in  std_ulogic;
98
 82                 WEB     : in  std_ulogic;
99
 83
100
 84                 DOA     : out std_logic_vector(3 downto 0);
101
 85                 DOB     : out std_logic_vector(3 downto 0));
102
 86     end component;
103
 87
104
 88     signal M_OPC_E      : std_logic_vector(15 downto 0);
105
 89     signal M_OPC_O      : std_logic_vector(15 downto 0);
106
 90     signal M_PMD_E      : std_logic_vector(15 downto 0);
107
 91     signal M_PMD_O      : std_logic_vector(15 downto 0);
108
 92
109
 93     signal L_WAIT_N     : std_logic;
110
 94     signal L_PC_0       : std_logic;
111
 95     signal L_PC_E       : std_logic_vector(10 downto 1);
112
 96     signal L_PC_O       : std_logic_vector(10 downto 1);
113
 97     signal L_PMD        : std_logic_vector(15 downto 0);
114
 98     signal L_PM_ADR_1_0 : std_logic_vector( 1 downto 0);
115
 99
116
100     begin
117
101
118
102         pe_0 : RAMB4_S4_S4 ---------------------------------------------------------
119
103         generic map(INIT_00 => pe_0_00, INIT_01 => pe_0_01, INIT_02 => pe_0_02,
120
104                     INIT_03 => pe_0_03, INIT_04 => pe_0_04, INIT_05 => pe_0_05,
121
105                     INIT_06 => pe_0_06, INIT_07 => pe_0_07, INIT_08 => pe_0_08,
122
106                     INIT_09 => pe_0_09, INIT_0A => pe_0_0A, INIT_0B => pe_0_0B,
123
107                     INIT_0C => pe_0_0C, INIT_0D => pe_0_0D, INIT_0E => pe_0_0E,
124
108                     INIT_0F => pe_0_0F)
125
109         port map(ADDRA => L_PC_E,                   ADDRB => I_PM_ADR(11 downto 2),
126
110                  CLKA  => I_CLK,                    CLKB  => I_CLK,
127
111                  DIA   => "0000",                   DIB   => "0000",
128
112                  ENA   => L_WAIT_N,                 ENB   => '1',
129
113                  RSTA  => '0',                      RSTB  => '0',
130
114                  WEA   => '0',                      WEB   => '0',
131
115                  DOA   => M_OPC_E(3 downto 0),      DOB   => M_PMD_E(3 downto 0));
132
116
133
117         pe_1 : RAMB4_S4_S4 ---------------------------------------------------------
134
118         generic map(INIT_00 => pe_1_00, INIT_01 => pe_1_01, INIT_02 => pe_1_02,
135
119                     INIT_03 => pe_1_03, INIT_04 => pe_1_04, INIT_05 => pe_1_05,
136
120                     INIT_06 => pe_1_06, INIT_07 => pe_1_07, INIT_08 => pe_1_08,
137
121                     INIT_09 => pe_1_09, INIT_0A => pe_1_0A, INIT_0B => pe_1_0B,
138
122                     INIT_0C => pe_1_0C, INIT_0D => pe_1_0D, INIT_0E => pe_1_0E,
139
123                     INIT_0F => pe_1_0F)
140
124         port map(ADDRA => L_PC_E,                   ADDRB => I_PM_ADR(11 downto 2),
141
125                  CLKA  => I_CLK,                    CLKB  => I_CLK,
142
126                  DIA   => "0000",                   DIB   => "0000",
143
127                  ENA   => L_WAIT_N,                 ENB   => '1',
144
128                  RSTA  => '0',                      RSTB  => '0',
145
129                  WEA   => '0',                      WEB   => '0',
146
130                  DOA   => M_OPC_E(7 downto 4),      DOB   => M_PMD_E(7 downto 4));
147
131
148
132         pe_2 : RAMB4_S4_S4 ---------------------------------------------------------
149
133         generic map(INIT_00 => pe_2_00, INIT_01 => pe_2_01, INIT_02 => pe_2_02,
150
134                     INIT_03 => pe_2_03, INIT_04 => pe_2_04, INIT_05 => pe_2_05,
151
135                     INIT_06 => pe_2_06, INIT_07 => pe_2_07, INIT_08 => pe_2_08,
152
136                     INIT_09 => pe_2_09, INIT_0A => pe_2_0A, INIT_0B => pe_2_0B,
153
137                     INIT_0C => pe_2_0C, INIT_0D => pe_2_0D, INIT_0E => pe_2_0E,
154
138                     INIT_0F => pe_2_0F)
155
139         port map(ADDRA => L_PC_E,                   ADDRB => I_PM_ADR(11 downto 2),
156
140                  CLKA  => I_CLK,                    CLKB  => I_CLK,
157
141                  DIA   => "0000",                   DIB   => "0000",
158
142                  ENA   => L_WAIT_N,                 ENB   => '1',
159
143                  RSTA  => '0',                      RSTB  => '0',
160
144                  WEA   => '0',                      WEB   => '0',
161
145                  DOA   => M_OPC_E(11 downto 8),     DOB   => M_PMD_E(11 downto 8));
162
146
163
147         pe_3 : RAMB4_S4_S4 ---------------------------------------------------------
164
148         generic map(INIT_00 => pe_3_00, INIT_01 => pe_3_01, INIT_02 => pe_3_02,
165
149                     INIT_03 => pe_3_03, INIT_04 => pe_3_04, INIT_05 => pe_3_05,
166
150                     INIT_06 => pe_3_06, INIT_07 => pe_3_07, INIT_08 => pe_3_08,
167
151                     INIT_09 => pe_3_09, INIT_0A => pe_3_0A, INIT_0B => pe_3_0B,
168
152                     INIT_0C => pe_3_0C, INIT_0D => pe_3_0D, INIT_0E => pe_3_0E,
169
153                     INIT_0F => pe_3_0F)
170
154         port map(ADDRA => L_PC_E,                   ADDRB => I_PM_ADR(11 downto 2),
171
155                  CLKA  => I_CLK,                    CLKB  => I_CLK,
172
156                  DIA   => "0000",                   DIB   => "0000",
173
157                  ENA   => L_WAIT_N,                 ENB   => '1',
174
158                  RSTA  => '0',                      RSTB  => '0',
175
159                  WEA   => '0',                      WEB   => '0',
176
160                  DOA   => M_OPC_E(15 downto 12),    DOB   => M_PMD_E(15 downto 12));
177
161
178
162         po_0 : RAMB4_S4_S4 ---------------------------------------------------------
179
163         generic map(INIT_00 => po_0_00, INIT_01 => po_0_01, INIT_02 => po_0_02,
180
164                     INIT_03 => po_0_03, INIT_04 => po_0_04, INIT_05 => po_0_05,
181
165                     INIT_06 => po_0_06, INIT_07 => po_0_07, INIT_08 => po_0_08,
182
166                     INIT_09 => po_0_09, INIT_0A => po_0_0A, INIT_0B => po_0_0B,
183
167                     INIT_0C => po_0_0C, INIT_0D => po_0_0D, INIT_0E => po_0_0E,
184
168                     INIT_0F => po_0_0F)
185
169         port map(ADDRA => L_PC_O,                   ADDRB => I_PM_ADR(11 downto 2),
186
170                  CLKA  => I_CLK,                    CLKB  => I_CLK,
187
171                  DIA   => "0000",                   DIB   => "0000",
188
172                  ENA   => L_WAIT_N,                 ENB   => '1',
189
173                  RSTA  => '0',                      RSTB  => '0',
190
174                  WEA   => '0',                      WEB   => '0',
191
175                  DOA   => M_OPC_O(3 downto 0),      DOB   => M_PMD_O(3 downto 0));
192
176
193
177         po_1 : RAMB4_S4_S4 ---------------------------------------------------------
194
178         generic map(INIT_00 => po_1_00, INIT_01 => po_1_01, INIT_02 => po_1_02,
195
179                     INIT_03 => po_1_03, INIT_04 => po_1_04, INIT_05 => po_1_05,
196
180                     INIT_06 => po_1_06, INIT_07 => po_1_07, INIT_08 => po_1_08,
197
181                     INIT_09 => po_1_09, INIT_0A => po_1_0A, INIT_0B => po_1_0B,
198
182                     INIT_0C => po_1_0C, INIT_0D => po_1_0D, INIT_0E => po_1_0E,
199
183                     INIT_0F => po_1_0F)
200
184         port map(ADDRA => L_PC_O,                   ADDRB => I_PM_ADR(11 downto 2),
201
185                  CLKA  => I_CLK,                    CLKB  => I_CLK,
202
186                  DIA   => "0000",                   DIB   => "0000",
203
187                  ENA   => L_WAIT_N,                 ENB   => '1',
204
188                  RSTA  => '0',                      RSTB  => '0',
205
189                  WEA   => '0',                      WEB   => '0',
206
190                  DOA   => M_OPC_O(7 downto 4),      DOB   => M_PMD_O(7 downto 4));
207
191
208
192         po_2 : RAMB4_S4_S4 ---------------------------------------------------------
209
193         generic map(INIT_00 => po_2_00, INIT_01 => po_2_01, INIT_02 => po_2_02,
210
194                     INIT_03 => po_2_03, INIT_04 => po_2_04, INIT_05 => po_2_05,
211
195                     INIT_06 => po_2_06, INIT_07 => po_2_07, INIT_08 => po_2_08,
212
196                     INIT_09 => po_2_09, INIT_0A => po_2_0A, INIT_0B => po_2_0B,
213
197                     INIT_0C => po_2_0C, INIT_0D => po_2_0D, INIT_0E => po_2_0E,
214
198                     INIT_0F => po_2_0F)
215
199         port map(ADDRA => L_PC_O,                   ADDRB => I_PM_ADR(11 downto 2),
216
200                  CLKA  => I_CLK,                    CLKB  => I_CLK,
217
201                  DIA   => "0000",                   DIB   => "0000",
218
202                  ENA   => L_WAIT_N,                 ENB   => '1',
219
203                  RSTA  => '0',                      RSTB  => '0',
220
204                  WEA   => '0',                      WEB   => '0',
221
205                  DOA   => M_OPC_O(11 downto 8),     DOB   => M_PMD_O(11 downto 8));
222
206
223
207         po_3 : RAMB4_S4_S4 ---------------------------------------------------------
224
208         generic map(INIT_00 => po_3_00, INIT_01 => po_3_01, INIT_02 => po_3_02,
225
209                     INIT_03 => po_3_03, INIT_04 => po_3_04, INIT_05 => po_3_05,
226
210                     INIT_06 => po_3_06, INIT_07 => po_3_07, INIT_08 => po_3_08,
227
211                     INIT_09 => po_3_09, INIT_0A => po_3_0A, INIT_0B => po_3_0B,
228
212                     INIT_0C => po_3_0C, INIT_0D => po_3_0D, INIT_0E => po_3_0E,
229
213                     INIT_0F => po_3_0F)
230
214         port map(ADDRA => L_PC_O,                   ADDRB => I_PM_ADR(11 downto 2),
231
215                  CLKA  => I_CLK,                    CLKB  => I_CLK,
232
216                  DIA   => "0000",                   DIB   => "0000",
233
217                  ENA   => L_WAIT_N,                 ENB   => '1',
234
218                  RSTA  => '0',                      RSTB  => '0',
235
219                  WEA   => '0',                      WEB   => '0',
236
220                  DOA   => M_OPC_O(15 downto 12),    DOB   => M_PMD_O(15 downto 12));
237
221
238
222         -- remember I_PC0 and I_PM_ADR for the output mux.
239
223         --
240
224         pc0: process(I_CLK)
241
225         begin
242
226             if (rising_edge(I_CLK)) then
243
227                 Q_PC <= I_PC;
244
228                 L_PM_ADR_1_0 <= I_PM_ADR(1 downto 0);
245
229                 if ((I_WAIT = '0')) then
246
230                     L_PC_0 <= I_PC(0);
247
231                 end if;
248
232             end if;
249
233         end process;
250
234
251
235         L_WAIT_N <= not I_WAIT;
252
236
253
237         -- we use two memory blocks _E and _O (even and odd).
254
238         -- This gives us a quad-port memory so that we can access
255
239         -- I_PC, I_PC + 1, and PM simultaneously.
256
240         --
257
241         -- I_PC and I_PC + 1 are handled by port A of the memory while PM
258
242         -- is handled by port B.
259
243         --
260
244         -- Q_OPC(15 ... 0) shall contain the word addressed by I_PC, while
261
245         -- Q_OPC(31 ... 16) shall contain the word addressed by I_PC + 1.
262
246         --
263
247         -- There are two cases:
264
248         --
265
249         -- case A: I_PC     is even, thus I_PC + 1 is odd
266
250         -- case B: I_PC + 1 is odd , thus I_PC is even
267
251         --
268
252         L_PC_O <= I_PC(10 downto 1);
269
253         L_PC_E <= I_PC(10 downto 1) + ("000000000" & I_PC(0));
270
254         Q_OPC(15 downto  0) <= M_OPC_E when L_PC_0 = '0' else M_OPC_O;
271
255         Q_OPC(31 downto 16) <= M_OPC_E when L_PC_0 = '1' else M_OPC_O;
272
256
273
257         L_PMD <= M_PMD_E               when (L_PM_ADR_1_0(1) = '0') else M_PMD_O;
274
258         Q_PM_DOUT <= L_PMD(7 downto 0) when (L_PM_ADR_1_0(0) = '0')
275
259                 else L_PMD(15 downto 8);
276
260
277
261     end Behavioral;
278
262
279
<pre class="filename">
280
src/prog_mem.vhd
281
</pre></pre>
282
<P>
283
 
284
<P><hr><BR>
285
<table class="ttop"><th class="tpre"><a href="20_Listing_of_prog_mem_content.vhd.html">Previous Lesson</a></th><th class="ttop"><a href="toc.html">Table of Content</a></th><th class="tnxt"><a href="22_Listing_of_reg_16.vhd.html">Next Lesson</a></th></table>
286
</BODY>
287
</HTML>

powered by: WebSVN 2.1.0

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