Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Can i store data with variable length in a RAM in VHDL ?

Status
Not open for further replies.

Mai89

Junior Member level 2
Joined
Jun 5, 2019
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
131
I need to store data with variable lengths in the same RAM. Can I do that using VHDL? If not, is there any suggestions to solve this ?
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
48,284
Helped
14,228
Reputation
28,717
Reaction score
12,923
Trophy points
1,393
Location
Bochum, Germany
Activity points
279,601
Basically yes, however variable length doesn't mean infinite length. To write synthesizable VHDL, you need to set an upper limit for the length.
 

    Mai89

    Points: 2
    Helpful Answer Positive Rating

Mai89

Junior Member level 2
Joined
Jun 5, 2019
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
131
Basically yes, however variable length doesn't mean infinite length. To write synthesizable VHDL, you need to set an upper limit for the length.
Yes, I have 3157 elements and the largest one is 424-bit.
 

barry

Advanced Member level 5
Joined
Mar 31, 2005
Messages
5,093
Helped
1,113
Reputation
2,238
Reaction score
1,100
Trophy points
1,393
Location
California, USA
Activity points
27,907
Are you saying you have 3157 elements and the elements are different sizes? That would mean you would need at least 1.3 Mega-bits of memory (3157 x 424).

Maybe you want to use a record rather than a memory?
 

    Mai89

    Points: 2
    Helpful Answer Positive Rating

Mai89

Junior Member level 2
Joined
Jun 5, 2019
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
131
Are you saying you have 3157 elements and the elements are different sizes? That would mean you would need at least 1.3 Mega-bits of memory (3157 x 424).

Maybe you want to use a record rather than a memory?
Yes, Like this:

c61626630396663356162626103636f6d00
0570726573730f75666f6e65636f6e666572656e636503636f6d00
096d61696c2d68656c7003636f6d00
076e696768746c790e77696e646f777375706461746573026575
056e63656261036f726700
08776f6f646d61746502697400
0477696e640d77696e646d696c6c64726f707303636f6d00
077765626d61696c09796f75727475726265036f726700
056170706c650f6c656e6f766f7369746567726f757003636f6d00
106672616d65776f726b737570706f7274036e657400
08746f7067616d736503636f6d00

They are exist in a text file. I need to store them using VHDL to perform some operations based on them.
Could you please give me a hint about how using "record" in this case and I will google it also.
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
48,284
Helped
14,228
Reputation
28,717
Reaction score
12,923
Trophy points
1,393
Location
Bochum, Germany
Activity points
279,601
Record can be used if the length of individual elements is fixed at compile time. I guess it's not.

For true variable length you can use linked list or index table.
 

    Mai89

    Points: 2
    Helpful Answer Positive Rating

Mai89

Junior Member level 2
Joined
Jun 5, 2019
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
131
Record can be used if the length of individual elements is fixed at compile time. I guess it's not.

For true variable length you can use linked list or index table.
Could you give me some examples please be useful in my case mentioned in the previous post.
 

KlausST

Super Moderator
Staff member
Joined
Apr 17, 2014
Messages
19,443
Helped
4,299
Reputation
8,603
Reaction score
4,260
Trophy points
1,393
Activity points
128,956
Hi,

If it is ASCII you may use delimiters.

Now the question is: Do you need access to a dedicated element?
Let's say element 345, then element 1765?
Or do you process them one after the other?

Klaus
 

    Mai89

    Points: 2
    Helpful Answer Positive Rating

barry

Advanced Member level 5
Joined
Mar 31, 2005
Messages
5,093
Helped
1,113
Reputation
2,238
Reaction score
1,100
Trophy points
1,393
Location
California, USA
Activity points
27,907
Could you give me some examples please be useful in my case mentioned in the previous post.
for example, if you know ahead of time that element 35 is always 18 bits long, etc., then you can use a record. But if element 35 can have any length, you can’t use a record, since it’s fixed length. Without knowing ,more about your data, it’s hard to make intelligent recommendations.
 

    Mai89

    Points: 2
    Helpful Answer Positive Rating

Mai89

Junior Member level 2
Joined
Jun 5, 2019
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
131
Hi,

If it is ASCII you may use delimiters.

Now the question is: Do you need access to a dedicated element?
Let's say element 345, then element 1765?
Or do you process them one after the other?

Klaus
No, it is in Hex format.
I will sort them ascending to access them one after one.
--- Updated ---

for example, if you know ahead of time that element 35 is always 18 bits long, etc., then you can use a record. But if element 35 can have any length, you can’t use a record, since it’s fixed length. Without knowing ,more about your data, it’s hard to make intelligent recommendations.
My data like this:
c61626630396663356162626103636f6d00
0570726573730f75666f6e65636f6e666572656e636503636f6d00
096d61696c2d68656c7003636f6d00
076e696768746c790e77696e646f777375706461746573026575
056e63656261036f726700
08776f6f646d61746502697400
0477696e640d77696e646d696c6c64726f707303636f6d00
077765626d61696c09796f75727475726265036f726700
056170706c650f6c656e6f766f7369746567726f757003636f6d00
106672616d65776f726b737570706f7274036e657400
08746f7067616d736503636f6d00

each element has fixed size(while the operation) but the size of all elements is not the same.

what I want exactly to store these data, sort them ascending and access any one at any time by it's address.
 

KlausST

Super Moderator
Staff member
Joined
Apr 17, 2014
Messages
19,443
Helped
4,299
Reputation
8,603
Reaction score
4,260
Trophy points
1,393
Activity points
128,956
Hi,

not clear.
each element has fixed size(while the operation) but the size of all elements is not the same.
It´s confusing to me.

what I want exactly to store these data, sort them ascending and access any one at any time by it's address.
If you sort them.... why not sort them before storing? Then there is no need to sort them afterwards.
and why not storing them with identical length?
Ascending to what exactly .. when they are not in the same length? (Then they need to be treated some kind of right_aligned or left_aligned. Treated like a string or like a unsigned_int, or a signed_int, or a floating point..)
What does address in this case mean?

Klaus
 

Mai89

Junior Member level 2
Joined
Jun 5, 2019
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
131
Hi,

not clear.

It´s confusing to me.


If you sort them.... why not sort them before storing? Then there is no need to sort them afterwards.
and why not storing them with identical length?
Ascending to what exactly .. when they are not in the same length? (Then they need to be treated some kind of right_aligned or left_aligned. Treated like a string or like a unsigned_int, or a signed_int, or a floating point..)
What does address in this case mean?

Klaus
I need to treat them as strings if it is possible, it will be more useful for me.
 

barry

Advanced Member level 5
Joined
Mar 31, 2005
Messages
5,093
Helped
1,113
Reputation
2,238
Reaction score
1,100
Trophy points
1,393
Location
California, USA
Activity points
27,907
You really haven't stated your intent clearly. I think you just have to have every element be maximum length.
 

    Mai89

    Points: 2
    Helpful Answer Positive Rating

Mai89

Junior Member level 2
Joined
Jun 5, 2019
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
131
You really haven't stated your intent clearly. I think you just have to have every element be maximum length.
Th task that I want is storing this data to perform "String Matching"

c61626630396663356162626103636f6d00
0570726573730f75666f6e65636f6e666572656e636503636f6d00
096d61696c2d68656c7003636f6d00
076e696768746c790e77696e646f777375706461746573026575
056e63656261036f726700
08776f6f646d61746502697400
0477696e640d77696e646d696c6c64726f707303636f6d00
077765626d61696c09796f75727475726265036f726700
056170706c650f6c656e6f766f7369746567726f757003636f6d00
106672616d65776f726b737570706f7274036e657400
08746f7067616d736503636f6d00

Is there any suggestions how to do this?

I tried to make a CAM but it needs data with the same size and also it consumes more logic
 

KlausST

Super Moderator
Staff member
Joined
Apr 17, 2014
Messages
19,443
Helped
4,299
Reputation
8,603
Reaction score
4,260
Trophy points
1,393
Activity points
128,956
Hi,

a string usually is delimited with 0x00. You are free to use any other suitable value. (0x0d, 0x0a...)

I don´t know whether using a string is possible or suitable ... as long as you don´t tell us what you want to achieve. What´s your goal?

Compare data .. is no goal.
Treat them as string ... is no goal.
It´s both like filling water into a glass. It´s just a step to the goal. Another step is to drink the water.
But the goal is not to die of thirst.


Klaus
 

    Mai89

    Points: 2
    Helpful Answer Positive Rating

Mai89

Junior Member level 2
Joined
Jun 5, 2019
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
131
Hi,

a string usually is delimited with 0x00. You are free to use any other suitable value. (0x0d, 0x0a...)

I don´t know whether using a string is possible or suitable ... as long as you don´t tell us what you want to achieve. What´s your goal?

Compare data .. is no goal.
Treat them as string ... is no goal.
It´s both like filling water into a glass. It´s just a step to the goal. Another step is to drink the water.
But the goal is not to die of thirst.


Klaus
My goal is to do "String Matching" as shown in the previous post.
Just wanna compare a certain input data is exist between these data or not.
 

KlausST

Super Moderator
Staff member
Joined
Apr 17, 2014
Messages
19,443
Helped
4,299
Reputation
8,603
Reaction score
4,260
Trophy points
1,393
Activity points
128,956
Hi,

I want to help. But it´s impossible...

I don´t want to annoy you with my questions. Thus I´d better leave.

I really hope that somebody finds out what you need.
Good luck with your project.

Klaus
 

barry

Advanced Member level 5
Joined
Mar 31, 2005
Messages
5,093
Helped
1,113
Reputation
2,238
Reaction score
1,100
Trophy points
1,393
Location
California, USA
Activity points
27,907
Your answers (And questions) are all over the place. Now you say you want to find certain data inside a bunch of other data, which is totally different from your original question. I am joining Klaus and leaving this discussion.

“Full of sound and fury, signifying nothing”
 

Mai89

Junior Member level 2
Joined
Jun 5, 2019
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
131
I really apologize, I don't want to bother anyone with my questions.

I'm confused also. My issue is :
I have a set of data as mentioned before (with variable lengths) and I want to store them as a database to perform "String Matching" and check if an input data is exist between them or not ( Like Content Addressable Memory), But I know that CAM work with data set with fixed length. So The first Title of this post : I'm asking if I can store data with variable lengths.

Anyways I appreciate your help and patience.
Thanks.
 

ads-ee

Super Moderator
Staff member
Joined
Sep 10, 2013
Messages
7,805
Helped
1,809
Reputation
3,628
Reaction score
1,768
Trophy points
1,393
Location
USA
Activity points
58,914
@Mai89, Do you write software and looked at VHDL and thought "I can write software for an FPGA"?

If so then use some form of HLS (High Level Synthesis) and write your code that way using C/C++ instead. Or implement a softcore processor and write the software for that embedded processor.

VHDL stands for VHSIC Hardware Description Language and VHSIC stands for Very High Speed Integrated Circuit, both the terms Hardware and IC should give you and idea that VHDL isn't exactly a software language and the paradigm for developing something doesn't necessarily use a software paradigm. You either need to think about a circuit architecture that supports what you want (hence all the questions about what your end goal is and not the individual steps) or write this in a software language (using HLS) so you can continue to develop this using a software paradigm.
--- Updated ---

I really apologize, I don't want to bother anyone with my questions.

I'm confused also. My issue is :
I have a set of data as mentioned before (with variable lengths) and I want to store them as a database to perform "String Matching" and check if an input data is exist between them or not ( Like Content Addressable Memory), But I know that CAM work with data set with fixed length. So The first Title of this post : I'm asking if I can store data with variable lengths.

Anyways I appreciate your help and patience.
Thanks.
You can store data any way you want, you have to come up with a hardware architecture to support writing and reading that data. Which is why you got all those previous questions, which you haven't answered.

If this has to be done without using software. Store the data as bytes with delimiters (looks like all but one of the lines ends with a 0x00 byte, a typo?) and write an FSM that reads the input string and compares that input string to the bytes in that data buffer with delimiters, you can then write an FSM that behaves like the equivalent software search algorithm. You will have to manage pointers to the data buffers and scan for the 0x00 bytes to determine both the end of each string and the number of strings processed.
 
Last edited:
  • Like
Reactions: Mai89

    Mai89

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top