A have 3 clocks(clk1, clk2, clk3) and I need to make a switch between these 3 clocks. My output master clock is CLK. I have a parameter, let's say 1000. I need to make first 200 pulses of CLK with clk1, then 600 pulses of CLK with clk2, then last 200 pulses of CLK with clk3. How can I implement this in verilog?? Thanks,
clocks switch
Dec 01, 2004
3 Replies
Hi Dan,
You can use an assignment statement to create a input mux to switch your clocks. Something like this should do the trick:
module mux3 (clk1, clk2, clk3, select, clkout);
input clk1, clk2, clk3; input [1:0]select; output clkout;
wire clkout;
assign clkout = select == 2'b00 ? clk1 : select == 2'b01 ? clk2 : clk3; //
10 or 11 would select clk3endmodule
Then all you need to do is to make a counter that's based on the selected clkout to change your switch signal.
Just something like always @(posedge clkout) counter I need to make first 200 pulses of CLK with clk1, then 600 pulses of
080508060409080902080909 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit
Hi Dan,
You need to draw wave forms of the 3 clocks and their individual select signals to make sure that they will not generate glitches at the transition time. (Think of a circuit when the select signal goes low and clock edge goes high at the same time, will an unwanted glitch be generated?)
If the clocks are totally independent with each other, you need to use double-FFs to synchronize between async boundary for each transition to eliminate meta-stable possibilities. The circuit is a lot more complex than the circuit below.
It is a little simpler (but you still need to check the waveforms thoroughly) if the 3 clocks are generated from the same source.
The counter should be simple to implement.
Ch>Matthew Plante wrote:
Join the Discussion
Have something to add? Share your thoughts — no account required.
Didn't find your answer?
Ask the community — no account required