> For the complete documentation index, see [llms.txt](https://soups-misc.gitbook.io/fpga-training/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://soups-misc.gitbook.io/fpga-training/vivado-kai-fa-liu-cheng-tcl.md).

# VIVADO開發流程(TCL)

本篇目標建立一個tcl mode工作流程

## A. Project mode

project mode主要目的是建立一個script，再做synth,imp都直接在terminal上跑，但看訊息還是到gui做

### A-1. tcl Sample code

以下範例是在建構好一個vivado project之後，在裡面建立一個tcl script(例如: project\_build.tcl)並依照剛剛建立的vivado  project名稱修改tcl內容

```tcl
set current_dir [pwd]
#puts "Print current_dir: $current_dir"

set project_name "your_project.xpr"
#puts "Print project_name: $your_project"

set project_path [file join $current_dir $project_name]
#puts "Print project_path: $project_path"

open_project $project_path
#open_bd_design {<project path>/sources_1/bd/design_1/design_1.bd}
#validate_bd_design
update_compile_order -fileset sources_1

reset_run synth_1
reset_run impl_1
#reset_run impl_1 -prev_step 

launch_runs synth_1 -jobs 7

wait_on_run synth_1

#launch_runs impl_1 -to_step write_bitstream -jobs 7
launch_runs impl_1 -jobs 7
wait_on_run impl_1

launch_runs write_bitstream -jobs 7
wait_on_run write_bitstream 
#launch_runs impl_1 -to_step write_bitstream -jobs 7
```

執行的時候在linux端進到vivado project folder內部執行以下命令

```sh
vivado -mode batch -source project_build.tcl
```

也可以使用>>把執行的訊息導到某個log/txt內，寫法如下:

```bash
vivado -mode batch -source RCCB_Scan_Ctrl.tcl >> aa.txt 
```

### A-2. import tcl

如果今天上網抓一個project下來用，通常都會是tcl srcipt，因此要使用tcl srcipt mode:

1. 開啟vivado gui
2. cd 你git clone或下載下來的檔案位置
3. 使用vivado gui上的"run tcl srcipt"

## Note:

* 想要在tcl執行時[有顏色](https://wiki.tcl-lang.org/page/ANSI+color+control)，再找時間研究


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://soups-misc.gitbook.io/fpga-training/vivado-kai-fa-liu-cheng-tcl.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
