|
51 | 51 | vals2 = [int(2**random.uniform(1, 8) - 2) for _ in range(20)] |
52 | 52 | vals3 = [int(2**random.uniform(1, 8) - 2) for _ in range(20)] |
53 | 53 |
|
54 | | -sim_trace = pyrtl.SimulationTrace() |
55 | | -sim = pyrtl.Simulation(tracer=sim_trace) |
| 54 | +sim = pyrtl.Simulation() |
56 | 55 | sim.step_multiple({ |
57 | 56 | 'in1': vals1, |
58 | 57 | 'in2': vals2, |
|
62 | 61 | # In order to get the result data, you do not need to print a waveform of the trace. |
63 | 62 | # You always have the option to just pull the data out of the tracer directly |
64 | 63 | print("---- Inputs and debug_out ----") |
65 | | -print("in1: ", str(sim_trace.trace['in1'])) |
66 | | -print("in2: ", str(sim_trace.trace['in2'])) |
67 | | -print("debug_out: ", str(sim_trace.trace['debug_out'])) |
| 64 | +print("in1: ", str(sim.tracer.trace['in1'])) |
| 65 | +print("in2: ", str(sim.tracer.trace['in2'])) |
| 66 | +print("debug_out: ", str(sim.tracer.trace['debug_out'])) |
68 | 67 | print('\n') |
69 | 68 |
|
70 | 69 | # Below, I am using the ability to directly retrieve the trace data to |
71 | 70 | # verify the correctness of the first adder |
72 | 71 |
|
73 | 72 | for i in range(len(vals1)): |
74 | | - assert sim_trace.trace['debug_out'][i] == sim_trace.trace['in1'][i] + sim_trace.trace['in2'][i] |
| 73 | + actual = sim.tracer.trace['debug_out'][i] |
| 74 | + expected = sim.tracer.trace['in1'][i] + sim.tracer.trace['in2'][i] |
| 75 | + assert actual == expected |
75 | 76 |
|
76 | 77 |
|
77 | 78 | # --- Probe ---- |
|
118 | 119 | vals1 = [int(2**random.uniform(1, 8) - 2) for _ in range(10)] |
119 | 120 | vals2 = [int(2**random.uniform(1, 8) - 2) for _ in range(10)] |
120 | 121 |
|
121 | | -sim_trace = pyrtl.SimulationTrace() |
122 | | -sim = pyrtl.Simulation(tracer=sim_trace) |
| 122 | +sim = pyrtl.Simulation() |
123 | 123 | sim.step_multiple({ |
124 | 124 | 'in1': vals1, |
125 | 125 | 'in2': vals2, |
|
128 | 128 | # Now we will show the values of the inputs and probes |
129 | 129 | # and look at that, we didn't need to make any outputs! |
130 | 130 | # (although we did, to demonstrate the power and convenience of probes) |
131 | | -sim_trace.render_trace() |
132 | | -sim_trace.print_trace() |
| 131 | +sim.tracer.render_trace() |
| 132 | +sim.tracer.print_trace() |
133 | 133 |
|
134 | 134 | print("--- Probe w/ debugging: ---") |
135 | 135 | # Say we wanted to have gotten more information about |
|
0 commit comments