模块代码
module DAC8831(
SCLK,
Clk,
Rst_n,
SDI, //串行输入
CS, //使能端
updataReq, //数据更新信号
updatadone, //数据输出有效信号
ctrlword //控制字
);
input Rst_n;
input updataReq;
input Clk;
input [15:0] ctrlword;
output reg CS;
output reg SCLK;
output reg SDI;
output reg updatadone;
reg [5:0]count; //序列计数器
always@(posedge Clk or negedge Rst_n)
if(!Rst_n)
count<=6'd0;
else if(updataReq==1|(count!=6'd0))
begin
if(count==6'd34)
count<=6'd0;
else
count<=count+6'd1;
end
else
count<=6'd0;
always@(posedge Clk or negedge Rst_n)
if(!Rst_n)
begin
SCLK<=1'b0; CS<=1'b1;
updatadone<=1'b0;
end
else
begin
case(count)
0:
begin
SCLK<=1'b0;
CS<=1&