飞道的博客

基于FPGA的2ASK调制仿真

214人阅读  评论(0)

2ASK调制技术总的来说很简单,先产生二进制基带信号,产生一个载波信号,利用一个2选1开关电路进行输出。比如为1输出载波,为0则置0。

按照这样的思想,我们可以得出2FSK、2PSK的调制。对于2FSK,要产生两个不同频率的载波信号,最后为1输出一个,为0输出另外一个。2PSK则只用产生一个,为1,输出,为0取反输出。

下面介绍2ASK整体模块的实现,最后文末给出整个示例工程。至于2FSK、2PSK,大家应该能举一反三,轻松完成。

我们先来确定一些参数。比如说我这里选取系统时钟为50M,经过50分频后为1M,利用分频后的时钟来产生基带信号,那么码元速率就为1M。至于载波信号,我这里选取4M。这些参数大家可以按照实际情况来改。

时钟分频模块

module clk_div(
 input clk, 
 output reg clk_out
);
reg [13:0] cnt;
parameter N = 50;
always @(posedge clk)
begin
 if(cnt == N/2 - 1)begin
  cnt <= 14'b0;
  clk_out <= ~clk_out;
 end
 else 
  cnt <= cnt + 1'b1;
end
endmodule

二进制序列生成模块

module MXL(
 input clk,
 output reg out
);
reg[4:0]tmp = 5'b0;
always @(posedge clk)
begin
 if(tmp > 5'd31)
  tmp <= 5'd0;
 else
  tmp <= tmp + 1'b1;
 case(tmp)
  5'd0: out <= 0;
  5'd1: out <= 0;
  5'd2: out <= 1;
  5'd3: out <= 1;
  5'd4: out <= 1;
  5'd5: out <= 1;
  5'd6: out <= 0;
  5'd7: out <= 0;
  5'd8: out <= 0;
  5'd9: out <= 0;
  5'd10: out <= 1;
  5'd11: out <= 1;
  5'd12: out <= 1;
  5'd13: out <= 1;
  5'd14: out <= 0;
  5'd15: out <= 0;
  5'd16: out <= 1;
  5'd17: out <= 0;
  5'd18: out <= 1;
  5'd19: out <= 0;
  5'd20: out <= 1;
  5'd21: out <= 1;
  5'd22: out <= 0;
  5'd23: out <= 1;
  5'd24: out <= 1;
  5'd25: out <= 0;
  5'd26: out <= 1;
  5'd27: out <= 1;
  5'd28: out <= 1;
  5'd29: out <= 1;
  5'd30: out <= 0;
  5'd31: out <= 0;
 endcase
end
endmodule

NCO模块(生成载波信号)
该模块基于查表法,sin_table提供。
频率计算方法,这里我们选取16位cnt,时钟为50M,那么频率为50M*5243/2^16=4M
可以通过改变cnt,利用上述计算方式,生成任意频率信号。

module nco(
 input clk,
 output reg [7:0]sin
);
reg [15:0]cnt;
wire [7:0]sin_table_out;
initial cnt <= 0;
always @(posedge clk)
begin
 cnt <= cnt + 16'd5243;
 sin <= sin_table_out;
end
sin_table INS_SINTABLE(cnt[15:7],sin_table_out);
endmodule

2选1开关电路

module choose(
 input [7:0]data_in,
 input sel,
 output [7:0]data_out
);
reg[7:0]daout;
always @(sel)
begin
 if(sel)
  daout <= data_in;
 else 
  daout <= 8'd0;
end
assign data_out = daout;
endmodule

最后附上用Signal Tap仿真出来的图

哈哈,一个简单的2ASK调制仿真就出来了。如果感兴趣的话就按照我开头所讲的方法,把2FSK和2PSK实现一下吧。

最后附上整个示例工程文件
链接:https://pan.baidu.com/s/17YGL-9Stcr_uSsyEiJg0SQ

参考资料
https://blog.csdn.net/VCA821/article/details/80768078


转载:https://blog.csdn.net/john_cxc/article/details/104590047
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场