-4
\$\begingroup\$

I have a ZYBO board with a 125 Mhz clock that am I trying to to bring down to 0.5 Hz in Verilog. Could anyone help me with the code to do this?

\$\endgroup\$
0
\$\begingroup\$

125,000,000 / 250,000,000 = 0.5 You will need counter of 27 bits to accommodate half of 250M minus 1

reg [26:0] counter;
reg clk_low;

always@(posedge clk or negedge reset) begin
    if(!reset) begin
        counter[26:0] <= {27{1'b0}};
        clk_low <= 1'b0;
    end else begin
        if(counter[26:0]==27'h773593F) begin
            clk_low <= ~clk_low;
            counter[26:0] <= {27{1'b0}};
        end else counter[26:0] <= counter[26:0] + 1'b1;
    end
end
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.