zoukankan      html  css  js  c++  java
  • 简易信号发生器的设计

         晚上写了一个简易的信号发生器的程序,上机验证成功,通过了 Signal Tap II验证。

         Mif 文件的数据是通过  mif_maker2010 这个软件生成的,它的使用教程通过这个链接可以找到:https://www.cnblogs.com/qidaiymm/p/6007704.html

         硬件环境为:DE1-SOC

         软件环境为:Quartus II_15.0

         可以通过四个拨码开关来进行波形及频率的切换,那个ROM-1 PORT的使用我就不介绍了

         实现的效果为:

         

        

      

    代码如下:

    模块1:

    module control_freq(
      clk,
      rst_n,
      key_in,
      fout
    );
    input clk;
    input rst_n;
    input[1:0] key_in;
    output fout;
    reg[3:0] cnt;
    reg clk_2,clk_4;
    reg fout;
    always@(posedge clk or negedge rst_n) 
      if(!rst_n)
        begin
          cnt<=4'd0;
      clk_2<=0;
      end
      else if(cnt==4'd1)
        begin
          cnt<=4'd0;
      clk_2<=~clk_2;
      end
      else
        cnt<=cnt+1'b1;
    always@(posedge clk_2 or negedge rst_n)
      if(!rst_n)
        clk_4<=0;
      else
        clk_4<=~clk_4;
    always@(posedge clk or negedge rst_n)
     begin
       if(!rst_n)
       fout<=0;
     else
       begin
        case(key_in)
          0:fout<=clk_2;
        1:fout<=clk_4;
        default:;
          endcase
         end
     end
     
    endmodule
     
    模块2:
    module sw_control(
      clk,
      rst_n,
      data_out,
      sw
    );
    input clk;
    input rst_n;
    input[1:0] sw;
    output[7:0] data_out;   //数据输出
    reg[7:0] address;
    wire[7:0] q1,q2,q3;       //地址寄存器
    reg[7:0] data_out;
    always@(posedge clk or negedge rst_n)
      if(!rst_n)
        address <= 8'd0;
      else if(address==255)
        address <=8'd0;
      else
        address <= address +1'b1;
     
    san_jiao_xing san_jiao_xing(
     .address(address),
     .clock(clk),
     .q(q1)
    );
    sin sin(
       .address(address),
     .clock(clk),
     .q(q2)
    );
    fang_bo fang_bo(
       .address(address),
     .clock(clk),
     .q(q3)  
    );
    always@(posedge clk or negedge rst_n)
      begin
        if(!rst_n)
          data_out<=8'd0;
        else
          begin
            case(sw)
          0:data_out<=q1;
        1:data_out<=q2;
        2:data_out<=q3;
        default:data_out<=8'd0;
            endcase
          end
      end
    endmodule
     
    //顶层模块
    module AD_pulse_signal_generator(
      clk,
      rst_n,
      key_in,
      sw,
      data_out
    );
    input clk;
    input rst_n;
    input[1:0] key_in;
    input[1:0] sw;
    output[7:0] data_out;
    control_freq u1(
      .clk(clk),
      .rst_n(rst_n),
      .key_in(key_in),
      .fout(fout)
    );
    sw_control u2(
      .clk(fout),
      .rst_n(rst_n),
      .data_out(data_out),
      .sw(sw)
    );
    endmodule
     
    欢迎各位朋友批评指正~
  • 相关阅读:
    Wordpress 所有hoor列表
    Redis的PHP操作手册(转)
    thinkphp pathinfo nginx 无法加载模块:Index
    gitlab 创建SSH Keys 报500错
    在docker 中配置hadoop1.2.1 cluser
    docker 配置文件引发的问题
    shell在一个大文件找出想要的一段字符串操作技巧
    php关于金额比较引发的问题(转)
    mac 终端乱码
    Swoole笔记(二)
  • 原文地址:https://www.cnblogs.com/571328401-/p/10581519.html
Copyright © 2011-2022 走看看