electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

how can i detect the positive edge of a signal in verilog?


Post new topic  Reply to topic    EDAboard.com Forum Index -> PLD, SPLD, GAL, CPLD, FPGA Design -> how can i detect the positive edge of a signal in verilog?
Author Message
superhet



Joined: 07 Jun 2005
Posts: 25


Post17 Jun 2005 3:23   

find positive edge of signal


how can i detect the positive edge of a signal using an if statement in verilog. if i had to detect the level of a signal i would use

Code:
if(signal)
begin
      ........
      ........
end


but what if i want to detect only the positive edge of a signal???

my limited knowledge of verilog tells me that i could use

Code:
always @(posedge signal)
begin
      ..........
      ..........
end


but as i said im using an if statement which means im already in an always block and always blocks cannot be nested.

so what is the solution
Back to top
dolby.yang



Joined: 02 Mar 2005
Posts: 74
Helped: 8


Post17 Jun 2005 3:53   

detect edge signal verilog


u can use this circuit -------
-------------------------------------| | out signal
singnal - - -- - ------ | |----------------
------------ -------------- ----------|>。---------| |
- - --> - -> - not gate | ---|
clk ------ clk -------
DFF DFF

Added after 1 minutes:

u can use this circuit -------
-------------------------------------| | out signal
singnal - - -- - ------ | |----------------
------------ -------------- ----------|>。---------| |
- - --> - -> - not gate | ---|
clk ------ clk ------- and gate
DFF DFF
Back to top
tom123



Joined: 04 Apr 2005
Posts: 116
Helped: 3


Post18 Jun 2005 8:52   

positive edge signal


following code can detect a posedge :

wire signal_in;
wire edge_detected;
reg signal_d;

always @(posedge clk or negedge rst_n)
begin
if (~rst_n)
signal_d <= #1 1'b0;
else
signal_d <= #1 signal_in;
end

assign edge_detected = signal_in & (~signal_d);

best regards




superhet wrote:
how can i detect the positive edge of a signal using an if statement in verilog. if i had to detect the level of a signal i would use

Code:
if(signal)
begin
      ........
      ........
end


but what if i want to detect only the positive edge of a signal???

my limited knowledge of verilog tells me that i could use

Code:
always @(posedge signal)
begin
      ..........
      ..........
end


but as i said im using an if statement which means im already in an always block and always blocks cannot be nested.

so what is the solution
Back to top
superhet



Joined: 07 Jun 2005
Posts: 25


Post18 Jun 2005 17:36   

detect edge + verilog code


i forgot to tell you one thing. i want something that is synthesizable. the # operators are used in simulation and wont give me something that is synthesizable.
Back to top
freeinthewind



Joined: 20 Oct 2004
Posts: 108
Helped: 1


Post23 Jun 2005 4:18   

how detect edge verilog


tom123 method is usable, u can delete all the #operators and have a try.
Back to top
Google
AdSense
Google Adsense




Post23 Jun 2005 4:18   

Ads




Back to top
nittinsharma80



Joined: 11 Apr 2005
Posts: 99
Helped: 7
Location: INDIA


Post23 Jun 2005 5:50   

detect a positive edge + verilog


Hi, yes tom's method should work even without #.
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> PLD, SPLD, GAL, CPLD, FPGA Design -> how can i detect the positive edge of a signal in verilog?
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
how can i detect the last edge in a switching digital signal (3)
detectiong positive edge and negative edge of a waveform (22)
to detect clock's rising edge and falling edge (3)
How to make a JK FF with positive-edge-triggered CLK input? (1)
how to detect lower edge of sine wave at 100Hz..? (5)
WHEN the voltage exceed THE EDGE how can strart time (2)
How close to the edge of the smith chart can you get ? (6)
How I can detect the 3 possible states in a bus RS485? (5)
D Flip-Flop with Negative-Edge Clock or Positive-Edge Clock (5)
How do I detect that a signal is a WIFI signal and not noise (2)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS