5 ms·
I'd like to for example create a PCB with some sensors, LEDs, and a microcontroller, specify the sensor input over time and the software on the microcontroller,
by madez 9y ago
I'd like to for example create a PCB with some sensors, LEDs, and a microcontroller, specify the sensor input over time and the software on the microcontroller, and let the computer figure out the behaviour of that system, so it can tell me state of the system (i.e. what LEDs are on, or what values are in the registers of the microcontroller?) at a given time. For performance reasons, that would require both low-level simulation (electrics) and high-level simulation (software on the microcontroller) simultaneously in a compatible way. Can SPICE do that?
- jimmyswimmy 9y agoSPICE can do a lot, but you're asking a LOT. Modelling internal states of a micro is generally a different package than the mainly analog simulation that SPICE does. It is rare for them to be tied together. Practically speaking, your interface ought to be separate enough that you can define the range of states the micro's inputs should see, and the range of outputs it should drive, and separate the two. There are times when I've wished for a combined simulation but it wasn't worth the hassle to set it up. Honestly for the accuracy I expect I usually prefer to just build the thing rather than simulate it. LEDs are really boring to model anyway.
- madez 9y agoI also think that I ask for a lot. And I know that simulation is hard, error-prone, and often more expensive than just buillding the real system. However, building the system does not always give the insight that a simulation can give, and it's sometimes prohibitively expensive. More specifically, I already had built the system, but I couldn't get the information out of it without disturbing it too much. That's why I wanted to simulate it.
- stephen_g 9y agoA full logic simulation of a processor can be done from VHDL or Verilog code in software, but cycle accurate simulations are many, many orders of magnitude slower than a real IC. You can set up testbench code that feeds in data and stuff, and link different stuff together digitally. I don't know if there's much in the way of analogue simulators like SPICE hooked up to logic simulators though. The next level down is to run it up on an FPGA, which is only a few orders of magnitude slower than you can clock an IC.
- jononor 9y agoCombined software/MCU and circuit simulation is, as far as I know, not really existing in the FOSS world. I would loove to be proven wrong on this. Several times I've considered building my own...
- madez 9y agoI'm thinking about what would be necessary for it. It seems doable to me. First, one would need to separate the simulation into different domains, define interfaces between them, and then figure out appropiate time stepping for the simulation so the domains are properly coordinated. Depending on how low-level the simulation needs to be, getting the needed data for the parts might be problematic. However, when that data isn't available, then maybe the simulation can just randomly create plausible values, and do the simulation for these values. In reality, every part has slight variations so every board is unique too, when inspected closely enough. There is also a lot of merit in a simulation even if it can't go very deep, say, considering quantum mechanical effects inside the IC's. That may be practically impossible due to unknown data, or just give impractical performance. But there are a lot of use-cases that don't need that level of detail. What level of detail is realistically possible? If we know that a certain level of detail is too slow to simulate, then writing a simulator for a higher level is easier and we need less data for the models.
- jononor 9y agoI would be fine with even needing to modify the MCU code to use the simulator APIs in the Hardware Abstraction Layer - then no MCU emulation needed at all. So then essentially this needs to push/pull data in from the SPICE domain for the circuit simulation part. It should be possible to reuse an exiting simulator there, hopefully.