Vivado实现纯逻辑开发——从最简单的开始

来源:互联网 发布:意大利 世界杯 知乎 编辑:程序博客网 时间:2024/05/17 14:15
vivado设计方法学视频http://p.bokecc.com/playvideo.bo?uid=290666218ACBA694&playerid=EEA982EE6B20F4D1&playertype=1&autoStart=false&vid=24C9FCCC54D6286A9C33DC5901307461http://static.youku.com/v1.0.0518/v/swf/loader.swf?VideoIDS=XNjI3NDMyNTg4&embedid=MTE2LjIyNy41LjE4MwIxNTY4NTgxNDcCeGlsaW54LmVldG9wLmNuAi8%3D&wd=&vext=pid%3D%26emb%3DMTE2LjIyNy41LjE4MwIxNTY4NTgxNDcCeGlsaW54LmVldG9wLmNuAi8%3D%26bc%3D%26type%3D0 Vivado实现纯逻辑开发——从最简单的开始-cuter的博客-AET电子技术应用网
  • 网站首页
  • 博客
  • 小组
  • 网络教室
欢迎游客  登录  注册  




  • 我的空间
  • 我的博客
  • 我的小组
  • 期刊投稿
  • 我的帐户
</div>     <div class="containt_r">    <div class="post-detail">        <div class="userinfo">    <div class="pic"><img src="http://files.chinaaet.com/images/2012/12/12/409750824584.jpg" alt="" width="50" height="50" /></div>    <div class="info"><a id="hlGoTo" href="/cuter521">去cuter的博客</a><a href="javascript:history.go(-1);"> << 返回上一页</a></div>                 </div>      <div class="subnav" >     <div class="post-pre">         <a id="hlRre" class="cblue3" href="http://blog.chinaaet.com/detail/35965">上一篇</a>                  </div>     <div class="post-next">        <a id="hlNext" class="cblue3" href="http://blog.chinaaet.com/detail/34173">下一篇</a>     </div>  </div>  <div class="post-content">         <div class="post-title">     <ul>        <li>            <h1 title="Vivado实现纯逻辑开发——从最简单的开始"><span id="labIsContest" style="color:Red;">赛&nbsp;</span>Vivado实现纯逻辑开发——从最简单的开始</h1>             <input type="hidden" id="postid" value="35946" />             <input name="txtcontestID" type="hidden" id="txtcontestID" value="17" />        </li>        <li>2014-07-20 00:51&nbsp;发表&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;            系统分类:<a href="http://blog.chinaaet.com/category/34">EDA</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;            自定义分类:<a href="/cuter521/uc1531">Vivado学习笔记</a></li>        <li>标签:<a href="http://blog.chinaaet.com/tag/Vivado">Vivado</a> <a href="http://blog.chinaaet.com/tag/-ZedBoard"> ZedBoard</a> </li>      </ul>     </div>     <div id="divend" class="voteend"><a href='http://blog.chinaaet.com/detail/35647' target='_blank'>本文最终票数为:10</a></div>     <div class="clear"></div>     <div class="post-body">         <p class="MsoNormal" align="center" style="text-align:center;text-indent:2em;"><span style="font-size:12pt;line-height:125%;"><strong>&nbsp;</strong></span><b><span style="font-size:18.0pt;font-family:黑体;"><strong>Vivado</strong></span></b><b><span style="font-size:18.0pt;font-family:黑体;"><strong>实现纯逻辑开发</strong></span></b> 

——从最简单的开始

硬件平台:ZedBoard

开发工具:Vivado 2014.2


1.       前言:

1.1.       关于软件的安装

本来不想提这一环节的,因为去官网下载安装包,安装,到网上找个license就搞定了,结果在这一环还走了弯路,不得不记录下来,作为教训和供他人借鉴的经验。

Xilinx官网有ISE+Vivado合体的安装包,也有网友推荐这个安装包,一次装俩,何乐而不为呢?本着这种贪小便宜的想法,我下载了这个安装包,下载的时候发现这个安装包和ISE的安装包差不多大,当时也没太在意。

我的破电脑哼哧哼哧下了N小时,完了安装,发现是Vivado版本是2012.4,当时觉得版本太低了,不太爽,想想再下载又要N久,先凑合用吧。破解,打开Vivado发现这个界面太熟悉了,和PlanAheadXPS的欢迎界面很像,有点不好的预感啊。

新建工程,发现不支持zynq系列芯片,只支持v7k7两个系列,太坑了!既不支持以前的低端系列,也不支持后来的高端系列。

无奈啊,回过头来去看启动Vivado时弹出的命令行窗口,根据一些提示信息可以推测,这个版本的Vivado只是做了一个界面,真正工作时是跑去调用ISE的组件,这也是为什么这个安装包的大小和ISE安装包大小差不多的原因。

在这里告诉后来人,不要贪小便宜,果断不要安装这个合体包,老老实实下载比较新的版本,最好不是最新的,有可能没破解。

1.1.       本来应该是前言的前言

在接触新东西的时候,我总会带有一丝敬畏,好像未知的东西总是不如熟悉的东西让人感觉踏实。所以我喜欢用自己掌握的很熟练的或者是很简单的东西去验证未知的东西,加快自己学习的进度。现在我选择上手Vivado,也打算从最简单的纯逻辑设计开始。

2.       规划:

在设计之初就能够进行良好地规划,可以节省后续的设计时间,当项目复杂度增加时,项目的规划和方案设计更加重要。

1)        项目功能:流水灯

2)        编程语言:Verilog

3)        设计流程:建立工程à代码编辑à功能仿真à综合、实现à板级测试(本文是现象的观察,后续会给出ChipScope的使用方法)

项目的功能十分简单,主要目的是为了Vivado开发流程,也就是上述第3个步骤。

3.       设计

功能简单,上个示意框图,简单描述一下吧。

1 总体框图

timer500ms模块:

功能是产生2hz的时钟,为led_ctrl模块提供时钟。

led_ctrl模块:

功能是实现循环移位,在硬件上的体现就是流水灯。输入时钟为2hz,时钟上升沿进行一次移位操作,每个led点亮0.5s

4.       实现:

4.1.       建立工程

下载了最新版的Vivado2014.2,找了个license,工具可以用了,IP可不可以还没有验证。欢迎界面看起来和之前的PlanAheadXPS的欢迎界面差别比较大了,可以说是焕然一新吧。


2 欢迎界面

点击Create New Project,进入新建工程的向导,逐步next即可。

3 新建工程向导step1

4 新建工程向导step2 指定工程名和存储路径

勾选图5椭圆内的选项,表明不在此时指定源文件。

5 新建工程向导step3

6 选择器件/开发板

最后一步:所建立工程的概要信息。

7 新建工程信息总览

点击Finish之后,就进入Vivado主界面了,如图8所示。

8 Vivado主界面

主界面主要包括:

Flow Navigator       在此可以找到整个设计过程中涉及到的所有流程

Sources                   工程包含的设计源文件,源码、约束等

Properties                所选中对象的属性信息

Project Summary     在此可以查看工程信息

Design Runs            在此可以查看提示信息、警告、错误、也可以输入tcl命令

4.2.       流程控制子窗口

9 流程子窗口

后续的“Add Sources”、“Simulation”、“Synthesis”、“Implementation”以及“Generate Bitstream”,都可以在该窗口找到执行菜单。

4.3.       代码编辑

顶层:


module runled_top(    input iClk,    input iRst_n,    output [7:0] oLed    );wire    clk2hz_sig;timer500ms timer500ms_inst(    .iClk100mhz(iClk),    .iRst_n(~iRst_n),    .oClk2hz(clk2hz_sig));    led_ctrl led_ctrl_inst(    .iClk(clk2hz_sig),    .iRst_n(~iRst_n),    .oLed(oLed));endmodule


时钟发生:


/*oFreq = iFreq/(2N) => N=iFreq/(2oFreq)=100,000,000/(2*2)=25,000,000=0x17d7840*/module timer500ms(iClk100mhz,iRst_n,oClk2hz)input   iClk100mhz;input   iRst_n;output  oClk2hz;            // period = 1/2sreg [31:0]  cnt2hz;always @(posedge iClk100mhz) beginif(iRst_n=1’b0) begin        oClk2hz <= 1’b0;        cnt2hz <= 32’b0;    end    else begin        if(cnt2hz=32’d25000000) begin            cnt2hz <= 32’b0;            oClk2hz <= ~ oClk2hz;        end else begin    cnt2hz <= cnt2hz + 1’b1;    oClk2hz <= oClk2hz;end    endendendmodule


led控制模块:


module led_ctrl(    input iClk,    input iRst_n,    output [7:0] oLed    );reg [7:0]   led;    /*\ 每个时钟上升沿,左移1bit,写法是为了实现循环左移*/    always @(posedge iClk) begin    if(iRst_n==1'b0)        led <= 8'b1;    else        led <= {led[6:0],led[7]};        end    assign  oLed = led;endmodule


添加代码源文件方法:点击Add Sources按钮,有两处有该按钮,如图10所示。

10 add source(1)

另外,还可以在Design Sources文件夹上单击鼠标右键,弹出的菜单中有“Add Sources”选项,如图11所示。

11 add source (2)

弹出图12所示的向导。

12 选择资源类型

此处添加的是HDL设计文件,所以选择椭圆内的“Add or Create Design Sources”,NEXT,弹出图13所示的界面,选择创建或者添加源文件。

13 创建/添加源文件

单击Create File按钮,进入图14所示的界面。

14 新建源文件

指定文件名和存储位置后点击OK,返回上一界面,界面发生变化,如图15所示。

15

点击Finish,弹出新建文件的助手,如图16所示。

16 源文件编辑助手

这里应该和ISE添加源文件的向导一样,我直接点击OK略过,然后自己编辑的代码。

4.4.       功能仿真

添加testbench,方法和4.3所述的类似,只是文件类型为“Add or Create SimulationSources”(图12)。

RunSimulation,会弹出仿真结果。此处以timer500ms模块的仿真为例,给出仿真结果:

17 timer500ms模块仿真结果

体会:在ISE中新建Testbench文件时,可以选择被仿真模块,然后自动实例化待仿真的模块;Vivado中需要自己手动编写所有代码。

4.5.       综合、实现、烧写

4.5.1.      约束文件的编写

ISE约束文件格式为ucfVivado约束文件为xdc,这是Vivado又一改进。xdc文件是

我的约束文件为:

#In the following the XDC constraint is matched to theoriganal UCF constraint, XDC above, UCF below # Commented

set_property PACKAGE_PIN Y9 [get_ports {iClk}]

set_property IOSTANDARD LVCMOS33 [get_ports {iClk}]

#NET GCLK          LOC = Y9  | IOSTANDARD=LVCMOS33;  #“GCLK”

# Bank 33, Vcco = 3.3V

#set_property IOSTANDARD LVCMOS33 [get_ports -filter {IOBANK == 33 } ]

set_property PACKAGE_PIN T22 [get_ports {oLed[0]}]

set_property IOSTANDARD LVCMOS33 [get_ports {oLed[0]}]

#NET LD0          LOC = T22  |IOSTANDARD=LVCMOS33;  # “LD0”

set_property PACKAGE_PIN T21 [get_ports {oLed[1]}]

set_property IOSTANDARD LVCMOS33 [get_ports {oLed[1]}]

#NET LD1          LOC = T21  |IOSTANDARD=LVCMOS33;  # “LD1”

set_property PACKAGE_PIN U22 [get_ports {oLed[2]}]

set_property IOSTANDARD LVCMOS33 [get_ports {oLed[2]}]

#NET LD2          LOC = U22  |IOSTANDARD=LVCMOS33;  # “LD2”

set_property PACKAGE_PIN U21 [get_ports {oLed[3]}]

set_property IOSTANDARD LVCMOS33 [get_ports {oLed[3]}]

#NET LD3           LOC = U21 | IOSTANDARD=LVCMOS33;  #“LD3”

set_property PACKAGE_PIN V22 [get_ports {oLed[4]}]

set_property IOSTANDARD LVCMOS33 [get_ports {oLed[4]}]

#NET LD4          LOC = V22  |IOSTANDARD=LVCMOS33;  # “LD4”

set_property IOSTANDARD LVCMOS33 [get_ports {oLed[5]}]

set_property PACKAGE_PIN W22 [get_ports {oLed[5]}]

#NET LD5          LOC = W22  |IOSTANDARD=LVCMOS33;  # “LD5”

set_property PACKAGE_PIN U19 [get_ports {oLed[6]}]

set_property IOSTANDARD LVCMOS33 [get_ports {oLed[6]}]

#NET LD6          LOC = U19  |IOSTANDARD=LVCMOS33;  # “LD6”

set_property IOSTANDARD LVCMOS33 [get_ports {oLed[7]}]

set_property PACKAGE_PIN U14 [get_ports {oLed[7]}]

#NET LD7          LOC = U14  |IOSTANDARD=LVCMOS33;  # “LD7”

# Bank 34, Vcco = Vadj

#set_property IOSTANDARD LVCMOS18 [get_ports -filter {IOBANK == 34 } ]

set_property IOSTANDARD LVCMOS18 [get_ports {iRst_n}]

set_property PACKAGE_PIN P16 [get_ports {iRst_n}]

#NET BTNC         LOC = P16  |IOSTANDARD=LVCMOS18;  # “BTNC”

注释写的很清楚了,和ZedBoarducf文件是一一对应的,很容易理解。

不过关于约束的编写也不是这么简单能说的清的,后续还需要进一步学习。如果快速入门的话,可以参考模版文件,模板文件如图18所示:

18 模板文件的使用

注意要选中Templates子选项卡(位于Sources旁边),然后点开红色方框内的xdc文件夹,找到自己想要进行的约束,然后可以看到参考语句,预览结果在上图绿色直线上方。

同样的,还有verilogvhdlTestbench等文件的参考语句,需要时可以参考,从而提高代码编辑效率。

4.5.2.      综合、实现、烧写

综合、实现的菜单在Flow Navigator中,如果想分开执行,分别点击即可。为了方便,可以直接选择“Generate Bitstream”。除错,直到成功为止。

烧写有两种方式,一种是通过impact,一种是通过SDK Tools菜单下的Progress FPGA指令实现

4.5.3.      本节体验:

从主观感觉上来说,对于简单的设计,ISE在综合、实现的时间上要比Vivado短。

4.6.       实验现象

传个视频玩一玩。


5.       小结

通过本次学习,基本掌握了Vivado做纯逻辑开发的流程,Vivado做逻辑开发较ISE而言稍微,在操作上稍微有点繁琐,但也有方便之处,可谓各有千秋吧。

6.       隐藏的小问题

设计存在两处小问题,我没有改,有兴趣的童鞋可以看看在哪里。


cuter原创^发文不易,转载请注明出处,3Q~

     </div>     <div class="post-extra"><a id="fileExtra"></a></div>                     <div class="shareto_toolbox">    <!-- BdShare Button BEGIN -->    <div class="bdsharebuttonbox">        <a href="#" class="bds_more" data-cmd="more"></a>        <a title="分享到新浪微博" href="#" class="bds_tsina" data-cmd="tsina"></a>        <a title="分享到QQ空间" href="#" class="bds_qzone" data-cmd="qzone"></a>        <a title="分享到微信" href="#" class="bds_weixin" data-cmd="weixin"></a>        <a title="分享到有道云笔记" href="#" class="bds_youdao" data-cmd="youdao"></a>    </div>    <!-- BdShare Button END -->    </div>    <div class="clear"></div>     <a name="a"></a>     <div class="post-comment-list">            <div class='comment-item clearfix' id='div_14402'><div class='pic'>   <a href='http://blog.chinaaet.com/coco'><img src='http://files.chinaaet.com/images/2009/10/28/270955958449.jpg' width='50' height='50' border='0' /></a></div><ul>   <li><a href='http://blog.chinaaet.com/coco' id='a_reply_14402'>木易</a>| <span>2014/7/21 9:53:58</span> </li>   <li><p>亲:你忘了我们的插入代码工具了吧!

  • 回复  引用
  •             <div class='comment-item clearfix' id='div_14403'><div class='pic'>   <img src='http://files.chinaaet.com/images/head/head_aet.gif' width='50' height='50' border='0' /></div><ul><li><lable id='a_reply_14403'>匿名用户(210.76.109.99  )</lable>| <span>2014/7/21 9:56:53</span> </li>   <li>接下来玩个复杂的,Vivado的优势就体现了。</li>   <li class='operation'><a href="javascript:ReplyComment(14403,0);" class="cblue3">回复</a>&nbsp;&nbsp;<a href="javascript:QuoteComment(14403,0);" class="cblue3">引用</a></li></ul>  </div>            <div class='comment-item clearfix' id='div_14404'><div class='pic'>   <a href='http://blog.chinaaet.com/cuter521'><img src='http://files.chinaaet.com/images/2012/12/12/409750824584.jpg' width='50' height='50' border='0' /></a></div><ul>   <li><a href='http://blog.chinaaet.com/cuter521' id='a_reply_14404'>cuter</a>| <span>2014/7/21 10:03:08</span> </li>   <li>@木易</br></br>用了啊…我的livewrite不能用了,发这种图片多的长文简直吐血,格式调整很费劲</li>   <li class='operation'><a href="javascript:ReplyComment(14404,143506);" class="cblue3">回复</a>&nbsp;&nbsp;<a href="javascript:QuoteComment(14404,143506);" class="cblue3">引用</a></li></ul>  </div>            <div class='comment-item clearfix' id='div_14405'><div class='pic'>   <a href='http://blog.chinaaet.com/cuter521'><img src='http://files.chinaaet.com/images/2012/12/12/409750824584.jpg' width='50' height='50' border='0' /></a></div><ul>   <li><a href='http://blog.chinaaet.com/cuter521' id='a_reply_14405'>cuter</a>| <span>2014/7/21 10:14:32</span> </li>   <li>@匿名用户(210.76.109.99  )</br></br>是的,后面做ps+pl开发的时候,已经感觉到了</li>   <li class='operation'><a href="javascript:ReplyComment(14405,143506);" class="cblue3">回复</a>&nbsp;&nbsp;<a href="javascript:QuoteComment(14405,143506);" class="cblue3">引用</a></li></ul>  </div>            <div class='comment-item clearfix' id='div_14406'><div class='pic'>   <a href='http://blog.chinaaet.com/admin'><img src='http://files.chinaaet.com/images/2010/11/24/150951872216.jpg' width='50' height='50' border='0' /></a></div><ul>   <li><a href='http://blog.chinaaet.com/admin' id='a_reply_14406'>AET</a>| <span>2014/7/21 16:16:06</span> </li>   <li>@cuter<br />



    鼓励一下。还得把Livewritter弄好

  • 回复  引用
  •             <div class='comment-item clearfix' id='div_14408'><div class='pic'>   <a href='http://blog.chinaaet.com/songhuangong'><img src='http://files.chinaaet.com/images/2014/05/05/20493596434930.png' width='50' height='50' border='0' /></a></div><ul>   <li><a href='http://blog.chinaaet.com/songhuangong' id='a_reply_14408'>宋桓公</a>| <span>2014/7/22 8:03:43</span> </li>   <li>很好,很强大,支持博主~~</li>   <li class='operation'><a href="javascript:ReplyComment(14408,135664);" class="cblue3">回复</a>&nbsp;&nbsp;<a href="javascript:QuoteComment(14408,135664);" class="cblue3">引用</a></li></ul>  </div>            <div class='comment-item clearfix' id='div_14472'><div class='pic'>   <a href='http://blog.chinaaet.com/lyc830'><img src='http://files.chinaaet.com/images/head/head_aet.gif' width='50' height='50' border='0' /></a></div><ul>   <li><a href='http://blog.chinaaet.com/lyc830' id='a_reply_14472'>lyc830</a>| <span>2014/7/29 13:54:52</span> </li>   <li>很详细,适合我等菜鸟入门学习</li>   <li class='operation'><a href="javascript:ReplyComment(14472,188830);" class="cblue3">回复</a>&nbsp;&nbsp;<a href="javascript:QuoteComment(14472,188830);" class="cblue3">引用</a></li></ul>  </div>            <div class='comment-item clearfix' id='div_14496'><div class='pic'>   <a href='http://blog.chinaaet.com/codyshao'><img src='http://files.chinaaet.com/images/head/head_aet.gif' width='50' height='50' border='0' /></a></div><ul>   <li><a href='http://blog.chinaaet.com/codyshao' id='a_reply_14496'>codyshao</a>| <span>2014/7/31 16:54:28</span> </li>   <li>楼主相当给力啊,感谢。。</li>   <li class='operation'><a href="javascript:ReplyComment(14496,187336);" class="cblue3">回复</a>&nbsp;&nbsp;<a href="javascript:QuoteComment(14496,187336);" class="cblue3">引用</a></li></ul>  </div>            <div class='comment-item clearfix' id='div_14592'><div class='pic'>   <a href='http://blog.chinaaet.com/songhuangong'><img src='http://files.chinaaet.com/images/2014/05/05/20493596434930.png' width='50' height='50' border='0' /></a></div><ul>   <li><a href='http://blog.chinaaet.com/songhuangong' id='a_reply_14592'>宋桓公</a>| <span>2014/8/19 17:14:53</span> </li>   <li><p>你的思路,我喜欢~~

    如果可以给多个赞,我希望是32个

  • 回复  引用
    • lynn| 2014/8/25 19:09:53
    • 博主说的两个小问题在哪?
    • 回复  引用
    • cuter| 2014/8/26 19:14:33
    • @lynn

      1、复位问题

      始终发生模块设计采用同步复位,所以按下复位按键后并不能达到逻辑上想要的 led全灭效果,复位按键按下后,时钟消失,所以无任何操作,会保持在当前状态。

      2、仿真时间问题

      这个问题比较隐蔽,其实也无伤大雅,仿真结果:周期不是500ms,而是1s,这是Testbench输入写错了,没有改~

    • 回复  引用
    • anchoret| 2014/9/17 17:04:50
    • 一步步学习!

    • 回复  引用
    • 匿名用户(60.2.146.82 )| 2014/10/11 15:02:36
    • 约束文件这块能讲的细一点吗
    • 回复  引用
    • 匿名用户(125.227.181.91 )| 2014/10/25 4:55:17
    • Vivado的威力是在大型電路, 在大型電路的合成上, 會比ISE快很多




    • 回复  引用
                <div class='comment-item clearfix' id='div_19845'><div class='pic'>   <a href='http://blog.chinaaet.com/jay778778'><img src='http://files.chinaaet.com/images/head/head_aet.gif' width='50' height='50' border='0' /></a></div><ul>   <li><a href='http://blog.chinaaet.com/jay778778' id='a_reply_19845'>jay778778</a>| <span>2015/3/25 20:56:44</span> </li>   <li>好例程哈 &nbsp;,感谢楼主的分享,刚好需要哈</li>   <li class='operation'><a href="javascript:ReplyComment(19845,1000000334);" class="cblue3">回复</a>&nbsp;&nbsp;<a href="javascript:QuoteComment(19845,1000000334);" class="cblue3">引用</a></li></ul>  </div>            <div class='pagenumber'>共1页&nbsp;15条记录&nbsp;&nbsp;&nbsp;首页 上一页&nbsp;<font color="#ff0000">1</font> 下一页 末页</div>     </div>     <div class="post-comment">         <h3 id="h3CommentTip"></h3>         <div class="text"><textarea id="post-comment-text" name="post-comment-text" style="width:650px;height:400px;"></textarea></div>         <div class="text hide" id="tVColde">             验证码:<input type="text" id="txtValidCode" name="txtValidCode" />                              <input type="hidden" name="txtCodeImgId" id="txtCodeImgId" value="" />             <span id="captchaImage"></span>         </div>         <input type="hidden" id="reply-text" name="reply-text" />         <div class="btn-post">             <input type="submit" name="btnPost" value="发表" id="btnPost" />                       </div>                  </div>     </div>  </div>    </div><div class="clear"></div></div>    
    var messageNum=0 if(messageNum != "0"){ $.jBox.messager("您有"+messageNum+"条新的消息!", "公告", 5000, { width: 200 });} var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://"); document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F0bc2b0756b170cff90e37c9e9628af4b' type='text/javascript'%3E%3C/script%3E"));
    <script type="text/javascript">    var clientUserID=0;    var editor;    KindEditor.ready(function (K) {        editor = K.create('#post-comment-text', {                cssPath: 'http://s1.chinaaet.com/kindeditor/plugins/code/prettify.css',                uploadJson: 'http://blog.chinaaet.com/uploadfiles.ashx',                resizeType: 1,                urlType: 'domain',                allowImageUpload: true,                allowFlashUpload: false,                allowMediaUpload: false,                 allowFileManager: false,                afterChange: function () {                    this.sync();                },                afterCreate:function()                {                                            K.ctrl(this.edit.doc, 13, function() {                                                    $("#btnPost").click();                                               });                        K.ctrl(document, 13, function() {                                                    $("#btnPost").click();                                               });                },                filterMode : false,                items : [                    'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',                    'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',                    'insertunorderedlist', '|','emoticons', 'link', 'unlink', 'image', 'flash', 'code', 'source', 'about']        });        var hCommentTip="欢迎您," + "";        if(clientUserID <= 0){                        //editor.readonly();            //$(".btn-post span").show();            //$(".btn-post span a").attr({href:"http://www.chinaaet.com/user/login/?returnurl=" + window.location});            $("#tVColde").show();            hCommentTip="您将以匿名用户身份发表,请<a href='http://www.chinaaet.com/user/login/?returnurl="+ window.location+"'>登录</a>|<a href='http://www.chinaaet.com//user/register/'>注册</a> ";        }        $("#h3CommentTip").html(hCommentTip);    })    function DelReply(id) {                   var submit = function (v, h, f) {            if (v == 'ok') {                $.jBox.tip("正在删除数据...", 'loading');                   $.ajax({                    type: "post",                    url: "/ajax.aspx",                    data: "otype=delreply&id=" + id,                    dataType: "json",                    success: function(data) {                                                if (data.isok){                            $.jBox.tip('删除成功。','success',{ closed: function () { location.reload(); } });                                                         }                    }                });                            }                            return true; //close        };        $.jBox.confirm("确定要删除数据吗?", "提示", submit);    }    function QuoteComment(id, userID) {                  var uname = '引用:' + $("#a_reply_" + id).text();                   var word = $("#div_" + id + " li").eq(1).html();        var nw = '<fieldset><legend>' + uname + '</legend><div>' + word + '</div></fieldset></br>';        $("#reply-text").val(userID);                    editor.html(nw);    }    function ReplyComment(id, userID) {                  var uname = '@' + $("#a_reply_" + id).text() +"</br></br>";                  $("#reply-text").val(userID);                    editor.html(uname);    }    function DownFileInfo(postid,libid) {        if(clientUserID <= 0)        {             alert("请登录后下载附件");            window.location.href = 'http://www.chinaaet.com/user/login/?returnurl=' + window.location;         }        else        {            window.location.href = '/downloadfile.aspx?postid=' + postid +"&libid=" + libid;        }    }    $(document).ready(function () {        $("#btnPost").click(function () {              //if(clientUserID <= 0)            //{             //    alert("请登录后再评论!");            //    window.location.href = 'http://www.chinaaet.com/user/login/?returnurl=' + window.location;             //    return;            //}            if (editor.isEmpty()) {                alert("评论不能为空!");                return false;            }                            if(clientUserID <=0){                var imageCode=$("#txtValidCode").val();                if(imageCode==""){                    alert("请输入验证码");                    return false;                }                if(!validImageCode()){                    alert("验证码错误!");                    return false;                }            }                            return true;        })        $("#vote").click(function () {            var postid = $("#postid").val();            var contestid = $("#txtcontestID").val();            $.ajax({                url: "/ajax.aspx?otype=vote&id=" + postid + "&cid=" + contestid,                dataType: "json",                cache:false,                success: function (msg) {                    if (msg.isok == true) {                        $("#votoCount").html(msg.vote);                    }                    var altmessage = msg.message;                    alert(altmessage);                    if (altmessage == '请登录后再投票') {                        window.location.href = 'http://www.chinaaet.com/user/login/?returnurl=' + window.location;                        return;                    }                }            })        });        $("#txtValidCode").focus(function () {              LoadCaptchaImage();                          });                  SyntaxHighlighter.defaults['toolbar'] = true;        SyntaxHighlighter.defaults['collapse'] = true;        SyntaxHighlighter.config.strings.help = "";        SyntaxHighlighter.config.strings.expandSource = "+ 查看代码";        SyntaxHighlighter.autoloader.apply(null, path(          'bash shell             @shBrushBash.js',          'cpp c                  @shBrushCpp.js',          'c# c-sharp csharp      @shBrushCSharp.js',          'css                    @shBrushCss.js',          'java                   @shBrushJava.js',          'js jscript javascript  @shBrushJScript.js',          'perl pl                @shBrushPerl.js',          'php                    @shBrushPhp.js',          'py python              @shBrushPython.js',          'ruby rails ror rb      @shBrushRuby.js',          'sql                    @shBrushSql.js',          'vb vbnet               @shBrushVb.js',          'verilog verilog        @shBrushVerilog.js',          'xml xhtml xslt html    @shBrushXml.js'        ));        SyntaxHighlighter.all();    })    var IsLoadCaptchaImage=false;    var preCaptchImageId=null;    function LoadCaptchaImage(){        if(!IsLoadCaptchaImage){            $.ajax({                url: "/tools/ImageCode.ashx?a=guid&id="+ preCaptchImageId,                                    cache:false,                success: function (msg) {                                           GetImageCode(msg);                }            });         }         }    function ReloadCaptchaImage(){        IsLoadCaptchaImage=false;        LoadCaptchaImage();    }    function GetImageCode(id){         IsLoadCaptchaImage=true;        preCaptchImageId=id;        $("#txtCodeImgId").val(id);                   $("#captchaImage").html('<a href="javascript:ReloadCaptchaImage()"><img src="/tools/ImageCode.ashx?a=img&id='+id+'" alt="验证码" title="刷新图片" width="100" height="30" border="0"/></a><a href="javascript:ReloadCaptchaImage()">换一张</a>');    }    function validImageCode()    {        var isValid=false;        var imageCode=$("#txtValidCode").val();        if(imageCode!=""){            $.ajax({                url: "/tools/ImageCode.ashx?a=valid&id="+ preCaptchImageId +"&code=" +imageCode,                                    cache:false,                async:false,                success: function (msg) {                                            if(msg=="true"){                        isValid=true;                    }                }            });         }                    return isValid;    }    function path() {        var args = arguments,            result = []        ;        for (var i = 0; i < args.length; i++)            result.push(args[i].replace('@', 'http://s1.chinaaet.com/Js/syntaxhighlighter/scripts/'));        return result    }</script><script type="text/javascript">window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"1","bdMiniList":["sqq","renren","kaixin001","print"],"bdPic":"","bdStyle":"1","bdSize":"16"},"share":{},"image":{"viewList":["tsina","qzone","weixin","youdao"],"viewText":"分享到:","viewSize":"16"}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script><script type="text/javascript">    document.write("<img src='http://www.chinaaet.com/Tools/Stats.aspx?cid=22&url=" + encodeURIComponent(document.location.href) + "&referrer=" + encodeURIComponent(document.referrer) + "&cate=EDA' width='0' height='0' />");</script>



    0 0