spartanthewarrior
Full Member level 2
divide by 5 circuit
Hi All,
Please help me it's urgent.................
Hi All,
Please help me it's urgent.................
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
arvkum02 said:The basic way to design is :
First design a normal divide by N (here N=5) or mod N counter .
Analyses all the waveforms from the flops O/P.
Take a waveform that is high for (N-1)/2 (here 2) clock cycles (over a period of N cycles).
Delay this waveform or flop o/p by half of the clock period (give this signal as an input to a -ve edge triggred flop , the o/p will be delayed by half clock period).
Add the delayed and non delayed signal you will get desired o/p.
Feel free to ask further.
Arvind
koggestone said:as suggested by arvkum02 in above reply , the steps are
1) generate straight forward div-by-5 with 40% duty cycle.
lets say its clkA.
2) feed this clkA to -ve edge triggerd flop . lets say the output is clkB.
3) required 50% duty cycle clk is OR of clkA and clkB.
clk50 = clkA | clkB;
Below is a pseudo code . u can use similar format for div-by-3/7/9/ etc ...
=========================
reg [2:0] count;
always @(posedge clk or negedge reset_n)
if (~reset_n)
count<=0;
else if (count == 3'd4)
count<=0;
else
count <=count+1;
assign clkA = count[1];
always@(negedge clk)
clkB <= clkA;
assign clk50 = clkA | clkB;
============================
In case , they ask u this question in interview ( Which 80% of time this will)
and u get hired , then Thank me (and arvkum2) in your Heart!!.
senthilos said:Hi Koggestone,
In your verilog code shouldn't CLKA be computed as
assign clkA = ~(count[1] | count[2]);
module clkdiv(
input CLKIN,
output clkout
);
reg [2:0] counter1;
reg [2:0] counter2;
wire clkout1;
wire clkout2;
always @(posedge CLKIN)
if(counter1!=4) counter1 <= counter1+1;
else counter1 <= 0;
always @(negedge CLKIN)
if(counter2!=4) counter2 <= counter2+1;
else counter2 <= 0;
assign clkout1 = counter1[1];
assign clkout2 = counter2[1];
assign clkout = clkout1|clkout2;
endmodule