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

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > FPGA

FPGA comp.arch.fpga newsgroup (usenet)

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-11-2006, 04:55 AM
vittal
Guest
 
Posts: n/a
Default @(posedge clk)

Hi,
What does a statement like @(posedge clk) synthesise to?
if i write:-

input b;
output c;
a=b;
@(posedge clk);
c=a;

Reply With Quote
  #2 (permalink)  
Old 12-11-2006, 06:42 AM
Ben Jackson
Guest
 
Posts: n/a
Default Re: @(posedge clk)

On 2006-12-11, vittal <[email protected]> wrote:
> Hi,
> What does a statement like @(posedge clk) synthesise to?
> if i write:-
>
> input b;
> output c;
> a=b;
> @(posedge clk);
> c=a;


Verilog introductions are TERRIBLE about clarifying what's synthesizable
and what's not. Verilog is two languages in one -- one procedural
language that is useful for controlling simulations, and one hardware
description language which can be synthesized. Your sequence of
instructions might be useful for an input stimulus file, but not for
describing hardware.

--
Ben Jackson AD7GD
<[email protected]>
http://www.ben.com/
Reply With Quote
  #3 (permalink)  
Old 12-11-2006, 06:50 AM
Neo
Guest
 
Posts: n/a
Default Re: @(posedge clk)


vittal wrote:
> Hi,
> What does a statement like @(posedge clk) synthesise to?
> if i write:-
>
> input b;
> output c;
> a=b;
> @(posedge clk);
> c=a;


Assuming your 'a' is a reg it will systhesize to one DFF with input b
and ouput c.

Reply With Quote
  #4 (permalink)  
Old 12-11-2006, 09:00 AM
vits
Guest
 
Posts: n/a
Default Re: @(posedge clk)

ok I will put it like this..
always @(*)
begin
a=b;
@(posedge clk);
c=a;
end
What does it mean.
Neo wrote:
> vittal wrote:
> > Hi,
> > What does a statement like @(posedge clk) synthesise to?
> > if i write:-
> >
> > input b;
> > output c;
> > a=b;
> > @(posedge clk);
> > c=a;

>
> Assuming your 'a' is a reg it will systhesize to one DFF with input b
> and ouput c.


Reply With Quote
  #5 (permalink)  
Old 12-11-2006, 05:46 PM
Guest
 
Posts: n/a
Default Re: @(posedge clk)


vits wrote:

> ok I will put it like this..
> always @(*)
> begin
> a=b;
> @(posedge clk);
> c=a;
> end
> What does it mean.


It is a bad idea. Synthesis tools will reject this code, and although a
simulator will process it, nobody reading your code will be able to
understand or maintain it.

To help you understand it, I'll explain what it does in simulation...

1) It waits for an event on a, b or clk
2) It sets a=b
3) It waits for a rising clock edge
4) It sets c=a
5) It loops from step 1.




> Neo wrote:
> > vittal wrote:
> > > Hi,
> > > What does a statement like @(posedge clk) synthesise to?
> > > if i write:-
> > >
> > > input b;
> > > output c;
> > > a=b;
> > > @(posedge clk);
> > > c=a;

> >
> > Assuming your 'a' is a reg it will systhesize to one DFF with input b
> > and ouput c.


Reply With Quote
  #6 (permalink)  
Old 12-12-2006, 08:54 AM
Andreas Ehliar
Guest
 
Posts: n/a
Default Re: @(posedge clk)

On 2006-12-11, [email protected] <[email protected]> wrote:
> vits wrote:
>
>> ok I will put it like this..
>> always @(*)
>> begin
>> a=b;
>> @(posedge clk);
>> c=a;
>> end
>> What does it mean.

>
> It is a bad idea. Synthesis tools will reject this code, and although a
> simulator will process it, nobody reading your code will be able to
> understand or maintain it.
>
> To help you understand it, I'll explain what it does in simulation...
>
> 1) It waits for an event on a, b or clk
> 2) It sets a=b
> 3) It waits for a rising clock edge
> 4) It sets c=a
> 5) It loops from step 1.


I thought this was an intriguing question because I did not know how
@(*) deals with clk in the case above so I looked it up in
the Verilog standard. (IEEE Std 1364-2005 to be exact, section
9.7.5.)

It turns out that @(*) should add all (net and variable) identifiers to
the sensitivity list unless at least one of the following is true:
* It is only used as a destination for an assignment
* It only appears in a wait or event expression.

The following is an example from the standard:
always @* begin // equivalent to a(b)
@(i) kid = b; // i is not added to @*
end


So the example above should be modified as follows:

1) It waits for an event on a or b


I could also note that the version of Modelsim I'm using (6.2b) does seem
to add identifiers in event expressions to the sensitivity list
unfortunately.

/Andreas
Reply With Quote
Reply

Bookmarks


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
posedge Amir Verilog 3 09-11-2008 02:25 AM
@(posedge clk) clk[=2] |-> --Ross Verilog 2 06-08-2008 06:48 PM
@(posedge clk) vittal Verilog 5 12-12-2006 08:54 AM
I2C and posedge sampling [email protected] FPGA 3 02-18-2006 08:10 AM
Use of Both Posedge Clk and Negedge Clock Chloe Verilog 5 05-27-2005 10:20 AM


All times are GMT +1. The time now is 11:55 AM.


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