0

If I have an enumerated type type flag_t is (ZERO, OFLOW, NEG); in the architecture of my entity, is there some way that one of the outputs of said entity is of type flag_t?

In other words, why does the following code fail to compile, and how to achieve this correctly.

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity alu is
    port (
    a: in std_logic_vector(15 downto 0);
    b: in std_logic_vector(15 downto 0);
    res: out std_logic_vector(15 downto 0);
    flags: out flag_t
    );
end alu;

architecture Behavioral of alu is
type flag_t is (ZERO, OFLOW, NEG);
begin

end Behavioral;

(Vivado reports an error on that code on line 9 saying Error: <flag_t> is not declared, which makes sense since it's only defined in the architecture portion.

Bernardo Meurer
  • 2,295
  • 5
  • 31
  • 52
  • @user1155120 I figure the cause was something like that, but is there any way to make this work? Declare all my enums in some separate file and include it somehow (as one could do in C for example)? – Bernardo Meurer Feb 23 '18 at 04:56
  • @user1155120 I'm sorry, I'm (fairly) new to VHDL, so I'm going to ask some, probably very, newbie questions, bear with me if you can. What does "a formal in an association list" mean? What's "component installation"? And what do you mean by a "package"? I think I know what some of those are, but just not what they're called. Again, sorry for the possibly stupid Qs. – Bernardo Meurer Feb 23 '18 at 05:02
  • [This](https://stackoverflow.com/questions/29011795/add-library-to-vivado-2014-4) Answered my question with regards to what a package is and how to implement it, which fixed the question, but if you can I'm still interested in the other two things I asked in the comment. Also, if you'd like to post an answer telling me to use a package I'll accept it, given that was the issue, and you solved it :) – Bernardo Meurer Feb 23 '18 at 05:16
  • Refer [link]http://web.engr.oregonstate.edu/~traylor/ece474/vhdl_lectures/component_instantiaton.pdf for `component instantiation` (not installation). A formal is the port of the entity that is being instantiated as a component. The association list defines which local signals connect to which component ports. – Vinay Madapura Feb 23 '18 at 07:36

0 Answers0