Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

Event Control contains a complex event expression?

Status
Not open for further replies.

digi001

Full Member level 5
Joined
Apr 5, 2011
Messages
244
Helped
22
Reputation
44
Reaction score
21
Trophy points
1,298
Activity points
2,904
Using Altera Quartus I get the warning:

"Event Control contains a complex event expression", for the following code:

always@(negedge signal1 && address==4'b0001 && chip_sel==0)

Is it bad practice to have an always@ occur for more than one signal or is this just a reminder for the programmer?
 

mrflibble

Advanced Member level 5
Joined
Apr 19, 2010
Messages
2,724
Helped
679
Reputation
1,360
Reaction score
651
Trophy points
1,393
Activity points
19,551
Possibly you want to use:
Code:
always@(negedge signal1 or address or chip_sel)
The handling of the actual values of address and chip_sel is to be done inside the main block of this always. Not in the sensitivity list (which is what you're trying to do now).

Try this:
Code:
always@(negedge signal1 or address or chip_sel) begin
    if (address==4'b0001 && chip_sel==0) begin
        // something
    end
end
 
  • Like
Reactions: digi001

    digi001

    points: 2
    Helpful Answer Positive Rating

digi001

Full Member level 5
Joined
Apr 5, 2011
Messages
244
Helped
22
Reputation
44
Reaction score
21
Trophy points
1,298
Activity points
2,904
Ah ok Thanks. Yes i was thinking to try that code. My original code works, but not as robust or good practice as what you have suggested.
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
47,478
Helped
14,046
Reputation
28,347
Reaction score
12,700
Trophy points
1,393
Location
Bochum, Germany
Activity points
276,115
I'm only occasionally using Verilog, but I don't think that the or combination of edge and level sensitive events is synthesizable. I must admit, that I didn't find a similar construct anywhere, except for the IEEE Verilog spec.
Code:
always@(negedge signal1 or address or chip_sel) begin
    if (address==4'b0001 && chip_sel==0) begin
And anyway, it won't turn the original "bad practice" in something good, I fear.

The original construct, if I understand it right, is evaluating a logic expression and then uses it as a clock. Because the logic expression is very likely having glitches, it will rarely work.

Using asynchronous action instead (level sensitive expressions) may work in special cases but is also far from good coding.

Why not using simple, straightforward synchronous coding, that does all register assignments under a clock edge?
 
  • Like
Reactions: digi001

    digi001

    points: 2
    Helpful Answer Positive Rating

yadog

Member level 1
Joined
Mar 12, 2006
Messages
33
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,288
Activity points
1,427
if u want to use edge and level sensitive in a same block,maybe you can use a edge detect circuit to detect edge sensitive signal,then you can turn it to level sensitive.

i think it is not good to use the combination combination of edge and level sensitive events .just for discussion
 
  • Like
Reactions: digi001

    digi001

    points: 2
    Helpful Answer Positive Rating

permute

Advanced Member level 3
Joined
Jul 16, 2010
Messages
923
Helped
294
Reputation
588
Reaction score
267
Trophy points
1,343
Activity points
8,543
FvM, Verilog started with "or" as the seperator for the sensitivity list. The VHDL "," was added in Verilog-2001. But Verilog is different than VHDL in that the edge events themselves are used in the sensitivity list. VHDL simply places "Clk" in the list and then qualifies the code in the block with "if rising_edge(Clk) then". VHDL, in theory, evaluates (and skips) the content of each process on every negative clock edge. Verilog is written to explicitly say "don't even attempt to evaluate this on the negative clock edge". Of course it is likely that every decent simulator would have realized this during the "optimization" phase.

The code above probably synthesizes to a combinatorial circuit -- similar to including a clock in a VHDL process but forgetting to add the "if rising_edge(Clk)" line.

IIRC, verilog as a language allows signals to not be globally static to a much higher degree than VHDL. eg, connecting A&&B to a port in verilog is valid. Placing A^B in a sensitivity list might make some sense.

Both languages are moving away from requiring sensitivity list management, so it'll will eventually be a non-issue. I've never seen anyone use both pos/negedge events and non-edge events in the same sensitivity list, nor anyone use operation other than the list seperators " or " or "," in the sensitivity list.

I'm not sure there is a valid way to write the original code. the OP seems to have found a way that works.
 
  • Like
Reactions: digi001

    digi001

    points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top