Forum Discussion
Altera_Forum
Honored Contributor
8 years agoThe problem here is in the code, not in the simulator.
Simulations are executed using "delta cycles" which are meant to be infinitely small divisions of time. Anyone signal can only have 1 value in any given delta cycle. So in your example, you have set the clock to change from 0 -> 1 after 2 ns. Your data changes from 0 -> 1 after 10 ns. At 10ns, the clock also changes from 0 to 1, giving a clock edge. But the edge is detected at the same time that RxD has also been set to 1, so it is detected as 1. so at 10 ns, what occurs is (when using your original code) delta 1: clk = 0, RxD = 0 detla 2: clk = 1, RxD = 1 (clock edge detected, use the value of RxD now, which is 1) If you synchronise to the clock, the Assignment to RxD doesnt happen until 1 delta after the rising edge delta 1 : clk = 0, RxD = 0 delta 2 : clk = 1, RxD = 0 (clock edge occurs, read value of RxD, schedule RxD to be set to 1 delta 3 : clk = 1, RxD = 1