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

Subversion Repositories cpu_lecture

[/] [cpu_lecture/] [trunk/] [html/] [28_Listing_of_RAMB4_S4_S4.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_RAMB4_S4_S4.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="27_Listing_of_uart_tx.vhd.html">Previous Lesson</a></th><th class="ttop"><a href="toc.html">Table of Content</a></th><th class="tnxt"><a href="29_Listing_of_test_tb.vhd.html">Next Lesson</a></th></table>
11
<hr>
12
 
13
<H1><A NAME="section_1">28 LISTING OF RAMB4_S4_S4.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:    a block memory module
41
 25     --
42
 26     -------------------------------------------------------------------------------
43
 27
44
 28     library IEEE;
45
 29     use IEEE.STD_LOGIC_1164.ALL;
46
 30     use IEEE.STD_LOGIC_ARITH.ALL;
47
 31     use IEEE.STD_LOGIC_UNSIGNED.ALL;
48
 32
49
 33     entity RAMB4_S4_S4 is
50
 34         generic(INIT_00 : bit_vector := X"00000000000000000000000000000000"
51
 35                                       &  "00000000000000000000000000000000";
52
 36                 INIT_01 : bit_vector := X"00000000000000000000000000000000"
53
 37                                       & X"00000000000000000000000000000000";
54
 38                 INIT_02 : bit_vector := X"00000000000000000000000000000000"
55
 39                                       & X"00000000000000000000000000000000";
56
 40                 INIT_03 : bit_vector := X"00000000000000000000000000000000"
57
 41                                       & X"00000000000000000000000000000000";
58
 42                 INIT_04 : bit_vector := X"00000000000000000000000000000000"
59
 43                                       & X"00000000000000000000000000000000";
60
 44                 INIT_05 : bit_vector := X"00000000000000000000000000000000"
61
 45                                       & X"00000000000000000000000000000000";
62
 46                 INIT_06 : bit_vector := X"00000000000000000000000000000000"
63
 47                                       & X"00000000000000000000000000000000";
64
 48                 INIT_07 : bit_vector := X"00000000000000000000000000000000"
65
 49                                       & X"00000000000000000000000000000000";
66
 50                 INIT_08 : bit_vector := X"00000000000000000000000000000000"
67
 51                                       & X"00000000000000000000000000000000";
68
 52                 INIT_09 : bit_vector := X"00000000000000000000000000000000"
69
 53                                       & X"00000000000000000000000000000000";
70
 54                 INIT_0A : bit_vector := X"00000000000000000000000000000000"
71
 55                                       & X"00000000000000000000000000000000";
72
 56                 INIT_0B : bit_vector := X"00000000000000000000000000000000"
73
 57                                       & X"00000000000000000000000000000000";
74
 58                 INIT_0C : bit_vector := X"00000000000000000000000000000000"
75
 59                                       & X"00000000000000000000000000000000";
76
 60                 INIT_0D : bit_vector := X"00000000000000000000000000000000"
77
 61                                       & X"00000000000000000000000000000000";
78
 62                 INIT_0E : bit_vector := X"00000000000000000000000000000000"
79
 63                                       & X"00000000000000000000000000000000";
80
 64                 INIT_0F : bit_vector := X"00000000000000000000000000000000"
81
 65                                       & X"00000000000000000000000000000000");
82
 66
83
 67         port(   ADDRA   : in  std_logic_vector(9 downto 0);
84
 68                 ADDRB   : in  std_logic_vector(9 downto 0);
85
 69                 CLKA    : in  std_ulogic;
86
 70                 CLKB    : in  std_ulogic;
87
 71                 DIA     : in  std_logic_vector(3 downto 0);
88
 72                 DIB     : in  std_logic_vector(3 downto 0);
89
 73                 ENA     : in  std_ulogic;
90
 74                 ENB     : in  std_ulogic;
91
 75                 RSTA    : in  std_ulogic;
92
 76                 RSTB    : in  std_ulogic;
93
 77                 WEA     : in  std_ulogic;
94
 78                 WEB     : in  std_ulogic;
95
 79
96
 80                 DOA     : out std_logic_vector(3 downto 0);
97
 81                 DOB     : out std_logic_vector(3 downto 0));
98
 82     end RAMB4_S4_S4;
99
 83
100
 84     architecture Behavioral of RAMB4_S4_S4 is
101
 85
102
 86     function cv(A : bit) return std_logic is
103
 87     begin
104
 88        if (A = '1') then return '1';
105
 89        else              return '0';
106
 90        end if;
107
 91     end;
108
 92
109
 93     function cv1(A : std_logic) return bit is
110
 94     begin
111
 95        if (A = '1') then return '1';
112
 96        else              return '0';
113
 97        end if;
114
 98     end;
115
 99
116
100     signal DATA : bit_vector(4095 downto 0) :=
117
101         INIT_0F & INIT_0E & INIT_0D & INIT_0C & INIT_0B & INIT_0A & INIT_09 & INIT_08 &
118
102         INIT_07 & INIT_06 & INIT_05 & INIT_04 & INIT_03 & INIT_02 & INIT_01 & INIT_00;
119
103
120
104     begin
121
105
122
106         process(CLKA, CLKB)
123
107         begin
124
108             if (rising_edge(CLKA)) then
125
109                 if (ENA = '1') then
126
110                     DOA(3) <= cv(DATA(conv_integer(ADDRA & "11")));
127
111                     DOA(2) <= cv(DATA(conv_integer(ADDRA & "10")));
128
112                     DOA(1) <= cv(DATA(conv_integer(ADDRA & "01")));
129
113                     DOA(0) <= cv(DATA(conv_integer(ADDRA & "00")));
130
114                     if (WEA = '1') then
131
115                         DATA(conv_integer(ADDRA & "11")) <= cv1(DIA(3));
132
116                         DATA(conv_integer(ADDRA & "10")) <= cv1(DIA(2));
133
117                         DATA(conv_integer(ADDRA & "01")) <= cv1(DIA(1));
134
118                         DATA(conv_integer(ADDRA & "00")) <= cv1(DIA(0));
135
119                     end if;
136
120                end if;
137
121             end if;
138
122
139
123             if (rising_edge(CLKB)) then
140
124                 if (ENB = '1') then
141
125                     DOB(3) <= cv(DATA(conv_integer(ADDRB & "11")));
142
126                     DOB(2) <= cv(DATA(conv_integer(ADDRB & "10")));
143
127                     DOB(1) <= cv(DATA(conv_integer(ADDRB & "01")));
144
128                     DOB(0) <= cv(DATA(conv_integer(ADDRB & "00")));
145
129                     if (WEB = '1') then
146
130                         DATA(conv_integer(ADDRB & "11")) <= cv1(DIB(3));
147
131                         DATA(conv_integer(ADDRB & "10")) <= cv1(DIB(2));
148
132                         DATA(conv_integer(ADDRB & "01")) <= cv1(DIB(1));
149
133                         DATA(conv_integer(ADDRB & "00")) <= cv1(DIB(0));
150
134                     end if;
151
135                 end if;
152
136             end if;
153
137         end process;
154
138
155
139     end Behavioral;
156
140
157
<pre class="filename">
158
test/RAMB4_S4_S4.vhd
159
</pre></pre>
160
<P>
161
 
162
<P><hr><BR>
163
<table class="ttop"><th class="tpre"><a href="27_Listing_of_uart_tx.vhd.html">Previous Lesson</a></th><th class="ttop"><a href="toc.html">Table of Content</a></th><th class="tnxt"><a href="29_Listing_of_test_tb.vhd.html">Next Lesson</a></th></table>
164
</BODY>
165
</HTML>

powered by: WebSVN 2.1.0

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