Xconnect Xlink / Link Problem

All technical discussions and projects around startKIT
User avatar
data
Active Member
Posts: 43
Joined: Wed Apr 06, 2011 8:02 pm

Post by data »

Chanends can transmit any type at any time; they do not have to be set up to send a specific type. There is no special initialization to do to make a chanend transmit a 32-bit integer, for instance. You can use a chanend to transmit a 32-bit integer, and in the next instruction use it to transmit an 8-bit char. Chanends do not "know" what types are going to be transmitted through them.

By "initialization" I meant the activity of setting up the chanends for static forwarding, which is the technique used in the dynamic Xlink demo. If those steps are not done properly, e.g. if you skip them or don't set up the routes properly, you could get an ET_ILLEGAL_RESOURCE.

You generally only use static forwarding if you have to have something like hot-plugging with Xlinks -- I believe it's a relatively unusual application, and it can be tricky to get working. (Note to XMOS: proper hardware & system support for hot-plugged Xlink would be received with great enthusiasm!)

At any rate, for static-forwarded links, the outuint-style functions are what you'll need to use.


Bambus
Member++
Posts: 27
Joined: Tue Feb 28, 2017 12:52 pm

Post by Bambus »

I just took the exact code from the demo and it works for transmitting characters. I am sending integers from one end but the receiving end throws exceptions when I try to write the data to an integer variable. I doesn't throw exceptions when I write data to a char. This is why I thought that there must be something about the chanend that I have missed. I have tried in/out inline asm instructions and outuint but to no avail.
User avatar
data
Active Member
Posts: 43
Joined: Wed Apr 06, 2011 8:02 pm

Post by data »

Did you also change the receiving end to receive integers, using inuint?
Bambus
Member++
Posts: 27
Joined: Tue Feb 28, 2017 12:52 pm

Post by Bambus »

Yes I also tried that. It just gives me the same resource exception.
User avatar
data
Active Member
Posts: 43
Joined: Wed Apr 06, 2011 8:02 pm

Post by data »

Can you post the code you changed?
Bambus
Member++
Posts: 27
Joined: Tue Feb 28, 2017 12:52 pm

Post by Bambus »

In the transmitting part:

case 5: /* send data tokens */
/*if (!link_got_credit(LINK_NUM)) {
comm_state = 4;
break;
}*/
unsafe {
// outct((chanend)c,XS1_CT_WRITE4);
outuint((chanend)c, 753);
}
if (err_ctr++ == SEND_CTRL_TOKEN) {
err_ctr = 0;
unsafe {
outct((chanend)c, XS1_CT_ACK); //Send a control token as app sync point

}
}
break;

And in the receiving part:

else {
unsafe{
// outct((chanend)c,0x83);
data=inuint((chanend)c);
// asm ("in %0, res[%1]":"=r"(data):"r"((chanend)c));

// c :> data;
volatile int * unsafe p = &g_data_tokens;
*p = *p + 1;
if (data!=753) error++;
}
}

edit: the code from the receiving part is in the test_ct function.
User avatar
data
Active Member
Posts: 43
Joined: Wed Apr 06, 2011 8:02 pm

Post by data »

If this is the only code you changed, I suspect that the control token is somehow coming through at the wrong time. This might not be caught by testct because testct only checks the next byte. What happens if you comment out the outct in the transmit part?

By the way, I'm afraid I steered you a bit wrong. In this code, the chanend is streaming, and when you use the I/O operators with a streaming chanend, they expand to the same instructions as inuint/outuint. So, the I/O operators are fine here.

I still prefer inuint/outuint in this situation, just because they make it very clear what's going on -- the I/O operator depends on the type of the rvalue and that can add a little confusion.
Bambus
Member++
Posts: 27
Joined: Tue Feb 28, 2017 12:52 pm

Post by Bambus »

When i comment out the outct, I still get the resource exception on the receive part.

I am surprised that there is no other thread on issues with xconnect. How do people setup anything if there is no document containing all necessary information?
User avatar
data
Active Member
Posts: 43
Joined: Wed Apr 06, 2011 8:02 pm

Post by data »

Don't despair -- some of us have got it working! This is an off-label use of Xconnect, so support can unfortunately be a bit light. In fact there's much more documentation than there used to be.

I'm out of guesses, so I'll try this out on my hardware (I have a setup for running this demo, as it happens).
Bambus
Member++
Posts: 27
Joined: Tue Feb 28, 2017 12:52 pm

Post by Bambus »

Thank you, I appreciate your help a lot! Always makes me happy when someone puts effort into helping me :)
Post Reply