简易信号发生器的设计

Posted 571328401-

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了简易信号发生器的设计相关的知识,希望对你有一定的参考价值。

     晚上写了一个简易的信号发生器的程序,上机验证成功,通过了 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;
[email protected](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;
[email protected](posedge clk_2 or negedge rst_n)
  if(!rst_n)
    clk_4<=0;
  else
    clk_4<=~clk_4;
[email protected](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;
[email protected](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)  
);
[email protected](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
 
欢迎各位朋友批评指正~

 

以上是关于简易信号发生器的设计的主要内容,如果未能解决你的问题,请参考以下文章

eda 信号发生器

2019年全国电子设计大赛D题《简易电路特性测试仪》输入阻抗测量

信号发生器电路中采用了多少级,多少放大器

G题:简易数字信号时序分析装置(高职高专)--2018年TI杯大学生电子设计竞赛

G题:简易数字信号时序分析装置(高职高专)--2018年TI杯大学生电子设计竞赛

信号发生器的工作原理