We present a hardware/software codesign methodology using formal transformations. The goal is to refine a given function specification of a task to an operational structure involving both hardware and software components, The refinement process is separated into two levels, the algorithmic and the structural, Within each level, refinement is accomplished by applying sequences of transformations that preserve the functionality of an initial specification, This allows various 'correct' design alternatives to be generated and their costs analyzed, At the algorithmic level, different algorithm designs are explored, each producing a computational schedule that has a different performance cost. At the structural level, different spatial structures with different resources and performance costs are explored. These costs which characterize the designs are used to assist in the hardware/software partitioning, An example is used throughout to illustrate this methodology.