Sign In

Don't have a Xilinx account yet?

  • Choose to receive important news and product information
  • Gain access to special content
  • Personalize your web experience on Xilinx.com

Create Account

Username

Password

Forgot your password?
XClose Panel
Xilinx Home
Reply
Regular Visitor
manvarjay
Posts: 36
Registered: ‎03-26-2012
0
Accepted Solution

Can we get output on FPGA board using HW Co-Simulation?

Hello there,

                I want to develop a realtime system which includes interfacing of matlab & FPGA board (using Sys. Gen.) in which I need to display the results on the LCD placed on the FPGA board.

 

For learning purpose I am trying to glow some LEDs. It works perfect for HW Co-Sim., but It do not give output accordingly on the board even when I define the pins on Gateway Out block of the model. The model and the pin assignment is shown in the attachment.

 

Is it possible to get such thing as I want? i.e. to get output on board along with the HW Co-Sim.

 

-
Jay Manvar.
LED_HW.png
Visitor
thomas1974
Posts: 37
Registered: ‎05-16-2012
0

Re: Can we get output on FPGA board using HW Co-Simulation?

I am not sure, but is it really possible to ran the real hardware in a simulation environment?

 

Too me HW Co sim ist still virtual, since the whole code is packed and wrapped to be calulated in hardware, rather than in software (MATLAB). AFAIK you will have to build the real design.

 

 

Super Contributor
vlavruhin
Posts: 195
Registered: ‎12-08-2010
0

Re: Can we get output on FPGA board using HW Co-Simulation?

Hello, Jay.


Is it possible to get such thing as I want? i.e. to get output on board along with the HW Co-Sim.

Yes, it is possible.

 

Your model contains two different parts.

 

 

1. First part is actually your design:

LED_HW_01.jpg

 

You can simulate this part of model using generated netlist. But this simulation allows you only to check your design in Simulink without taking into consideration placing, routing and real delays in your target FPGA.

 

But you can generate for this part of model bitstream (using System Generator token). Then this bitstream could be written into FPGA. And if you set pins in Gateway In and Gateway Out ports, then these pins will be used in bitstream.


... It do not give output accordingly on the board even when I define the pins on Gateway Out block of the model. The model and the pin assignment is shown in the attachment.

Such pin assignment will let you get output only if you configure the FPGA using generated bitstream and provide some data to the FPGA pin assigned as input (Gateway In).

 

 

 

2. Second part of your model is used for HW-cosimulation:

LED_HW_02.jpg

 

HW-cosimulation allows you to feed input data to the model, then process it in the FPGA and get output data to Simulink. But you can declare some input/output ports as the physical pins of the FPGA. To do this, you need to create new custom board target plugin for HW-cosimulation. Look at pages 241 and 317 of System Generator User Guide:

http://www.xilinx.com/support/documentation/sw_manuals/xilinx13_4/sysgen_user.pdf

There is a detailed description of non-memory mapped gateways and the process of creating custom board target plugin.

Best Regards,
Vitaly.
Visitor
thomas1974
Posts: 37
Registered: ‎05-16-2012
0

Re: Can we get output on FPGA board using HW Co-Simulation?

ok, but then this is a modified design ...

 

maybe it is reasonable to generally add additional io pins to be able to investigate some output also physically,(?)

 

 

Regular Visitor
manvarjay
Posts: 36
Registered: ‎03-26-2012
0

Re: Can we get output on FPGA board using HW Co-Simulation?

Hello Vitaly,

 

             Thanks for the reply. I got the things you have explained. But still have some doubts.

1st part : 

              In 1st part as I am taking input from simulink blocks I can't assign any pin to input. And other thing is that, I want to make a real time system which processes in MATLAB any gives output to FPGA and FPGA processes for the given input and gives output. Now I am getting output at the simulink (from FPGA) with one click(real time) but I also want to see the output on the FPGA board so that no one can doubt that "it is just a simulation" rather it is a HW implementation.

             And I don't want to download the bit file manually, I have already done it and after the successful output of the code, I put it in the Black Box and now I am trying to make it real time.

 

2nd part : 

             I have tried as per your guidance but still it doesn't work. The user guide tells to make changes in template files but the template files are general for Sys. Gen., what when we want to use it for other program? Moreover in the ucf file(in .zip folder) of the new custom board it shows the pins I have assigned but as you said it also need input pin, it do not give any output. 

can you explore the 2nd part if possible.

-
Jay Manvar.
Super Contributor
vlavruhin
Posts: 195
Registered: ‎12-08-2010
0

Re: Can we get output on FPGA board using HW Co-Simulation?

Hello, Jay.

 

So you would like to HW-cosimulate the model with input from Simulink and output to the pins of FPGA.


             I have tried as per your guidance but still it doesn't work. The user guide tells to make changes in template files but the template files are general for Sys. Gen., what when we want to use it for other program?


No, you shouldn't change original board files. Template is provided just for reference.


Moreover in the ucf file(in .zip folder) of the new custom board it shows the pins I have assigned but as you said it also need input pin, it do not give any output.


You can set just output ports as non-memory mapped gateways. Input port is memory mapped. So you can feed data through it from Simulink.

 

Create new custom board plugin. Set your target FPGA, the parameters of JTAG connection, the clock pins and the pins of your output non-memory mapped gateways. Then install this plugin. Close System Generator's window with parameters. Open it again by clicking on System Generator token in the model. Now you should be able to see your new custom board HW-cosimulation target. Don't forget to generate library with custom non-memory mapped gateways and replace output gateways with them in your model before generation of HW-cosimulation block.

Best Regards,
Vitaly.
Regular Visitor
manvarjay
Posts: 36
Registered: ‎03-26-2012
0

Re: Can we get output on FPGA board using HW Co-Simulation?

Hello Vitaly,

 

Thanks once again for the reply.

 

__________________________________________________________________________________________

So you would like to HW-cosimulate the model with input from Simulink and output to the pins of FPGA.

__________________________________________________________________________________________

 

yes, exactly this is what I want to do.

 

 

______________________________________________________________________________________________________

Create new custom board plugin. Set your target FPGA, the parameters of JTAG connection, the clock pins and the pins of your output non-memory mapped gateways. Then install this plugin. Close System Generator's window with parameters. Open it again by clicking on System Generator token in the model. Now you should be able to see your new custom board HW-cosimulation target. Don't forget to generate library with custom non-memory mapped gateways and replace output gateways with them in your model before generation of HW-cosimulation block.

______________________________________________________________________________________________________

 

I have done everything except last two step 1) generating library with custom non-memory mapped gateways and 2)  replace output gateways.

 

I don't know how to generate custom library. can you please tell me how to generate it?


-
Jay Manvar.
Super Contributor
vlavruhin
Posts: 195
Registered: ‎12-08-2010
0

Re: Can we get output on FPGA board using HW Co-Simulation?


I don't know how to generate custom library. can you please tell me how to generate it?

Jay, look for a MATLAB script named <your_custom_target_board_name>_libgen.m in the folder <your_custom_target_board_name>, where your plugin has been installed. Or you can save custom target plugin during generation in zip file. This archive also contains <your_custom_target_board_name>_libgen.m.

 

Execute this script from MATLAB command line and it will create a library with non-memory mapped gateways.

Best Regards,
Vitaly.
Regular Visitor
manvarjay
Posts: 36
Registered: ‎03-26-2012
0

Re: Can we get output on FPGA board using HW Co-Simulation?

Hi Vitaly,

 

    Thanks a lot for the solution, it's working perfectly. I still have one query. In this case it is working because we are glowing some LEDs and leave it (I mean timing does not metter here). But if we want to display some results on LCD then it is not working as it requires perticular signals to be set/reset at defined time. I don't understand the relation between timings of simulink and FPGA clk. Hope you can add some valuable thoughts on the topic "http://forums.xilinx.com/t5/DSP-Tools/How-to-cope-up-with-large-time-simulation-in-Simulink/td-p/234..." which will help me solving this LCD display problem as well as saves time to make my system real time so that I can show a demo (only if it takes less time) for my Dissertation.

-
Jay Manvar.
Visitor
amruta.jadhav
Posts: 7
Registered: ‎12-17-2012
0

Re: Can we get output on FPGA board using HW Co-Simulation?

Hello ,

I also have the same problem. i am also  using hardware cosimulation  in my simulink model .ihave also tried all the steps you told.i have also created new custom board plugin . there is a lot of timing  difference in the simulink scode output and output on actual haraware pin.

 

 

i just want to ask you that is it possible  for eg .if i generate 1kHz sinwave in simulink model.and generate hardware cosimulink block for that model.can i get the same 1Khz ouptut on actual fpga board if measure on oscilloscope.

 

please help to solve my problem.

 

regards,

Amruta