r/embedded • • 4d ago

Emulation and Simulation

In the last year AI has completely taken over how much my team used AI and We were able to basically just Gen code left right and center. Using connected hardware CI/CD works to a certain extent but it felt like we really need better ways to handle the type of load that AI was putting for the pace we "needed" to be going with agents.

So when generation is easy and validation is still hard, how useful are people finding emulation/simulation? And since its important this is for usually post silicon micro-controller level work IOT, automotive etc.

16 Upvotes

24 comments sorted by

7

u/mossy_stile 4d ago

Renode only simulates the datasheet, not the silicon errata.

2

u/ActBrokeToStayRich 3d ago

well with current LLMs you could just feed in the errata too? where would you draw the line?

6

u/PurpleSupermarket1 4d ago

I have Claude making changes and running it on emulation. Emulation is very helpful to find RTL issues. This is pre-silicon.

4

u/ActBrokeToStayRich 3d ago

yeah this is where the big split it feels like, when I worked in pre-silicon FPGA emulation and even just normal QEMU was very much used. but post silicon it completely falls off which I feel like theres a gap in how we can do our process

5

u/Simple_Tough4223 4d ago

Instead of using (or even building) a simulator/emulator, I would rather build a hook/mcp for the agent to knows what's happening in the board, or at least hook a debug tool for the agent to handle and understand what's going on. And even it can mock peripheral to "simulate" directly in the hardware instead of a sim tool in computer.

And if it needs you to interact your board, it can pause and ask/guide you do to, then it will auto continue.

3

u/ActBrokeToStayRich 3d ago

yes but with that understanding, isnt the logical step that you make a emulator/simulater where you can upkeep behaviour? regression etc?

2

u/Simple_Tough4223 2d ago

Uhmm yeah, from an aspect, we can say that.

But in fact, I don't trust any simulators that are just pure softwares in the computer. There must be something different from the real hardware, especially some important features, not jst simple GPIOs

Or in other words, we still need hardware, and connect with the computer by some ways (serial debug port, udp, tcp or anything else that'll be able to provide enough info and tools about that specific hardware). And the "simulator" here will be hooked into that communication (or connect directly), then bypass to the agent.

The agent then can read any info it wants or even control peripherals via a set of commands. So it consists of 2 parts: "simulator" in computer, and a small engine as firmware/bootloader on chip (it's not the main program).

For now we have to self-build both of them for a specific MCU. But then if it become a standard, the manufacture can integrate into the chip as a protocol - the hardest part. The other part (simulator) is more flexible - someone will provide, or we can self-build easier with AI's help. But must connect the hardware to computer for the best result and diagnose.

4

u/ArgVoid42 3d ago

In my experience, simulation is super useful as long as you're clear about what you're actually testing with it.

I use PC simulation a lot for complex state machines (including sub-state machines) per unit. Since I can just spin up a thread per unit on a PC, I can simulate the actual network communication and timing interactions between multiple units way faster than on a physical test bench.

For the hardware layer, I keep it simple with stubs and mocks instead of trying to emulate silicon accurately. For example, for hardware ID detection (an ADC reading from a resistor voltage divider), I just stub it directly. For something like a stepper motor on a robot arm, I use a mock so I can inject whatever state, position, or fault I want and verify how the state machines react.

It obviously won't catch silicon errata or real electrical quirks, so you still need the hardware farm at the end. But it takes a huge load off your physical CI boards because you catch almost all the state machine, protocol, and fault-handling bugs on PC first.

2

u/ActBrokeToStayRich 3d ago

Yeah networking seems like a place where everyone can do more host based sim. I really agree that we should just be honest of what gets tested and what doesnt in which layer.

So past the host based mock is kind of the idea we had where there needs to be a more silicon accurate layer after host based testing, because ISRs, driver level things etc. I think where people like me want something is where we could do more the actual register behaviour and things(Renode like)

2

u/ArgVoid42 3d ago

Yeah, thats true!

Honestly, in my experience, once you get down to real register behavior and ISRs, it's usually cheaper to just hook up a real board / HIL setup than to build and maintain a simulator for that layer.

I know it's not the ideal scenario when your hardware farm is already a bottleneck, but on most real budgets that ends up being the practical approach. If Renode already supports your exact MCU and peripherals out of the box it can be great, otherwise maintaining accurate register/peripheral models gets expensive pretty fast.

2

u/ArgVoid42 3d ago

A lightweight stub/mock PC setup like this is way cheaper, and AI can actually help you spin it up pretty fast...

One more thought: if you really want detailed hardware-level simulation, a full Digital Twin is an option, though it gets quite expensive to build and maintain.

4

u/Ohmic_Test_Systems 3d ago

Making Renode simulations has been very powerful for me. With Claude and a debugger you can scrape all the registers and put together a good simulation quickly. Same goes for sensors IC's too.

There's several projects where I do all my firmware development in Renode now and don't need the hardware. Which opens up the door to many parallel devices working on different firmware tickets at the same time. Really powerful if done right.

2

u/ActBrokeToStayRich 3d ago

How much of the maintainance of renode are you having to do yourself? With AI I have also found Renode really helpful but doing BLE and IOT things it seems to struggle and you need to sink so much time there?

2

u/Ohmic_Test_Systems 3d ago

You're right that I'm constantly maintaining the Renode simulations now, but only when I see they don't match the physical hardware. Then I have enough claude credits it doesn't take much of my time, it just takes up one my debuggers and units under test, so it slows down other development.

BLE/IoT are not as easy though, I agree. All I can say is keep adding logging statements to help figure out the behavior.

3

u/ActBrokeToStayRich 3d ago

you should upstream your findings! they are pretty slow to get it in though. but I feel like now with most people able to do their own debugger + validation mismatch Renode can be so much better than it is..

14

u/madsci 4d ago

I have yet to find anything that I need simulated where I could depend on the simulation to model the behavior I'm interested in. If the hardware always worked the same as the documentation says, I wouldn't have all of these bugs to figure out.

4

u/RepresentativeCut486 STM32 Supremacy 4d ago

Simulacra and Simulation

1

u/wolfefist94 2d ago

"I understood that reference"

3

u/duane11583 3d ago

Hire experienced engineers and pay them 

You need to understand the code ai creates otherwise you Mr company has no value 

1

u/Aggressive_Canary_10 4d ago

I have been using Ai to write code and have been running it on cadence emulation platforms. The Ai was helpful in coding as well as to give me assistance in using the cadence tools.

1

u/ActBrokeToStayRich 3d ago

what chips? or boards?

3

u/Aggressive_Canary_10 2d ago

I was testing a risc v core that will go in a chip under development

1

u/ActBrokeToStayRich 1d ago

yeah makes a lot of sense for pre silicon dev

2

u/ventZl CMRX RTOS 2d ago

We isolate hardware behind the driver API which abstracts hardware behavior away. Not that we put a thick abstraction on top of the HW. The difference in HW behavior is a problem of the driver. It **MUST** provide stable behavior.

Then the rest is just a standard application software. So we'll usually build spec-compliant mock of the driver and assemble the software on top of it for testing purposes.

You can do A LOT this way.