Can I uses in VHDL something similar to the C-Sourcecode-Macros __DATE__
and __TIME__
to make the compile time available in the FPGA as a kind of version time stamp?
As a >>>new-comer<<< to VHDL I want to modify the following existing code, which puts a hard coded date into a FPGA register. I always have to remember adjusting the values before compiling. It would be easier if this is done automatically. Can I also include hours/minutes/seconds?
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
ENTITY Datum2 IS
PORT
(
Day :OUT std_logic_vector(4 downto 0);
Month :OUT std_logic_vector(3 downto 0);
Year :OUT std_logic_vector(4 downto 0)
);
END Datum2 ;
ARCHITECTURE rtl OF Datum2 IS
BEGIN
-- "08.08.0013"
Day <= conv_std_logic_vector(8, 5);
Month <= conv_std_logic_vector(8, 4);
Year <= conv_std_logic_vector(13, 5);
END ARCHITECTURE rtl;
You don't need to write out the full code every time the timestamp is update. In Quartus you can use TCL to set top-level generics prior to compilation:
Pass the generics down to you timestamp entity:
And then use a preflow-script to set the generics:
I've used this approach successfully with both timestamps, git revision, build ID. I find it convenient to convert it to a word array and then accessing as a ROM. Just use your imagination.