UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Visitor koen.lostrie
Visitor
336 Views
Registered: ‎04-18-2018

automated synthesis with custom VHDL packages and libraries

Jump to solution

Dear all,

I've written a couple of automated tcl scripts to synthesize VHDL designs that students hand in. Sometimes they use custom packages and libraries though, which of course results in errors during synthesis.

Is there a way to find out which packages and libraries they use with tcl commands, knowing they only hand in their .vhd and .xdc files?

When a student for instance uses a library "digital" in which he compiled a package "globalSignals", how can I extract this information using tcl commands?

Or, if this is not possible, is there a file in their project directory they should hand in as well, so that my script can synthesize this?

Thanks for your expertise.

Regards,

Koen

0 Kudos
1 Solution

Accepted Solutions
324 Views
Registered: ‎07-23-2019

Re: automated synthesis with custom VHDL packages and libraries

Jump to solution

 

"I've written a couple of automated tcl scripts"

So you are an automata. AI is here!

No, TCL is not for browsing and finding stuff in vhd or xdc files. forget about that.

I would simply read them. Being student assignments it shouldn't be that much.

Text editors have good find tools. Notepad++ is very good at that. Millions of programmers use it since 20 (?) years ago and is still good. There must be a reason.

Otherwise, if really want to "automate" things, I suggest a Python script... the latest millenial fashion. But I wonder if it will take longer than manually. Also, wherever there is software there are bugs. 

View solution in original post

6 Replies
325 Views
Registered: ‎07-23-2019

Re: automated synthesis with custom VHDL packages and libraries

Jump to solution

 

"I've written a couple of automated tcl scripts"

So you are an automata. AI is here!

No, TCL is not for browsing and finding stuff in vhd or xdc files. forget about that.

I would simply read them. Being student assignments it shouldn't be that much.

Text editors have good find tools. Notepad++ is very good at that. Millions of programmers use it since 20 (?) years ago and is still good. There must be a reason.

Otherwise, if really want to "automate" things, I suggest a Python script... the latest millenial fashion. But I wonder if it will take longer than manually. Also, wherever there is software there are bugs. 

View solution in original post

Visitor koen.lostrie
Visitor
317 Views
Registered: ‎04-18-2018

Re: automated synthesis with custom VHDL packages and libraries

Jump to solution

Thank you for your quick reply.

 

I agree that reading them manually solves this problem... if there weren't over 70 students that hand in 8 or 9 excercises... multiple times... and expect feedback on them every week.

So I hope you understand my need for automation ;-)

I do read their (latest) code manually and discuss this with them, but this is easier when you already know if the code is working and got approved by my automated testbenches.

The aid of other script languages is of course a good solution. I was hoping for a tcl command, which avoids writing another script, but alas ;-)

Thanks again!

Scholar brimdavis
Scholar
299 Views
Registered: ‎04-26-2012

Re: automated synthesis with custom VHDL packages and libraries

Jump to solution

@koen.lostrie   "Is there a way to find out which packages and libraries they use with tcl commands"

The get_files and report_compile_order commands have a  -used_in synthesis option which might help, e.g.

   report_compile_order -used_in synthesis

The following thread gives an example of finding libraries for simulation:

   https://forums.xilinx.com/t5/Simulation-and-Verification/finding-simulation-libraryes-from-IP/m-p/858734/highlight/true#M22295 

set ip_files [get_files -compile_order sources -used_in simulation -of_objects [get_ips <ip_name>]]

foreach file $ip_files { puts "[get_property LIBRARY $file] $file" }

-Brian

 

0 Kudos
Visitor koen.lostrie
Visitor
156 Views
Registered: ‎04-18-2018

Re: automated synthesis with custom VHDL packages and libraries

Jump to solution

Dear brimdavis,

Thank you very much for your input. However this is not a solution for me, since this only works for an IP block, where the library information for each source file is included in the IP block. The students hand in separate VHDL source files, which all get the default library xil_defaultlib associated with them.

I appreciate your input, but I'm afraid I will have to use some other script to parse their code in advance (as archangel suggested) and use this in my tcl script.

Thanks again!

0 Kudos
Scholar brimdavis
Scholar
131 Views
Registered: ‎04-26-2012

Re: automated synthesis with custom VHDL packages and libraries

Jump to solution

@koen.lostrie   "this is not a solution for me, since this only works for an IP block"

The report I suggested is *NOT* limited to IP blocks (although it can be used that way); report_compile_order will by default list library mappings for all the files in the project that are -used_in the selected flow.

So as long as your students are using Vivado for development, before turning in their project they'd first run this:

report_compile_order -used_in synthesis -file ./compile_order.rpt

And then include the output file  compile_order.rpt  with their source files. An example compile_order.rpt,  snippets with highlighting:

INFO: [Vivado 12-3442] The output from report_compile_order is primarily targeted for human readability and ease of use. The 'get_files' command, with the -compile_order and -used_in options, produces this same information in a format that is better suited for automated scripts.
Source compile order for 'synthesis' with fileset 'sources_1' in source management mode 'All':
Index  File Name            Used_In      File_Type  Library         Ngc Wrapper  Full Path Name
-----  -------------------  -----------  ---------  --------------  -----------  ----------------------------------------------------------------------
1      y1_constants.vhd     Synth & Sim  VHDL       xil_defaultlib  No           C:/Projects/yard/hdl/cores/y1a/y1_constants.vhd
2      y1a_config.vhd       Synth & Sim  VHDL       xil_defaultlib  No           C:/Projects/yard/hdl/cores/y1a/y1a_config.vhd
3      addsub.vhd           Synth & Sim  VHDL       xil_defaultlib  No           C:/Projects/yard/hdl/cores/y1a/addsub.vhd
4      barrel.vhd           Synth & Sim  VHDL       xil_defaultlib  No           C:/Projects/yard/hdl/cores/y1a/barrel.vhd
...
10     debounce.vhd         Synth & Sim  VHDL       debounce        No           C:/Projects/yard/hdl/common/debounce/debounce.vhd
11     debounce_pkg.vhd     Synth & Sim  VHDL       debounce        No           C:/Projects/yard/hdl/common/debounce/debounce_pkg.vhd
12     debounce_tick.vhd    Synth & Sim  VHDL       debounce        No           C:/Projects/yard/hdl/common/debounce/debounce_tick.vhd
...

Unless I misread your post, you were looking for an automated way of finding the source file library mappings (packages should 'just work' as long as you've placed the student's files in the correct libraries within your automated scripting), which the above report should enable.

EDIT: There are a number of different ways to figure out the library mappings; another method would be to have the students include their Vivado project file (.xpr) extension, which is an XML file that also includes the filename and library information

-Brian

 

Visitor koen.lostrie
Visitor
97 Views
Registered: ‎04-18-2018

Re: automated synthesis with custom VHDL packages and libraries

Jump to solution

@brimdavis My apologies, but I thought you suggested I ran the report_compile_order command on their vhdl files.

Out of the two solutions you propose, I would certainly select the .xpr option for the simple reason that it should not only be a "fool proof" solution, it should be "student proof" (which is the next level up) ;-)

At the moment, the only thing they must hand in is all their relevant .vhd files and their .xdc file. You'd be surprised how many students fail this very simple task (.xci files, vhd code pasted in .txt or .docx files, .xpr files,...). Having them open the Tcl console, type in a command, find the generated file and hand it in will cause me much more problems, holding their hands and practically typing it in for them. I could have an entire off topic discussion/rant here about teaching students (especially first year students) to read walkthroughs and instructions, but I'm afraid that wouldn't achieve much here ;-)

Your second solution, the .xpr file is definitely an option which I'll look into. In the meantime, I've written a small parser script in Tcl (see below) which works so far without changing the file types they have to hand in. If I run into problems with that, I'll definitely use the .xpr option, but I will have to do it from the beginning of the semester (next year) or it will definitely confuse them.

Thanks a lot for your input!

 

The piece of Tcl script:

# search all vhd source files for custom packages/libraries
# first find custom packages
set files [glob ../*.vhd]
set customPackages {}
for {set i 0} {$i < [llength $files]} {incr i} {
  set fh [open [lindex $files $i]]
  while {[gets $fh line] != -1} {
    if {[regexp -nocase {package[ \t\r\n]+([^ \t\r\n]+)[ \t\r\n]+is} $line fullMatch packageName]} {
      puts -nonewline "Custom package $packageName found in file: "
      puts [lindex $files $i]
      lappend customPackages $packageName
      set packageFile($i) $packageName
    }
  }
  close $fh
}
puts "Custom packages found: $customPackages"
# Then find in which libraries these packages should be compiled
for {set i 0} {$i < [llength $files]} {incr i} {
  set fh [open [lindex $files $i]]
  while {[gets $fh line] != -1} {
    for {set j 0} {$j < [llength $customPackages]} {incr j} {
      set packageName [lindex $customPackages $j]
      if {[regexp -nocase "use\[ \t\r\n\]+\(\[^ \t\r\n\]+\)\[ \t\r\n\]*\.\[ \t\r\n\]*$packageName\[ \t\r\n\]*\." $line fullMatch libName]} {
        set packageLib($packageName) $libName
      }
    }
  }
  close $fh
}

# read in the source files from the upper directory
# custom packages should be associated with the correct library
for {set i 0} {$i < [llength $files]} {incr i} {
  set curFile [lindex $files $i]
  if {[info exists packageFile($i)]} {
    set curLib $packageLib($packageFile($i))
    puts "Reading $curFile to custom library $curLib"
    read_vhdl -library $curLib $curFile
  } else {
    read_vhdl $curFile
  }
}

read_xdc [ glob ../*.xdc ]

...
0 Kudos