leonardt / fault

A Python package for testing hardware (part of the magma ecosystem)
BSD 3-Clause "New" or "Revised" License
41 stars 13 forks source link

Read port value post-sim #171

Closed standanley closed 5 years ago

standanley commented 5 years ago

The purpose of this change is to allow the user to read results out of the simulation after running it. I intend it to work a lot like Print, except you get the value in python rather than a string to StdOut.

What the code does right now: I've tacked some functionality onto Expect, creating a special type of Expect that really just functions as a marker for the time+port you care about, and has no assert. After the simulation you get back an array of values, each one corresponding to one special Expect statement. (Also, right now it only works for SpiceTarget, since that's what I was using)

What I think it should do: The functionality should probably be its own action (maybe Read is a good name), but maybe it could be part of Peek or Print. There should be some way of linking a particular Read to its post-simulation value rather than relying on the user to remember which value in the array corresponds to what in the simulation. I propose that Read actually just returns the relevant time in the simulation, and post-simulation there is a function to give the user the value of any port at that time. (This might be difficult if we add some flow control to the simulation inputs; in that case an arbitrary handle might be better than the time.)

If someone can give a second opinion on 1) whether this should be part of an existing action, and 2) what's a good way to link a pre-sim request for a value and the post-sim access of that value, I can get started on some new code.