zoukankan      html  css  js  c++  java
  • Xilinx ISE14.1用Verilog语言实现一个半加器并测试

    <一>建立一个工程

          注:Xilinx ISE的安装在此不再过多说明,网上有参考资料

    1.打开软件进入如下界面

     

    2.创建工程

    File-->New Project

     

     3.创建文件(我取名为firstTry)

    右键选择New Source;

    设置参数

    4.编写代码

    module half_add(     input a,     input b,     output sum,     output cout     );

               assign sum = a^b;

               assign cout = a&b;

    endmodule

    5.测试代码

    选择项目并且右键(New Source)

    测试代码如下:

    module half_addtest;

     // Inputs

     reg a;  

    reg b;

     // Outputs  

    wire sum;  

    wire cout;

     // Instantiate the Unit Under Test (UUT)  

    half_add uut (   .a(a),   .b(b),   .sum(sum),   .cout(cout)  );

     initial begin  

     // Initialize Inputs   

    a = 0;  

    b = 0;

      // Wait 100 ns for global reset to finish   

    //#100; 这句最好暂时不用          

    // Add stimulus here      

    #0.001 a = ~a;   

    #0.001 b = ~b;   

    #0.001 a = ~a;  

     #0.001 b = ~b;   

    #0.001 a = ~a;   

    #0.001 b = ~b;   

    #0.001 a = ~a;   

    #0.001 b = ~b;   

     end      

    endmodule

    测试步骤:

    6.测试代码分析

    #0.001 a = ~a;   

    注意:#N中的N是以ns为单位的,而在测试截图中的时间单位是ps,其中 1ns = 1000 ps;

    说到这里也知道测试代码中的#100为什么不要了的原因

    这句话2就是从执行这句代码起,等待0.001ns后a取反,然后结合测试截图就可以理解了。

    7.生成顶层文件

    双击Synthesize中的View RTL Schematic 

  • 相关阅读:
    汇编指令lodsb和stosb、lodsd和stosd
    编码查询
    CLD汇编指令
    Win32编程
    MessageBox
    windows 数据类型
    STL总结
    解析结构化异常处理(SEH)(第二部分)
    FS[XX]
    ShellCode入门(提取ShellCode)
  • 原文地址:https://www.cnblogs.com/LCCRNblog/p/3397666.html
Copyright © 2011-2022 走看看