测试123

来源:转载

assign data_in_abs = data_in[5]? (~(data_in[5:0]) + 1'b1):data_in;

// 计算1024个输入数据的平均功率

always @(posedge clk or negedge reset_n)

begin

if(reset_n == 1'b0)

begin

data_in_sum <= 32'd0; //累加寄存器清零

sum_cnt <= 16'd0; //清零累加计数

interrupt_flag <= 1'b0; //中断标志清零

power_sum <= 32'd0;

end

else

begin

if(sum_cnt == 16'd1024)

begin

sum_cnt <= 16'd0; //清零累加计数

interrupt_flag <= 1'b1; //触发中断信号

power_sum <= data_in_sum; //将总的功率进行输出

data_in_sum <= 32'd0; //累加寄存器清零

end

else

begin

sum_cnt <= sum_cnt + 1'b1;

interrupt_flag <= 1'b0; //中断标志清零

data_in_sum <= data_in_sum + data_in_abs[5:0];//累加操作

end

end

end

分享给朋友:
您可能感兴趣的文章:
随机阅读: