Simple XLink code example?

Technical questions regarding the XTC tools and programming with XMOS.
User avatar
leon_heller
XCore Expert
Posts: 546
Joined: Thu Dec 10, 2009 10:41 pm
Location: St. Leonards-on-Sea, E. Sussex, UK.

Simple XLink code example?

Post by leon_heller »

I've been trying to find some simple code examples for communicating via XLinks, without any success. Is there such a thing?

Leon


Heater
Respected Member
Posts: 296
Joined: Thu Dec 10, 2009 10:33 pm

Post by Heater »

Leon, have a look in that xmos_avr project over in the xlinkers forum.

Though it seems there are easier ways than that to set up external links using .xn files. Have yet to research that.
User avatar
leon_heller
XCore Expert
Posts: 546
Joined: Thu Dec 10, 2009 10:41 pm
Location: St. Leonards-on-Sea, E. Sussex, UK.

Post by leon_heller »

I looked at that, there must be something simpler.

Leon
Heater
Respected Member
Posts: 296
Joined: Thu Dec 10, 2009 10:33 pm

Post by Heater »

Well from what I hear you can define these external links, their ports, widths, speeds etc in a .xc file.
This does not seem to be well described anywhere yet. One should be able to read the description of the links in the processor documentation and then match it up to the description of .xn files. Where ever that may be.

Also the is somewhere a project involving an XMOS talking to an xlink implemeted in an FPGA. Apparently that project uses the .xn set up thing.

Not being very helpful am I...
User avatar
leon_heller
XCore Expert
Posts: 546
Joined: Thu Dec 10, 2009 10:41 pm
Location: St. Leonards-on-Sea, E. Sussex, UK.

Post by leon_heller »

I looked at xlink_fpga as well. I just found something very simple that I must have downloaded from somewhere a long time ago for connecting two XC-1 boards, but it's missing the pair.h header file:

Code: Select all

#include <print.h>
#include "pair.h"

void one( chanend outChan, chanend andBackChan )
{
  int a=23;
  printstr("In one...\n");
  outChan <: a;
  andBackChan :> a;
  printstr("Got response...\n");
}

void two( chanend outChan, chanend andBackChan )
{
  int a;
  outChan :> a;
  andBackChan <: a;
}

int main()
{
  chan outChan, andBackChan;
  par
  {
    on stdcore[0]: one(outChan,andBackChan);
    on stdcore[4]: two(outChan,andBackChan);
  }
  return( 0 );
}
and here is the pair.xn file:

Code: Select all

<Network>

  <Declarations>
    <Declaration>core stdcore[8]</Declaration>
  </Declarations>

  <Nodes>
    <Node Number="0" Type="XS1-G4A-FB512">
      <Core Number="0" Reference="stdcore[0]"/>
      <Core Number="1" Reference="stdcore[1]"/>
      <Core Number="2" Reference="stdcore[2]"/>
      <Core Number="3" Reference="stdcore[3]"/>
    </Node>
    <Node Number="1" Type="XS1-G4A-FB512">
      <Core Number="0" Reference="stdcore[4]"/>
      <Core Number="1" Reference="stdcore[5]"/>
      <Core Number="2" Reference="stdcore[6]"/>
      <Core Number="3" Reference="stdcore[7]"/>
    </Node>
  </Nodes>

  <Links>
    <Link Encoding="5wire" Delays="15,15">
      <LinkEndpoint Node="0" Link="10"/>
      <LinkEndpoint Node="1" Link="10"/>
    </Link>
  </Links>

  <Boot>
    <JTAGChain>
       <JTAGDevice Node="0"/>
       <JTAGDevice Node="1"/>
    </JTAGChain>
    <SPIBoot Node="0"/>
  </Boot>

</Network>

I only got five errors when I commented out the pair.h include statement, so it shouldn't be difficult to reconstruct it.

Leon
Heater
Respected Member
Posts: 296
Joined: Thu Dec 10, 2009 10:33 pm

Post by Heater »

Ah, that's just what the Prop to XMOS link needs.

<Link Encoding="5wire" Delays="15,15">

15 clocks between bits and 15 clocks between tokens, or whatever number.

But where to set the link clock divider if you want to?