N
Neeraj
Guest
Hi everyone,
First, a little context. A friend of mine wanted to design a
synthesizable circuit which would count the number of consecutive zeros
in a byte in ONE clock cycle (the byte in question being known
beforehand). His solution used a for loop in the following manner:
//----code----
integer i;
integer count_zeros; //keeps track of the number of zeros
reg array [7:0]; //the byte in question is stored here
//clock defined
//count_zeros initialized to zero at start of simulation
//----code----
always @ (posedge clock) begin
for(i = 0; i < 8; i=i + 1) begin
if(array == 0) begin
count_zeros = count_zeros + 1;
end
end
end
Now, the question he asked me was: If the for loop gets synthesized to
a counter, what clock does it work on? In other words, what signal does
the counter use as a reference to increment its value?
My answer was that the logic synthesizer would be smart enough to
create a signal that basically would be 8 times the clock frequency
(since it needed to increment eight times in one clock).
What I'm wondering is, is my answer correct? Would the logic
synthesizer actually be astute enough to generate the required clock?
Thanks for any help/ comments,
Ciao.
First, a little context. A friend of mine wanted to design a
synthesizable circuit which would count the number of consecutive zeros
in a byte in ONE clock cycle (the byte in question being known
beforehand). His solution used a for loop in the following manner:
//----code----
integer i;
integer count_zeros; //keeps track of the number of zeros
reg array [7:0]; //the byte in question is stored here
//clock defined
//count_zeros initialized to zero at start of simulation
//----code----
always @ (posedge clock) begin
for(i = 0; i < 8; i=i + 1) begin
if(array == 0) begin
count_zeros = count_zeros + 1;
end
end
end
Now, the question he asked me was: If the for loop gets synthesized to
a counter, what clock does it work on? In other words, what signal does
the counter use as a reference to increment its value?
My answer was that the logic synthesizer would be smart enough to
create a signal that basically would be 8 times the clock frequency
(since it needed to increment eight times in one clock).
What I'm wondering is, is my answer correct? Would the logic
synthesizer actually be astute enough to generate the required clock?
Thanks for any help/ comments,
Ciao.