Thank you for this explanation! It was very helpful for understanding the difference between synchronous and asynchronous and where to put what in the always blocks to make it one or the other.
Do we have to write the synchronous part in combinational always block? Wouldn't it work like this: always @(negedge clk,negedge reset_n) begin if(!reset_n) Q_reg
Yes, that is equivalent, because if "not ~reset_n", that means that the first "always" block was triggered by a negative edge of "clk", thus you're only checking "clear_n" on a clock edge and so it is synchronous. (I also elaborated the design using your suggestion and it results in the same schematic).
Thank you for this explanation! It was very helpful for understanding the difference between synchronous and asynchronous and where to put what in the always blocks to make it one or the other.
Do we have to write the synchronous part in combinational always block? Wouldn't it work like this:
always @(negedge clk,negedge reset_n) begin
if(!reset_n)
Q_reg
Yes, that is equivalent, because if "not ~reset_n", that means that the first "always" block was triggered by a negative edge of "clk", thus you're only checking "clear_n" on a clock edge and so it is synchronous. (I also elaborated the design using your suggestion and it results in the same schematic).
sir please provide testbench code also
You can do it by yourself if you have happened to watch his previous videos..
you can find them in his github