EDAboard.com | EDAboard.de | EDAboard.co.uk | WTWH Media

Can I use Verilog or SystemVerilog to write a state machine

Ask a question - edaboard.com

elektroda.net NewsGroups Forum Index - FPGA - Can I use Verilog or SystemVerilog to write a state machine

Goto page 1, 2, 3, 4, 5  Next

Weng Tianxiang
Guest

Sat Jan 05, 2019 5:45 am   



Hi,

Can I use Verilog or SystemVerilog to write a state machine with clock gating function?

I know VHDL has no such function and want to know if Verilog or SystemVerilog has the clock gating function for a state machine.

Thank you.

Weng

Nicolas Matringe
Guest

Sat Jan 05, 2019 12:45 pm   



On 05/01/2019 05:29, Weng Tianxiang wrote:
Quote:
Hi,

Can I use Verilog or SystemVerilog to write a state machine with clock gating function?

I know VHDL has no such function and want to know if Verilog or SystemVerilog has the clock gating function for a state machine.


Clock gating can be written in any language you like. It's FPGAs that
don't support clock gating.

Nicolas

Weng Tianxiang
Guest

Sat Jan 05, 2019 3:45 pm   



On Saturday, January 5, 2019 at 3:44:39 AM UTC-8, Nicolas Matringe wrote:
Quote:
On 05/01/2019 05:29, Weng Tianxiang wrote:
Hi,

Can I use Verilog or SystemVerilog to write a state machine with clock gating function?

I know VHDL has no such function and want to know if Verilog or SystemVerilog has the clock gating function for a state machine.

Clock gating can be written in any language you like. It's FPGAs that
don't support clock gating.

Nicolas


Hi Nicolas,

I am asking if Verilog or SystemVerilog has the ability to automatically generate a state machine with clock gating function without any extra new statements? For example, do they have an attribute if the attribute being set the state machine generated will have the clock gating function?

At least VHDL-2008 does not have the ability.

Thank you.

Weng

Nicolas Matringe
Guest

Sat Jan 05, 2019 7:45 pm   



On 05/01/2019 15:18, Weng Tianxiang wrote:

Quote:
Hi Nicolas,

I am asking if Verilog or SystemVerilog has the ability to automatically generate a state machine with clock gating function without any extra new statements? For example, do they have an attribute if the attribute being set the state machine generated will have the clock gating function?


Well then I don't know what that "clock gating function" is, I'm sorry.

Nicolas

KJ
Guest

Sat Jan 05, 2019 8:45 pm   



Apparently you cannot, but yes it can be done by others. It can also be written in VHDL but apparently you don't like how to do that so you state that it can't be done. Perhaps you should more clearly state your problem.

Kevin

Theo
Guest

Sat Jan 05, 2019 10:45 pm   



Weng Tianxiang <wtxwtx_at_gmail.com> wrote:

Quote:
I am asking if Verilog or SystemVerilog has the ability to automatically
generate a state machine with clock gating function without any extra new
statements?


What do you mean 'extra new statements'? This looks to me like clock
gating:


input clk;
input enable;
wire gated;

assign gated = clk & enable;

always @(posedge gated) begin
....
end


Quote:
For example, do they have an attribute if the attribute being
set the state machine generated will have the clock gating function?


I don't know what you mean by that. (System)Verilog's abstraction doesn't
generate abstract state machines, it just allows you to write them.
Whatever synthesis tools do with that code is up to them. I presume tools
could pick up the above style if they so desire (I don't know if any ASIC
tools do but expect they would).

Theo

Richard Damon
Guest

Sat Jan 05, 2019 11:45 pm   



On 1/4/19 11:29 PM, Weng Tianxiang wrote:
Quote:
Hi,

Can I use Verilog or SystemVerilog to write a state machine with clock gating function?

I know VHDL has no such function and want to know if Verilog or SystemVerilog has the clock gating function for a state machine.

Thank you.

Weng


One big question is what do you mean by 'clock gating'

As was mentioned, one option for this is to do something like

assign gatedclk = clk & gate;

or sometimes

assign gatedclk = clk | gate;

and then us the gatedclk as the clock. The big issue with this is that
you need to worry about clock skew when you do this, as well as glitches
(the second version works better for gate changing on the rising edge of
clk, but needs to be stable before the falling edge.)

A second thing called 'clock gating' is to condition the transition on
the gate signal, something like

always @(posedge clk) begin
if(gate) begin
.... state machine here.
end
end

This make the machine run on the original clock, but it will only change
on the cycles where the gate signal is true.

VHDL can do the same.

There is no need for a 'special statement', you just do it. If doing
the first version, of actually gating the clock, you may want to use
some implementation defined macro function to buffer the clock and put
it into a low skew distribution network, like may have been done for the
original clock.

Weng Tianxiang
Guest

Sun Jan 06, 2019 2:45 am   



On Saturday, January 5, 2019 at 2:35:28 PM UTC-8, Richard Damon wrote:
Quote:
On 1/4/19 11:29 PM, Weng Tianxiang wrote:
Hi,

Can I use Verilog or SystemVerilog to write a state machine with clock gating function?

I know VHDL has no such function and want to know if Verilog or SystemVerilog has the clock gating function for a state machine.

Thank you.

Weng


One big question is what do you mean by 'clock gating'

As was mentioned, one option for this is to do something like

assign gatedclk = clk & gate;

or sometimes

assign gatedclk = clk | gate;

and then us the gatedclk as the clock. The big issue with this is that
you need to worry about clock skew when you do this, as well as glitches
(the second version works better for gate changing on the rising edge of
clk, but needs to be stable before the falling edge.)

A second thing called 'clock gating' is to condition the transition on
the gate signal, something like

always @(posedge clk) begin
if(gate) begin
... state machine here.
end
end

This make the machine run on the original clock, but it will only change
on the cycles where the gate signal is true.

VHDL can do the same.

There is no need for a 'special statement', you just do it. If doing
the first version, of actually gating the clock, you may want to use
some implementation defined macro function to buffer the clock and put
it into a low skew distribution network, like may have been done for the
original clock.


Hi Theo and Richard,

Thank you for your help.

Using clock gating function is to save power consumption. Why I ask the question is:

A cache line in Cache I, Cache II or even Cache III in a CPU usually has 64 (2**6) bytes and each cache line must have a state machine to keep data coherence among data over all situations.

For a 6M (2**22 + 2**21) bytes cache II (the most I have seen in current market) a CPU must have at least (2**16 + 2**15) state machines, ~= 100,000, and those ~100,000 state machines don't change states most of time.

In above situation each of the ~100,000 state machines with each having more than 10 states must have a clock gating function to save power consumption:

when it will not change states on the next cycle, a clock pulse should not be generated to keep the state unchanged and save power consumption.

Do you think if it is reasonable?

For an application implemented in a FPGA chip, the clock gating function may not be necessary because too few state machines are implemented in any normal application.

Actually I realized how to implement the power consumption scheme in VHDL as follows after the post is posted:

type STATE_TYPE is (s0, s1, ..., Sn);

signal WState, WState_NS: STATE_TYPE;

....;
a: process(clk)
begin
if rising_edge(clk) then
if SINI then
WState <= S0;

elsif WState /= WState_NS then -- WState /= WState_NS is necessary!
WState <= WState_NS;
end if;
end if;
end process;

b: process(all)
begin
case WState is
when S0 =>
if C00 then
WState_NS <= S1;

elsif C01 then
WState_NS <= S2;

else
WState_NS <= S0;
end if;

...;
end case;
end process;

Thank you.

Weng

Richard Damon
Guest

Sun Jan 06, 2019 3:45 am   



On 1/5/19 8:23 PM, Weng Tianxiang wrote:
Quote:
On Saturday, January 5, 2019 at 2:35:28 PM UTC-8, Richard Damon wrote:
On 1/4/19 11:29 PM, Weng Tianxiang wrote:
Hi,

Can I use Verilog or SystemVerilog to write a state machine with clock gating function?

I know VHDL has no such function and want to know if Verilog or SystemVerilog has the clock gating function for a state machine.

Thank you.

Weng


One big question is what do you mean by 'clock gating'

As was mentioned, one option for this is to do something like

assign gatedclk = clk & gate;

or sometimes

assign gatedclk = clk | gate;

and then us the gatedclk as the clock. The big issue with this is that
you need to worry about clock skew when you do this, as well as glitches
(the second version works better for gate changing on the rising edge of
clk, but needs to be stable before the falling edge.)

A second thing called 'clock gating' is to condition the transition on
the gate signal, something like

always @(posedge clk) begin
if(gate) begin
... state machine here.
end
end

This make the machine run on the original clock, but it will only change
on the cycles where the gate signal is true.

VHDL can do the same.

There is no need for a 'special statement', you just do it. If doing
the first version, of actually gating the clock, you may want to use
some implementation defined macro function to buffer the clock and put
it into a low skew distribution network, like may have been done for the
original clock.

Hi Theo and Richard,

Thank you for your help.

Using clock gating function is to save power consumption. Why I ask the question is:

A cache line in Cache I, Cache II or even Cache III in a CPU usually has 64 (2**6) bytes and each cache line must have a state machine to keep data coherence among data over all situations.

For a 6M (2**22 + 2**21) bytes cache II (the most I have seen in current market) a CPU must have at least (2**16 + 2**15) state machines, ~= 100,000, and those ~100,000 state machines don't change states most of time.

In above situation each of the ~100,000 state machines with each having more than 10 states must have a clock gating function to save power consumption:

when it will not change states on the next cycle, a clock pulse should not be generated to keep the state unchanged and save power consumption.

Do you think if it is reasonable?

For an application implemented in a FPGA chip, the clock gating function may not be necessary because too few state machines are implemented in any normal application.

Thank you.

Weng


One issue with gated clocks is that each gating of the clock needs to be
considered a different clock domain from every other gating of the clock
and from the ungated clock, because the gating (and rebuffering) of the
clock introduces a delay in the clock, so you need to take precautions
when the signal passes from one domain to another. A FPGA might have,
and a gate array may provide a special circuit to generate a set of
gated clocks that will be kept in good enough alignment to not need
this, but then that would be a special application macro that needs to
be instanced.

Second, the power consumption between my first and second method (actual
gating of the clock and using a clock enable) is primarily in the power
to drive the clock line as the clock enable also keeps the state the
same in the 'skipped' clock cycle.

Weng Tianxiang
Guest

Sun Jan 06, 2019 6:45 pm   



On Saturday, January 5, 2019 at 6:28:35 PM UTC-8, Richard Damon wrote:
Quote:
On 1/5/19 8:23 PM, Weng Tianxiang wrote:
On Saturday, January 5, 2019 at 2:35:28 PM UTC-8, Richard Damon wrote:
On 1/4/19 11:29 PM, Weng Tianxiang wrote:
Hi,

Can I use Verilog or SystemVerilog to write a state machine with clock gating function?

I know VHDL has no such function and want to know if Verilog or SystemVerilog has the clock gating function for a state machine.

Thank you.

Weng


One big question is what do you mean by 'clock gating'

As was mentioned, one option for this is to do something like

assign gatedclk = clk & gate;

or sometimes

assign gatedclk = clk | gate;

and then us the gatedclk as the clock. The big issue with this is that
you need to worry about clock skew when you do this, as well as glitches
(the second version works better for gate changing on the rising edge of
clk, but needs to be stable before the falling edge.)

A second thing called 'clock gating' is to condition the transition on
the gate signal, something like

always @(posedge clk) begin
if(gate) begin
... state machine here.
end
end

This make the machine run on the original clock, but it will only change
on the cycles where the gate signal is true.

VHDL can do the same.

There is no need for a 'special statement', you just do it. If doing
the first version, of actually gating the clock, you may want to use
some implementation defined macro function to buffer the clock and put
it into a low skew distribution network, like may have been done for the
original clock.

Hi Theo and Richard,

Thank you for your help.

Using clock gating function is to save power consumption. Why I ask the question is:

A cache line in Cache I, Cache II or even Cache III in a CPU usually has 64 (2**6) bytes and each cache line must have a state machine to keep data coherence among data over all situations.

For a 6M (2**22 + 2**21) bytes cache II (the most I have seen in current market) a CPU must have at least (2**16 + 2**15) state machines, ~= 100,000, and those ~100,000 state machines don't change states most of time.

In above situation each of the ~100,000 state machines with each having more than 10 states must have a clock gating function to save power consumption:

when it will not change states on the next cycle, a clock pulse should not be generated to keep the state unchanged and save power consumption.

Do you think if it is reasonable?

For an application implemented in a FPGA chip, the clock gating function may not be necessary because too few state machines are implemented in any normal application.

Thank you.

Weng


One issue with gated clocks is that each gating of the clock needs to be
considered a different clock domain from every other gating of the clock
and from the ungated clock, because the gating (and rebuffering) of the
clock introduces a delay in the clock, so you need to take precautions
when the signal passes from one domain to another. A FPGA might have,
and a gate array may provide a special circuit to generate a set of
gated clocks that will be kept in good enough alignment to not need
this, but then that would be a special application macro that needs to
be instanced.

Second, the power consumption between my first and second method (actual
gating of the clock and using a clock enable) is primarily in the power
to drive the clock line as the clock enable also keeps the state the
same in the 'skipped' clock cycle.


Hi Richard,

There are 2 things to consider on how to generate a clock gating function:
1. Generate CE logic.
2. Make gated clock signal working properly.

You address the part 2) and I emphasize on the part 1).

Is it complex to generate CE logic?

In my understanding generating a clock pulse is consuming more power than skipping the clock pulse.

I want to know if each of CPU ~100,000 state machine implementation actually has clock gating function.

Based on your code I think it is reasonable to think each of CPU ~100,000 state machine implementation actually has clock gating function.

Only CPU designers know their implementation. I need the information.

Thank you.

Weng

Richard Damon
Guest

Sun Jan 06, 2019 7:45 pm   



On 1/6/19 12:08 PM, Weng Tianxiang wrote:
Quote:
On Saturday, January 5, 2019 at 6:28:35 PM UTC-8, Richard Damon wrote:
On 1/5/19 8:23 PM, Weng Tianxiang wrote:
On Saturday, January 5, 2019 at 2:35:28 PM UTC-8, Richard Damon wrote:
On 1/4/19 11:29 PM, Weng Tianxiang wrote:
Hi,

Can I use Verilog or SystemVerilog to write a state machine with clock gating function?

I know VHDL has no such function and want to know if Verilog or SystemVerilog has the clock gating function for a state machine.

Thank you.

Weng


One big question is what do you mean by 'clock gating'

As was mentioned, one option for this is to do something like

assign gatedclk = clk & gate;

or sometimes

assign gatedclk = clk | gate;

and then us the gatedclk as the clock. The big issue with this is that
you need to worry about clock skew when you do this, as well as glitches
(the second version works better for gate changing on the rising edge of
clk, but needs to be stable before the falling edge.)

A second thing called 'clock gating' is to condition the transition on
the gate signal, something like

always @(posedge clk) begin
if(gate) begin
... state machine here.
end
end

This make the machine run on the original clock, but it will only change
on the cycles where the gate signal is true.

VHDL can do the same.

There is no need for a 'special statement', you just do it. If doing
the first version, of actually gating the clock, you may want to use
some implementation defined macro function to buffer the clock and put
it into a low skew distribution network, like may have been done for the
original clock.

Hi Theo and Richard,

Thank you for your help.

Using clock gating function is to save power consumption. Why I ask the question is:

A cache line in Cache I, Cache II or even Cache III in a CPU usually has 64 (2**6) bytes and each cache line must have a state machine to keep data coherence among data over all situations.

For a 6M (2**22 + 2**21) bytes cache II (the most I have seen in current market) a CPU must have at least (2**16 + 2**15) state machines, ~= 100,000, and those ~100,000 state machines don't change states most of time.

In above situation each of the ~100,000 state machines with each having more than 10 states must have a clock gating function to save power consumption:

when it will not change states on the next cycle, a clock pulse should not be generated to keep the state unchanged and save power consumption.

Do you think if it is reasonable?

For an application implemented in a FPGA chip, the clock gating function may not be necessary because too few state machines are implemented in any normal application.

Thank you.

Weng


One issue with gated clocks is that each gating of the clock needs to be
considered a different clock domain from every other gating of the clock
and from the ungated clock, because the gating (and rebuffering) of the
clock introduces a delay in the clock, so you need to take precautions
when the signal passes from one domain to another. A FPGA might have,
and a gate array may provide a special circuit to generate a set of
gated clocks that will be kept in good enough alignment to not need
this, but then that would be a special application macro that needs to
be instanced.

Second, the power consumption between my first and second method (actual
gating of the clock and using a clock enable) is primarily in the power
to drive the clock line as the clock enable also keeps the state the
same in the 'skipped' clock cycle.

Hi Richard,

There are 2 things to consider on how to generate a clock gating function:
1. Generate CE logic.
2. Make gated clock signal working properly.

You address the part 2) and I emphasize on the part 1).

Is it complex to generate CE logic?

In my understanding generating a clock pulse is consuming more power than skipping the clock pulse.

I want to know if each of CPU ~100,000 state machine implementation actually has clock gating function.

Based on your code I think it is reasonable to think each of CPU ~100,000 state machine implementation actually has clock gating function.

Only CPU designers know their implementation. I need the information.

Thank you.

Weng


Actually gating the clock is a single gate (but then in an ASIC it can't
drive much logic, so things start to get more complicated). Making it
work gets things much more complicated, and probably gets you out of the
domain of portable Verilog or VHDL. That is the nature of clock trees.

Thus, step one is in a sense trivial if you are ignoring step two, but
doing step one while ignoring step two is worthless.

I personally don't know whether it is simpler/better to add the clock
enable functionality to the flip flops or gate the clock and deal with
all the timing/buffering issues, and it wouldn't surprise me if it
turned out that which is better very much depends on the process and
other criteria.

The only real answer would be to talk to the process people, but my
guess is that the answer is very much proprietary, and unless it looks
like you are willing and planning on spending the big bucks to actually
do this, won't waste their time talking about it.


Guest

Sun Jan 06, 2019 8:45 pm   



On Sunday, January 6, 2019 at 1:20:16 PM UTC-5, Richard Damon wrote:
Quote:
On 1/6/19 12:08 PM, Weng Tianxiang wrote:
On Saturday, January 5, 2019 at 6:28:35 PM UTC-8, Richard Damon wrote:
On 1/5/19 8:23 PM, Weng Tianxiang wrote:
On Saturday, January 5, 2019 at 2:35:28 PM UTC-8, Richard Damon wrote:
On 1/4/19 11:29 PM, Weng Tianxiang wrote:
Hi,

Can I use Verilog or SystemVerilog to write a state machine with clock gating function?

I know VHDL has no such function and want to know if Verilog or SystemVerilog has the clock gating function for a state machine.

Thank you.

Weng


One big question is what do you mean by 'clock gating'

As was mentioned, one option for this is to do something like

assign gatedclk = clk & gate;

or sometimes

assign gatedclk = clk | gate;

and then us the gatedclk as the clock. The big issue with this is that
you need to worry about clock skew when you do this, as well as glitches
(the second version works better for gate changing on the rising edge of
clk, but needs to be stable before the falling edge.)

A second thing called 'clock gating' is to condition the transition on
the gate signal, something like

always @(posedge clk) begin
if(gate) begin
... state machine here.
end
end

This make the machine run on the original clock, but it will only change
on the cycles where the gate signal is true.

VHDL can do the same.

There is no need for a 'special statement', you just do it. If doing
the first version, of actually gating the clock, you may want to use
some implementation defined macro function to buffer the clock and put
it into a low skew distribution network, like may have been done for the
original clock.

Hi Theo and Richard,

Thank you for your help.

Using clock gating function is to save power consumption. Why I ask the question is:

A cache line in Cache I, Cache II or even Cache III in a CPU usually has 64 (2**6) bytes and each cache line must have a state machine to keep data coherence among data over all situations.

For a 6M (2**22 + 2**21) bytes cache II (the most I have seen in current market) a CPU must have at least (2**16 + 2**15) state machines, ~= 100,000, and those ~100,000 state machines don't change states most of time.

In above situation each of the ~100,000 state machines with each having more than 10 states must have a clock gating function to save power consumption:

when it will not change states on the next cycle, a clock pulse should not be generated to keep the state unchanged and save power consumption.

Do you think if it is reasonable?

For an application implemented in a FPGA chip, the clock gating function may not be necessary because too few state machines are implemented in any normal application.

Thank you.

Weng


One issue with gated clocks is that each gating of the clock needs to be
considered a different clock domain from every other gating of the clock
and from the ungated clock, because the gating (and rebuffering) of the
clock introduces a delay in the clock, so you need to take precautions
when the signal passes from one domain to another. A FPGA might have,
and a gate array may provide a special circuit to generate a set of
gated clocks that will be kept in good enough alignment to not need
this, but then that would be a special application macro that needs to
be instanced.

Second, the power consumption between my first and second method (actual
gating of the clock and using a clock enable) is primarily in the power
to drive the clock line as the clock enable also keeps the state the
same in the 'skipped' clock cycle.

Hi Richard,

There are 2 things to consider on how to generate a clock gating function:
1. Generate CE logic.
2. Make gated clock signal working properly.

You address the part 2) and I emphasize on the part 1).

Is it complex to generate CE logic?

In my understanding generating a clock pulse is consuming more power than skipping the clock pulse.

I want to know if each of CPU ~100,000 state machine implementation actually has clock gating function.

Based on your code I think it is reasonable to think each of CPU ~100,000 state machine implementation actually has clock gating function.

Only CPU designers know their implementation. I need the information.

Thank you.

Weng


Actually gating the clock is a single gate (but then in an ASIC it can't
drive much logic, so things start to get more complicated). Making it
work gets things much more complicated, and probably gets you out of the
domain of portable Verilog or VHDL. That is the nature of clock trees.

Thus, step one is in a sense trivial if you are ignoring step two, but
doing step one while ignoring step two is worthless.

I personally don't know whether it is simpler/better to add the clock
enable functionality to the flip flops or gate the clock and deal with
all the timing/buffering issues, and it wouldn't surprise me if it
turned out that which is better very much depends on the process and
other criteria.

The only real answer would be to talk to the process people, but my
guess is that the answer is very much proprietary, and unless it looks
like you are willing and planning on spending the big bucks to actually
do this, won't waste their time talking about it.


Sure, in full custom ASICs it is not uncommon to gate the clock. In fast chips the clock tree design can consume half the dynamic power in the chip. So gating the clock can bring significant power savings. However, the clock gating being described here is over far too small a portion of the chip to be effective on many levels if I understand what is going on. The OP is talking about 100,000 identical state machines, one for each cache item. I believe what he is talking about as FSMs are really just a handful of FFs but I'm not sure. If so, the clock gating logic is nearly as large and so would consume nearly as much power and area as the logic it is controlling..

Will it be practical to design 100,000 clock gating circuits to control 100,000 tiny FSMs? Maybe I am wrong about the size of the FSMs. Or maybe it would be practical to combine the clock gating to many of the 100,000 FSMs so they are shut off in large blocks? I don't know, but the OP seems preoccupied with the idea of this being a language feature rather than a design feature added by the user. I'm sure he wants to produce an idea using a library or something that he can patent. That seems to be his MO. Oh well....

Rick C.

- Get 6 months of free supercharging
- Tesla referral code - https://ts.la/richard11209

Weng Tianxiang
Guest

Sun Jan 06, 2019 10:45 pm   



On Sunday, January 6, 2019 at 11:23:10 AM UTC-8, gnuarm.del...@gmail.com wrote:
Quote:
On Sunday, January 6, 2019 at 1:20:16 PM UTC-5, Richard Damon wrote:
On 1/6/19 12:08 PM, Weng Tianxiang wrote:
On Saturday, January 5, 2019 at 6:28:35 PM UTC-8, Richard Damon wrote:
On 1/5/19 8:23 PM, Weng Tianxiang wrote:
On Saturday, January 5, 2019 at 2:35:28 PM UTC-8, Richard Damon wrote:
On 1/4/19 11:29 PM, Weng Tianxiang wrote:
Hi,

Can I use Verilog or SystemVerilog to write a state machine with clock gating function?

I know VHDL has no such function and want to know if Verilog or SystemVerilog has the clock gating function for a state machine.

Thank you.

Weng


One big question is what do you mean by 'clock gating'

As was mentioned, one option for this is to do something like

assign gatedclk = clk & gate;

or sometimes

assign gatedclk = clk | gate;

and then us the gatedclk as the clock. The big issue with this is that
you need to worry about clock skew when you do this, as well as glitches
(the second version works better for gate changing on the rising edge of
clk, but needs to be stable before the falling edge.)

A second thing called 'clock gating' is to condition the transition on
the gate signal, something like

always @(posedge clk) begin
if(gate) begin
... state machine here.
end
end

This make the machine run on the original clock, but it will only change
on the cycles where the gate signal is true.

VHDL can do the same.

There is no need for a 'special statement', you just do it. If doing
the first version, of actually gating the clock, you may want to use
some implementation defined macro function to buffer the clock and put
it into a low skew distribution network, like may have been done for the
original clock.

Hi Theo and Richard,

Thank you for your help.

Using clock gating function is to save power consumption. Why I ask the question is:

A cache line in Cache I, Cache II or even Cache III in a CPU usually has 64 (2**6) bytes and each cache line must have a state machine to keep data coherence among data over all situations.

For a 6M (2**22 + 2**21) bytes cache II (the most I have seen in current market) a CPU must have at least (2**16 + 2**15) state machines, ~= 100,000, and those ~100,000 state machines don't change states most of time.

In above situation each of the ~100,000 state machines with each having more than 10 states must have a clock gating function to save power consumption:

when it will not change states on the next cycle, a clock pulse should not be generated to keep the state unchanged and save power consumption..

Do you think if it is reasonable?

For an application implemented in a FPGA chip, the clock gating function may not be necessary because too few state machines are implemented in any normal application.

Thank you.

Weng


One issue with gated clocks is that each gating of the clock needs to be
considered a different clock domain from every other gating of the clock
and from the ungated clock, because the gating (and rebuffering) of the
clock introduces a delay in the clock, so you need to take precautions
when the signal passes from one domain to another. A FPGA might have,
and a gate array may provide a special circuit to generate a set of
gated clocks that will be kept in good enough alignment to not need
this, but then that would be a special application macro that needs to
be instanced.

Second, the power consumption between my first and second method (actual
gating of the clock and using a clock enable) is primarily in the power
to drive the clock line as the clock enable also keeps the state the
same in the 'skipped' clock cycle.

Hi Richard,

There are 2 things to consider on how to generate a clock gating function:
1. Generate CE logic.
2. Make gated clock signal working properly.

You address the part 2) and I emphasize on the part 1).

Is it complex to generate CE logic?

In my understanding generating a clock pulse is consuming more power than skipping the clock pulse.

I want to know if each of CPU ~100,000 state machine implementation actually has clock gating function.

Based on your code I think it is reasonable to think each of CPU ~100,000 state machine implementation actually has clock gating function.

Only CPU designers know their implementation. I need the information.

Thank you.

Weng


Actually gating the clock is a single gate (but then in an ASIC it can't
drive much logic, so things start to get more complicated). Making it
work gets things much more complicated, and probably gets you out of the
domain of portable Verilog or VHDL. That is the nature of clock trees.

Thus, step one is in a sense trivial if you are ignoring step two, but
doing step one while ignoring step two is worthless.

I personally don't know whether it is simpler/better to add the clock
enable functionality to the flip flops or gate the clock and deal with
all the timing/buffering issues, and it wouldn't surprise me if it
turned out that which is better very much depends on the process and
other criteria.

The only real answer would be to talk to the process people, but my
guess is that the answer is very much proprietary, and unless it looks
like you are willing and planning on spending the big bucks to actually
do this, won't waste their time talking about it.

Sure, in full custom ASICs it is not uncommon to gate the clock. In fast chips the clock tree design can consume half the dynamic power in the chip.. So gating the clock can bring significant power savings. However, the clock gating being described here is over far too small a portion of the chip to be effective on many levels if I understand what is going on. The OP is talking about 100,000 identical state machines, one for each cache item. I believe what he is talking about as FSMs are really just a handful of FFs but I'm not sure. If so, the clock gating logic is nearly as large and so would consume nearly as much power and area as the logic it is controlling.

Will it be practical to design 100,000 clock gating circuits to control 100,000 tiny FSMs? Maybe I am wrong about the size of the FSMs. Or maybe it would be practical to combine the clock gating to many of the 100,000 FSMs so they are shut off in large blocks? I don't know, but the OP seems preoccupied with the idea of this being a language feature rather than a design feature added by the user. I'm sure he wants to produce an idea using a library or something that he can patent. That seems to be his MO. Oh well....

Rick C.

- Get 6 months of free supercharging
- Tesla referral code - https://ts.la/richard11209


Hi Rick,
You misunderstand and ~100,000 state machines are even coded as the same but with different input signals and output signals, act differently and you cannot "combine the clock gating to many of the 100,000 FSMs". Each has more than 10 states, so each state machine must have 4 registers to implement and each has its clock gating logic and clock gating device.

Weng

Richard Damon
Guest

Mon Jan 07, 2019 12:45 am   



On 1/6/19 4:30 PM, Weng Tianxiang wrote:
Quote:
Hi Rick,
You misunderstand and ~100,000 state machines are even coded as the same but with different input signals and output signals, act differently and you cannot "combine the clock gating to many of the 100,000 FSMs". Each has more than 10 states, so each state machine must have 4 registers to implement and each has its clock gating logic and clock gating device.

Weng


If you are really talking gating for 4 FFs, than my guess is that using
Clock Enabled ffs would be much simpler and probably better than trying
to gate the clock and keeping things synchronized.

The big issue would be that to make the gated clocking work you may need
double the clock distribution tree, one for an 'early' clock that is to
be gated, and a second 'late' clock that ungated parts of the system
used that will line up with the gated clocks. This need for the second
clock distribution tree probably eats up more power than you are saving
by stopping the clock to those flip flops.

The primary alternative to two clocks would be running on opposite edges
(so skew isn't as much of a problem), but that then limits the speed the
system can run at.

Weng Tianxiang
Guest

Mon Jan 07, 2019 3:45 am   



I want to use my method in all types of circuits. A clock gating device is basically a latch. A FF with a clock enable input is a FF having a latch. Thank you.

Goto page 1, 2, 3, 4, 5  Next

elektroda.net NewsGroups Forum Index - FPGA - Can I use Verilog or SystemVerilog to write a state machine

Ask a question - edaboard.com

Arabic version Bulgarian version Catalan version Czech version Danish version German version Greek version English version Spanish version Finnish version French version Hindi version Croatian version Indonesian version Italian version Hebrew version Japanese version Korean version Lithuanian version Latvian version Dutch version Norwegian version Polish version Portuguese version Romanian version Russian version Slovak version Slovenian version Serbian version Swedish version Tagalog version Ukrainian version Vietnamese version Chinese version Turkish version
EDAboard.com map