FPGAsm must know where to place instances. In most cases, each module must declare a loc paramname, and each instance must set its location using a loc:... name:value pair.
There are two kinds of locations on the FPGA. There are absolute locations such as K12 or SLICE_X5Y12. There are also locations relative to this module.
Absolute locations are usually specified for IO ports and other unique FPGA primitives. The location information may be set in the instance of the primitive, or passed to it from above using the variable syntax !..!. See Spartan3 module 'InSimple' for an example.
but0 InSimple loc:K12 ;
In many cases we want to be able to instantiate multiple copies of modules in different locations. To do that we must use relative locations. This requires two steps:
1) declare a parameter named loc in the module,
2) each instance should set its loc parameter using the relative xy(..,..) syntax. For instance:
mymod(loc) ....{ submod sub1 loc:xy(0,0) .. ; submod sub2 loc:xy(0,1) .. ; }
submods are now located on a grid relative to the mymod. So if at some later point we instantiate in our top module:
xx mymod loc:xy(10,10)
it will in turn create our submods at xy(10,10) and xy(10,11).
Relative locations will propagate as deep as the hierarchy goes, placing instances at correct FPGA primitive sites.