Forum Discussion
Altera_Forum
Honored Contributor
11 years agoClocking question: modelsim
Hello, I came across a matter which I do not understand: always@(posedge clk or negedge reset) begin
if(!reset) ....
When clk does not clock I change reset from high to low and .....
Altera_Forum
Honored Contributor
11 years agoIf you use the "bad" example above:
always @(posedge clk or negedge rst)
if(!rst)
q<=0;
if(clk) // WRONG!
q<=d; ...this will happen during simulation: - clock rising edge -> process becomes executed, the "if(clk)" path of your statement becomes (so far so good)
- reset becomes low -> this is basically a reset falling edge -> process becomes executed, the "if(!rst)" path of your statement becomes executed -> reset (still good), but since the clock is still high, the "if(clk)" path is then also executed, virtually overriding the thing the "if(!rst)" path did!
- clock falling edge -> nothing happens (as expected)
- clock rising edge -> process becomes executed, again both paths become executed, as before - again, the reset has no effect!
- reset becomes high -> nothing happens (as expected)
- clock rising edge -> everything goes as usual