Skip to content
Snippets Groups Projects
Unverified Commit 5c2eb117 authored by Recolic Keghart's avatar Recolic Keghart
Browse files

did some naive test

parent 4b9199e9
No related branches found
No related tags found
No related merge requests found
##Bank = 34, Pin name = IO_L14P_T2_SRCC_34, Sch name = SW15
set_property PACKAGE_PIN P4 [get_ports {i}] set_property PACKAGE_PIN P4 [get_ports {i}]
set_property IOSTANDARD LVCMOS33 [get_ports {i}] set_property IOSTANDARD LVCMOS33 [get_ports {i}]
set_property PACKAGE_PIN T8 [get_ports {j}] set_property PACKAGE_PIN T8 [get_ports {j}]
set_property IOSTANDARD LVCMOS33 [get_ports {j}] set_property IOSTANDARD LVCMOS33 [get_ports {j}]
\ No newline at end of file
module mod1(
input i,
output wire j
);
assign j = i;
endmodule // mod1
\ No newline at end of file
...@@ -32,7 +32,7 @@ if [[ $1 == build ]]; then ...@@ -32,7 +32,7 @@ if [[ $1 == build ]]; then
echo "# Generated by Vivado wrapper, licensed under GPL 3.0 echo "# Generated by Vivado wrapper, licensed under GPL 3.0
# Copyright (C) Recolic Keghart <root@recolic.net> # Copyright (C) Recolic Keghart <root@recolic.net>
open_project ${xpr} open_project ${xpr}
`find ${proj_dir}/*.srcs -regex '^.*\.s?v$' -exec echo add_files ./\{\} \;` `find ${proj_dir}/*.srcs -regex '^.*\.s?vh?$' -exec echo add_files \{\} \;`
set_property top ${top_mod} [current_fileset] set_property top ${top_mod} [current_fileset]
reset_run ${run_name_synth} reset_run ${run_name_synth}
reset_run ${run_name_impl} reset_run ${run_name_impl}
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
<!-- --> <!-- -->
<!-- Copyright 1986-2018 Xilinx, Inc. All Rights Reserved. --> <!-- Copyright 1986-2018 Xilinx, Inc. All Rights Reserved. -->
<Project Version="7" Minor="36" Path="/home/recolic/tmp/temp-project/temp-project.xpr"> <Project Version="7" Minor="36" Path="/home/recolic/tmp/_log/temp_project/temp_project.xpr">
<DefaultLaunch Dir="$PRUNDIR"/> <DefaultLaunch Dir="$PRUNDIR"/>
<Configuration> <Configuration>
<Option Name="Id" Val="f82f6a5f20b647dc83d6a988b89187d3"/> <Option Name="Id" Val="10aeba4a0c564ee4b9367894dc7cd541"/>
<Option Name="Part" Val="xc7a100tcsg324-1"/> <Option Name="Part" Val="xc7a100tcsg324-1"/>
<Option Name="CompiledLibDir" Val="$PCACHEDIR/compile_simlib"/> <Option Name="CompiledLibDir" Val="$PCACHEDIR/compile_simlib"/>
<Option Name="CompiledLibDirXSim" Val=""/> <Option Name="CompiledLibDirXSim" Val=""/>
...@@ -55,14 +55,6 @@ ...@@ -55,14 +55,6 @@
<FileSets Version="1" Minor="31"> <FileSets Version="1" Minor="31">
<FileSet Name="sources_1" Type="DesignSrcs" RelSrcDir="$PSRCDIR/sources_1"> <FileSet Name="sources_1" Type="DesignSrcs" RelSrcDir="$PSRCDIR/sources_1">
<Filter Type="Srcs"/> <Filter Type="Srcs"/>
<File Path="$PSRCDIR/sources_1/new/test.v">
<FileInfo>
<Attr Name="AutoDisabled" Val="1"/>
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="implementation"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<Config> <Config>
<Option Name="DesignMode" Val="RTL"/> <Option Name="DesignMode" Val="RTL"/>
<Option Name="TopAutoSet" Val="TRUE"/> <Option Name="TopAutoSet" Val="TRUE"/>
...@@ -81,7 +73,6 @@ ...@@ -81,7 +73,6 @@
</Config> </Config>
</FileSet> </FileSet>
<FileSet Name="sim_1" Type="SimulationSrcs" RelSrcDir="$PSRCDIR/sim_1"> <FileSet Name="sim_1" Type="SimulationSrcs" RelSrcDir="$PSRCDIR/sim_1">
<Filter Type="Srcs"/>
<Config> <Config>
<Option Name="DesignMode" Val="RTL"/> <Option Name="DesignMode" Val="RTL"/>
<Option Name="TopAutoSet" Val="TRUE"/> <Option Name="TopAutoSet" Val="TRUE"/>
...@@ -118,7 +109,9 @@ ...@@ -118,7 +109,9 @@
<Runs Version="1" Minor="10"> <Runs Version="1" Minor="10">
<Run Id="synth_1" Type="Ft3:Synth" SrcSet="sources_1" Part="xc7a100tcsg324-1" ConstrsSet="constrs_1" Description="Vivado Synthesis Defaults" WriteIncrSynthDcp="false" State="current" IncludeInArchive="true"> <Run Id="synth_1" Type="Ft3:Synth" SrcSet="sources_1" Part="xc7a100tcsg324-1" ConstrsSet="constrs_1" Description="Vivado Synthesis Defaults" WriteIncrSynthDcp="false" State="current" IncludeInArchive="true">
<Strategy Version="1" Minor="2"> <Strategy Version="1" Minor="2">
<StratHandle Name="Vivado Synthesis Defaults" Flow="Vivado Synthesis 2018"/> <StratHandle Name="Vivado Synthesis Defaults" Flow="Vivado Synthesis 2018">
<Desc>Vivado Synthesis Defaults</Desc>
</StratHandle>
<Step Id="synth_design"/> <Step Id="synth_design"/>
</Strategy> </Strategy>
<ReportStrategy Name="Vivado Synthesis Default Reports" Flow="Vivado Synthesis 2018"/> <ReportStrategy Name="Vivado Synthesis Default Reports" Flow="Vivado Synthesis 2018"/>
...@@ -126,7 +119,9 @@ ...@@ -126,7 +119,9 @@
</Run> </Run>
<Run Id="impl_1" Type="Ft2:EntireDesign" Part="xc7a100tcsg324-1" ConstrsSet="constrs_1" Description="Default settings for Implementation." WriteIncrSynthDcp="false" State="current" SynthRun="synth_1" IncludeInArchive="true"> <Run Id="impl_1" Type="Ft2:EntireDesign" Part="xc7a100tcsg324-1" ConstrsSet="constrs_1" Description="Default settings for Implementation." WriteIncrSynthDcp="false" State="current" SynthRun="synth_1" IncludeInArchive="true">
<Strategy Version="1" Minor="2"> <Strategy Version="1" Minor="2">
<StratHandle Name="Vivado Implementation Defaults" Flow="Vivado Implementation 2018"/> <StratHandle Name="Vivado Implementation Defaults" Flow="Vivado Implementation 2018">
<Desc>Default settings for Implementation.</Desc>
</StratHandle>
<Step Id="init_design"/> <Step Id="init_design"/>
<Step Id="opt_design"/> <Step Id="opt_design"/>
<Step Id="power_opt_design"/> <Step Id="power_opt_design"/>
......
#
# Required options
#
# You may use SystemVerilog, Verilog, or VHDL files as sources.
# sources=(test_main.sv lib/* ./mod?.v)
sources=()
# The directory where generated bitstream is put
bit_dir=./build
# All of your top_modules and its constraint files.
# top_modules=(
# "test_main:constraint/test_main.xdc"
# "mod1:constraint/mod1.xdc"
# )
top_modules=(
)
# Your default top_module. Maybe override by commandline option.
# top_module=test_main
top_module=
#
# Optional options
#
# Path to vivado executable. It will override environment variable `vivado_exec`
# vivado_exec="/path/to/vivado"
# It's recommanded to set thread_num to cores of your CPU.
# thread_num=4
#!/bin/bash #!/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_bin_name="$0"
_vw_version_major="0" _vw_version_major="1"
_vw_version_minor="2" _vw_version_minor="0"
_vw_version="${_vw_version_major}.${_vw_version_minor}" _vw_version="${_vw_version_major}.${_vw_version_minor}"
[[ $_vw_version_major == 0 ]] && echo "Vivado wrapper is unfinished, and unable to work." && exit 11 [[ $_vw_version_major == 0 ]] && echo "Vivado wrapper is unfinished, and unable to work." && exit 11
...@@ -72,6 +78,16 @@ function where_am_i () { ...@@ -72,6 +78,16 @@ function where_am_i () {
where_is_him "$_my_path" where_is_him "$_my_path"
} }
function naive_opt () {
_opt_prev=""
for opt in $@; do
[[ $_opt_prev == '--top' ]] && top_module="$opt"
[[ $_opt_prev == '--device' ]] && device_name="$opt"
[[ $_opt_prev == '--constraint' ]] && constr_path="$opt"
_opt_prev="$opt"
done
}
function import_vivadofile_impl () { 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
...@@ -82,13 +98,14 @@ function import_vivadofile_impl () { ...@@ -82,13 +98,14 @@ function import_vivadofile_impl () {
function import_vivadofile () { function import_vivadofile () {
import_vivadofile_impl import_vivadofile_impl
[[ $? == 1 ]] && echo 'Vivadofile, vivadofile, VivadoFile not found.' && return 1 [[ $? == 1 ]] && echo 'Vivadofile, vivadofile, VivadoFile not found.' && return 1
[[ -e ${vivado_exec} ]] && echo "vivado_exec '${vivado_exec}' not found." && return 1 [[ ! -e ${vivado_exec} ]] && echo "vivado_exec '${vivado_exec}' not found." && return 1
[[ -x ${vivado_exec} ]] && echo "vivado_exec '${vivado_exec}' not executable." && return 1 [[ ! -x ${vivado_exec} ]] && echo "vivado_exec '${vivado_exec}' not executable." && return 1
[[ "${thread_num}" == '' ]] && thread_num=1 [[ "${thread_num}" == '' ]] && thread_num=1
[[ "${sources[*]}" == '' ]] && echo "sources not provided." && return 1 [[ "${sources[*]}" == '' ]] && echo "sources not provided." && return 1
[[ "${bit_dir}" == '' ]] && echo "bit_dir not provided." && return 1 [[ "${bit_dir}" == '' ]] && echo "bit_dir not provided." && return 1
[[ "${top_modules[*]}" == '' ]] && echo "top_modules not provided." && return 1 [[ "${top_modules[*]}" == '' ]] && echo "top_modules not provided." && return 1
[[ "${top_module}" == '' ]] && echo "top_module not provided." && return 1 [[ "${top_module}" == '' ]] && echo "top_module not provided." && return 1
return 0
} }
function get_constraint_of_module () { function get_constraint_of_module () {
...@@ -98,18 +115,20 @@ function get_constraint_of_module () { ...@@ -98,18 +115,20 @@ function get_constraint_of_module () {
_value=${_ele#*:} _value=${_ele#*:}
[[ ${_key} == ${_mod_name} ]] && echo -n "${_value}" && return 0 [[ ${_key} == ${_mod_name} ]] && echo -n "${_value}" && return 0
done done
return 1 echo "Error: Can not find constraint for module '$_mod_name'"
exit 1
} }
function generate_real_project () { function generate_real_project () {
# Create a temp real vivado project in /tmp, link all sources to it, and prepare for future usage. [[ "$constr_path" == '' ]] && constr_path="$(pwd)/$(get_constraint_of_module $top_module)"
cp -r "$my_path/template/project" "$temp_dir/" cp -r "$my_path/template/project" "$temp_dir/"
_real_proj_src="$temp_dir/project/temp_project.srcs"
for src in `echo ${sources[@]}`; do for src in `echo ${sources[@]}`; do
_unpathed_src=`echo $src | tr '/' '_' | tr ' ' '_'` mkdir -p "$_real_proj_src/sources_1/new/$(dirname "$src")"
ln -s "$(pwd)/$src" "$temp_dir/project/temp-project.srcs/sources_1/new/$_unpathed_src" ln -s "$(pwd)/$src" "$_real_proj_src/sources_1/new/$src"
done done
rm "$temp_dir/project/temp-project.srcs/constrs_1/new/constraint.xdc" rm "$_real_proj_src/constrs_1/new/constraint.xdc"
ln -s "$constr_path" "$temp_dir/project/temp-project.srcs/constrs_1/new/constraint.xdc" ln -s "$constr_path" "$_real_proj_src/constrs_1/new/constraint.xdc"
echo "real_project generated at $temp_dir" echo "real_project generated at $temp_dir"
} }
...@@ -125,30 +144,35 @@ function do_init () { ...@@ -125,30 +144,35 @@ function do_init () {
} }
function do_build () { function do_build () {
# TODO: Parse cmdline, override top_module and constr
constr_path="$(pwd)/$(get_constraint_of_module $top_module)"
generate_real_project generate_real_project
"$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 "$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 "$vivado_exec" -mode batch -source "$temp_dir/sh.tcl" -nojournal -nolog
_bit_file="$temp_dir/project/temp-project.runs/impl_1/$top_module.bit" _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."
clean_real_project clean_real_project
} }
function burn_file () { function burn_file () {
# TODO: Parse cmdline to get device_name if any.
file_to_burn="$1" file_to_burn="$1"
"$my_path/gen_tcl.sh" burn-file "$file_to_burn" > $temp_dir/sh.tcl "$my_path/gen_tcl.sh" burn-file "$file_to_burn" "$device_name" > $temp_dir/sh.tcl
"$vivado_exec" -mode batch -source "$temp_dir/sh.tcl" -nojournal -nolog "$vivado_exec" -mode batch -source "$temp_dir/sh.tcl" -nojournal -nolog
} }
function do_burn () { function do_burn () {
# TODO: Parse cmdline, override top_module and device_name
burn_file "$bit_dir/$top_module.bit" burn_file "$bit_dir/$top_module.bit"
} }
function do_gui () {
generate_real_project
"$my_path/gen_tcl.sh" gui "$temp_dir/project/temp_project.xpr" > $temp_dir/sh.tcl
"$vivado_exec" -mode batch -source "$temp_dir/sh.tcl" -nojournal -nolog
clean_real_project
}
my_path=`where_am_i` my_path=`where_am_i`
temp_dir=`mktemp -d` temp_dir=`mktemp -d`
# If noob user add space character in $1, just truncate it. # If noob user add space character in $1, just truncate it.
...@@ -162,6 +186,8 @@ if [[ $vw_cmd == 'build' ]] || [[ $vw_cmd == 'burn' ]] || [[ $vw_cmd == 'gui' ]] ...@@ -162,6 +186,8 @@ if [[ $vw_cmd == 'build' ]] || [[ $vw_cmd == 'burn' ]] || [[ $vw_cmd == 'gui' ]]
[[ $? != 0 ]] && echo "Vivadofile error reported. Exiting..." && exit 2 [[ $? != 0 ]] && echo "Vivadofile error reported. Exiting..." && exit 2
fi fi
naive_opt $@
case $vw_cmd in case $vw_cmd in
'init' ) 'init' )
do_init do_init
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment