IDE: Quartus 15
I'm new to VHDL programming so there are some nuances I am not used to (translating from C++). Whilst I have found resources for programming the "source" files, I've struggled to find anything for the "header" files.
In short, what is the standard layout / syntax of a VHDL "header" file?
To keep things simple, the use cases I'm interested in are declaring subtype
and function references for use between "source" files.
I found the following code snippet here which has helped a little, but I'm still not sure of what the differences between package
and package body
are. I'm also unsure of where "work" comes from.
"Header":
package DEFS is
CONSTANT MAJOR_VERSION: INTEGER := 0;
CONSTANT MINOR_VERSION: INTEGER := 22;
CONSTANT MAXREG: integer := 52;
TYPE REGS_TYPE is array (0 to MAXREG) of STD_LOGIC_VECTOR(15 downto 0);
FUNCTION opndrn(inp: std_logic) return std_logic;
end package DEFS;
package body DEFS is
FUNCTION opndrn(inp: std_logic) return std_logic IS
begin
CASE INP is
WHEN '0' => return '0';
WHEN OTHERS => return 'Z';
END CASE;
end;
end package body DEFS;
"Source":
LIBRARY work;
USE work.defs.all;
Any and all help is appreciated.