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.

problem with always block and sensitivity list

Status
Not open for further replies.

kuntul

Newbie level 6
Joined
May 1, 2010
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,379
I have a verilog code below.


Code:
always @(posedge Clk) begin

ForwardA = 0;
ForwardB = 0;

//EX Hazard
if (EXMEMRegWrite == 1) begin
 if (EXMEMrd != 0)
    if (EXMEMrd == IDEXrs)
        ForwardA = 2'b10;
   if (EXMEMrd == IDEXrt && IDEXTest == 0)
        ForwardB = 2'b10;
end


//MEM Hazard

if (MEMWBRegWrite == 1) begin
 if (MEMWBrd != 0) begin
    if (!(EXMEMRegWrite == 1 && EXMEMrd != 0 && (EXMEMrd == IDEXrs)))
            if (MEMWBrd == IDEXrs)
                ForwardA = 2'b01;
    if (IDEXTest == 0) begin
        if (!(EXMEMRegWrite == 1 && EXMEMrd != 0 && (EXMEMrd == IDEXrt)))
            if (MEMWBrd == IDEXrt)
                ForwardB = 2'b01;
    end
 end
end

end


The problem is that the output, which is ForwardA and ForwardB is not updated not on the rising clock edge rather than on the next rising clock edge... why is this?? How do I resolve so that the output is updated on the same positive rising clock edge?

Here's an image to clarify my point:

**broken link removed**

ForwardA is updated with 2 on the next rising clock edge and not on the same rising clock edge. How do I make it so that it updates on the first rising clock edge as it already satisfies the if statement there.
 

I don't see any logic problem there..... what are you seeing?
 

To update on the same clock edge, don't use the clock for the second signal.

It seems that all the signals in the tests are clocked. If so, the Forward outputs will always change one edge after all the tested signals allow a change.

A simple way to explain this - signals are tested or used with the values they have before the clock edge, and the signals change values after the clock edge.
 

you mean I need to change it so that the sensitivity list is EXMEMrd...etc,etc...
 

Yes, that will work.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top