191k views
5 votes
Counter-based Clock divider] See the "1Hz clock generation" part in lab9.v, which is a counter-based clock divider that generates 1 Hz clock signal out of the given 50MHz clock (CLOCK_50). In the code, the counter (clk_count) resets to 0 upon reset, then increases by 1 whenever the rising edge of CLOCK_50 arrives. The clock output (CLK_lHz) is ' 1 ' until the counter value reaches a half of the threshold (half_th). Then, while the counter value is between half_th and th−1, the clock output is ' 0 '. When it reaches the constant number defined as th, the counter value resets to 0 . This way, the period of the clock output (CLK_1Hz) becomes th∗T−CLK, where T_CLK denotes the clock period of the original clock (CLOCK_50).

In our case, we aim at 1 Hz for CLK_1Hz and the T_CLK is 1/50MHz=20 ns. Calculate the value of th that results in 1 Hz.

1 Answer

5 votes

Final answer:

To generate a 1 Hz clock signal from a 50MHz clock, the threshold value (th) should be set to 25,000,000, as this value would allow the counter-based clock divider to output a signal with the correct frequency.

Step-by-step explanation:

The goal is to calculate the value of th that would allow a counter-based clock divider to generate a 1 Hz clock signal from a 50MHz clock (CLOCK_50), where the given T_CLK (clock period of the original clock) is 20 ns. to find this threshold value, th, we'll use the relationship between the frequency of the output clock and the original clock frequency, given that frequency f is the inverse of the period (T). The desired output frequency f is 1 Hz, which is equivalent to 1 cycle per second. the period T of the desired 1 Hz frequency is the inverse of the frequency, so T = 1/f, and because we want f = 1 Hz, the period T equals 1 second. Since T_CLK is 20 ns, the number of T_CLK periods in one second is 1 second / 20 ns, which gives us 50,000,000.

Therefore, th must be half of this number because the clock output is high for half the time and low for the other half, making th = 25,000,000.

User Khan Abdulrehman
by
7.8k points