Continue to Site

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.

[SOLVED] Rising and Falling Edge Detection using SystemVerilog Macros?

Status
Not open for further replies.

lithium

Member level 1
Joined
Mar 4, 2003
Messages
34
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
USA
Activity points
220
I was trying to write a macro for this but ran into problems when I wrote one for falling edge because of re-declaring intermediate logic

// Rising Edge Detection Logic
`define RISE_EDGE_DET(out, in, clock, rst_b) \
begin \
logic inF; \
`MYFF (inF, in, clock, rst_b) \
// Rising edge detection \
always_comb out = in & ~inF; \
end

If I declare a similar one for falling edge, I have use a signal different from inF as the compiler complains that it has been declared twice.

Is there any way to make this generic instead of defining a 'module'?
 

I figured it out....
We have to use in``F

// Rising Edge Detection Logic
`define RISE_EDGE_DET(out, in, clock, rst_b) \
begin \
logic in``F; \
`MYFF (in``F, in, clock, rst_b) \
// Rising edge detection \
always_comb out = in & ~in``F; \
end

I tested this and it works!
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top