Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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

Status
Not open for further replies.

superhet

Junior Member level 3
Joined
Jun 7, 2005
Messages
25
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,599
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
 

dolby.yang

Member level 4
Joined
Mar 2, 2005
Messages
73
Helped
10
Reputation
20
Reaction score
2
Trophy points
1,288
Activity points
1,862
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
 

    superhet

    Points: 2
    Helpful Answer Positive Rating

tom123

Advanced Member level 4
Joined
Apr 4, 2005
Messages
116
Helped
5
Reputation
10
Reaction score
2
Trophy points
1,298
Activity points
2,338
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 said:
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
 
  • Like
Reactions: hsnhsyn1

    superhet

    Points: 2
    Helpful Answer Positive Rating

    hsnhsyn1

    Points: 2
    Helpful Answer Positive Rating

superhet

Junior Member level 3
Joined
Jun 7, 2005
Messages
25
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,599
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.
 

freeinthewind

Advanced Member level 4
Joined
Oct 20, 2004
Messages
108
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,298
Activity points
784
how detect edge verilog

tom123 method is usable, u can delete all the #operators and have a try.
 

    superhet

    Points: 2
    Helpful Answer Positive Rating

nittinsharma80

Member level 5
Joined
Apr 11, 2005
Messages
93
Helped
11
Reputation
22
Reaction score
2
Trophy points
1,288
Location
INDIA
Activity points
2,337
detect a positive edge + verilog

Hi, yes tom's method should work even without #.
 

    superhet

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top