• Support PF! Buy your school textbooks, materials and every day products Here!

[verilog] change from always@ to assign

  • Thread starter hoheiho
  • Start date
  • #1
47
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

Answers and Replies

  • #2
47
0
Did anyone can see whats the problem :(?
 

Related Threads on [verilog] change from always@ to assign

Replies
6
Views
8K
  • Last Post
Replies
1
Views
1K
  • Last Post
Replies
0
Views
2K
  • Last Post
Replies
0
Views
2K
  • Last Post
Replies
1
Views
2K
  • Last Post
Replies
0
Views
1K
Replies
1
Views
2K
Replies
0
Views
13K
  • Last Post
Replies
1
Views
2K
  • Last Post
Replies
1
Views
13K
Top