测试程序:clk是2M的数据写入时钟。
module dactest(clk,rst,dac_data);
input clk,rst;
output[13:0] dac_data;
reg[13:0] dac_data;
always@ (posedge clk)
begin
if(!rst)
begin
dac_data<=14'b0;
end
else
begin
dac_data<=dac_data+1;
if(dac_data>14'//b11111111111110)
dac_data<=14'b0;
end
end
endmodule