FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > Verilog

Verilog comp.lang.verilog newsgroup / usenet

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-29-2007, 04:26 PM
konstantink
Guest
 
Posts: n/a
Default Clock propagation

Hi, everyone!

Please, somebody explain one thing. Regarding such code:

module top ( clk, reset, in_a, in_b, out );

input clk, reset, in_a, in_b;
output out;

reg out;

always @( posedge clk or negedge reset )
if ( reset == 1'b0 )
out <= 1'b0;
else
out <= ( clk ) ? in_a : in_b;

endmodule

The question is: is the output of the multiplexer regarded as clock
line and why?
And can you tell me when the clock propagation stops?

Thanks a lot!!!!

Reply With Quote
  #2 (permalink)  
Old 03-29-2007, 04:54 PM
Jonathan Bromley
Guest
 
Posts: n/a
Default Re: Clock propagation

On 29 Mar 2007 07:26:34 -0700, "konstantink"
<[email protected]> wrote:

>module top ( clk, reset, in_a, in_b, out );
>
> input clk, reset, in_a, in_b;
> output out;
>
> reg out;
>
> always @( posedge clk or negedge reset )
> if ( reset == 1'b0 )
> out <= 1'b0;
> else
> out <= ( clk ) ? in_a : in_b;
>
>endmodule
>
>The question is: is the output of the multiplexer regarded as clock
>line and why?
>And can you tell me when the clock propagation stops?


This is VERY strange code.

At first glance it looks like a flip-flop. It has the right
structure, and the body of the always block looks
correct too. But then we find (clk) appearing as a term
in the logic! This is crazy. The "else" branch of your
if statement will execute only on (posedge clk), so
(assuming no X values) clk is definitely 1; so the
last line of code is equivalent to
out <= in_a;

A signal is regarded as a clock only if you use it
to clock some registers. You can do that with the
STANDARD clocked process arrangement.
In your example there is no "clock propagation"
of any kind. There is no multiplexer, for the
reasons I have described. And the output of the
circuit might be a clock, or it might not be,
depending on what you do with it elsewhere.

There are, I think, three possibilities here:

(1) You have a prof. who thinks he's being clever,
but in fact is just being confused. (It happens.)
(2) This is a "spot the deliberate mistake" homework
question, and I just gave you the right answer.
Shame on me.
(3) You have some colleagues who urgently need to
come on one of our Verilog training courses to learn
how to write sensible flip-flop models.
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
[email protected]
http://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
Reply With Quote
  #3 (permalink)  
Old 03-29-2007, 05:07 PM
Alex
Guest
 
Posts: n/a
Default Re: Clock propagation

On Mar 29, 10:26 am, "konstantink" <slip...@yandex.ru> wrote:
> Hi, everyone!
>
> Please, somebody explain one thing. Regarding such code:
>
> module top ( clk, reset, in_a, in_b, out );
>
> input clk, reset, in_a, in_b;
> output out;
>
> reg out;
>
> always @( posedge clk or negedge reset )
> if ( reset == 1'b0 )
> out <= 1'b0;
> else
> out <= ( clk ) ? in_a : in_b;
>
> endmodule
>
> The question is: is the output of the multiplexer regarded as clock
> line and why?
> And can you tell me when the clock propagation stops?
>
> Thanks a lot!!!!



In your example, out <= in_a since clk is always "1" after the
posedge.
Synthesis tools will implement your block as a singe flip-flop.

-Alex

Reply With Quote
  #4 (permalink)  
Old 03-29-2007, 05:57 PM
Mike Lewis
Guest
 
Posts: n/a
Default Re: Clock propagation


"Alex" <[email protected]> wrote in message
news:[email protected] oups.com...
> On Mar 29, 10:26 am, "konstantink" <slip...@yandex.ru> wrote:
>> Hi, everyone!
>>
>> Please, somebody explain one thing. Regarding such code:
>>
>> module top ( clk, reset, in_a, in_b, out );
>>
>> input clk, reset, in_a, in_b;
>> output out;
>>
>> reg out;
>>
>> always @( posedge clk or negedge reset )
>> if ( reset == 1'b0 )
>> out <= 1'b0;
>> else
>> out <= ( clk ) ? in_a : in_b;
>>
>> endmodule
>>
>> The question is: is the output of the multiplexer regarded as clock
>> line and why?
>> And can you tell me when the clock propagation stops?
>>
>> Thanks a lot!!!!

>
>
> In your example, out <= in_a since clk is always "1" after the
> posedge.
> Synthesis tools will implement your block as a singe flip-flop.
>
> -Alex
>


That's assuming the synthesizer doesn't gack on the fact you are using the
clock as both clock and data.

Mike


Reply With Quote
  #5 (permalink)  
Old 03-29-2007, 08:51 PM
Alex
Guest
 
Posts: n/a
Default Re: Clock propagation

On Mar 29, 11:57 am, "Mike Lewis" <some...@micrsoft.com> wrote:
> "Alex" <agnu...@gmail.com> wrote in message
>
> news:[email protected] oups.com...
>
>
>
> > On Mar 29, 10:26 am, "konstantink" <slip...@yandex.ru> wrote:
> >> Hi, everyone!

>
> >> Please, somebody explain one thing. Regarding such code:

>
> >> module top ( clk, reset, in_a, in_b, out );

>
> >> input clk, reset, in_a, in_b;
> >> output out;

>
> >> reg out;

>
> >> always @( posedge clk or negedge reset )
> >> if ( reset == 1'b0 )
> >> out <= 1'b0;
> >> else
> >> out <= ( clk ) ? in_a : in_b;

>
> >> endmodule

>
> >> The question is: is the output of the multiplexer regarded as clock
> >> line and why?
> >> And can you tell me when the clock propagation stops?

>
> >> Thanks a lot!!!!

>
> > In your example, out <= in_a since clk is always "1" after the
> > posedge.
> > Synthesis tools will implement your block as a singe flip-flop.

>
> > -Alex

>
> That's assuming the synthesizer doesn't gack on the fact you are using the
> clock as both clock and data.
>
> Mike


Synthesis tool indeed compiles design to 1 flop, but data pin of this
flop is connected to in_b ! In other words, synthesis tool assumes
that within always process clk = 0.

Morale: don't even try to mix clock with data

Reply With Quote
  #6 (permalink)  
Old 03-30-2007, 08:50 PM
gabor
Guest
 
Posts: n/a
Default Re: Clock propagation

On Mar 29, 2:51 pm, "Alex" <agnu...@gmail.com> wrote:
> On Mar 29, 11:57 am, "Mike Lewis" <some...@micrsoft.com> wrote:
>
>
>
> > "Alex" <agnu...@gmail.com> wrote in message

>
> >news:[email protected] roups.com...

>
> > > On Mar 29, 10:26 am, "konstantink" <slip...@yandex.ru> wrote:
> > >> Hi, everyone!

>
> > >> Please, somebody explain one thing. Regarding such code:

>
> > >> module top ( clk, reset, in_a, in_b, out );

>
> > >> input clk, reset, in_a, in_b;
> > >> output out;

>
> > >> reg out;

>
> > >> always @( posedge clk or negedge reset )
> > >> if ( reset == 1'b0 )
> > >> out <= 1'b0;
> > >> else
> > >> out <= ( clk ) ? in_a : in_b;

>
> > >> endmodule

>
> > >> The question is: is the output of the multiplexer regarded as clock
> > >> line and why?
> > >> And can you tell me when the clock propagation stops?

>
> > >> Thanks a lot!!!!

>
> > > In your example, out <= in_a since clk is always "1" after the
> > > posedge.
> > > Synthesis tools will implement your block as a singe flip-flop.

>
> > > -Alex

>
> > That's assuming the synthesizer doesn't gack on the fact you are using the
> > clock as both clock and data.

>
> > Mike

>
> Synthesis tool indeed compiles design to 1 flop, but data pin of this
> flop is connected to in_b ! In other words, synthesis tool assumes
> that within always process clk = 0.
>
> Morale: don't even try to mix clock with data



I would take this as the synthesizer being more knowledgable about
the hardware than the simulator. Take the template for a flip-flop
and you have a 2:1 mux selected on clock feeding the D. I would think
a
rising edge flop would need a significant negative hold time to
see the clock as "high" at the sampling edge. This sort of thing
(mixing active edge with active state) always bothered me when I
look at VHDL code like (clk'event and clk = 1). If there's an
event, clk is changing. So is it 1 or zero? Yes. At which edge?
Both.

Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
modeling of the propagation delay between two inout ports Jim Verilog 5 11-16-2005 10:03 PM
generate a 20 MHZ clock(pulse) with duty cycle other than 50 % from master clock 40 MHZ having 50 % duty cycle MegaPowerStar Verilog 2 08-19-2003 02:29 AM


All times are GMT +1. The time now is 03:06 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved