1 |
14 |
bbeaver |
//------------------------------------------------------------------------
|
2 |
|
|
// This Verilog file was developed by Altera Corporation. It may be
|
3 |
|
|
// freely copied and/or distributed at no cost. Any persons using this
|
4 |
|
|
// file for any purpose do so at their own risk, and are responsible for
|
5 |
|
|
// the results of such use. Altera Corporation does not guarantee that
|
6 |
|
|
// this file is complete, correct, or fit for any particular purpose.
|
7 |
|
|
// NO WARRANTY OF ANY KIND IS EXPRESSED OR IMPLIED. This notice must
|
8 |
|
|
// accompany any copy of this file.
|
9 |
|
|
//
|
10 |
|
|
//------------------------------------------------------------------------
|
11 |
|
|
// Imported to Opencores directory. Date Sept 10, 2001
|
12 |
|
|
// Split related modules into separate files, as the manual splits them.
|
13 |
|
|
// Added example instantiations to the beginning of each file.
|
14 |
|
|
//
|
15 |
|
|
/* EXAMPLE INSTANTIATIONS:
|
16 |
|
|
|
17 |
|
|
lpm_inpad
|
18 |
|
|
#( 1 // lpm_width (width of input)
|
19 |
|
|
) lpm_inpad_example (
|
20 |
|
|
.pad (data_in[lpm_width-1:0]),
|
21 |
|
|
.result (data_out[lpm_width-1:0])
|
22 |
|
|
);
|
23 |
|
|
|
24 |
|
|
lpm_outpad
|
25 |
|
|
#( 1 // lpm_width (width of input)
|
26 |
|
|
) lpm_outpad_example (
|
27 |
|
|
.pad (data_out[lpm_width-1:0]),
|
28 |
|
|
.data (data_in[lpm_width-1:0])
|
29 |
|
|
);
|
30 |
|
|
|
31 |
|
|
lpm_bipad
|
32 |
|
|
#( 1 // lpm_width (width of input)
|
33 |
|
|
) lpm_bipad_example (
|
34 |
|
|
.pad (data_bi[lpm_width-1:0]),
|
35 |
|
|
.result (data_out[lpm_width-1:0]),
|
36 |
|
|
.data (data_in[lpm_width-1:0]),
|
37 |
|
|
.enable (oe_data_to_pad)
|
38 |
|
|
);
|
39 |
|
|
*/
|
40 |
|
|
|
41 |
|
|
//------------------------------------------------------------------------
|
42 |
|
|
// LPM Synthesizable Models
|
43 |
|
|
//------------------------------------------------------------------------
|
44 |
|
|
// Version 1.5 (lpm 220) Date 12/17/99
|
45 |
|
|
//
|
46 |
|
|
// Modified LPM_ADD_SUB and LPM_MULT to accomodate LPM_WIDTH = 1.
|
47 |
|
|
// Default values for LPM_WIDTH* are changed back to 1.
|
48 |
|
|
// Added LPM_HINT to LPM_DIVIDE.
|
49 |
|
|
// Rewritten LPM_FIFO_DC to output correctly.
|
50 |
|
|
// Modified LPM_FIFO to output 0s before first read, output correct
|
51 |
|
|
// values after aclr and sclr, and output LPM_NUMWORDS mod
|
52 |
|
|
// exp(2, LPM_WIDTHU) when FIFO is full.
|
53 |
|
|
//
|
54 |
|
|
//------------------------------------------------------------------------
|
55 |
|
|
// Version 1.4.1 (lpm 220) Date 10/29/99
|
56 |
|
|
//
|
57 |
|
|
// Default values for LPM_WIDTH* of LPM_ADD_SUB and LPM_MULT are changed
|
58 |
|
|
// from 1 to 2.
|
59 |
|
|
//
|
60 |
|
|
//------------------------------------------------------------------------
|
61 |
|
|
// Version 1.4 (lpm 220) Date 10/18/99
|
62 |
|
|
//
|
63 |
|
|
// Default values for each optional inputs for ALL modules are added.
|
64 |
|
|
// Some LPM_PVALUE implementations were missing, and now implemented.
|
65 |
|
|
//
|
66 |
|
|
//------------------------------------------------------------------------
|
67 |
|
|
// Version 1.3 (lpm 220) Date 06/23/99
|
68 |
|
|
//
|
69 |
|
|
// Corrected LPM_FIFO and LPM_FIFO_DC cout and empty/full flags.
|
70 |
|
|
// Implemented LPM_COUNTER cin/cout, and LPM_MODULUS is now working.
|
71 |
|
|
//
|
72 |
|
|
//------------------------------------------------------------------------
|
73 |
|
|
// Version 1.2 (lpm 220) Date 06/16/99
|
74 |
|
|
//
|
75 |
|
|
// Added LPM_RAM_DP, LPM_RAM_DQ, LPM_IO, LPM_ROM, LPM_FIFO, LPM_FIFO_DC.
|
76 |
|
|
// Parameters and ports are added/discarded according to the spec.
|
77 |
|
|
//
|
78 |
|
|
//------------------------------------------------------------------------
|
79 |
|
|
// Version 1.1 (lpm 220) Date 02/05/99
|
80 |
|
|
//
|
81 |
|
|
// Added LPM_DIVIDE module.
|
82 |
|
|
//
|
83 |
|
|
//------------------------------------------------------------------------
|
84 |
|
|
// Version 1.0 Date 07/09/97
|
85 |
|
|
//
|
86 |
|
|
//------------------------------------------------------------------------
|
87 |
|
|
// Excluded Functions:
|
88 |
|
|
//
|
89 |
|
|
// LPM_FSM and LPM_TTABLE.
|
90 |
|
|
//
|
91 |
|
|
//------------------------------------------------------------------------
|
92 |
|
|
// Assumptions:
|
93 |
|
|
//
|
94 |
|
|
// 1. LPM_SVALUE, LPM_AVALUE, LPM_MODULUS, and LPM_NUMWORDS,
|
95 |
|
|
// LPM_STRENGTH, LPM_DIRECTION, and LPM_PVALUE default value is
|
96 |
|
|
// string UNUSED.
|
97 |
|
|
//
|
98 |
|
|
//------------------------------------------------------------------------
|
99 |
|
|
// Verilog Language Issues:
|
100 |
|
|
//
|
101 |
|
|
// Two dimensional ports are not supported. Modules with two dimensional
|
102 |
|
|
// ports are implemented as one dimensional signal of (LPM_SIZE * LPM_WIDTH)
|
103 |
|
|
// bits wide.
|
104 |
|
|
//
|
105 |
|
|
//------------------------------------------------------------------------
|
106 |
|
|
// Synthesis Issues:
|
107 |
|
|
//
|
108 |
|
|
// 1. LPM_COUNTER
|
109 |
|
|
//
|
110 |
|
|
// Currently synthesis tools do not allow mixing of level and edge
|
111 |
|
|
// sensetive signals. To overcome that problem the "data" signal is
|
112 |
|
|
// removed from the clock always block of lpm_counter, however the
|
113 |
|
|
// synthesis result is accurate. For correct simulation add the "data"
|
114 |
|
|
// pin to the sensetivity list as follows:
|
115 |
|
|
//
|
116 |
|
|
// always @(posedge clock or posedge aclr or posedge aset or
|
117 |
|
|
// posedge aload or data)
|
118 |
|
|
//------------------------------------------------------------------------
|
119 |
|
|
|
120 |
|
|
module lpm_inpad ( result, pad );
|
121 |
|
|
|
122 |
|
|
// NOTE: Parameters must be declared in the same order as the Properties
|
123 |
|
|
// are specified in the Cell Specification document.
|
124 |
|
|
parameter lpm_width = 1;
|
125 |
|
|
parameter lpm_type = "lpm_inpad";
|
126 |
|
|
parameter lpm_hint = "UNUSED";
|
127 |
|
|
parameter lpm_source_version = "lpm 220 version 1.6";
|
128 |
|
|
|
129 |
|
|
input [lpm_width-1:0] pad;
|
130 |
|
|
output [lpm_width-1:0] result;
|
131 |
|
|
|
132 |
|
|
reg [lpm_width-1:0] result;
|
133 |
|
|
|
134 |
|
|
always @(pad)
|
135 |
|
|
begin
|
136 |
|
|
result = pad;
|
137 |
|
|
end
|
138 |
|
|
|
139 |
|
|
// Check for previous Parameter declaration order
|
140 |
|
|
initial if ((lpm_width === "lpm_inpad") || (lpm_type !== "lpm_inpad"))
|
141 |
|
|
begin
|
142 |
|
|
$display ("LPM 220 Version 1.6 Parameter Order changed; update instantiation");
|
143 |
|
|
$finish;
|
144 |
|
|
end
|
145 |
|
|
endmodule // lpm_inpad
|
146 |
|
|
|
147 |
|
|
//------------------------------------------------------------------------
|
148 |
|
|
|
149 |
|
|
module lpm_outpad ( data, pad );
|
150 |
|
|
|
151 |
|
|
// NOTE: Parameters must be declared in the same order as the Properties
|
152 |
|
|
// are specified in the Cell Specification document.
|
153 |
|
|
parameter lpm_width = 1;
|
154 |
|
|
parameter lpm_type = "lpm_outpad";
|
155 |
|
|
parameter lpm_hint = "UNUSED";
|
156 |
|
|
parameter lpm_source_version = "lpm 220 version 1.6";
|
157 |
|
|
|
158 |
|
|
input [lpm_width-1:0] data;
|
159 |
|
|
output [lpm_width-1:0] pad;
|
160 |
|
|
|
161 |
|
|
reg [lpm_width-1:0] pad;
|
162 |
|
|
|
163 |
|
|
always @(data)
|
164 |
|
|
begin
|
165 |
|
|
pad = data;
|
166 |
|
|
end
|
167 |
|
|
|
168 |
|
|
// Check for previous Parameter declaration order
|
169 |
|
|
initial if ((lpm_width === "lpm_outpad") || (lpm_type !== "lpm_outpad"))
|
170 |
|
|
begin
|
171 |
|
|
$display ("LPM 220 Version 1.6 Parameter Order changed; update instantiation");
|
172 |
|
|
$finish;
|
173 |
|
|
end
|
174 |
|
|
endmodule // lpm_outpad
|
175 |
|
|
|
176 |
|
|
//------------------------------------------------------------------------
|
177 |
|
|
|
178 |
|
|
module lpm_bipad ( result, pad, data, enable );
|
179 |
|
|
|
180 |
|
|
// NOTE: Parameters must be declared in the same order as the Properties
|
181 |
|
|
// are specified in the Cell Specification document.
|
182 |
|
|
parameter lpm_width = 1;
|
183 |
|
|
parameter lpm_type = "lpm_bipad";
|
184 |
|
|
parameter lpm_hint = "UNUSED";
|
185 |
|
|
parameter lpm_source_version = "lpm 220 version 1.6";
|
186 |
|
|
|
187 |
|
|
input [lpm_width-1:0] data;
|
188 |
|
|
input enable;
|
189 |
|
|
inout [lpm_width-1:0] pad;
|
190 |
|
|
output [lpm_width-1:0] result;
|
191 |
|
|
|
192 |
|
|
reg [lpm_width-1:0] tmp_pad;
|
193 |
|
|
reg [lpm_width-1:0] result;
|
194 |
|
|
|
195 |
|
|
always @(data or pad or enable)
|
196 |
|
|
begin
|
197 |
|
|
if (enable == 1)
|
198 |
|
|
begin
|
199 |
|
|
tmp_pad = data;
|
200 |
|
|
result = 'bz;
|
201 |
|
|
end
|
202 |
|
|
else if (enable == 0)
|
203 |
|
|
begin
|
204 |
|
|
result = pad;
|
205 |
|
|
tmp_pad = 'bz;
|
206 |
|
|
end
|
207 |
|
|
end
|
208 |
|
|
|
209 |
|
|
assign pad = tmp_pad;
|
210 |
|
|
|
211 |
|
|
// Check for previous Parameter declaration order
|
212 |
|
|
initial if ((lpm_width === "lpm_bipad") || (lpm_type !== "lpm_bipad"))
|
213 |
|
|
begin
|
214 |
|
|
$display ("LPM 220 Version 1.6 Parameter Order changed; update instantiation");
|
215 |
|
|
$finish;
|
216 |
|
|
end
|
217 |
|
|
endmodule // lpm_bipad
|