Skip to content

Commit 254638d

Browse files
committed
vivado-prj: Change bitstream file name and set device immediately
1 parent 1969ea8 commit 254638d

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ Please check the official [HBS user manual](https://github.com/m-kru/hbs/blob/ma
3838
### Changed
3939
- Improved error messages.
4040
- Improved regex for errors and warnings.
41+
- `vivado-prj`: Part is set immediately as `hbs::SetDevice` is called.
42+
- `vivado-prj`: Bitstream file name changed from current project name to `hbs::Top`.
43+
This is required for `write_hw_platform -include_bit` command to work without any extra actions.
4144

4245
### Fixed
4346
- Generics handling for xsim.

hbs.tcl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ namespace eval hbs {
193193

194194
hbs::Debug "setting device to '$dev'"
195195
set hbs::Device $dev
196+
197+
switch $hbs::Tool {
198+
"vivado-prj" { hbs::vivado-prj::setDevice $dev }
199+
}
196200
}
197201

198202
# Sets name of the HDL library.
@@ -1946,6 +1950,10 @@ namespace eval hbs::nvc {
19461950
# - implementation.
19471951
# - bitstream.
19481952
namespace eval hbs::vivado-prj {
1953+
proc setDevice {dev} {
1954+
hbs::Eval "set_property part $dev \[current_project\]"
1955+
}
1956+
19491957
proc setTool {} {
19501958
set prjName [regsub -all :: "$hbs::ThisCorePath\:\:$hbs::ThisTargetName" --]
19511959
set hbs::targetDir [file join $hbs::BuildDir $prjName]
@@ -2086,9 +2094,8 @@ namespace eval hbs::vivado-prj {
20862094
#
20872095
hbs::evalPrePrjCbs
20882096
if {$hbs::Device == ""} {
2089-
hbs::panic "cannot set part, hbs::Device not set"
2097+
hbs::panic "hbs::Device not set"
20902098
}
2091-
hbs::Eval "set_property part $hbs::Device \[current_project\]"
20922099

20932100
if {$hbs::Top == ""} {
20942101
hbs::panic "cannot set top, hbs::Top not set"
@@ -2127,7 +2134,7 @@ namespace eval hbs::vivado-prj {
21272134
#
21282135
hbs::evalPreBitCbs
21292136
hbs::Eval "open_run impl_1"
2130-
hbs::Eval "write_bitstream $hbs::ArgsPrefix \[get_property DIRECTORY \[current_run\]\]/\[current_project\].bit $hbs::ArgsSuffix"
2137+
hbs::Eval "write_bitstream $hbs::ArgsPrefix \[get_property DIRECTORY \[current_run\]\]/$hbs::Top.bit $hbs::ArgsSuffix"
21312138
hbs::evalPostBitCbs
21322139
}
21332140
}

tests/dry-run/vivado-prj/cmd.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env bash
22

3-
echo "read_vhdl -library lib_a -vhdl2008 $HBS_TESTS_DIR/dry-run/vivado-prj/a.vhd
3+
echo "set_property part xc7z020clg400-1 [current_project]
4+
read_vhdl -library lib_a -vhdl2008 $HBS_TESTS_DIR/dry-run/vivado-prj/a.vhd
45
read_vhdl -library lib_b -vhdl2008 $HBS_TESTS_DIR/dry-run/vivado-prj/b.vhd
56
read_verilog -library xil_defaultlib -sv $HBS_TESTS_DIR/dry-run/vivado-prj/c.sv
67
set_property generic GEN=64 [current_fileset]
7-
set_property part xc7z020clg400-1 [current_project]
88
set_property top TopEntity [current_fileset]
99
launch_runs SynthArgsPrefix synth_1 SynthArgsSuffix
1010
wait_on_run synth_1
@@ -17,7 +17,7 @@ if {[get_property PROGRESS [get_runs impl_1]] != \"100%\"} {
1717
error \"impl_1 failed\"
1818
}
1919
open_run impl_1
20-
write_bitstream BitArgsPrefix [get_property DIRECTORY [current_run]]/[current_project].bit BitArgsSuffix" > golden.txt
20+
write_bitstream BitArgsPrefix [get_property DIRECTORY [current_run]]/TopEntity.bit BitArgsSuffix" > golden.txt
2121

2222
export HBS_TOOL=vivado-prj
2323
../../../hbs dry-run core-c::src > output.txt

0 commit comments

Comments
 (0)