Forum Discussion
Implementing firmware version
I am trying to make a code that can store firmware versions from a .txt file, I tried doing it with a ROM initialized with a .mif file, but it's not working. I have a Cyclone III that sends that info to a microcontroller and then to a HMI (human machine interface) screen so I can see the FPGA's firmware version. It's all in VHDL, but I posted this issue a few days ago and I got this reply (that seemed more appropriate, but I don't know how to do it):
--- Quote Start --- What you are attempting I have done in the past to store hardware versions and software build numbers but I had Nios II reading out the values. Perhaps you can skip using the ROM and just 'include a value defined in a verilog include file that is generated by your build system. In the include file you could just have something like 'define VERSION_NUMBER <machine generated version number> and in your hardware design refer to that value. --- Quote End --- But I've never done anything in verilog, only VHDL. I searched that out but still can't make much of it. If anyone could possibly post a code on how that's done, it would really help me, been trying to do this for long now.22 Replies
- Altera_Forum
Honored Contributor
--- Quote Start --- I did that but I get this error ... --- Quote End --- That is not adding the command to your path. That was an attempt to change directory. In Tcl all things are strings. Because your command had a space in it, Tcl interprets it as two strings. You just needed to use quotes, or parentheses, i.e., cd "c:/program files/tortoiseSVN/bin" cd {c:/program files/tortoiseSVN/bin} But this is not the solution I was recommending. You need to add this path to you PATH environment variable. Once you have done that, at the Quartus Tcl console you can type: puts $env(PATH) and you should see the new variable. Note that you will need to re-start Quartus once you change the PATH variable since the application only reads it when it starts. Cheers, Dave - Altera_Forum
Honored Contributor
--- Quote Start --- But this is not the solution I was recommending. You need to add this path to you PATH environment variable. --- Quote End --- How do I do that? I am trying this: setenv PATH ${"C:/program files/TortoiseSVN/bin"} but it gives an error: Error:can't read ""C:/program files/TortoiseSVN/bin"": no such variable I may need administrator acess on this machine to change any enviroment variable, since I'm having so many errors. - Altera_Forum
Honored Contributor
What operating system are you using?
Under Windows, you would set the path via the control panel. Under Linux you can use scripts that get executed at login. In either case, you can set the variable before you start Quartus if you use a command-line shell, eg., start a NIOS II IDE shell, and type
and then Quartus will start, with the PATH extended to include the path to SVN. Of course, you now have non-portable HDL build system. Personally, I'd look into a solution where when you check into/out of SVN, a file is created with the SVN version info. You can then use Quartus to parse that file, and there is no need to worry about SVN being in the path for Quartus. Cheers, Daveexport PATH=$PATH:"C:/program files/TortoiseSVN/bin" quartus - Altera_Forum
Honored Contributor
--- Quote Start --- Of course, you now have non-portable HDL build system. Personally, I'd look into a solution where when you check into/out of SVN, a file is created with the SVN version info. You can then use Quartus to parse that file, and there is no need to worry about SVN being in the path for Quartus. --- Quote End --- I'm using windows XP. I did go to control panel, but I couldn't add anything to PATH because I need adm access, which is going to take some time since IT services are slow. Adding the PATH from control panel won't have the problem you mentioned? - Altera_Forum
Honored Contributor
--- Quote Start --- I'm using windows XP. I did go to control panel, but I couldn't add anything to PATH because I need adm access, which is going to take some time since IT services are slow. --- Quote End --- You should be able to edit the path as a user; Control Panel, System, Advanced Tab, Environment Variables, Edit the user Path variable. --- Quote Start --- Adding the PATH from control panel won't have the problem you mentioned? --- Quote End --- Because you are having your HDL project manipulate additional tools (SVN), you will always have a portability issue. If someone gets give a zip file of your code, then they cannot build it if they do not have SVN installed, and your repo checked out. Cheers, Dave - Altera_Forum
Honored Contributor
I see... well I guess I'll stick to the other idea, which is reading from a file containing the version number.
Btw, is there a way to read one line at a time and store the value of each line into their own variable? - Altera_Forum
Honored Contributor
--- Quote Start --- I see... well I guess I'll stick to the other idea, which is reading from a file containing the version number. Btw, is there a way to read one line at a time and store the value of each line into their own variable? --- Quote End --- Yes, you can do things like that with Tcl. However, if you are writing the file with the version number in it, simply create the file using Tcl syntax, and then just have your build script source the file. Eg., something like the following (which is probably more complicated than you need, but you get the point)
Cheers, Dave# version.tcl# # Automatically generated version file. Do not manually edit.# set version_major 1 set version_minor 2 set version - Altera_Forum
Honored Contributor
I don't think that helps me because I have to send the version number (inside the .txt file which is always going to be inside the project's file) to a 16 bit output in my VHDL code:
data_rev: out std_logic_vector(15 downto 0) And each 8 bits of it is 1 number, so say I have a version = 14.10, after converting to binary my output will be: data_rev(15 downto 8) <= 0000 1110 -- 14 data_rev(7 downto 0) <= 0000 1010 -- 10 And that's why I need to get each number into their own variable. The format of my .txt file can be:
or1410
Or even some other way that makes it easy to get each 2-digit number into 2 variables (maybe separate the 2 numbers with space). I looked for ways of reading line by line, but I don't know how to separate each number into variable a and b. Here's some examples I found, but they use 1 variable:14 10
I would set those 2 variables from the .txt into 2 generics:1) set in set lineNumber 0 while { >= 0} { puts ": $line" } close $in ---------------------------------------- 2) set fp set file_data close $fp set data foreach line $data { #do something here to set the a and b values maybe? } ------Could it set index 0 to variable a and index 1 to variable b?-------- 3) set fid ;# Open file for read-only access set fields ;# Split the string into a list while { != -1 } { # Just print out the first field puts ;# Extract item at index 0 }
For that I'd then use in the script:GENERIC( version: integer := 1; -- a revision: integer := 0; -- b );
Question: can I put set_parameter directly in my version.tcl or it's only in the .qsf? So now my question remains, how do I treat those 2 numbers separately... Note: The .txt file is manually editted so I'm not treating it at all only reading it with TCL.set_parameter -name VERSION $a set_parameter -name REVISION $b - Altera_Forum
Honored Contributor
--- Quote Start --- can I put set_parameter directly in my version.tcl or it's only in the .qsf? --- Quote End --- Your version file can be Tcl, and can include any Quartus Tcl commands. You source that file via the Quartus Tcl console. So create a version file with the following syntax:
--- Quote Start --- The .txt file is manually edited so I'm not treating it at all only reading it with TCL. --- Quote End --- Since the file is manually edited, I see no problem with the file simply being created in Tcl format. No need to complicate things :) Cheers, Dave# version.tcl set_parameter -name VERSION 14 set_parameter -name REVISION 10 - Altera_Forum
Honored Contributor
Thanks for everything Dave. Now I just have to test it on the FPGA.