How about an emulator/simulator that runs on your computer and emulates/simulates the Teensy itself?

impcc

Active member
I've found a number of threads about the Teensy emulating lots of different stuff like classic games, etc. But how about the other way around? Can we emulate/simulate a Teensy itself on a desktop/laptop//PC/Mac computer (with any reasonable speed or fidelity?) I did not manage to find a thread talking about this.

I realize that once we get to the 4.1, it's probably getting towards "not reasonable speed any more" emulating a 600MHz ARM on a 4GHz Intel i7, but it seems like it could be a reasonably useful developer tool, even if it can't keep up with the native hardware running at full speed.

Just a thought.

-Ian
 
Sure. IIRC, the 68332's manual was ~1600 pages. And there was a sim for that, back in the day (early 90s). I didn't write it, but...

I'm not requesting that someone create one, just asking if someone happened to have already done so. :)
 
Even a simulator for this ARM core would be nice to know about. It would be great to simulate Teensy audio library processing algorithms on my PC before moving to the Teensy itself.

So, even if it is not for the whole Teensy 4.1 device, might anyone know about a simulator for its ARM core?

Chip
 
To simulate audio lib code only needs a framework to mimic the audio lib framework, not the whole board and processor.
 
I agree that it doesn't need the whole board, but it does need some processor-oriented elements. As two examples, it needs the data type truncation / overflow behavior of the ARM core as well as have simulations of the ARM CMSIS DSP routines.
 
For what it is worth, I am developing Teensy code on PC in Visual studio. I don't need fancy simulator. From audio library I am only using DMA streaming code, nothing else, on PC side I am using ASIO to get pretty much the same low latency streaming. I do all calculations in float and Teensy handles float processing pretty fast. Doing development on PC greatly shortens compile-change cycle and allows debugging.
 
Yeah, that's mainly what I was hoping for: a way to iterate super-quickly on a PC, preferably with some kind of I/O sim (at least GPIO), but even just CPU sim would be cool. Again, I'm not demanding, mainly just asking if something already exists. I remember, from the days of yore (yeesh... 30 years ago), that bootstrapping a 68338 bootloader/kernel was made a lot a lot easier by using Mac SE30s (68030) for development vs erasing & burning EPROMs over and over. Teensy is a lot easier than that, to be sure, but I figured it couldn't hurt to ask.
 
The problem with a microcontroller compared to a microprocessor is that it has a whole lot of peripherals on the chip, dozens and dozens of them for something like the iMX RT1060, making an emulator a much weightier endevour than just an instruction set - and the peripherals run in real time in parallel too. To be really useful an emulator basically has to be cycle perfect as well, meaning you have to emulate all the timing of caches and the dual-issue instruction pipelines to be thorough. Probably the only reliable emulator is the VDHL/Verilog model the manufacturer used (which ain't ever going to be available without heavy NDA restrictions).

I'd say split your code into hardware-specific parts that need real hardware to prove, and hardware independent parts you can test separately. Even then the specialized DSP instructions will be a headache (heavily used in the Audio library).

For playing with DSP coding I always start in Python as its much more productive for experimentation, coding to C++ only when ready to try out on the T4.
 
I don't really see the need for a simulator. I tend to agree with MarkT is that the real problem is simulating the devices. Until you can simulate all of the devices hooked up, only a few things could be done on a simulator.

Then you get to the issue of who is going to build such a thing? In general for the scope people want, you generally are not going to get people to dedicate a large effort and make this simulator free or at least a cheap enough charge that the majority of folk will use it. You also have the issue that to simulate a program can often take hundreds if not thousands of instructions on the host doing the simulation. Sure in some cases, ancient 8-bit game code on MAME simulators might be faster than the original machine, but I suspect in general, it will just be faster to use a Teensy.

Now in doing compiler development since 1979, I have often used simulators, particularly when when I was supporting new targets. These were created so the compiler teams could implement support for a new CPU (either a completely new architecture, or a tweak on an existing architecture that has new instructions) before the silicon was available.

In terms of my use, these were often instruction set simulators that adds the new instructions, and you don't worry about the performance of the code. Generally, when the first real machines were made available for my use, I would move from using simulators to using the real hardware. Now, often that first generation of real hardware is slowed down, but until I'm running benchmarks, it typically doesn't matter. Generally by the time I need to run benchmarks, I prefer to do it on real hardware that is not the initial generation, because I am skeptical that any simulator will be completely cycle accurate.

But there are simulators that are much more detailed and try to be cycle accurate. They allow the cpu hardware designers to isolate bottlenecks during their design. I don't know what the performance numbers are for these simulators, but I recall in the past for a different employer, that it would often take a week of simulation to get to allow the user program to print its first message (and the machines doing the simulation were often the fastest/largest machines of the current generation). And such simulations often needs tons of disk to hold all of the information that can be reduced to look at the issue at hand.

In terms of the Teensy, the unfortunate thing is we don't have access to the JTAG hardware to allow a debugger to more easily debug the code. I believe there is a port of a gdb stub that allows Teensys to be debugged without using JTAG support. It may be a better use of time to enhance this support so it is more useful.

In a previous job, I ran into somebody that was the corporate fixer. One of her jobs was chip courier. She would fly first class (because they get double the carry on luggage) and carry two empty carry on suitcases. She would meet her contact at the airport and load up the suitcases with the very first chips coming out of the fab. She would fly back ASAP, and then deliver the chips to the various teams bringing up the chip. At this stage, there are likely things that don't work, and the bring up teams will need to deal with the issues.
 
Last edited:
Back
Top