FPGARelated.com
Forums

manipulation of two dimensional matrices in VHDL

Started by sanghamitra6 8 years ago13 replieslatest reply 8 years ago440 views

Two dimensional matrices can be handled in VHDL if we directly enter the elements of the matrix in the VHDL module. But if the matrix is very large typing all the elements could be time consuming and so the matrix can be given as input through text files. How to manipulate such two dimensional matrices through text files in VHDL.

[ - ]
Reply by martinthompsonOctober 15, 2016

Where is the data coming from (that you would otherwise have to type in?)

Can you generate it programmatically? 

Or if it's image data, you could use my PGM reading functions:

http://parallelpoints.com/reading-image-files-with...


Beware, think of where it is going to be stored in the FPGA - you can not usually store the whole thing at once without external memory - so you will need to stream it through your processing.

[ - ]
Reply by sanghamitra6October 15, 2016

Thanks for the help @martinthompson.For the time being if I ignore the hardware implementation n focus on simulation of the LSB based image steganography algorithm. How do I start developing the code for the algorithm in VHDL. I have very little knowledge of VHDL.

[ - ]
Reply by martinthompsonOctober 15, 2016

Sounds like you need to learn VHDL first... (think about the response you would get if you went to a software-based message board and said "How do I start developing the algorithm in C.  I have very little knowledge of C" - the answer would be similar - learn some C first)

A suggested first project: 

Try making a simulation of a counter.  

Then synthesise it - use that counter to turn an LED on and off at a slow enough rate to see by eye.  This is the FPGA equivalent of "Hello World".


[ - ]
Reply by sanghamitra6October 15, 2016
Thank you so much. I have already done that first project u mentioned.
[ - ]
Reply by martinthompsonOctober 15, 2016
OK, so now you need to think about building up to the task you actually want to accomplish.  I'll say (again) I don't think this is a sensible FPGA project, unless it is just for educational reasons, but if you do want to carry on, here's one simulation-based approach:


* Create a memory block - ideally infer it, use your vendor's synthesis guidelines for sample code

* Get a small image into the memory - read it from disk and manipulate the memory block pins to write it in

* Write more code to read the memory block out and write it to disk.  Check that you get the same image that you put in

* Now write the code to manipulate the LSB of the image and place it in between the memory read process and the writing to disk process.

[ - ]
Reply by PtorruOctober 15, 2016

Hi there,

is this a testbench or synthesizeable code?

[ - ]
Reply by sanghamitra6October 15, 2016

This is not a test bench.

[ - ]
Reply by sanghamitra6October 15, 2016

Post deleted by author

[ - ]
Reply by adamt99October 15, 2016

What fpga are you targeting? If it is spartan 6, seven series or later i would use the free HLS in C and use the matrix manipulation libraries. 


You can then use c to open and read in the text files the core to manipulate your matrix as you desire and then save it back to a file for analysis

[ - ]
Reply by sanghamitra6October 15, 2016

I am going to use Spartan 6.

[ - ]
Reply by sanghamitra6October 15, 2016

I need to manipulate matrices of image pixels to implement LSB based steganography algorithm in VHDL.

[ - ]
Reply by asserOctober 15, 2016

In such a situation, I usually use something like perl script to generate the vhdl text with the matrix content. (Perl can be built in the simulator). But in modelling, it would be better to load the file with the data into the vhdl model. I use the loader of .bmp files because it is rather simple to describe it in vhdl. The computation results I output to the .bmp file as well and see, analyse it by the usual image tool.

[ - ]
Reply by martinthompsonOctober 15, 2016

I'm intrigued, why do you need to use an FPGA for that?  That seems like a software task...