Bluegiga BGScript Accelerator sample. I want to understand the example code
You are using a front end language to program an 8051 with a proprietary BLE transceiver, the binary-only driver libraries of which are otherwise only compatible with a fairly uncooperatrive, expensive, windows-only C compiler and IDE.  But most of your questions can be understood through the generic 8051-ness of it and the fact that you are interfacing a well-documented peripheral.


  According to "hardware_io_port_config_direction", the direction is the setting of I/O. For example, hardware_io_port_config_direction(1,$7) means Port1_7pin is used as Input, isn't it?


That would depend if the function's documentation says it takes a port pin number or a power-of-two place value.  My suspicion (almost certain given the way it is used later in the code and the match for how the 8051 I/O ports work) would be on the latter.  So this is not a reference to port pin 7, but rather to the combinations of port pins 0, 1, and 2, with values of 1, 2, and 4 which together add up to 7.

call hardware_io_port_write(1,$7,$3)             



  Why port 1? The Datasheet shows P1_7 is "DCDC on/bypass control". Why $7?  Just "7" with out "$" is not correct? What $3 means?  


Controlling a DC/DC converter is a possible alternate function of Port 1 pin 7, but if not configured (or software driven?) for that purpose you can also use it as a general purpose I/O.  However, the idea that this is a reference to port pin 7 is almost certainly a misinterpretation.

Instead, 7 is the combination of the place values of port pins 0, 1, and 2.  It would appear that BGscript syntax uses $ to denote a literal value or possible a hex value, we can't tell from the number given, but you could by reading the documentation.  We'll get to the reason for the specific values in a minute.

What's really interesting though is that there are two constants instead of just one.  It may be that the first is a bit mask which restricts which port pins' values can be altered by the call, and the second sets those values.  To be sure you would have to check the function documentation.

call hardware_spi_transfer(0,2,"\x0a\x06")      



  The Datasheet shows P0_2 is "UART CTS".  What is "\x0a\x06"? What this lien meaning !?


The documentation will tell you for sure, but this appears to be writing a count of 2 bytes to the SPI 0 synchronous serial engine.  Or perhaps 0 indicates that it should not use a hardware chip select - check the documentation. "\x0a\x06" is clearly a payload of two bytes to be written, values 0x0a (10 decimal) and 0x06 (6 decimal).

Now examining a typical sequence:

call hardware_io_port_write(1,$7,$7)
call hardware_spi_transfer(0,2,"\x18\x00")(spiresult,channel,tlen,tmp(0))
call hardware_io_port_write(1,$7,$3)    
call attributes_write(x_data,0,2,tmp(0:2))


The two io_port calls set port one to a value of 7, and then 3 before and after an SPI access.  This would appear to assert the bit with a value of 4 - ie, port pin 2 during the SPI transfer.  That's fairly sensible and suggests it is being used as the SPI select pin to the peripheral.  The only thing odd is the ordering - usually SPI selects are active low and so we'd expect to see it written to 3 (pin 2 = 0) before the transfer and back to 7 (pin 2 = 1) afterwards.  Does the ADXL345 have an active-high SPI select?

The final line of the block appears as if it is writing the measured data to something in the BLE system so that the measurement can be obtained by a remote device.

3 What is cdc.xml. Is it necessary?


That sounds like something involved in enabling CDC-ACM virtual serial port communications with a PC via the CC2540's USB port.  

4 Can I debug using display? I want to display x,y,z_data on screen.


Yes, possibly if you have virtual serial output over USB as above.  But you'd have to check the Bluegiga docs to learn how.