Speed comparison pyCPU vs. 8bit AVR

The Following is a comparison of the execution speed of a very simple PORT toggling programm between an 8bit atmega AVR and the pyCPU, just to get an idea.

The C Programm for the AVR:

#include <avr/io.h> // (1)

int main (void) {            

   DDRB  = 0xFF;             
   PORTB = 0x00;             

   while(1) {              

   return 0;                 

The python Programm for the pyCPU:

def main():
  global PORTC_OUT


  while 1:

Comparison of the Bytecode instructions vs. the AVR Assembler instructions of the mainloop:

In this simple example the instructions generated look quite similar although the pyCPU has a stack based architecture (the xor instruction has no parameter and is always executed with the items on the top of the stack). In this example the pyCPU executes the code faster because the jump there only takes one cycle. Another thing is that a normal 8bit AVR runs in the 0-20 Mhz range. But the pyCPU can be ran for example on a CycloneII FPGA with approximatly 60 MHz. Anyway this example is maybe only hardly usfull. But it makes pyCPU look good!!

Next thing to go into some detail is probably code-density and resource usage.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: