📄 clktest.v
字号:
module clockadjuster(clkin,clkout,test_item,delay_enable,output_select);
input clkin;
output clkout;
input [1:0] test_item; //00-- test function disable
//01-- increase duty-cycle test
//10-- decrease duty-cycle test
//11-- clk delay test
input [31:0] delay_enable;
input [4:0] output_select;
wire [31:0] temp_clk;
reg delay_clk = 1'b0;
reg clkout = 1'b0;
//Instant 32 x AND gate in series to delay clkin
assign temp_clk[0] = clkin & delay_enable[0];
genvar i;
generate
for (i=0; i < 31; i=i+1)
begin: andgate
assign temp_clk[i+1] = temp_clk[i] & delay_enable[i+1];
end
endgenerate
//Generate clk for adjusting duty-cycle and phase of clkout
always @(output_select,temp_clk)
begin
case(output_select)
5'h00 : delay_clk <= temp_clk[0];
5'h01 : delay_clk <= temp_clk[1];
5'h02 : delay_clk <= temp_clk[2];
5'h03 : delay_clk <= temp_clk[3];
5'h04 : delay_clk <= temp_clk[4];
5'h05 : delay_clk <= temp_clk[5];
5'h06 : delay_clk <= temp_clk[6];
5'h07 : delay_clk <= temp_clk[7];
5'h08 : delay_clk <= temp_clk[8];
5'h09 : delay_clk <= temp_clk[9];
5'h0a : delay_clk <= temp_clk[10];
5'h0b : delay_clk <= temp_clk[11];
5'h0c : delay_clk <= temp_clk[12];
5'h0d : delay_clk <= temp_clk[13];
5'h0e : delay_clk <= temp_clk[14];
5'h0f : delay_clk <= temp_clk[15];
5'h10 : delay_clk <= temp_clk[16];
5'h11 : delay_clk <= temp_clk[17];
5'h12 : delay_clk <= temp_clk[18];
5'h13 : delay_clk <= temp_clk[19];
5'h14 : delay_clk <= temp_clk[20];
5'h15 : delay_clk <= temp_clk[21];
5'h16 : delay_clk <= temp_clk[22];
5'h17 : delay_clk <= temp_clk[23];
5'h18 : delay_clk <= temp_clk[24];
5'h19 : delay_clk <= temp_clk[25];
5'h1a : delay_clk <= temp_clk[26];
5'h1b : delay_clk <= temp_clk[27];
5'h1c : delay_clk <= temp_clk[28];
5'h1d : delay_clk <= temp_clk[29];
5'h1e : delay_clk <= temp_clk[30];
5'h1f : delay_clk <= temp_clk[31];
endcase
end
//Generate module output clk
always @ (test_item,clkin,delay_clk)
begin
case (test_item)
2'b00 : clkout <= clkin;
2'b01 : clkout <= clkin | delay_clk;
2'b10 : clkout <= clkin & (~delay_clk);
2'b11 : clkout <= delay_clk;
endcase
end
endmodule
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -