Writing a plugin for `xsim`.

Technical questions regarding the XTC tools and programming with XMOS.
User avatar
errordeveloper
Active Member
Posts: 50
Joined: Wed Dec 16, 2009 6:04 pm
Location: London
Contact:

Writing a plugin for `xsim`.

Post by errordeveloper »

Hello,

I have started looking into the example plugin code distributed with the XDE,
however it appears to have almost no documentation to it.

Does anyone here have experience writing plugins for xsim?

I have a few ideas, though for now I'll probably start by doing an audio testbench
similar to what I did for Verilog VPI (https://github.com/errordeveloper/sftb).
The way I'd like to do this is using I2S, hence I'll need to react to the clock pulses,
is this possible?

I can see there is also a TB example (ExableTestbench), what is the major difference??

Another great idea in the future would be to write an interface for co-simulating
with Qemu, probably first by implementing a plugin that would mimic XLink and
then finding the best way to interface to Qemu. There is one existing yet closed
project that uses Qemu & device trees to co-simulate Linux on Microblaze/FPGA
(http://www.petalogix.com/products/cosim).

Certainly a networking plugin would be also very interesting, but seems more
complex of a task. Well, at the moment I'd very much appreciate hearing of
anybody who worked with xsim plugin API. I haven't yet submitted a support
ticket, but may be someone from Xmos could reply whether a draft of some
kind exists that documents this API. The examples and `xsiplugin.h` are quite
okay to read, though I wish I didn't have to guess how things work!

Cheers,
--
Ilya


User avatar
errordeveloper
Active Member
Posts: 50
Joined: Wed Dec 16, 2009 6:04 pm
Location: London
Contact:

Post by errordeveloper »

Ok, I have just realised that this question is an extended version of my previous question.
I will revisit the answers given there and the examples attached. However, if anyone has
done some work in this area since then, I'd be happy to hear any updates!
User avatar
davelacey
Experienced Member
Posts: 104
Joined: Fri Dec 11, 2009 8:29 pm

Post by davelacey »

The plugin/testbench interface is described in Section 12 of the tools user guide (https://www.xmos.com/support/documentation).

If you are interested, I also put up a small project that lets you write testbenches in python:

https://github.com/xcore/tool_pyxsim

Regards,
Dave
User avatar
errordeveloper
Active Member
Posts: 50
Joined: Wed Dec 16, 2009 6:04 pm
Location: London
Contact:

Post by errordeveloper »

davelacey wrote:The plugin/testbench interface is described in Section 12 of the tools user guide (https://www.xmos.com/support/documentation).
Ah, thanks!! For some reason I have bumped into an odd page on xmos site, namely
it was "http://www.xmos.com/create-simulator-plugin", so I though the documentation
is not quite there yet. I cannot remember what the keywords had been, but may I
suggest that it probably needs deletion/redirection.

I can now see that there even exists 'www.xmos.com/system/files/xsimtest.pdf'
in the search results, although it's cached by Google, it doesn't appear to be on
accessible as PDF any more. Well, go figure .. but I presume that it's all merged
in the Section 12 as you suggested?
If you are interested, I also put up a small project that lets you write testbenches in python:

https://github.com/xcore/tool_pyxsim
I have cloned this one already, though this item in TODO is a bit confusing:
* Implement a value passing mechanism between testbench and simulator
What did you mean by that, David?

Well, in fact all what REAME states is not quite clear:
* Allows you to create simulator instances and run from python
* Within the testbench run plugins written in python
From the first sentence it seems like all you can do is start the
simulator process from python AND if you are saying that the
values cannot be passed around, what it may be possibly useful
for? While the second sentence seems to say that you could do
something like '#include <mycode.py>' in your testbench file?

I'd be quite happy to use Python and all it's libraries, but this README
totally confused me in what I can do with pyxsim after all...
I don't know whether it's just me though ...

And of course, trying to use it on 64-bit Linux didn't quite work :(
Perhaps some wrapper could be written (e.g. until Adobe Flash
had been shipped in 64-bit version, there existed a wrapper for
the 32-bit version to run in 64-bit browsers). Otherwise, I'll try
building Python in 32-bit if I decide to use pyxsim.
I understand that it's easier for Xmos to ship only one 32-bit build
of the library and it sort of reminds me of Verilog VPI which is also
32-bit only by the spec.
User avatar
davelacey
Experienced Member
Posts: 104
Joined: Fri Dec 11, 2009 8:29 pm

Post by davelacey »

errordeveloper wrote: * Implement a value passing mechanism between testbench and simulator
What did you mean by that, David?
This is already done so I should take it out of the TODO llist. If you look at the example you can see that there is a "write_symbol_word" and "read_symbol_word" to poke/peek values from the memory of the simulated device.
Well, in fact all what REAME states is not quite clear:
* Allows you to create simulator instances and run from python
* Within the testbench run plugins written in python
From the first sentence it seems like all you can do is start the
simulator process from python AND if you are saying that the
values cannot be passed around, what it may be possibly useful
for?
You can start the simulator from python *and* write some python plugins to simulate pin behaviour. See the test_pyxsim.py example - it has a sample loopback plugin
While the second sentence seems to say that you could do
something like '#include <mycode.py>' in your testbench file?
No. The python code is only part of the testbench framework.
I'd be quite happy to use Python and all it's libraries, but this README
totally confused me in what I can do with pyxsim after all...
I don't know whether it's just me though ...
I think running the example and playing around will help you. This repo is not particularly developed at the moment but could still be useful to you.
And of course, trying to use it on 64-bit Linux didn't quite work :(
I've removed this from the README now since we now ship native 64-bit versions of the tools (https://www.xmos.com/products/development-tools).
User avatar
errordeveloper
Active Member
Posts: 50
Joined: Wed Dec 16, 2009 6:04 pm
Location: London
Contact:

Post by errordeveloper »

I've removed this from the README now since we now ship native 64-bit versions of the tools (https://www.xmos.com/products/development-tools).
Hm, that's interesting ... I have installed `Desktop-Tools-(Linux-64)(11.2.2).tgz` and I can see:

Code: Select all

> file bin/xcc
bin/xcc: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.2.5, not stripped
> file lib/libxsidevice.so
lib/libxsidevice.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, not stripped
In general it appears that there is a mixture:

Code: Select all

> find | xargs file | grep ELF | cut -d: -f2 | tr -s ' ' | sort | uniq -c
     16  ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.2.5, not stripped
      4  ELF 32-bit LSB relocatable, version 1 (SYSV), not stripped
     12  ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, not stripped
      1  ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.4, not stripped
      4  ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped
      6  ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, stripped

MaxFlashrom
Experienced Member
Posts: 82
Joined: Fri Nov 05, 2010 2:59 pm

Post by MaxFlashrom »

errordeveloper wrote: And of course, trying to use it on 64-bit Linux didn't quite work :(

Perhaps some wrapper could be written (e.g. until Adobe Flash
had been shipped in 64-bit version, there existed a wrapper for
the 32-bit version to run in 64-bit browsers). Otherwise, I'll try
building Python in 32-bit if I decide to use pyxsim.
I understand that it's easier for Xmos to ship only one 32-bit build
of the library and it sort of reminds me of Verilog VPI which is also
32-bit only by the spec.
I don't know if this helps, but it's possible to install the 32-bit libraries on x64 Linux with

Code: Select all

sudo apt-get install ia32-libs 
(or equivalent for RedHat)

This enables any tools that were linked with 32-bit libraries to work. It seemed from the comments that the latest version was supposedly all 64-bit, but your tests seem to confirm otherwise. I'll check my x64 Ubuntu with XMOS 11.2.2 tools setup.

Max.
User avatar
phalt
Respected Member
Posts: 298
Joined: Thu May 12, 2011 11:14 am
Contact:

Post by phalt »

Moved to a more appropriate forum
MaxFlashrom
Experienced Member
Posts: 82
Joined: Fri Nov 05, 2010 2:59 pm

Post by MaxFlashrom »

phalt wrote:Moved to a more appropriate forum
Paul, where should further comment on this topic be directed?
:?
Max.
User avatar
phalt
Respected Member
Posts: 298
Joined: Thu May 12, 2011 11:14 am
Contact:

Post by phalt »

MaxFlashrom wrote:
phalt wrote:Moved to a more appropriate forum
Paul, where should further comment on this topic be directed?
:?
Max.
I've moved the entire topic to the correct thread. It's now in its correct place!
Post Reply