📄 flex6000_atoms.v
字号:
// Copyright (C) 1988-2002 Altera Corporation
// Any megafunction design, and related netlist (encrypted or decrypted),
// support information, device programming or simulation file, and any other
// associated documentation or information provided by Altera or a partner
// under Altera's Megafunction Partnership Program may be used only
// to program PLD devices (but not masked PLD devices) from Altera. Any
// other use of such megafunction design, netlist, support information,
// device programming or simulation file, or any other related documentation
// or information is prohibited for any other purpose, including, but not
// limited to modification, reverse engineering, de-compiling, or use with
// any other silicon devices, unless such use is explicitly licensed under
// a separate agreement with Altera or a megafunction partner. Title to the
// intellectual property, including patents, copyrights, trademarks, trade
// secrets, or maskworks, embodied in any such megafunction design, netlist,
// support information, device programming or simulation file, or any other
// related documentation or information provided by Altera or a megafunction
// partner, remains with Altera, the megafunction partner, or their respective
// licensors. No other licenses, including any licenses needed under any third
// party's intellectual property, are provided herein.
// Quartus II 3.0 Build 197 06/18/2003
///////////////////////////////////////////////////////////////////////////////
//
// FLEX6K LCELL ATOM
//
// Supports lut_mask, does not support equations.
// Support normal, arithmetic, and counter mode.
// parameter output_mode is informational only and has no simulation function. // No checking is done for validation of parameters passed from top level.
// Input default values are implemented using tri1 and tri0 net.
//
///////////////////////////////////////////////////////////////////////////////
`timescale 1 ps/1 ps
//
// flex6k_asynch_lcell
//
module flex6k_asynch_lcell (dataa, datab, datac, datad,
cin, cascin, qfbkin,
combout, regin, cout, cascout) ;
parameter operation_mode = "normal" ;
parameter output_mode = "reg_and_comb";
parameter lut_mask = "ffff" ;
parameter cin_used = "false";
input dataa, datab, datac, datad ;
input cin, cascin, qfbkin;
output cout, cascout, regin, combout ;
reg icout, data, iregin;
wire icascout, idataa;
reg tmp_cascin;
buf (idataa, dataa);
buf (idatab, datab);
buf (idatac, datac);
buf (idatad, datad);
buf (icascin, cascin);
buf (icin, cin);
initial
begin
//icascin = 1;
tmp_cascin = 1;
end
specify
(dataa => combout) = (0, 0) ;
(datab => combout) = (0, 0) ;
(datac => combout) = (0, 0) ;
(datad => combout) = (0, 0) ;
(cascin => combout) = (0, 0) ;
(cin => combout) = (0, 0) ;
(qfbkin => combout) = (0, 0) ;
(dataa => cout) = (0, 0);
(datab => cout) = (0, 0);
(datac => cout) = (0, 0);
(datad => cout) = (0, 0);
(cin => cout) = (0, 0) ;
(qfbkin => cout) = (0, 0) ;
(cascin => cascout) = (0, 0) ;
(cin => cascout) = (0, 0) ;
(dataa => cascout) = (0, 0) ;
(datab => cascout) = (0, 0) ;
(datac => cascout) = (0, 0) ;
(datad => cascout) = (0, 0) ;
(qfbkin => cascout) = (0, 0) ;
(dataa => regin) = (0, 0) ;
(datab => regin) = (0, 0) ;
(datac => regin) = (0, 0) ;
(datad => regin) = (0, 0) ;
(cascin => regin) = (0, 0) ;
(cin => regin) = (0, 0) ;
(qfbkin => regin) = (0, 0) ;
endspecify
function [16:1] str_to_bin ;
input [8*4:1] s;
reg [8*4:1] reg_s;
reg [4:1] digit [8:1];
reg [8:1] tmp;
integer m , ivalue ;
begin
ivalue = 0;
reg_s = s;
for (m=1; m<=4; m= m+1 )
begin
tmp = reg_s[32:25];
digit[m] = tmp & 8'b00001111;
reg_s = reg_s << 8;
if (tmp[7] == 'b1)
digit[m] = digit[m] + 9;
end
str_to_bin = {digit[1], digit[2], digit[3], digit[4]};
end
endfunction
function lut4 ;
input [4*8:1] lut_mask ;
input dataa, datab, datac, datad ;
reg [15:0] mask ;
reg prev_lut4;
reg dataa_new, datab_new, datac_new, datad_new;
integer h, i, j, k;
integer hn, in, jn, kn;
integer exitloop;
integer check_prev;
begin
mask = str_to_bin (lut_mask) ;
begin
if ((datad === 1'bx) || (datad === 1'bz))
begin
datad_new = 1'b0;
hn = 2;
end
else
begin
datad_new = datad;
hn = 1;
end
check_prev = 0;
exitloop = 0;
h = 1;
while ((h <= hn) && (exitloop == 0))
begin
if ((datac === 1'bx) || (datac === 1'bz))
begin
datac_new = 1'b0;
in = 2;
end
else
begin
datac_new = datac;
in = 1;
end
i = 1;
while ((i <= in) && (exitloop ==0))
begin
if ((datab === 1'bx) || (datab === 1'bz))
begin
datab_new = 1'b0;
jn = 2;
end
else
begin
datab_new = datab;
jn = 1;
end
j = 1;
while ((j <= jn) && (exitloop ==0))
begin
if ((dataa === 1'bx) || (dataa === 1'bz))
begin
dataa_new = 1'b0;
kn = 2;
end
else
begin
dataa_new = dataa;
kn = 1;
end
k = 1;
while ((k <= kn) && (exitloop ==0))
begin
case ({datad_new, datac_new, datab_new, dataa_new})
4'b0000: lut4 = mask[0] ;
4'b0001: lut4 = mask[1] ;
4'b0010: lut4 = mask[2] ;
4'b0011: lut4 = mask[3] ;
4'b0100: lut4 = mask[4] ;
4'b0101: lut4 = mask[5] ;
4'b0110: lut4 = mask[6] ;
4'b0111: lut4 = mask[7] ;
4'b1000: lut4 = mask[8] ;
4'b1001: lut4 = mask[9] ;
4'b1010: lut4 = mask[10] ;
4'b1011: lut4 = mask[11] ;
4'b1100: lut4 = mask[12] ;
4'b1101: lut4 = mask[13] ;
4'b1110: lut4 = mask[14] ;
4'b1111: lut4 = mask[15] ;
default: $display ("Warning: Reached forbidden part of lcell code.\n");
endcase
if ((check_prev == 1) && (prev_lut4 !==lut4))
begin
lut4 = 1'bx;
exitloop = 1;
end
else
begin
check_prev = 1;
prev_lut4 = lut4;
end
k = k + 1;
dataa_new = 1'b1;
end // loop a
j = j + 1;
datab_new = 1'b1;
end // loop b
i = i + 1;
datac_new = 1'b1;
end // loop c
h = h + 1;
datad_new = 1'b1;
end // loop d
end
end
endfunction
always @(idatad or idatac or idatab or idataa or icin or icascin or qfbkin)
begin
if (operation_mode == "normal")
begin
if ((icascin == 1'b1) || (icascin == 1'b0))
tmp_cascin = icascin;
data = ((cin_used == "true") ?
(lut4 (lut_mask, idataa, idatab, icin, idatad)) :
(lut4(lut_mask, idataa, idatab, idatac, idatad)))
&& tmp_cascin;
end
if (operation_mode == "arithmetic")
begin
if ((icascin == 1'b1) || (icascin == 1'b0))
tmp_cascin = icascin;
data = (lut4 (lut_mask, idataa, idatab, icin, 'b1))
&& tmp_cascin ;
icout = lut4 ( lut_mask, idataa, idatab, icin, 'b0) ;
end
if (operation_mode == "counter")
begin
if ((icascin == 1'b1) || (icascin == 1'b0))
tmp_cascin = icascin;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -