2

How to know if this piece of code is for a sequential or a combinational circuit?enter image description here

James
  • 123
  • 5

2 Answers2

6

This will synthesize to sequential logic. If b is 1, then output will become 01. Consider the case when both the inputs a and b are 0. No condition of your code is satisfied, which means that the output will be unchanged. This implies that we are storing previous value, for which a latch is required. This occurs due to incomplete if else statements, that is, all the cases are not covered.

Shashank V M
  • 2,279
  • 13
  • 47
0

You can find out if a circuit is combinational if the circuit does not depend on previous states. Also a combinational circuit is time independent. In case that one of those conditions are not met, your circuit is sequential.

Regarding verilog code, one way to find out the combinational part from your module is to see the always block and its sensitivity list.

Always@ (*) block is used to describe combinational logic and logic gates. The star (*) represents the sensitivity list specifies which signals should trigger the elements inside the always@ block to be updated. Also a rule of thumb is to use only blocking assignments in an always@(*) block (e.g OUT = A & B).

Concerning your verilog code, there is a CLK signal in your sensitivity list and non-blocking assignments are used (which are used only in sequential logic circuits). However, I would say that your code is combinational because it is not synchronized with clk signal and the ouput is changed according to a or b inputs and the output does not depend on previous state (such as q <= ~q). In Verilog, if you want to create sequential logic use a clocked always block with nonblocking assignments. If you want to create combinational logic use an always block with blocking assignments

pantarhei
  • 879
  • 6
  • 18