中级会员
- 积分
- 490
- 金钱
- 490
- 注册时间
- 2019-1-18
- 在线时间
- 101 小时
|
6金钱
- module sin_creater(
- input clk,
- input rst_n,
- input sin_creater_en,
- output [7:0] sin_dat
- );
- //parameter SIN_FREQ = 'd12_000;
- parameter SIN_FREQ_ADJ = 'd156250000/12000/100;
- parameter [4:0] SIN_PHASE = 5'b0;
- reg [31:0] freq_cnt;
- reg [4:0] rd_addr;
- //**********************main code****************************
- rom_256x8b_sinwave sin_source(
- .clock(clk),
- .address(rd_addr),
- .q(sin_dat)
- );
- //freq counter,divide 50m clk
- always @(posedge clk or negedge rst_n) begin
- if(rst_n == 1'b0)
- freq_cnt <= 32'd0;
- else if(!sin_creater_en)
- freq_cnt <= 32'd0;
- else begin
- if(freq_cnt == SIN_FREQ_ADJ)
- freq_cnt <= 32'd0;
- else
- freq_cnt <= freq_cnt + 32'd1;
- end
- end
- //rd_addr to read rom
- always @(posedge clk or negedge rst_n) begin
- if(rst_n == 1'b0)
- rd_addr <= 5'd0 + SIN_PHASE;
- else if(!sin_creater_en)
- rd_addr <= 5'd0 + SIN_PHASE;
- else begin
- if(freq_cnt == SIN_FREQ_ADJ)
- rd_addr <= rd_addr + 5'd1;
- end
- end
- endmodule
复制代码 给一个正弦波发生器添加了一个使能信号sin_creater_en,当使能端拉高时模块开始工作。经signaltapii抓取波形sin_creater_en拉高信号可以正常进来,但是fq_cnt不走,请问是我设计的逻辑有问题吗?
|
|