현재 날짜와 시간은 VHDL에서 직접 사용할 수 없지만 해결책은 아래에 제시되어 있습니다.
EDITED 2013-08-10 : Altera Quartus II Tcl 자동 생성에 대한 설명이 추가되었습니다.
날짜와 시간을 가능하게하는 한 가지 방법은 다음과 같이 자동으로 생성 된 VHDL 패키지를 통해이 VHDL 패키지가이 같은 Tcl의 스크립트를 생성 할 수 있습니다
library ieee;
use ieee.std_logic_1164.all;
package datetime is
-- Date information
constant YEAR_INT : integer := 2013;
constant YEAR_HEX : std_logic_vector(15 downto 0) := X"2013";
constant MONTH_INT : integer := 08;
constant MONTH_HEX : std_logic_vector(7 downto 0) := X"08";
constant DAY_INT : integer := 09;
constant DAY_HEX : std_logic_vector(7 downto 0) := X"09";
constant DATE_HEX : std_logic_vector(31 downto 0) := YEAR_HEX & MONTH_HEX & DAY_HEX;
-- Time information
constant HOUR_INT : integer := 13;
constant HOUR_HEX : std_logic_vector(7 downto 0) := X"13";
constant MINUTE_INT : integer := 06;
constant MINUTE_HEX : std_logic_vector(7 downto 0) := X"06";
constant SECOND_INT : integer := 29;
constant SECOND_HEX : std_logic_vector(7 downto 0) := X"29";
constant TIME_HEX : std_logic_vector(31 downto 0) := X"00" & HOUR_HEX & MINUTE_HEX & SECOND_HEX;
-- Miscellaneous information
constant EPOCH_INT : integer := 1376046389; -- Seconds since 1970-01-01_00:00:00
end package;
:
# Make datetime.vhd package from Tcl script
# Current date, time, and seconds since epoch
# Array index 0 1 2 3 4 5 6
set datetime_arr [clock format [clock seconds] -format {%Y %m %d %H %M %S %s}]
# Write VHDL package
set filename datetime.vhd
set file [open $filename w]
puts $file "library ieee;"
puts $file "use ieee.std_logic_1164.all;"
puts $file ""
puts $file "package datetime is"
puts $file " -- Date information"
puts $file " constant YEAR_INT : integer := [lindex $datetime_arr 0];"
puts $file " constant YEAR_HEX : std_logic_vector(15 downto 0) := X\"[lindex $datetime_arr 0]\";"
puts $file " constant MONTH_INT : integer := [lindex $datetime_arr 1];"
puts $file " constant MONTH_HEX : std_logic_vector(7 downto 0) := X\"[lindex $datetime_arr 1]\";"
puts $file " constant DAY_INT : integer := [lindex $datetime_arr 2];"
puts $file " constant DAY_HEX : std_logic_vector(7 downto 0) := X\"[lindex $datetime_arr 2]\";"
puts $file " constant DATE_HEX : std_logic_vector(31 downto 0) := YEAR_HEX & MONTH_HEX & DAY_HEX;"
puts $file " -- Time information"
puts $file " constant HOUR_INT : integer := [lindex $datetime_arr 3];"
puts $file " constant HOUR_HEX : std_logic_vector(7 downto 0) := X\"[lindex $datetime_arr 3]\";"
puts $file " constant MINUTE_INT : integer := [lindex $datetime_arr 4];"
puts $file " constant MINUTE_HEX : std_logic_vector(7 downto 0) := X\"[lindex $datetime_arr 4]\";"
puts $file " constant SECOND_INT : integer := [lindex $datetime_arr 5];"
puts $file " constant SECOND_HEX : std_logic_vector(7 downto 0) := X\"[lindex $datetime_arr 5]\";"
puts $file " constant TIME_HEX : std_logic_vector(31 downto 0) := X\"00\" & HOUR_HEX & MINUTE_HEX & SECOND_HEX;"
puts $file " -- Miscellaneous information"
puts $file " constant EPOCH_INT : integer := [lindex $datetime_arr 6]; -- Seconds since 1970-01-01_00:00:00"
puts $file "end package;"
close $file
Altera Quartus II에서는 합성 전에이 스크립트를 실행하여 날짜/시간 패키지를 생성 할 수 있습니다. 이는 Quartus II 기능의 추가 설명은 Quartus II Tcl Example: Automatic Script Execution에서 찾을 수 있습니다
set_global_assignment -name PRE_FLOW_SCRIPT_FILE "quartus_sh:make_datetime.tcl"
: 이것은 스크립트가 "make_datetime.tcl"라는 아래 라인으로 .qsf 파일에서 이루어집니다.

이전 다른 솔루션을 설명
:
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;
library work;
use work.datetime;
architecture rtl of Datum2 is
begin
Day <= conv_std_logic_vector(datetime.day_int, 5);
Month <= conv_std_logic_vector(datetime.month_int, 4);
Year <= conv_std_logic_vector(datetime.year_int mod 100, 5);
end architecture rtl;
이는 Quartus II의 합성 후 RTL 뷰어 아래와 같이 모듈의 출력을 보여준다
Datum2 모듈은 다음과 같이 패키지를 사용하여 다음과 같은 Bash 스크립트를 사용하여 VHDL 패키지를 생성하십시오 :
# Make datetime.vhd package from shell script
# Current date, time, and seconds since epoch
# Array index 0 1 2 3 4 5 6
datetime_arr=($(date +"%Y %m %d %H %M %S %s"))
# Write VHDL package
filename="datetime.vhd"
echo "library ieee;" > $filename
echo "use ieee.std_logic_1164.all;" >> $filename
echo "" >> $filename
echo "package datetime is" >> $filename
echo " -- Date information" >> $filename
echo " constant YEAR_INT : integer := ${datetime_arr[0]};" >> $filename
echo " constant YEAR_HEX : std_logic_vector(15 downto 0) := X\"${datetime_arr[0]}\";" >> $filename
echo " constant MONTH_INT : integer := ${datetime_arr[1]};" >> $filename
echo " constant MONTH_HEX : std_logic_vector(7 downto 0) := X\"${datetime_arr[1]}\";" >> $filename
echo " constant DAY_INT : integer := ${datetime_arr[2]};" >> $filename
echo " constant DAY_HEX : std_logic_vector(7 downto 0) := X\"${datetime_arr[2]}\";" >> $filename
echo " constant DATE_HEX : std_logic_vector(31 downto 0) := YEAR_HEX & MONTH_HEX & DAY_HEX;" >> $filename
echo " -- Time information" >> $filename
echo " constant HOUR_INT : integer := ${datetime_arr[3]};" >> $filename
echo " constant HOUR_HEX : std_logic_vector(7 downto 0) := X\"${datetime_arr[3]}\";" >> $filename
echo " constant MINUTE_INT : integer := ${datetime_arr[4]};" >> $filename
echo " constant MINUTE_HEX : std_logic_vector(7 downto 0) := X\"${datetime_arr[4]}\";" >> $filename
echo " constant SECOND_INT : integer := ${datetime_arr[5]};" >> $filename
echo " constant SECOND_HEX : std_logic_vector(7 downto 0) := X\"${datetime_arr[5]}\";" >> $filename
echo " constant TIME_HEX : std_logic_vector(31 downto 0) := X\"00\" & HOUR_HEX & MINUTE_HEX & SECOND_HEX;" >> $filename
echo " -- Miscellaneous information" >> $filename
echo " constant EPOCH_INT : integer := ${datetime_arr[6]}; -- Seconds since 1970-01-01_00:00:00" >> $filename
echo "end package;" >> $filename
플랫폼 독립성을 위해3210
는 다음과 같은 파이썬 3.x의 스크립트를 사용할 수있다 :
library ieee;
use ieee.std_logic_1164.all;
entity tb is
end entity;
library work;
use work.datetime;
architecture sim of tb is
signal date_hex : std_logic_vector(31 downto 0);
signal time_hex : std_logic_vector(31 downto 0);
begin
date_hex <= datetime.DATE_HEX;
time_hex <= datetime.TIME_HEX;
process is begin wait; end process;
end architecture;
:
# Make datetime.vhd package from Python 3.x script
# Get date and time
import datetime
import time
now = datetime.datetime.now()
now_epoch_sec = int(time.time())
# Write VHDL package
file = open('datetime.vhd', 'wt')
file.write('library ieee;\n')
file.write('use ieee.std_logic_1164.all;\n')
file.write('\n')
file.write('package datetime is\n')
file.write(' -- Date information\n')
file.write(' constant YEAR_INT : integer := {};\n'.format(now.strftime('%Y')))
file.write(' constant YEAR_HEX : std_logic_vector(15 downto 0) := X\"{}\";\n'.format(now.strftime('%Y')))
file.write(' constant MONTH_INT : integer := {};\n'.format(now.strftime('%m')))
file.write(' constant MONTH_HEX : std_logic_vector(7 downto 0) := X\"{}\";\n'.format(now.strftime('%m')))
file.write(' constant DAY_INT : integer := {};\n'.format(now.strftime('%d')))
file.write(' constant DAY_HEX : std_logic_vector(7 downto 0) := X\"{}\";\n'.format(now.strftime('%d')))
file.write(' constant DATE_HEX : std_logic_vector(31 downto 0) := YEAR_HEX & MONTH_HEX & DAY_HEX;\n')
file.write(' -- Time information\n')
file.write(' constant HOUR_INT : integer := {};\n'.format(now.strftime('%H')))
file.write(' constant HOUR_HEX : std_logic_vector(7 downto 0) := X\"{}\";\n'.format(now.strftime('%H')))
file.write(' constant MINUTE_INT : integer := {};\n'.format(now.strftime('%M')))
file.write(' constant MINUTE_HEX : std_logic_vector(7 downto 0) := X\"{}\";\n'.format(now.strftime('%M')))
file.write(' constant SECOND_INT : integer := {};\n'.format(now.strftime('%S')))
file.write(' constant SECOND_HEX : std_logic_vector(7 downto 0) := X\"{}\";\n'.format(now.strftime('%S')))
file.write(' constant TIME_HEX : std_logic_vector(31 downto 0) := X\"00\" & HOUR_HEX & MINUTE_HEX & SECOND_HEX;\n')
file.write(' -- Miscellaneous information\n')
file.write(' constant EPOCH_INT : integer := {}; -- Seconds since 1970-01-01_00:00:00\n'.format(now_epoch_sec))
file.write('end package;\n')
file.close()
32 비트 레지스터 값의 날짜와 시간의 발표를 들어, 모듈은 다음과 같이 할 수있다
파형은 아래와 같습니다.

배쉬 파이썬 스크립트 접근 방식은 자동 패키지 생성을위한 빌드 흐름의 통합이 필요합니다.
EDITED 2016-08-08 (Damien 업데이트) : Altera Quartus의 비 Tcl 스크립트 호출에 대한 설명.
Linux에서 bash 스크립트를 통합하려면 프로세스의 일부로 bash 스크립트를 호출하는 Tcl 랩퍼 스크립트를 작성하십시오. 알테라의 빌드 흐름으로 통합
# Useful if the script is in a subdirectory
proc getScriptDirectory {} {
set dispScriptFile [file normalize [info script]]
set scriptFolder [file dirname $dispScriptFile]
return $scriptFolder
}
set scriptDir [getScriptDirectory]
# Call the bash script which does the real work
exec $scriptDir/make_datetime_vhdl.sh
# Add a message the Altera workflow
post_message -type info "Created datetime.vhd"
다음에 의해 달성 될 수있다 :이 예에서는 "call_bash.tcl"스크립트와 실제 작업을 수행하는 "make_datetime.sh"을 가진 "스크립트"디렉토리가 qsf 파일에 다음을 추가하십시오.
set_global_assignment -name PRE_FLOW_SCRIPT_FILE "quartus_sh:scripts/call_bash.tcl"
나는 비슷한 것을하고, 자동 빌드 스크립트의 일부로 버전 개정판에 서브 버전 개정판과 날짜를 넣습니다. 이를 수행하는 방법은 여러 가지가 있지만 일반적으로 비 VHDL 프로세스가 포함 된 특정 메타 데이터로 디자인에 사용되는 VHDL 파일을 업데이트하는 것이 중요합니다. –
그리고 누락 된 부분은 특정 도구 환경에서 프로세스를 자동화하는 방법입니다. 태그는 fpga altera 및 nios입니다. 적절한 응답은 그 환경을 사용하는 누군가를 요구하는 것으로 보입니다. 또한 세 가지 비트 필드를 중심으로 한 질문에 주목하십시오. 일 std_logic_vector (4 downto 0), 월 std_logic_vector (3 downto 0) 및 연도 std_logic_vector (4에서 0까지). 또한 일부 도구 환경 (http://www.doulos.com/knowhow/fpga/Setting_Generics_Parameters_for_Synthesis/ 참조)에는 매개 변수를 직접 설정할 수있는 기능이 있습니다. – user1155120
@David Koontz : 좋은 지적; 나는 자동 실행을 위해 Quartus II 플로우에 통합 된 Altera Quartus II의 특정 제안에 대한 해답을 업데이트했다. –