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
Contributor
pavel47
Posts: 73
Registered: ‎10-31-2011
0
Accepted Solution

SYSGEN: How to deliver image inside "Gateway In"

Hello,

 

How can I deliver image matrix (Image From File, Simulink) trough block Gateway In. The output of Image From File is matrix 240x320. Gateway In accepts only scalars. DSP block Unbuffer doesn't help, as it only converts 240x320 into flow 1x320. Should I develop some custom converter, or there is some Simulink facility ?

 

Thanks in advance.

 

Regards.

 

Pavel.

Expert Contributor
eilert
Posts: 2,058
Registered: ‎08-14-2007
0

Re: SYSGEN: How to deliver image inside "Gateway In"

Hi,

do the data setup for your simulation in matlab.

Then your simulink model can read the data from the workspace.

You can even trigger the simulation from your matlab script.

 

e.g:

t= 1:1000;

t=t'; %make it a column vector

image= some_load_image_function();

image_stream =image(:);  

 

sim('my_model.mdl');

% you can add extra code for intense result analysis after this.

%provided the simulink results have been written to the workspace.

 

 

And there's also some "Convert 2-D to 1-D" in the Signal Processing Blockset.

 

Have a nice simulation

  Eilert

Contributor
pavel47
Posts: 73
Registered: ‎10-31-2011
0

Re: SYSGEN: How to deliver image inside "Gateway In"

[ Edited ]

Hello Eilert,

Thank you for suggestions.

Concerning matlab setup, for the moment I don't need in additional extracode. Maybe later ...

What I want to do for the moment is just run a simple simulation - run image through Xilinx gateways. But it doesn't work (please, look at picture in attachment).Gateway In accepts only scalars, but not arrays - either 1xN, or MxN.

It seems that to accomplish this task one must create some sort of clocked transmitter, that sent one pixel of image array per clock.

Or maybe there is other solution - find some kind of tsuch ransmitter in Simulink blocksets, or read image directly in Xilinx block ?

Regards.

Pavel.

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

Re: SYSGEN: How to deliver image inside "Gateway In"

Hello, Pavel.

 

Try to use "Reshape" block to convert your image to the vector. And then convert it to the stream of samples by using block "Unbuffer".

 

convert_image_to_samples.jpg

Best Regards,

Vitaly.

Best Regards,
Vitaly.
Contributor
pavel47
Posts: 73
Registered: ‎10-31-2011
0

Re: SYSGEN: How to deliver image inside "Gateway In"

Hello Vitaly,

 

Simulation run without errors. Thanks.

 :smileyhappy:

 

Now the problem is how to get image out of Xilinx Gateway Out. The array simout is filled with '0' (please look at picture)

Maybe I didn't correctly set Gateway In:

Output Type: Unsigned

Number of bits: 8

Binary point:1

 

Regards,

 

Pavel.

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

Re: SYSGEN: How to deliver image inside "Gateway In"

Hello, Pavel.

 

It's better to set "binary point" to 0 if your input's type is 'uint8'. But it's not critical.

 

It seems that your problem is connected with simulation time.

In order to get some meaningful data out of "Buffer" block, simulation time should be equal or larger than your buffer size. In your case it's 240*320. It's due to the fact that buffer needs time to accumulate input samples. And after that it ouputs the frame of accumulated samples.

 

Best Regards,

Vitaly.

Best Regards,
Vitaly.
Expert Contributor
eilert
Posts: 2,058
Registered: ‎08-14-2007
0

Re: SYSGEN: How to deliver image inside "Gateway In"

Hi guys,

actually the Reshape block and the Convert 2D to 1D block perform the same operation.

I missed that something like Unbuffer is needed in the simulink environment, because I rarely work directly there.Sorry.

(Too unflexible, too much clicking in dialogs)

In the script using u(:) is sufficient, because the column vector data from the workspace is read in elementwise.

(Also I'm using just simple In/Out blocks rather than From/To Workspace, so I can use my models directly as subsystems for larger systems.)

 

Have a nice simulation

   Eilert

 

Contributor
pavel47
Posts: 73
Registered: ‎10-31-2011
0

Re: SYSGEN: How to deliver image inside "Gateway In"

The best! :smileyhappy:

Only bizarre thing - array simout contains 153600 elements (240*320*2) and first half is '0'.

I set simulation time to 320*240.

Regards.

Pavel.

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

Re: SYSGEN: How to deliver image inside "Gateway In"

Yes, but it's normal. All pixels (or samples) are processed in the system one by one. So when you input one pixel, the system outputs one pixel. But buffer block waits for all input pixels of given image size (240*320) before it can output this frame. You can set default initial value of output as parameter "Initial conditions" of "Buffer" block.

 

 

Best Regards,

Vitaly.

 

 

Best Regards,
Vitaly.
Super Contributor
vlavruhin
Posts: 195
Registered: ‎12-08-2010
0

Re: SYSGEN: How to deliver image inside "Gateway In"


eilert wrote:
(Too unflexible, too much clicking in dialogs)

In the script using u(:) is sufficient, because the column vector data from the workspace is read in elementwise.

(Also I'm using just simple In/Out blocks rather than From/To Workspace, so I can use my models directly as subsystems for larger systems.)

 

Have a nice simulation

   Eilert

 



Hello, Eilert.

 

Absolutely agree with you. Processing of MATLAB variables is much easier to do in scripts than in Simulink.

Best Regards,
Vitaly.