cambridgehackers / connectal

Connectal is a framework for software-driven hardware development.
MIT License
161 stars 46 forks source link

Added unmanaged impl constraint option #153

Closed acw1251 closed 6 years ago

acw1251 commented 6 years ago

This adds support for adding unmanaged implementation constraint files in Vivado with the flag --unmanaged-implconstraints.

An unmanaged constraint file is an XDC file that is imported as a plain TCL file, and vivado will not try to add or remove constraints from the file. This allows for more of the TCL language to be included in the file such as foreach and if. As a side effect of this, some critical warnings in managed constraint files get promotes to errors in unmanaged constraint files, resulting in some builds failing if all constraint files are blindly set to unmanaged.

Unmanaged constraint files are read using the -unmanaged flag of the read_xdc command.

acw1251 commented 6 years ago

related pull request in fpgamake: https://github.com/cambridgehackers/fpgamake/pull/20

acw1251 commented 6 years ago

And for reference, I have an FPGA build for a RISC-V processor that used to fail timing due to false paths, but I got rid of all of the false paths using the following unmanaged constraint file, and now the processor meets timing and works.

puts "Executing the unmanaged constraint file!"

foreach fifo_cell [get_cells -hier -filter {FILE_NAME =~ */FIFO_DUALCLOCK_MACRO.v} *fifo*] {
    set fifo_rst_pin [get_pins -filter {NAME =~ *RST} -of_objects $fifo_cell]
    set driving_clk [all_fanin -flat -startpoints_only $fifo_rst_pin]

    # reset pin of FIFO_DUALCLOCK_MACRO should be asynchronous

    # puts "set_false_path -reset_path -to $fifo_rst_pin"
    # set_false_path -reset_path -to $fifo_rst_pin

    puts "set_false_path -reset_path -from $driving_clk -to $fifo_rst_pin"
    set_false_path -reset_path -from $driving_clk -to $fifo_rst_pin
}

foreach reset_meta_reg [get_cells -hier -filter {FILE_NAME =~ */PositiveReset.v || FILE_NAME =~ */SyncReset.v} reset_meta_reg] {
    set reset_meta_pins [get_pins -filter {NAME =~ */D || NAME =~ */S} -of_objects $reset_meta_reg]
    set driving_clk [all_fanin -flat -startpoints_only $reset_meta_pins]

    foreach s $driving_clk {
        foreach d $reset_meta_pins {
            puts "set_false_path -reset_path -from $s -to $d"
            set_false_path -reset_path -from $s -to $d
        }
    }
}