📄 220model.v
字号:
//-------------------------------------------------------------------------
// This Verilog file was developed by Altera Corporation. It may be
// freely copied and/or distributed at no cost. Any persons using this
// file for any purpose do so at their own risk, and are responsible for
// the results of such use. Altera Corporation does not guarantee that
// this file is complete, correct, or fit for any particular purpose.
// NO WARRANTY OF ANY KIND IS EXPRESSED OR IMPLIED. This notice must
// accompany any copy of this file.
//------------------------------------------------------------------------
//
// Quartus II 4.0 Build 214 1/28/2004
//
//------------------------------------------------------------------------
// LPM Synthesizable Models (Support string type generic)
// These models are based on LPM version 220 (EIA-IS103 October 1998).
//------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
// Assumptions:
//
// 1. The default value for LPM_SVALUE, LPM_AVALUE, LPM_PVALUE, and
// LPM_STRENGTH is string UNUSED.
//
//-----------------------------------------------------------------------------
// Verilog Language Issues:
//
// Two dimensional ports are not supported. Modules with two dimensional
// ports are implemented as one dimensional signal of (LPM_SIZE * LPM_WIDTH)
// bits wide.
//
//-----------------------------------------------------------------------------
//START_MODULE_NAME------------------------------------------------------------
//
// Module Name : LPM_DEVICE_FAMILIES
//
// Description : Common Altera device families comparison
//
// Limitation :
//
// Results expected:
//
//END_MODULE_NAME--------------------------------------------------------------
// BEGINNING OF MODULE
`timescale 1 ps / 1 ps
// MODULE DECLARATION
module LPM_DEVICE_FAMILIES;
// FUNCTON DECLARATION
function IS_VALID_FAMILY;
input device;
reg[8*20:1] device;
reg is_valid;
begin
if (IS_FAMILY_APEX20K(device) || IS_FAMILY_APEX20KE(device) ||
IS_FAMILY_APEXII(device) || IS_FAMILY_ACEX2K(device) ||
IS_FAMILY_STRATIXGX(device) || IS_FAMILY_STRATIX(device) ||
IS_FAMILY_MERCURY(device) || IS_FAMILY_MAX(device) ||
IS_FAMILY_FLEX6000(device) || IS_FAMILY_FLEX8000(device) ||
IS_FAMILY_FLEX10K(device) || IS_FAMILY_FLEX10KE(device) ||
IS_FAMILY_STRATIXII(device) || IS_FAMILY_STRATIXHC(device) ||
IS_FAMILY_MAXII(device))
is_valid = 1;
else
is_valid = 0;
IS_VALID_FAMILY = is_valid;
end
endfunction // IS_VALID_FAMILY
function IS_FAMILY_APEX20K;
input device;
reg[8*20:1] device;
reg is_20k;
begin
if (device == "APEX20K")
is_20k = 1;
else
is_20k = 0;
IS_FAMILY_APEX20K = is_20k;
end
endfunction // IS_FAMILY_APEX20K
function IS_FAMILY_APEX20KE;
input device;
reg[8*20:1] device;
reg is_20ke;
begin
if ((device == "APEX20KE") || (device == "APEX20KC") ||
(device == "EXCALIBUR_ARM") || (device == "EXCALIBUR_MIPS"))
is_20ke = 1;
else
is_20ke = 0;
IS_FAMILY_APEX20KE = is_20ke;
end
endfunction // IS_FAMILY_APEX20KE
function IS_FAMILY_APEXII;
input device;
reg[8*20:1] device;
reg is_apexii;
begin
if ((device == "APEX II") || (device == "APEXII"))
is_apexii = 1;
else
is_apexii = 0;
IS_FAMILY_APEXII = is_apexii;
end
endfunction // IS_FAMILY_APEXII
function IS_FAMILY_ACEX2K;
input device;
reg[8*20:1] device;
reg is_acex2k;
begin
if ((device == "CYCLONE") || (device == "Cyclone"))
is_acex2k = 1;
else
is_acex2k = 0;
IS_FAMILY_ACEX2K = is_acex2k;
end
endfunction // IS_FAMILY_ACEX2K
function IS_FAMILY_STRATIXGX;
input device;
reg[8*20:1] device;
reg is_stratixgx;
begin
if ((device == "STRATIX-GX") || (device == "STRATIX GX") ||
(device == "Stratix GX"))
is_stratixgx = 1;
else
is_stratixgx = 0;
IS_FAMILY_STRATIXGX = is_stratixgx;
end
endfunction // IS_FAMILY_STRATIXGX
function IS_FAMILY_STRATIX;
input device;
reg[8*20:1] device;
reg is_stratix;
begin
if ((device == "STRATIX") || (device == "Stratix"))
is_stratix = 1;
else
is_stratix = 0;
IS_FAMILY_STRATIX = is_stratix;
end
endfunction // IS_FAMILY_STRATIX
function IS_FAMILY_MERCURY;
input device;
reg[8*20:1] device;
reg is_mercury;
begin
if ((device == "MERCURY") || (device == "Mercury"))
is_mercury = 1;
else
is_mercury = 0;
IS_FAMILY_MERCURY = is_mercury;
end
endfunction // IS_FAMILY_MERCURY
function IS_FAMILY_MAX;
input device;
reg[8*20:1] device;
reg is_max;
begin
if ((device == "MAX5000") || (device == "MAX3000A") || (device == "MAX7000") ||
(device == "MAX7000A") || (device == "MAX7000AE") || (device == "MAX7000E") ||
(device == "MAX7000S") || (device == "MAX7000B") || (device == "MAX9000"))
is_max = 1;
else
is_max = 0;
IS_FAMILY_MAX = is_max;
end
endfunction // IS_FAMILY_MAX
function IS_FAMILY_FLEX6000;
input device;
reg[8*20:1] device;
reg is_flex6k;
begin
if (device == "FLEX6000")
is_flex6k = 1;
else
is_flex6k = 0;
IS_FAMILY_FLEX6000 = is_flex6k;
end
endfunction // IS_FAMILY_FLEX6000
function IS_FAMILY_FLEX8000;
input device;
reg[8*20:1] device;
reg is_flex8k;
begin
if (device == "FLEX8000")
is_flex8k = 1;
else
is_flex8k = 0;
IS_FAMILY_FLEX8000 = is_flex8k;
end
endfunction // IS_FAMILY_FLEX8000
function IS_FAMILY_FLEX10K;
input device;
reg[8*20:1] device;
reg is_flex10k;
begin
if ((device == "FLEX10K") || (device == "FLEX10KA"))
is_flex10k = 1;
else
is_flex10k = 0;
IS_FAMILY_FLEX10K = is_flex10k;
end
endfunction // IS_FAMILY_FLEX10K
function IS_FAMILY_FLEX10KE;
input device;
reg[8*20:1] device;
reg is_flex10ke;
begin
if ((device == "FLEX10KE") || (device == "FLEX 10KE") ||
(device == "ACEX1K") || (device == "ACEX 1K"))
is_flex10ke = 1;
else
is_flex10ke = 0;
IS_FAMILY_FLEX10KE = is_flex10ke;
end
endfunction // IS_FAMILY_FLEX10KE
function IS_FAMILY_STRATIXII;
input device;
reg[8*20:1] device;
reg is_stratixii;
begin
if (device == "Stratix II")
is_stratixii = 1;
else
is_stratixii = 0;
IS_FAMILY_STRATIXII = is_stratixii;
end
endfunction // IS_FAMILY_STRATIXII
function IS_FAMILY_STRATIXHC;
input device;
reg[8*20:1] device;
reg is_stratixhc;
begin
if ((device == "STRATIXHC") || (device == "StratixHC") ||
(device == "STRATIX HC") || (device == "Stratix HC") ||
(device == "HardCopy Stratix") || (device == "HARDCOPY STRATIX"))
is_stratixhc = 1;
else
is_stratixhc = 0;
IS_FAMILY_STRATIXHC = is_stratixhc;
end
endfunction // IS_FAMILY_STRATIXHC
function IS_FAMILY_MAXII;
input device;
reg[8*20:1] device;
reg is_maxii;
begin
if ((device == "MAX II") || (device == "max ii") ||
(device == "MAXII") || (device == "maxii"))
is_maxii = 1;
else
is_maxii = 0;
IS_FAMILY_MAXII = is_maxii;
end
endfunction //IS_FAMILY_MAXII
endmodule // LPM_DEVICE_FAMILIES
//START_MODULE_NAME------------------------------------------------------------
//
// Module Name : LPM_HINT_EVALUATION
//
// Description : Common function to grep the value of altera specific parameters
// within the lpm_hint parameter.
//
// Limitation : No error checking to check whether the content of the lpm_hint
// is valid or not.
//
// Results expected: If the target parameter found, return the value of the parameter.
// Otherwise, return empty string.
//
//END_MODULE_NAME--------------------------------------------------------------
// BEGINNING OF MODULE
`timescale 1 ps / 1 ps
// MODULE DECLARATION
module LPM_HINT_EVALUATION;
// FUNCTON DECLARATION
// This function will search through the string (given string) to look for a match for the
// a given parameter(compare_param_name). It will return the value for the given parameter.
function [8*200:1] GET_PARAMETER_VALUE;
input [8*200:1] given_string; // string to be searched
input [8*50:1] compare_param_name; // parameter name to be looking for in the given_string.
integer param_value_char_count; // to indicate current character count in the param_value
integer param_name_char_count; // to indicate current character count in the param_name
integer white_space_count;
reg extract_param_value; // if 1 mean extracting parameters value from given string
reg extract_param_name; // if 1 mean extracting parameters name from given string
reg param_found; // to indicate whether compare_param_name have been found in the given_string
reg include_white_space; // if 1, include white space in the parameter value
reg [8*200:1] reg_string; // to store the value of the given string
reg [8*50:1] param_name; // to store parameter name
reg [8*20:1] param_value; // to store parameter value
reg [8:1] tmp; // to get the value of the current byte
begin
reg_string = given_string;
param_value_char_count = 0;
param_name_char_count =0;
extract_param_value = 1;
extract_param_name = 0;
param_found = 0;
include_white_space = 0;
white_space_count = 0;
tmp = reg_string[8:1];
// checking every bytes of the reg_string from right to left.
while ((tmp != 0 ) && (param_found != 1))
begin
tmp = reg_string[8:1];
//if tmp != ' ' or should include white space (trailing white space are ignored)
if((tmp != 32) || (include_white_space == 1))
begin
if(tmp == 32)
begin
white_space_count = 1;
end
else if(tmp == 61) // if tmp = '='
begin
extract_param_value = 0;
extract_param_name = 1; // subsequent bytes should be part of param_name
include_white_space = 0; // ignore the white space (if any) between param_name and '='
white_space_count = 0;
param_value = param_value >> (8 * (20 - param_value_char_count));
param_value_char_count = 0;
end
else if (tmp == 44) // if tmp = ','
begin
extract_param_value = 1; // subsequent bytes should be part of param_value
extract_param_name = 0;
param_name = param_name >> (8 * (50 - param_name_char_count));
param_name_char_count = 0;
if(param_name == compare_param_name)
param_found = 1; // the compare_param_name have been found in the reg_string
end
else
begin
if(extract_param_value == 1)
begin
param_value_char_count = param_value_char_count + white_space_count + 1;
include_white_space = 1;
if(white_space_count > 0)
begin
param_value = {8'b100000, param_value[20*8:9]};
white_space_count = 0;
end
param_value = {tmp, param_value[20*8:9]};
end
else if(extract_param_name == 1)
begin
param_name = {tmp, param_name[50*8:9]};
param_name_char_count = param_name_char_count + 1;
end
end
end
reg_string = reg_string >> 8; // shift 1 byte to the right
end
// for the case whether param_name is the left most part of the reg_string
if(extract_param_name == 1)
begin
param_name = param_name >> (8 * (50 - param_name_char_count));
if(param_name == compare_param_name)
param_found = 1;
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -