Forum Discussion
Altera_Forum
Honored Contributor
13 years agoI 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:1410 or 14
10 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: 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
}
I would set those 2 variables from the .txt into 2 generics: GENERIC(
version: integer := 1; -- a
revision: integer := 0; -- b
); For that I'd then use in the script:
set_parameter -name VERSION $a
set_parameter -name REVISION $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.