synchronization between 2 clock domains

Status
Not open for further replies.

yaqub

Newbie level 1
Joined
Sep 10, 2009
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
PAKistan
Activity points
1,295
synchronization of 2 clocks

hey!
i m trying to synchronize between 2 clock domains which differ only slighlty in frequency(mesosynchronous). the problem is that the counters used in both domains increment by a value of 2 whenver the data goes from high to low. the counters should actually increment by 1 which they do when there is no data on the data bus and even for the rising edge of the data.
at negative edges of the data the counters misbehave e.g instead of going from 1 to 2 it goes from 1 to 3. i have figured out that the counter block get activated on both the edges of clock when data goes high to low whereas it should only be activated at rising edges..i am using spartan 3 fpga
here are the codes
///simple counter
module counter(clk,count,reset);
input clk,reset;
output [1:0] count;
reg [1:0] count;

always @ (posedge clk or posedge reset)//posedge
if (reset)
count<=2'b00;
else if (count==2'b11)
count<=2'b01;
else
count<=count+1'b1;




// onehot coder
module count_ring(clk,in_count,out_count);
input clk;
input [1:0] in_count;
output [2:0] out_count;
reg [2:0] out_count;
always @ (negedge clk)//posedge
case (in_count)

2'b01: out_count<=3'b001;
2'b10: out_count<=3'b010;
2'b11: out_count<=3'b100;
default : out_count<=3'b000;
endcase



endmodule
 

2 clk counter

Hi,

Try this one!

 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…