You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -16,6 +18,8 @@ cpp_logic_simulation is a framework for constructing simulations of digital [log
16
18
A further sub-class of the *Device* class is the *Simulation* class, which lies at the top-level and contains the *Device* or *Devices* that comprise the logic circuit. The *Simulation* can also contain members of two additional utility classes, *Clocks* to drive the contained logic circuit, and *Probes*, which can sample and display the logical state of any inputs or outputs of *Gates* or *Devices* within the circuit. The state of the logic circuit is recalculated automatically in response to any state changes at it's inputs. However, sampling and displaying state using *Probes* can only occur while the simulation is 'running', with the circuit driven via one or more *Clocks*.
17
19
18
20
To do anything more interesting than view *Probe* output tables of changing logic levels within the circuit, a way to 'break the fourth wall' and interface with system resources 'outside' of the simulation is required. This is provided by a final *Device* sub-class, the *MagicDevice*. In addition to the usual *Device* functionality, *MagicDevices* contain special custom code (the *MagicEngine*) to interact with system resources outside of the simulation, and interfaces that hook into the simulated operation of the logic-circuit, and vice-versa. This allows us to create *MagicDevices* that, for example, behave as a RAM IC by accessing data contained in an array, a ROM IC by accessing data contained in a text file, or even a UART-like IC communicating with a remote text terminal! See `./sim_src/magic_devices/simple_ram.cpp`, `simple_rom.cpp` and `simple_terminal.cpp` for examples.
Great! We can see the output responding to the changing input stimulus as we should expect for an SR latch.
130
+
<br />
131
+
<br />
126
132
127
133
Encapsulating our circuit in a *Device*.
128
134
-------------------------------------------
@@ -271,8 +277,9 @@ CHILDSET: Component test_sim:sr_latch:sr_latch terminal R set to F
271
277
user@home:~/cpp_logic_simulation$
272
278
```
273
279
274
-
Great! We can see our SR latch device out pin responding to the changing in pin stimulus as we should expect for an SR latch, just as before.\
275
-
\
280
+
Great! We can see our SR latch device out pin responding to the changing in pin stimulus as we should expect for an SR latch, just as before.
281
+
<br />
282
+
<br />
276
283
277
284
Nesting *Devices*.
278
285
-------------------------
@@ -499,8 +506,9 @@ Great!
499
506
500
507
Note - Part of solving the initial device internal state involves assigning random states to all *Gate* inputs. The consequence of this is that all latches and flip-flops will settle with random initial out pin state (as with real devices).
501
508
502
-
You may see slightly different output on the console when you run the simulation depending on which SR latches initially settle with out pin state = true.\
503
-
\
509
+
You may see slightly different output on the console when you run the simulation depending on which SR latches initially settle with out pin state = true.
0 commit comments