EmbDev.net

Forum: FPGA, VHDL & Verilog VHDL records


von Mark G. (Company: JHU Applied Physics Lab) (mwgilson)


Rate this post
useful
not useful
I am trying to figure out if it is possible to assign all contents of a 
record with a single statement or assign an output port as the entirety 
of a record...for example:

Declarations & signal creation...etc...
1
type MY_RECORD is record
2
    A : std_logic;
3
    B : std_logic;
4
    C : std_logic_vector(5 downto 0);
5
    D : std_logic_vector(8 downto 0);
6
    E : std_logic_vector(14 downto 0);
7
  end record;
8
9
signal my_new_rec : MY_RECORD;
1
 process (SYSCLK, nRESET) is
2
  begin
3
    if nRESET = '0' then
4
      my_new_rec  <= (others => '0');
5
 ...
6
...
7
PORT_OUT  <= my_new_rec;

I've tried the .ALL (e.g. my_new_rec.ALL) but that is of course used 
with variables.  Then I began to wonder if it might be possible to 
complete this task by using variables as an intermediate?  If anyone has 
any ideas please let me know.  In short, I'm trying to use records to 
further subdivide a 32 bit std_logic_vector so I can do things like:
1
if(my_new_rec.A = '1') then
2
etc...
3
end if;

Please help.

von Duke Scarring (Guest)


Rate this post
useful
not useful
With a default constant like this:
1
type MY_RECORD_t is record
2
    A : std_logic;
3
    B : std_logic;
4
    C : std_logic_vector(5 downto 0);
5
    D : std_logic_vector(8 downto 0);
6
    E : std_logic_vector(14 downto 0);
7
end record;
8
constant default_my_record_c : my_record_t := (
9
  a => '0',
10
  b => '0',
11
  c => (others => '0'),
12
  d => (others => '0'),
13
  e => (others => '0')
14
);
15
16
signal my_new_rec : MY_RECORD_t;
1
 process (SYSCLK, nRESET) is
2
  begin
3
    if nRESET = '0' then
4
      my_new_rec  <= default_my_record_c;
5
 ...
6
...
7
PORT_OUT  <= my_new_rec;

Duke

von Andreas S. (andreas) (Admin)


Rate this post
useful
not useful
You can't use records to directly subdivide a vector. If you want to use 
a record, you need to assign the components manually (or write a 
function to do it). Another option is using aliases:
1
alias a is my_slv(5);
2
alias b is my_slv(4 downto 0);
3
4
if (a = '1') then
5
...
6
end if;

von Mark G. (Company: JHU Applied Physics Lab) (mwgilson)


Rate this post
useful
not useful
Duke, I think your method is a good solution to initialize a 
record...thanks!
Andreas, I think this is one possible solution to parsing individual 
parts of a vector...but in my scenario I will have tens of these records 
of different types and I'm concerned these aliases could take up alot of 
code space.  I think what I've found is that records are not the answer 
to my problem.

To follow up, what are your suggestions to taking an input 
std_logic_vector(31 downto 0) and also an output std_logic_vector(31 
downto 0) and having the ability to dynamically "cast" these to 
particular "formats" based on a given state.  In other words, maybe at a 
given time each bit in the input std_logic_vector has a different 
"name", but in another state the input is divided into an upper and 
lower word.  instead of doing:
1
alias a is input(0);
2
alias b is input(1);
3
alias c is input(2);
4
...
5
6
alias a_a is input(31 downto 16);
7
alias a_b is input(15 downto 0);
8
...

I would have tens and tens if not hundreds of aliases if I did it this 
way, which is why I tried using records until I found out there 
limitations.  No other solutions?

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.