Common code for software and hardware