Question re XN file

Technical questions regarding the XTC tools and programming with XMOS.
User avatar
russf
XCore Addict
Posts: 146
Joined: Thu Dec 10, 2009 10:17 pm

Question re XN file

Post by russf »

In XDE 11.2 #1871, there may be an issue with the rendering of XN files in the Proj Explorer.

The XN file below, once a build is successful using a stub main.xc, shows in the outline a stdcore[2] port called Torvalds.

Liskov and Knuth are missing.

If I increment the Core Number attributes from 0..2, then I see our old friends Knuth and Liskov again.

But that seems to contradict the def of Number in 8.6.2 of the TUG.

Edit: I found that the XS1-2L1.xn does the same in my setup. I attach it at the end.

--r.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<Network xmlns="http://www.xmos.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.xmos.com http://www.xmos.com">

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

	<Packages>
	
		<Package Id="P1" Type="XS1-L1A-TQ128">
			<Nodes>
				<Node Id="Bridge" Type="XS1-L1A" InPackageId="0" >
					<Core Number="0" Reference="stdcore[0]">
            <Port Location="XS1_PORT_8C" Name="Knuth" />
					</Core>
				</Node>
			</Nodes>
		</Package>
		
		<Package Id="P2" Type="XS1-L1A-TQ128">
      <Nodes>
        <Node Id="Buffer" Type="XS1-L1A" InPackageId="0" >
          <Core Number="0" Reference="stdcore[1]">        
             <Port Location="XS1_PORT_8C" Name="Liskov" />
          </Core>
        </Node>
      </Nodes>
    </Package>
		
		
		<Package Id="P3" Type="XS1-L1A-LQ64">
			<Nodes>
				<Node ID="ADC" Type="XS1-L1A" InPackageId="0" >
					<Core Number="0" Reference="stdcore[2]">
             <Port Location="XS1_PORT_8C" Name="Torvalds" />
					</Core>
				</Node>
			</Nodes>
		</Package>
		
	</Packages>

	<Links>
		<Link Encoding="5wire" Delays="0,1">
			<LinkEndpoint NodeId="Bridge" Link="X0LC" />
			<LinkEndpoint NodeId="Buffer" Link="X0LD" />
		</Link>
		<Link Encoding="2wire" Delays="0,1">
			<LinkEndpoint NodeId="Bridge" Link="X0LA" />
			<LinkEndpoint NodeId="Buffer" Link="X0LB" />
		</Link>
		<Link Encoding="2wire" Delays="0,1">
			<LinkEndpoint NodeId="Buffer" Link="X0LC" />
			<LinkEndpoint NodeId="ADC" Link="X0LB" />
		</Link>
	</Links>
	
	<JTAGChain>
		<JTAGDevice NodeId="Bridge" />
		<JTAGDevice NodeId="Buffer" />
		<JTAGDevice NodeId="ADC" />
	</JTAGChain>

</Network>

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<Network xmlns="http://www.xmos.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.xmos.com http://www.xmos.com">
  <Type>Board</Type>

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

  <Nodes>
    <Node Id="0" Type="XS1-L1A-TQ128">
      <Core Number="0" Reference="stdcore[0]"/>
    </Node>
    <Node Id="1" Type="XS1-L1A-TQ128">
      <Core Number="0" Reference="stdcore[1]"/>
    </Node>
  </Nodes>
  
  <Links>
    <Link Encoding="2wire" Delays="0,1">
      <LinkEndpoint NodeId="0" Link="1"/>
      <LinkEndpoint NodeId="1" Link="0"/>
    </Link>
  </Links>
  
    <JTAGChain>
       <JTAGDevice NodeId="0"/>
       <JTAGDevice NodeId="1"/>   
    </JTAGChain>

</Network>


User avatar
russf
XCore Addict
Posts: 146
Joined: Thu Dec 10, 2009 10:17 pm

Post by russf »

Using the above XN file, the code in the box below works fine.

But what if I want to skip the port array csNames, and simply pass Knuth as parameter into the call, something like:

main_core_0(Knuth);

?

When I insert Knuth, I get

../src/main.xc:16: error: parse error before "on"

and the "on" in question derives from the expansion of Knuth. (I still get the same error if I remove 'on stdcore[0] : '.)

Surely this can be done, but the syntax fails me at the moment - not for want of research.

--r.

Code: Select all

#include <xs1.h>
#include <print.h>
#include <platform.h>

out port csNames[1] = {Knuth};

int main_core_0(out port pp){
  pp <: 1;
  return 0;
}

int main()
{
  par
  {
    on stdcore[0] : main_core_0(csNames[0]);
  }
  return 0;
}
m_y
Experienced Member
Posts: 69
Joined: Mon May 17, 2010 10:19 am

Post by m_y »

russf wrote:Surely this can be done, but the syntax fails me at the moment - not for want of research.
I don't think it can be done. "Knuth" is an intialiser for a variable of type port; it's not a value that can be passed as a parameter. Ports can only be initialised statically so being able to pass initialisers around wouldn't, in any case, be of much utility. Your working example takes the right approach: declare and initialise the port then pass the port itself, not its initialiser.
m_y
Experienced Member
Posts: 69
Joined: Mon May 17, 2010 10:19 am

Post by m_y »

russf wrote:In XDE 11.2 #1871, there may be an issue with the rendering of XN files in the Proj Explorer.

The XN file below, once a build is successful using a stub main.xc, shows in the outline a stdcore[2] port called Torvalds.

Liskov and Knuth are missing.
I've just tried to reproduce this, screenshot attached. I see all three ports in the XN pane and in the Outline pane. Is this different from what you're seeing?
outline.png
You do not have the required permissions to view the files attached to this post.
User avatar
russf
XCore Addict
Posts: 146
Joined: Thu Dec 10, 2009 10:17 pm

Post by russf »

m_y wrote: Your working example takes the right approach: declare and initialise the port then pass the port itself, not its initialiser.
Thanks for getting back m_y

The working example succeeds by defining an array of ports, by using the initializer. How can I successfully define a single port, using the initializer? That is what I'm having trouble with. I see several examples of the array type syntax (params to flash access routines, for example) but I don't see an example of a single port using the initializer. I'm prepared to be embarrassed by the simplicity of it... Just need to cross this tiny bridge.

--r.
User avatar
russf
XCore Addict
Posts: 146
Joined: Thu Dec 10, 2009 10:17 pm

Post by russf »

m_y wrote:I see all three ports in the XN pane and in the Outline pane. Is this different from what you're seeing?
In the pane to the right, I see the same as you.

The issue is in the Project Explorer pane, on the left, under platform.h, where I see only Torvalds (apparently by virtue of it being the last defined), unless I provide differing numbers for the Cores in the packages. In the latter case I see all, the cores, and all the ports.
Screenshot-3.png
You do not have the required permissions to view the files attached to this post.
m_y
Experienced Member
Posts: 69
Joined: Mon May 17, 2010 10:19 am

Post by m_y »

russf wrote:How can I successfully define a single port, using the initializer?
Like this?

Code: Select all

#include <xs1.h>
#include <print.h>
#include <platform.h>

out port csName = Knuth;

int main_core_0(out port pp){
  pp <: 1;
  return 0;
}

int main()
{
  par
  {
    on stdcore[0] : main_core_0(csName);
  }
  return 0;
}
m_y
Experienced Member
Posts: 69
Joined: Mon May 17, 2010 10:19 am

Post by m_y »

russf wrote:The issue is in the Project Explorer pane, on the left, under platform.h, where I see only Torvalds (apparently by virtue of it being the last defined), unless I provide differing numbers for the Cores in the packages. In the latter case I see all, the cores, and all the ports.
I see it now. That looks like a bug.

In that XN file all the cores should have "Number" as 0. Having them set as anything else is likely to cause bigger issues later on.
User avatar
russf
XCore Addict
Posts: 146
Joined: Thu Dec 10, 2009 10:17 pm

Post by russf »

Thanks m_y

I'm going to allow finding the bug (+1) to neutralise the initializer foolery (-1) and try to get out of here with my shirt.

Have a good weekend!

--r.