- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi again,
For my project, I've defined a custom data type which actually is an array of 16 8-bit std_logic_vectors:
TYPE census_line IS ARRAY(0 TO 15) OF std_logic_vector(7 downto 0);
However from a memory module, all I get is a single, large 128-bit std_logic_vector. I tried to cast the large vector tor a census_line, but all I get is:
census_line(vector):
Error (10305): VHDL Type Conversion error at stereo.vhd(61): cannot convert type "std_logic_vector" to type "census_line"
Is there any way to cast it still? Thank you and regards, Reggi
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use a function containing a loop that maps the input std_logic_vector into your census_line type, i.e.,
function to_census_line (slv : in std_logic_vector) returns census_line is
variable result : census_line;
begin
for i in 0 to 15 loop
result(i) <= slv(8*i+7 downto i);
end loop;
return result;
end function;
This function needs to go after the census_line type definition. I just typed this directly into the forum, you'll have to debug any VHDL errors :) Cheers, Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Dave,
Thanks a lot for your suggestion - with a few modifications it works as expected :) On the downside however, the resource-requirements for this unit increase considerably, just by changing:
TYPE census_line IS ARRAY(0 TO 15) OF UNSIGNED(7 downto 0);
TYPE census_block IS ARRAY(0 TO 15) OF census_line;
to:
TYPE census_line IS ARRAY(0 TO 15) OF std_logic_vector(7 downto 0);
TYPE census_block IS ARRAY(0 TO 15) OF std_logic_vector(127 downto 0);
and using the conversion method mentioned, my design increases from ~1.1k ALMs to 2.3k ALMs. Any ideas what is going wrong here? Thanks, Reggi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Problem solved :)
Using larger std_logic_vectors somehow reduced optimization freedome for quartus. When I switched to M10K-blocks for instead of registers, resource-useage went down to 1.1k ALMs which is actually great :) Thanks!- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The function just maps the two different data types, it uses zero resources.
As you have determined, the difference was in what your hardware was doing with those data types :) Cheers, Dave
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page