**UPGRADE YOUR BROWSER**

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community Forums
- :
- Forums
- :
- Hardware Development
- :
- Video
- :
- Re: Work with matrix

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

elizash

Visitor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

08-10-2011 10:50 PM

7,769 Views

Registered:
05-11-2011

Hi all,

I need to generate the random sparse matrix but elements of have to be at specific place for example random numbers on diagonal other is 0.How can I store it ? And how I can get the special element of this matrix each time?

Thanks in advance !

1 Solution

Accepted Solutions

francism

Xilinx Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

09-20-2011 08:50 AM

8,478 Views

Registered:
05-23-2008

All,

in Coregen there is a Linear Algebra toolkit IP. Please see http://www.xilinx.com/products/intellectual-property/EF-DI-LAT.htm

regards

Mike

8 Replies

eilert

Advisor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

08-11-2011 12:48 AM

7,766 Views

Registered:
08-14-2007

Re: Work with matrix

hi,

matlab has the "eye" function, giving you amatrix filled with ones on the diagonal:

e.g.:

>> eye(7)

ans =

1 0 0 0 0 0 0

0 1 0 0 0 0 0

0 0 1 0 0 0 0

0 0 0 1 0 0 0

0 0 0 0 1 0 0

0 0 0 0 0 1 0

0 0 0 0 0 0 1

now you can multiply this with a rqandom matrix of the same size using the ".*" operator for element wise multiplication

e.g.:

rand(7,7).*eye(7)

ans =

0.0648 0 0 0 0 0 0

0 0.5798 0 0 0 0 0

0 0 0.4611 0 0 0 0

0 0 0 0.8744 0 0 0

0 0 0 0 0.2140 0 0

0 0 0 0 0 0.4399 0

0 0 0 0 0 0 0.6072

So much for generating such a matrix.

But for the other questions, please be more specific.

Is this also just matlab related, or is anything with FPGAs involved?

Have a nice simulation

Eilert

elizash

Visitor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

08-11-2011 11:36 PM

7,752 Views

Registered:
05-11-2011

Re: Work with matrix

Hi,

If be more specific, I need store this matrix in some element in system generator .I know two store elements which probably can be appropriate for it: ROM and single port RAM.But my problem is how to get specific element of this matrix ?For example I need only element (5,5)?And another question which appears :How can I do matrix multiplication?not just multiplication element by element?

if and then ^{[1]}

and size of matrix can be different.

eilert

Advisor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

08-12-2011 12:29 AM

7,750 Views

Registered:
08-14-2007

Re: Work with matrix

Hi,

ok, so you want to do matrix math inside an FPGA.

It's not impssible, but kind of inconvenient, if you are used to the high level matlab functions.

Actually you have to redesign the algorithms according to your system specifications all by yourself.

In some cases you may find predifined libraries written in some HDL, but they may not always fit to your requirements one way or the other.

So, how to proceed:

Lets just assume that you somehow managed to store some 2D Matrix into a RAM.

The RAM now holds a 1D representation of your matrix.

e.g.

RAM address Matrix element

0 a

1 b

2 c

3 d

4 e

5 f

6 g

7 h

Now you need some controlling device (e.g. some FSM) that performs read operations on this ram and controlls a data path, that is able to do two multiplications and one addition (e.g.: a*e + b*g), the result then can be stored to some other ram position or forwarded to some output, depending on your requirements.

As you can see the adress for some specific element of the marix can be calculated using some simple operations:

adress=row_pos+col_pos*row_length

If your matrix dimension is a 2^n value, the multiplication herein is a simple shift operation.

There are many things that can be done to optimize the performance of your design in any direction (area vs. speed), but they are very specific to your requirements.

If the size of your matrix shall be different, you need to make your controller flexible, e.g. by using loadable counters for address calculations. basically just the same as you would do in software, just that you have to care fore some more limitations because the arithmetic structure (your datapath) has to be fixed, and can not change at runtime.

Also your memory is kind of limited, if you intend to use just internal RAM ressources.

Hope you got an idea now what lies in front of you.

This is hardware design and the higher grade of freedom has to be paid with work time.

Have a nice synthesis

Eilert

elizash

Visitor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

08-18-2011 05:53 AM - edited 08-18-2011 06:21 AM

7,745 Views

Registered:
05-11-2011

Re: Work with matrix

Thanks for reply and I am trying to it.But now I faced other problem I need to find a reminder.I am tring to use Divider Generator but it gives result only after 50 time clk. But I need that it gives each time.I try to use black box but it gives me 0 output.

Simple verilog code:

module remaider(counter,matrixsize,remainder,clk); input [15:0] counter; input [15:0] matrixsize; input clk; output signed [14:10] remainder; always @ (posedge clk ) begin assign remainder = counter%matrixsize; end endmodule

I know why it gives 0 because output of model changes to [5:0] but i didn't get why??

eilert

Advisor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

09-12-2011 10:55 PM

7,721 Views

Registered:
08-14-2007

Re: Work with matrix

Hi,

sorry for answering so late, I had some weeks of vacancy.

The solution is simple, you hopefully already found it by yourself.

In your black box the HDL simulator isn't activated:

sim_method "Inactive"

So, without a HDL simulator runnig you won't get any outputs from the black box.

You can choose between ISIM or Modelsim. In the later case you also have to add the ModelSim block to your simulink model.

Have a nice simulation

Eilert

francism

Xilinx Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

09-20-2011 08:50 AM

8,479 Views

Registered:
05-23-2008

All,

in Coregen there is a Linear Algebra toolkit IP. Please see http://www.xilinx.com/products/intellectual-property/EF-DI-LAT.htm

regards

Mike

Highlighted
##

Jump to solution

elizash

Visitor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-21-2011 06:20 AM

7,698 Views

Registered:
05-11-2011

Re: Work with matrix

Yes thanks)I already understood problem)

boudy

Visitor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-02-2014 02:23 AM

6,363 Views

Registered:
03-20-2014

Re: Work with matrix

bro how can i multiply a matrix, using xilinx block in simulink?