writing current date to a 32 bit register

O

oktem

I want to automatically put the current date (year,month,day maybe
hour) in a 32 bit register during the synthesis stage. I am using
Modelsim as a simulator and Xilinx Xst as a synthesis tool. My target
fpga is Spartan 3.

Can someone explain me is there an easy way to implement?
 
K

Ken Cecka

I want to automatically put the current date (year,month,day maybe
hour) in a 32 bit register during the synthesis stage. I am using
Modelsim as a simulator and Xilinx Xst as a synthesis tool. My target
fpga is Spartan 3.

Can someone explain me is there an easy way to implement?

I add a timestamp like this to my builds by generating a package in the makefile I drive the build with. Here's an excerpt:

version.vhd: Makefile
@echo "generating $@"
@rm -f $@
@echo "PACKAGE version IS" > $@
@echo " CONSTANT C_VER_DESIGN : INTEGER := $(VER_DESIGN);" >> $@
@echo " CONSTANT C_VER_MAJOR : INTEGER := $(VER_MAJOR);" >> $@
@echo " CONSTANT C_VER_MINOR : INTEGER := $(VER_MINOR);" >> $@
@echo " CONSTANT C_VER_REV : INTEGER := $(VER_REV);" >> $@
@echo " CONSTANT C_VER_TIMESTAMP : INTEGER := $(shell date +%s);">> $@
@echo "END version;" >> $@

The C_VER_TIMESTAMP is a constant containing the number of seconds since the epoch (1970-01-01 00:00:00 GMT).

This only guarantees an up-to-date timestamp if I build with make. When I'm building from an ISE project, all bets are off.

Ken
 
O

oktem

I add a timestamp like this to my builds by generating a package in the makefile I drive the build with.  Here's an excerpt:

version.vhd: Makefile
        @echo "generating $@"
        @rm -f $@
        @echo "PACKAGE version IS" > $@
        @echo "  CONSTANT C_VER_DESIGN    : INTEGER := $(VER_DESIGN);" >> $@
        @echo "  CONSTANT C_VER_MAJOR     : INTEGER := $(VER_MAJOR);" >> $@
        @echo "  CONSTANT C_VER_MINOR     : INTEGER := $(VER_MINOR);" >> $@
        @echo "  CONSTANT C_VER_REV       : INTEGER := $(VER_REV);" >> $@
        @echo "  CONSTANT C_VER_TIMESTAMP : INTEGER := $(shell date +%s);">> $@
        @echo "END version;" >> $@

The C_VER_TIMESTAMP is a constant containing the number of seconds since the epoch (1970-01-01 00:00:00 GMT).

This only guarantees an up-to-date timestamp if I build with make.  When I'm building from an ISE project, all bets are off.

Ken

Now i have a tcl script which takes current date and convert it to a
binary
I can run this tcl script from the tcl shell menu of xilinx project
navigator
I added a generic current_date variable on my top module
I added this varible to generics, parameters part of Synthesis Options
menu of Xilinx.

So everythime i want to synthesize, I need to run the tcl script, get
the output of the function, copy and paste it to the current_date at
the generics tab of synthesis options and run.
Actually I was not able to do it with the makefile approach since it
seems harder for me. I need a little more explanation.

best regards
 
O

oktem

You can set the generics within ISE using the Xilinx specific Tcl command

project set "Generics, Parameters" "Max=10" -process "Synthesize - XST"

where Max is an integer generic with the value 10.

If your generic is a string, you'll need to work out the quoting syntax.
If you want to see how Xilinx has stored your generic, export your
project settings using the ISE menu

Project > Generate Tcl Script...

You can then put your own Tcl script at the front to generate the time
value, and then run it using the command

xtclsh script.tcl

xtclsh is the Xilinx Tcl interpreter, which understands the Xilinx Tcl
extensions, as well as plain Tcl.

regards
Alan


Project > Generate Tcl Script...
You can then put your own Tcl script at the front to generate the
time value, and then run it using the command

Regarding this statement I have some newbie questions

so when go to ISE menu > project > create a Tcl script to regenerate
the project file
1- Do i have to exclude anything from the export list. There is a vhd
file,my tcl script,there is a ncd file and lastly a timesim_vhw file.
2- What difference does it make if I add output files and add report
files.
3- After I finish exporting I noticed an import.tcl and an export tcl
file in my project directory. Should I run these from the tcl shell
menu of project navigator. What do I do with these files. If I run
these files is it posible to not copy paste the date for each
synthesis


I started using tcl yesterday so sorry for the foolish questions.
 
O

oktem

 Project > Generate Tcl Script...
 You can then put your own Tcl script at the front to generate the
time value, and then run it using the command

 Regarding this statement I have some newbie questions

 so when go to ISE menu > project > create a Tcl script to regenerate
the project file
1- Do i have to  exclude anything from the export list. There is a vhd
file,my tcl script,there is a ncd file and lastly a timesim_vhw file.
2- What difference does it make if I add output files and add report
files.
3- After I finish exporting I noticed an import.tcl and an export tcl
file in my project directory. Should I run these from the tcl shell
menu of project navigator. What do I do with these files. If I run
these files is it posible to not copy paste the date for each
synthesis

I started using tcl yesterday so sorry for the foolish questions.


I put this line
project set "Generics, Parameters" "ID=my_date" -process "Synthesize -
XST"
at the end of my tcl script so that i do not have to copy and paste it
everytime.

so now i need to undertand these import.tcl and export.tcl files.

Also im having problem with integer to binary conversion. Is there a
tcl function that I can determine the width of the output. if I
convert 3 to binary can I get an output of exactly 4 bits like this
(0011) not 2 bits (11) or 8 bits (00000011) or 32 bits
(00000000000000000000000000000011)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top