PIC16F84 emulation
Chris Merck
Posts: 55
heater's post on his 8085 emulator (this one: http://forums.parallax.com/showthread.php?p=711157) made me smile, and then seriously consider writing a PIC emulator.
I am thinking a starting point would be emulating the PIC16F84. Since it uses a 34-instruction RISC this should be relatively simple. And, since the PIC is typically run at 4Mhz (and up to 20Mhz max) there is a chance that emulator performance will approach that of the real device. Furthermore, due to the plethora of existing PIC projects and tools, this emulator may be valuable in quickly moving projects over to the propeller. And if the emulation could run fast enough, perhaps there could be a "real-time" mode where timing-critical PIC code targeted for 4Mhz operation could run properly in the emulator! Lastly, there is the potential for high-level emulation, if certain methods of hardware interfacing are taken as standards. For example, the emulator could be extended with video peripherals in the following way: code the emulator-on-prop to function in the same way as Jesus Arias's emulator-on-pc does (www.ele.uva.es/~jesus/pic/).
Anyway, this summer I will probably be tied up with my maglev research (which may use a prop), but this is another idea. I am especially looking for comments on the 1) technical feasibility and 2) expected usefulness of such an emulator.
Thanks,
Chris
I am thinking a starting point would be emulating the PIC16F84. Since it uses a 34-instruction RISC this should be relatively simple. And, since the PIC is typically run at 4Mhz (and up to 20Mhz max) there is a chance that emulator performance will approach that of the real device. Furthermore, due to the plethora of existing PIC projects and tools, this emulator may be valuable in quickly moving projects over to the propeller. And if the emulation could run fast enough, perhaps there could be a "real-time" mode where timing-critical PIC code targeted for 4Mhz operation could run properly in the emulator! Lastly, there is the potential for high-level emulation, if certain methods of hardware interfacing are taken as standards. For example, the emulator could be extended with video peripherals in the following way: code the emulator-on-prop to function in the same way as Jesus Arias's emulator-on-pc does (www.ele.uva.es/~jesus/pic/).
Anyway, this summer I will probably be tied up with my maglev research (which may use a prop), but this is another idea. I am especially looking for comments on the 1) technical feasibility and 2) expected usefulness of such an emulator.
Thanks,
Chris
Comments
The PIC16F84 was the first PIC I got involved with. Using a BS2 OEM pcb and Al Williams' application and loader/programmer; not the easiest device to begin with. Was tough without a debugger/simulator/emulator to debug programs. Later graduated to -87x PICs; enjoyed that much more.
Hope you have the time to do more than just consider a PIC emulator. I'm sure others will be interested in such an emulator.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko
I have been considering attempting another emulation project and PIC was a first thought but I think I'm more tempted by Atmel's AVRs. You see one main motivation behind the 8085 project was to be able to use a free C compiler (BDS) for the 8085. With AVRs we also have a free C development kit for Windows and Linux courtesy of GCC.
Not sure I'd want to get into trying to emulate all the peripherals that these devices have though.
Anyway looks like my available time will be limited for such things in the future.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
That is very true. Unfortunately I have never worked with AVRs (maybe because Microchip gives out freebies ). I have heard good things though, like less quirky assembler and as you mention GCC port.
But if we are going to emulate them, who cares if they can't get the real ones?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
There are quite a few addresing modes to take care of.
Things like skip (an instruction) can skip 2 or more bytes depending on the following instruction so you can't just bump the PC but have to decode the following instruction redundantly to see what size skip to make.
I don't think I'm up for that.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
Choosing a processor is the next tough choice, and it definitely helps if one has experience with whatever's chosen.
First question is how complicated is it, which really means how easy is it to decode the opcodes and the fewer opcodes the better, and then how well does the instruction set sit with the Propeller hardware - a 32-bit processor limits the number of object code instructions which can be held in RAM, 8-bit may allow more but comes with more complex decoding.
For the PICmicro, 12-bit and 14-bit instruction sets don't fit nicely with 8/16/32-bit, and the special operations with specific SFR registers (FSR, INDF) and register banking complicates things. I wouldn't say don't but it wouldn't be my choice in expecting a clean and lean emulation.
Another issue is Status Register bits. They can really mess up an otherwise elegant emulator.
I'd not paid much attention to the Texas Instruments MSP430 until recently, but that looks like it could be a nice architecture to emulate but it still has a few complications in addressing modes ( especially load constants ) ...
mspgcc.sourceforge.net/manual/x223.html