Eisenwave

Notes on Logic Circuit Simulation

Oct 31st, 2016
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. When creating an engine which simulates the behavior of logic gates, there is three fundamental problems for the engine to overcome:
  2.  
  3. PROBLEM #1: "The NOT Problem"
  4.  
  5. Imagine a NOT-Gate A with one input a and one output b. Should b be directly connected to a, A will negate itself and turn b off. In return, a will be disabled and A will enable b again.
  6. As you can see, a NOT-Gate connected to itself is an infinite logic loop and unless an infinite loop should result internally, the amount of ticks or the "engine speed" has to be reduced to a finite amount of "ticks".
  7.  
  8.  
  9. PROBLEM #2: "The XOR Problem"
  10.  
  11. Imagine two sensors A and B and an XOR Gate C, given that A = B. A and B will activate simultaneously, meaning that on paper C will never output a signal.
  12. To accomplish this, C has to wait for both A and B to send their information to C's inputs and then process these.
  13.  
  14.  
  15. PROBLEM #3: "The OR, AND Problem"
  16.  
  17. Imagine three sensors A, B, C aswell as an AND-Gate X and an OR-Gate Y. A = B.
  18. The connections are as following:
  19. A---|
  20. X---?
  21. B-| |
  22. Y-|
  23. C-|
  24. The expected outcome is that when the sensors are activated, first Y gets activated and turns on one of X's inputs and A gets activated, turning on the other input of X, making X output information. If there is a delay between these operations, it could be that within the next tick Y outputs to X, but the sensor A is already turned off.
  25.  
  26. As a result of this, should A (B) be sensors that only output for one tick, a delay in data transfer and incorrect order of component ticking leads to X not being able to output information.
  27.  
  28. Thus, define the order in which components are activated as their longest, unique, non-repititive path to a source. Define "source" as a component which does not have any path from any of its inputs to a component without any inputs.
  29.  
  30. In this example, the longest path of A, B and C to a source is precisely of length 0, as they are root-components themselves. Thus, they are being ticked by the engine first.
  31. Y's longest path to a root component is of length 1 (Y->B or Y->C), thus, it is activated next.
  32. X's longest path to a root component is of length 2 (X->Y->B or X->Y->C), thus, it is activated after Y.
  33.  
  34. Examples of root components are:
  35. - batteries
  36. - sensors
  37. - unconnected/self-connected NOT-Gates
Advertisement
Add Comment
Please, Sign In to add comment