I initialised it to 1 in the initial block, clearly it should get assigned back to 0 on the posedge no?.
So "ticking in an always block" is not the same as assigning to 1 outside an always block, even tho it creates a posedge?
Here is the odd thing about
initial and
always blocks.
They run in parallel.
I learned Verilog long ago, long enough ago to have used the SILOS III simulator, and to have found a bug in it, and I called them up on the phone and spoke to one of the developers who said, "Yep, that's a bug, look for a fix shortly ..." and one of the things which was pointed out was that the
initial block is not an initializer block! That is, it was never intended to be something where you stuff all of your signal resets and initializers. But somehow synthesis semantics have made it so.
Basically the differences between the two blocks are:
a) The
initial block cannot have a sensitivity list, which means that
b) it runs only at the start of time and when it suspends it's done. It never goes back up to the top of the block and start executing again, and it needs to have waits and delays to advance time.
c) An
always block has a sensitivity list, which means that it wakes up whenever there is a transaction on the signals in its sensitivity list. (If an
always block doesn't have a sensitivity list, you need to make sure that there are waits or delays to advance time. It's almost like an
initial block in that sense but execution jumps back to the start of the block when it reaches the end.)
Now if you assign a wire to 1'b1 outside of an always (or initial) block, congratulations, you have made a constant. If you assign to the same signal inside a block and outside, well, you can't do that -- as noted before, signals assigned inside a block (either
initial or
always!) must be of reg type; signals assigned outside the block must be wires.
To be honest, this sort of silliness (and the whole idea of blocking and non-blocking assignments in a block) is why I prefer VHDL over Verilog, where the semantics of the language are clear.