Cita:
Código: Seleccionar todo
Have other don.t solder(PIN_M2), you can use a
5X7 volume Crystal oscillator solder on.
Citado fichero:
Moderador: jepalza
Código: Seleccionar todo
Have other don.t solder(PIN_M2), you can use a
5X7 volume Crystal oscillator solder on.
Código: Seleccionar todo
module clk_detect(/*AUTOARG*/
// Outputs
clk_ok,
// Inputs
sys_clk, reset_n, clk_in
);
input sys_clk, reset_n, clk_in;
output clk_ok;
reg [8:0] count_clk_in;
reg [7:0] count_sys_clk;
reg cy_count_clk_in_r, cy_count_clk_in_rr;
wire reset_cnt = ~cy_count_clk_in_rr & cy_count_clk_in_r;
assign clk_ok = ~count_sys_clk[7];
always@(posedge clk_in or negedge reset_n) begin
if (!reset_n)
count_clk_in <= 0;
else
count_clk_in <= count_clk_in + 1'b1;
end
// double flop synchronizer for clk_in counter carry!
always @(posedge sys_clk or negedge reset_n) begin
if (!reset_n) begin
cy_count_clk_in_r <= 1'b0;
cy_count_clk_in_rr <= 1'b0;
end else begin
cy_count_clk_in_r <= count_clk_in[8];
cy_count_clk_in_rr <= cy_count_clk_in_r;
end
end
// retriggerable monoshot!
always @(posedge sys_clk or negedge reset_n) begin
if (!reset_n) begin
count_sys_clk <= 0;
end else begin
if (reset_cnt)
count_sys_clk <= 0;
else if (!count_sys_clk[7])
count_sys_clk <= count_sys_clk + 1'b1;
end
end
endmodule // clk_detect