Skip to content

Commit

Permalink
Merge pull request #1 from recolic/support_newboard
Browse files Browse the repository at this point in the history
Support any hardware board, add new entry to vivadofile.
  • Loading branch information
recolic committed Sep 3, 2018
2 parents 8eea0d4 + 05d1efb commit 0be67c5
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 159 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
template/*

!template/Vivadofile
!template/*.xdc

18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

> Run vivado natively in linux command line.
## Features

- Init, build, burn any vivado project in one command.

- Extremely simple, flexible, and customizable project layout.

- Burn auto saved built binary at anytime and any machine.

- Full vivado GUI support.

- Support every hardware supported by vivado.

- Theoretically support any vivado version (But latest is the best).

## Installation

```sh
Expand All @@ -26,13 +40,11 @@ alias vivadow=vivado-wrapper # I'll use this wrapper in the doc below.
mkdir my_project && cd my_project
vivadow init
code . # Or any editor you prefer.
vim Vivadofile # To tell vivado-wrapper about your module~constraint relationship.
vim Vivadofile # To tell vivado-wrapper about your module~constraint relationship, threads, board, etc.
```

- Build Project

Warning: this project will use `xc7a100tcsg324-1` (for HUST) as your board. Please fork and modify template if you'd like to use other board. We can easily support changing board by Vivadofile, if you can solve the TODO in ./vivado-wrapper:line5.

```sh
cd vivado-wrapper/example
vivadow build
Expand Down
12 changes: 12 additions & 0 deletions gen_tcl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ elif [[ $1 == gui ]]; then
echo "open_project ${xpr}
`find ${proj_dir}/*.srcs -regex '^.*\.s?vh?$' -exec echo add_files \{\} \;`
start_gui"
elif [[ $1 == init-project ]]; then
proj_name="$2"
proj_dir="$3"
part_name="$4" # xc7a100tcsg324-1
echo "# Generated by Vivado wrapper, licensed under GPL 3.0
# Copyright (C) Recolic Keghart <root@recolic.net>
create_project ${proj_name} ${proj_dir} -part ${part_name}
file mkdir ${proj_dir}/${proj_name}.srcs/constrs_1/new
close [ open ${proj_dir}/${proj_name}.srcs/constrs_1/new/constraint.xdc w ]
add_files -fileset constrs_1 ${proj_dir}/${proj_name}.srcs/constrs_1/new/constraint.xdc"
rm -f ${proj_dir}/${proj_name}.srcs/constrs_1/new/constraint.xdc
rm -rf ${proj_dir}/${proj_name}.cache/*
else
echo "Usage: $0 build <xpr path> <run_name_synth> <run_name_impl> <to_step> <top module name> <threads_num>
$0 burn <xpr path> <run_name_impl> <top_module_name> <dev_name(Ex:xc7a100t_0)>"
Expand Down
3 changes: 3 additions & 0 deletions template/Vivadofile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ top_modules=(
# top_module=test_main
top_module=

# Name of your board in vivado. HUST uses 'xc7a100tcsg324-1' by default.
board="xc7a100tcsg324-1"

#
# Optional options
#
Expand Down
6 changes: 0 additions & 6 deletions template/project/temp_project.hw/temp_project.lpr

This file was deleted.

Empty file.
140 changes: 0 additions & 140 deletions template/project/temp_project.xpr

This file was deleted.

28 changes: 18 additions & 10 deletions vivado-wrapper
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
#!/bin/bash

# TODO: Vivado create new project:
# create_project temp_project /home/recolic/tmp/_log/temp_project -part xc7a100tcsg324-1
# file mkdir /home/recolic/tmp/_log/temp_project/temp_project.srcs/constrs_1/new
# close [ open /home/recolic/tmp/_log/temp_project/temp_project.srcs/constrs_1/new/constraint.xdc w ]
# add_files -fileset constrs_1 /home/recolic/tmp/_log/temp_project/temp_project.srcs/constrs_1/new/constraint.xdc

_vw_bin_name="$0"

_vw_version_major="1"
Expand Down Expand Up @@ -100,6 +94,7 @@ function import_vivadofile_impl () {
[[ -e ./Vivadofile ]] && source ./Vivadofile && return 0
[[ -e ./vivadofile ]] && source ./vivadofile && return 0
[[ -e ./VivadoFile ]] && source ./VivadoFile && return 0
[[ -e ./VIVADOFILE ]] && source ./VIVADOFILE && return 0
return 1
}

Expand Down Expand Up @@ -129,37 +124,50 @@ function get_constraint_of_module () {
kill -s TERM $_vw_mypid
}

function vivado_check_and_init_template () {
[[ -z "$board" ]] && echo "You must set variable 'board'. Try \`vivadow init\` again." && return 4
[[ -d "$my_path/template/$board" ]] && return 0
"$my_path/gen_tcl.sh" init-project temp_project "$my_path/template/$board" "$board" > $temp_dir/sh.tcl
"$vivado_exec" -mode batch -source "$temp_dir/sh.tcl" -nojournal -nolog
rm -f "$my_path/template/$board/temp_project/temp_project.srcs/constrs_1/new/constraint.xdc"
rm -rf "$my_path/template/$board/temp_project.cache/"*
}

function generate_real_project () {
[[ "$constr_path" == '' ]] && constr_path="$(pwd)/$(get_constraint_of_module $top_module)"
cp -r "$my_path/template/project" "$temp_dir/"
vivado_check_and_init_template || return 4
cp -r "$my_path/template/"* "$temp_dir/"
ln -s "$temp_dir/$board" "$temp_dir/project"
_real_proj_src="$temp_dir/project/temp_project.srcs"
for src in `echo ${sources[@]}`; do
mkdir -p "$_real_proj_src/sources_1/new/$(dirname "$src")"
ln -s "$(pwd)/$src" "$_real_proj_src/sources_1/new/$src"
done
rm "$_real_proj_src/constrs_1/new/constraint.xdc"
rm -f "$_real_proj_src/constrs_1/new/constraint.xdc"
ln -s "$constr_path" "$_real_proj_src/constrs_1/new/constraint.xdc"
echo "real_project generated at $temp_dir"
}

function clean_real_project () {
rm -rf $temp_dir
rm -rf $temp_dir ./.Xil
echo "real_project cleaned"
}

function do_init () {
mkdir constraint build src
[[ -f ./Vivadofile ]] && mv ./Vivadofile ./Vivadofile.backup
cp "$my_path"/template/Vivadofile ./Vivadofile
echo "init done."
}

function do_build () {
generate_real_project
[[ $? -ne 0 ]] && echo "Generate real project failed." && clean_real_project && exit 4

"$my_path/gen_tcl.sh" build "$temp_dir/project/temp_project.xpr" synth_1 impl_1 write_bitstream "$top_module" $thread_num > $temp_dir/sh.tcl
"$vivado_exec" -mode batch -source "$temp_dir/sh.tcl" -nojournal -nolog
_bit_file="$temp_dir/project/temp_project.runs/impl_1/$top_module.bit"
[[ -e "$_bit_file" ]] && cp "$_bit_file" "$bit_dir/$top_module.bit" || echo "vivado-wrapper: Error: Build failed."
[[ -e "$_bit_file" ]] && cp "$_bit_file" "$bit_dir/$top_module.bit" || echo "vivado-wrapper: Error: Build failed. Please check previous error report."

clean_real_project
}
Expand Down

0 comments on commit 0be67c5

Please sign in to comment.