I cant Trace signal when simulating my application

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
IgorLopez
Member++
Posts: 25
Joined: Tue Mar 11, 2014 8:16 pm

I cant Trace signal when simulating my application

Post by IgorLopez »

Hi,

I have a problem tracing signals when simulating my application which uses an external plugin to handle the pins my application is looking at.
What I get from xtimecomposer after pressing run is:
XScopePlugin: Error: Unable to find __sodFlag symbol on tile: tile[0]
I am sure I am not setting things up properly and is therefore in need of someone pointing in the right direction. The plugin needs three argument which are given as space separated strings after the specified plugin file on the External tab under Simulator when opening the Run Configurations window. The arguments must be "0 X0D23 X0D13" (without the two ")

My target code is this:

Code: Select all

#include <i2c.h>
#include <xs1.h>
#include <platform.h>
#include <syscall.h>


port p_scl = XS1_PORT_1F; // XOD13
port p_sda = XS1_PORT_1H; // XOD23

//[[distributable]]
void i2c_slave_register_file(server i2c_slave_callback_if i2c)
{
  while (1) {
    select {
    case i2c.start_read_request(void):
      break;
    case i2c.ack_read_request(void) -> i2c_slave_ack_t response:
      response = I2C_SLAVE_ACK;
      break;
    case i2c.start_write_request(void):
      break;
    case i2c.ack_write_request(void) -> i2c_slave_ack_t response:
      response = I2C_SLAVE_ACK;
      break;
    case i2c.start_master_write(void):
      break;
    case i2c.master_sent_data(uint8_t data) -> i2c_slave_ack_t response:
      response = I2C_SLAVE_ACK;
      break;
    case i2c.start_master_read(void):
      break;
    case i2c.master_requires_data() -> uint8_t data:
      data = 1;
      break;
    case i2c.stop_bit():
      break;
    }
  }
}

int main() {
  i2c_slave_callback_if i_i2c;
  par {
    i2c_slave_register_file(i_i2c);
    i2c_slave(i_i2c, p_scl, p_sda, 0x21);
  }
  return 0;
}
which is targeted for a startkit board. I am using the latest i2c_lib (3.1.1) and the other libs included are lib_logging (2.0.0), lib_startkit_support (2.0.0) and lib_assert (2.0.0)

I have attached my plugin as plugintest.tar.gz (both source code folder and the resulting .so file built for x86_64) if somebody wants to test, md5sum should be: 9f915a8018daf8c53badb38d4145fa40. Note, the library makefile is made with paths for placing the library in the lib folder such that its location should be inside the plugin folder (Community_14.0.3/src/plugins/I2CTestPlugin)
Make the library by:
make -f MakefileUnixGPP.mak
g++ -g -fPIC -O3 -Wall -Wsign-compare -Wpointer-arith -c I2CTestPlugin.cpp -o I2CTestPlugin.o -I../../../include
g++ I2CTestPlugin.o -shared -o ../../../lib/I2CTestPlugin.so -lc -ldl -lstdc++
Attachments
plugintest.tar.gz
zipped source and lib
(3.74 KiB) Downloaded 233 times
plugintest.tar.gz
zipped source and lib
(3.74 KiB) Downloaded 233 times


User avatar
kris
Experienced Member
Posts: 84
Joined: Mon Jan 18, 2010 2:52 pm

Post by kris »

Hi Igor

Have you set -fxscope in the makefile?
e.g:

XCC_FLAGS = -O2 -g -fxscope

Cheers,
Kris.
IgorLopez
Member++
Posts: 25
Joined: Tue Mar 11, 2014 8:16 pm

Post by IgorLopez »

Thanks Kris, as usual do You solve my problem.
Back to my I2C again.
IgorLopez
Member++
Posts: 25
Joined: Tue Mar 11, 2014 8:16 pm

Post by IgorLopez »

Ok, the simulator does run but I have two problems(at least).

The first one is that I do not get the trace (VCD) for more than 22 us even though I have limited the simulation to 11000 steps (since the app is a while(1) type) and my plugin only has data for up to 110 us (I am expecting the plugin_clock to be called every 10ns).

Secondly, during the 22 us I have I know that my plugin should drive the sda from high to low at time step at 5 us and the scl from high to low at 10 us and then back up from low to high at 17 us.
In the VCD view when checking the ports in question, tile[0]_XS1_PORT_1F/H nothing is happening.
What could the cause of this be?

/Igor
User avatar
kris
Experienced Member
Posts: 84
Joined: Mon Jan 18, 2010 2:52 pm

Post by kris »

Hi Igor,

How are you limiting the simulation. If it's via the 'Limit cycles to' option in the
Simulator tab of the run configuration, then this number refers to core clock
cycles (i.e. 400/500MHz), and not reference clock cycles (i.e. 100MHz).

Also, plugin_clock will be called once per core clock (i.e. every 2 ns), thus
maybe this explains the discrepancy.

Cheers,
Kris.
IgorLopez
Member++
Posts: 25
Joined: Tue Mar 11, 2014 8:16 pm

Post by IgorLopez »

Kris, thanks again for helping me out.
Now I see the whole simulation and need to figure out why the first 20 us does not behave as my plugin is designed for.

B.R
/Igor
IgorLopez
Member++
Posts: 25
Joined: Tue Mar 11, 2014 8:16 pm

Post by IgorLopez »

Tracing signals works but for some reason is the simulation doing something else than my plugin during the first 20 us. Note that in the attached image are sda and scl low in the beginning and sda changes to high at 22.88 us and scl from low to high at 22.98 us but my plugin is setting both pins high at the first call to plugin_clock.
I moved the whole message 30 us forward in time and then I can see a correct pattern on scl/sda with the exception that my I2C slave app does not ACK on the ninth bit.
I have attached an image of the simulation and note that the ACK from the I2C slave should be a high on sda during bit 9 (since there is no electrical pull-up when simulating) so I modified the lib so it does that:

Code: Select all

p_sda <: 1; // FIXME : changed to from 0 to 1 since no pull-up when simulating
Attachments
Simulating_NoAckFromSlave.png
(138.98 KiB) Not downloaded yet
Simulating_NoAckFromSlave.png
(138.98 KiB) Not downloaded yet
Post Reply