Automated Scratchpad Mapping and Allocation for Embedded Processors