always @(posedge clk) begin
if (~rst) begin // ?????
sclk_cnt <= 9'b0;
end else if (~resetb) begin // ???
sclk_cnt <= 9'b0;
end else begin
sclk_cnt <= sclk_cnt + 1;
end
end
assign sclk = sclk_cnt[8];////////9??5
// ????????????
always @(posedge clk) begin
if (~resetb) begin
dclk_cnt <= 7'b0; // ???7????dclk_cnt[6]
dclk <= 1'b0;
end else begin
// ?????
if (dclk_cnt == 7'd63) begin // 64??????????
dclk_cnt <= 7'b0;
dclk <= ~dclk; // ?????????dclk
end else begin
dclk_cnt <= dclk_cnt + 1;
end
end
end
assign rst_dclk = (sclk ^ dclk);
//????
always @ (posedge dclk or negedge resetb)//
begin
if (resetb==0)
begin
stop<=0;
stopcount <= 5'b0;
end
else
if (stopcount==24)
begin
stopcount <= 5'b0;
stop<=1;
end
else begin
stopcount <= stopcount+1;
end
end
// ???sel load????
always @ (posedge dclk or negedge resetb)
begin
if (resetb==0)
begin
stopcount2 <= 5'b0;
end
else
if (stopcount2==26)
begin
stopcount2 <= 5'b0;
end
else
begin
stopcount2 <= stopcount2+1;
end
end
assign dclk2=dclk&~stop;
//????&??
always@(posedge sclk or negedge resetb)
begin
if(!resetb)
begin
sdo <= 0;
datak<=256'h923456789ABCDEF123456789ABCDEFF0123456789ABCDEF0123456789ABC9ABD;
end
else
begin
datak<=datak<<1;
sdo <= datak[255];
//sdo <= 1;
end
end
assign clkout=dclk2;
always @ (posedge clk or negedge resetb)//
begin
if (resetb==0)
begin
sel=0;
end
else
if ((stopcount2==25))
begin
sel=1;
end
end
always @ (posedge clk or negedge resetb)//
begin
if (resetb==0)
begin
load=0;
end
else
if ((stopcount2==26))
begin
load=1;
end
end
clk_wiz_0 instance_name
(
// Clock out ports
.clk_out1(clk), // output clk_out1
// Status and control signals
.reset(~rst),
// input reset
.locked(locked), // output locked
// Clock in ports
.clk_in1_p(clk_in1_p), // input clk_in1_p
.clk_in1_n(clk_in1_n));
clk_wiz_1 clk_wiz_inst
(
// Clock out ports
.clk_out1(), // output clk_out1
// Status and control signals
.reset(resetb), // input reset
.locked(locked2), // output locked
// Clock in ports
.clk_in1_p(clk_in2_p), // input clk_in1_p
.clk_in1_n(clk_in2_n));