[verilog] change from always@ to assign

  • Thread starter Thread starter hoheiho
  • Start date Start date
  • Tags Tags
    Change
Click For Summary
SUMMARY

The discussion revolves around the transition from using the Verilog construct always@ to assign for signal assignment in a digital design context. The user, Ivan, initially implemented a clocked process that introduced a one-clock-cycle delay in the output signal recover. After switching to a continuous assignment, the expected behavior was not achieved, resulting in the signal being high for two clock cycles. The issue stems from the incorrect use of multiple assign statements for the same signal, which leads to conflicting assignments.

PREREQUISITES
  • Understanding of Verilog syntax and constructs, particularly always@ and assign.
  • Knowledge of digital design concepts, including clock cycles and signal propagation.
  • Familiarity with combinational versus sequential logic in hardware description languages.
  • Experience with simulation tools to analyze waveforms and signal behavior.
NEXT STEPS
  • Review Verilog continuous assignments and their implications on signal behavior.
  • Learn about the differences between combinational and sequential logic in Verilog.
  • Explore how to use the always@ block effectively to avoid timing issues.
  • Investigate waveform analysis techniques to debug signal timing in digital designs.
USEFUL FOR

Digital designers, Verilog programmers, and students learning about hardware description languages who are looking to optimize signal assignments and understand timing issues in their designs.

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: 622
  • pic2.jpg
    pic2.jpg
    10.6 KB · Views: 606
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
4K
  • · Replies 1 ·
Replies
1
Views
13K
  • · 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