[verilog] change from always@ to assign

  • Thread starter Thread starter hoheiho
  • Start date Start date
  • Tags Tags
    Change
Click For Summary
The discussion centers on a Verilog coding issue where the user attempts to change from an always block to an assign statement to eliminate a one-clock-cycle delay in outputting a signal. The original always block correctly sets the 'recover' signal based on conditions, but the user finds that the assign statement does not produce the desired immediate output. The user is confused about why the 'recover' signal remains high for two clock cycles instead of responding immediately to changes in 'pcreg_1'. The problem lies in the incorrect use of the assign statements, which are overwriting each other and not logically combining the conditions. Clarifying the logic and combining the conditions into a single assign statement could resolve the issue.
hoheiho
Messages
43
Reaction score
0

Homework Statement


Halo, I have written a always@ (code i,pic1) which can output what I want but the result is delayed 1 clock cycle, therefore I have changed it to assign (code ii,pic2)and try to output the recover signal immediately when pcreg_1 is changed. But waveform is not what I wanted. Did I miss somethings in (code ii)? The recover is high in 2 clock cycle and I cannot get 0.

code i
Code:
always @(posedge clk)
begin
  if (store)
      if (m2==pcreg_1)
        recover = 0;
      else
        recover = 1;
  else
      if (m1==pcreg_1)
        recover = 0;
      else
        recover = 1;     
end

code ii
Code:
assign recover = (store && (m2==pcreg_1))? 1'b0:1'b1;
assign recover = (!store && (m1==pcreg_1))? 1'b0:1'b1;

Could anyone give me a hand for me :(?

Thank you very much for help
Ivan
 

Attachments

  • pic1.jpg
    pic1.jpg
    11.1 KB · Views: 618
  • pic2.jpg
    pic2.jpg
    10.6 KB · Views: 600
Physics news on Phys.org
Did anyone can see what's the problem :(?
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
21K
  • · Replies 6 ·
Replies
6
Views
11K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 1 ·
Replies
1
Views
12K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
5K
Replies
1
Views
4K
Replies
9
Views
5K
  • · Replies 6 ·
Replies
6
Views
2K