Chen Yulin's BlogChen Yulin's Blog
HomeArchivesCategoriesTagsAbout
  • Categories
  • Note
Copy-Paste in Hyprland across Wayland & XWayland
Posted 2024-05-24Updated 2025-06-26Note2 minutes read (About 277 words)

Copy-Paste in Hyprland across Wayland & XWayland

After a certain upgrade of hyprland, I can no longer copy&paste across Wayland & XWayland apps, which is very annoying.
The relatied issue: https://github.com/hyprwm/Hyprland/issues/6132
Maybe fixed in: https://github.com/hyprwm/Hyprland/pull/6086

According to 6132 issue, some provide a walk around. I tailored it to adapt it to my system.

Create a shell in ~ directory, named clipsync.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env sh
# Two-way clipboard syncronization between Wayland and X11.
# Requires: wl-clipboard, xclip, clipnotify.
#
# Usage:
# clipsync.sh watch - run in background.
# clipsync.sh kill - kill all background processes.
# echo -n any | clipsync.sh insert - insert clipboard content fron stdin.
#
# Workaround for issue:
# "Clipboard synchronization between wayland and xwayland clients broken"
# https://github.com/hyprwm/Hyprland/issues/6132

# Updates clipboard content of both Wayland and X11 if current clipboard content differs.
# Usage: echo -e "1\n2" | clipsync insert
insert() {
# Read all the piped input into variable.
value=$(cat)
wValue="$(wl-paste)"
xValue="$(xclip -o -selection clipboard)"

notify() {
notify-send -u low -c clipboard "$1" "$value"
}

if [ "$value" != "$wValue" ]; then
notify "Wayland"
echo -n "$value" | wl-copy
fi

if [ "$value" != "$xValue" ]; then
notify "X11"
echo -n "$value" | xclip -selection clipboard
fi
}

watch() {
# Wayland -> X11
wl-paste --type text --watch "/home/cyl/clipsync.sh" insert &

# X11 -> Wayland
while clipnotify; do
xclip -o -selection clipboard | ~/clipsync.sh insert
done &
}

kill() {
pkill wl-paste
pkill clipnotify
pkill xclip
pkill clipsync
}

"$@"

alias in ~/.zshrc:

1
alias clipsync="~/clipsync.sh"

enable it by running

1
clipsync watch

kill all by running

1
clipsync kill

Self-start, configured in ~/.config/hyprland/hyprland.conf

1
exec-once = clipsync watch

REMEMBER TO REMOVE ALL THESE STUFF WHEN HYPRLAND HAS FIXED THE ISSUE

Solved in ISSUE 6086

JustWork 参考文档
Posted 2024-05-24Updated 2025-06-26Notea few seconds read (About 78 words)

JustWork 参考文档

Unity 本体

新的Input System:https://gamedevbeginner.com/input-in-unity-made-easy-complete-guide-to-the-new-system/#how_to_manage_input

物理引擎

目前的想法是将unity的physx和mujoco结合在一起,简化physx的对于相对运动很少的刚体间的物理解算。
Mujoco:https://mujoco.readthedocs.io/en/latest/unity.html

STM32 Development on Linux
Posted 2024-05-21Updated 2025-06-26Note6 minutes read (About 833 words)

STM32 Development on Linux

System used: Archlinux

Pre-requirements

  • c language server (for completion, diagnostics), e.g. clangd
  • A code editor that use language server, e.g. vscode, vim/neovim

Install Related Softwares

STM32CubeMX

STM32CubeMX is mainly responsible for generating the project with your configuration.

For Distro like Ubuntu/Debain, you can go to the ST official site
Or you can install the software through distro repository

1
yay -S stm32cubemx

For Arch, you need to modify the AUR repository (I mean, maybe the maintainer doesn’t do a good job).
The URL for the repository:https://aur.archlinux.org/packages/stm32cubemx

First clone the repository

1
git clone https://aur.archlinux.org/stm32cubemx.git

Modify the required jdk version in file stm32cubemx.sh
from exec archlinux-java-run --min 17 -- -jar /opt/stm32cubemx/STM32CubeMX "$@" to exec archlinux-java-run --min 17 --max 20 -- -jar /opt/stm32cubemx/STM32CubeMX "$@"

Then build and install the STM32CubeMX

1
makepkg --noconfirm --skipinteg -si

Since STM32CubeMX is not compatible with jdk22 (which is the default jdk that arch is currently using), you need to install jdk17 through yay -S jdk17-openjdk

Then you can start STM32CubeMX by running stm32cubemx, and hopefully, everything is fine.

Compiler

Use arm-none-eabi-gcc

1
2
yay -S arm-none-eabi-gcc
yay -S arm-none-eabi-newlib

Debugger

Use OpenOCD to burn and debug STM32 through STLink v2 (the blue USB device provided by us).

1
yay -S openocd

Setup Your STM32 Project

Open your STM32CubeMX, follow the instruction of Lab1.pdf to configure your project.

NOTE: In Project Manage -> Project -> Project Settings -> Toolchain / IDE, use Makefile/CMake.

Generate the code and go to the project directory (with Makefile/CMakeLists.txt in the directory).

Then you need to generate the compile_commands.json for clangd to recognize the project.

Makefile

1
bear -- make

CMake

1
cmake -S ./ -B ./build

Build Project

Makefile

1
make

Then target binary file is ./build/<Project Name>.bin

CMake

1
cmake --build ./build

Then target binary file is ./build/<Project Name>.elf

Load to STM32F103C8T6

Use OpenOCD to load the binary file to the board.

1
sudo openocd -f /usr/share/openocd/scripts/interface/stlink.cfg -f /usr/share/openocd/scripts/target/stm32f1x.cfg -c "program ./build/<Project Name>.bin reset exit 0x8000000"

Result

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Open On-Chip Debugger 0.12.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : clock speed 1000 kHz
Info : STLINK V2J37S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.222587
Info : [stm32f1x.cpu] Cortex-M3 r1p1 processor detected
Info : [stm32f1x.cpu] target has 6 breakpoints, 4 watchpoints
Info : starting gdb server for stm32f1x.cpu on 3333
Info : Listening on port 3333 for gdb connections
[stm32f1x.cpu] halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08000dc8 msp: 0x20005000
** Programming Started **
Info : device id = 0x20036410
Info : flash size = 64 KiB
** Programming Finished **
** Resetting Target **
shutdown command invoked

NOTE: In different Distro, the cfg file for OpenOCD may locate in different directories. You need to find it by yourselves.

By the way, if you use CMake

Note: When uploading binary file to STM32, it’s recommended to use .bin file instead of .elf file.
Please use the following script to convert the .elf to .bin and upload.

1
2
3
4
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .
cmake --build ./build
arm-none-eabi-objcopy -O binary -S ./build/*.elf ./build/target.bin
sudo openocd -f /usr/share/openocd/scripts/interface/stlink.cfg -f /usr/share/openocd/scripts/target/stm32f1x.cfg -c "program ./build/target.bin reset exit 0x8000000"

Debug

You have three possible choices. I recommend using Ozone.

openocd+gdb+gdbfrontend(not recommended)

reference:
https://rohanrhu.github.io/gdb-frontend/tutorials/embedded-debugging/

openocd+vscode+PlatformIO (not recommended)

reference:
https://blog.csdn.net/qq_41757528/article/details/127741620

Segger Ozone!!!

reference:
https://blog.csdn.net/weixin_41572450/article/details/124710818

Maybe the best debug tool for stm32

To use segger ozone, you need a different linker called jlink (originally we use st-link v2). You need to buy this linker first (maybe on Taobao or Amazon).

Install Ozone through:

1
yay -S ozone

Setup of ozone project:

  • Start Ozone
  • Choose Device
    • Device: STM32F103C8
    • Register Set: Cortex-M3
    • Peripherials (optional): /opt/SEGGER/Ozone/Config/Peripherals/STM32F103xx.svd
  • Connection Settings
    • Target Interface: SWD
    • Target Interface Speed: 4MHz
    • Host Interface: USB
  • Program File: select the binary file you have built (.elf is recommended).

Debug:

set some breakpoints and watch some variables of your interest.
Press the green “power” icon on the upper left corner to start (upload the program and start the debugging process)
Press the blue “play” icon besides “power” to continue.

Unix Network Programming SRC
Posted 2024-05-16Updated 2025-06-26Notea minute read (About 134 words)

Unix Network Programming SRC

The source code repository:https://github.com/unpbook/unpv13e

Preparation

1
git clone https://github.com/unpbook/unpv13e

Configure the makefile for your system:

1
CC=gcc CFLAGS=-w CPPFLAGS=-w ./configure    

In archlinux, if you use ./configure directly, you will get Wimplicit compile error in the following steps.

Build the dependence library.

1
2
3
4
5
6
cd lib
make
cd ../libfree
make
cd ../libroute
make

You can test by using the sample program

1
2
3
cd ../intro
make daytimetcpcli
./daytimetcpcli 127.0.0.1

If you get error

1
connect error: Connection refused

You need to install xinetd, configure it and start the service

1
2
3
yay -S xinetd
nvim /etc/xinetd.d/daytime # set `disable` from `yes` to `no`
systemctl start xinetd

And run daytimetcpcli again, you will get something like

1
16 MAY 2024 14:09:07 CST

Then, you are all set.

Posted 2024-05-13Updated 2025-06-26Notea few seconds read (About 110 words)

Matter of Life and Death

ideology != philosophy

philosophy will never judge the correctness of reality while ideology will.
关于ideology,例如苏联的连环杀人狂,在资本世界才有连环杀人于是苏联对于自己国家的杀人狂不追查,认为不存在。

ethics definition

The philosophy of relation.
Doesn’t judge anything, just describe all the interaction.(unlike morality)

deontology

There is no reason for that. The reason is simply because of being.
Dead-end for ethical argument.

consequentialism

The ends justify the means(the efforts for getting the result).

Game Principle of <JustWork>
Posted 2024-05-12Updated 2025-06-26Note2 minutes read (About 363 words)

Game Principle of <JustWork>

参考

Besiege

核心功能

机械建造

需要更高的建造自由度:例如刚体零件的顶点自定义,3轴移动,3轴旋转,3轴缩放。
可视化内容更丰富:例如碰撞箱,连接点。

物理优化

目前还是使用phsX引擎,考虑一下GPU加速这块功能。
零件之间的连接考虑使用joint以外的方式,特别是某些刚性连接。

逻辑电路体系

参考我写的BesiegeModern Mod

零件材质自定义

{金属,木,玻璃}
需要自己写shader material实现该功能。

次要功能

更好的机械破坏系统

譬如撞击变形,高速击穿之类的
很难
在已有父刚体在运行中,更改碰撞箱布置是非常耗费性能的。

场景建造

自定义场景元素

教程系统

参考mc机械动力模组的“思索”
animation制作

故事模式

起部分教程作用,添加沉浸感,吸引一些非硬核玩家

三渲二

难,可能对电脑性能有较高要求。

目前需要的技术栈

unity shader
unity animation
美术相关工具
物理引擎Game Physics Engine Development
unity URP

Posted 2024-05-12Updated 2025-06-26Note4 minutes read (About 561 words)

如果哪天有幸接触乐器的话,一定要弹弹下面的曲子呀

Goal

  • 人生的旋转木马(本命)
  • 残酷天使的行动纲领
  • 使一颗心免于哀伤(请使我不再哀伤)
  • 生命的名字
  • 梦中飞行(好不容易有了爱的人,却面临失去的恐惧)
  • 人生的约束
  • Take Me Home Country Roads (From <The Best of John Denver>)
  • 跨越时空的思念(泛音好仙)
  • Five Hundred Miles
  • 春日影
  • God knows
  • Call of Silence
  • 黄金之风处刑曲
  • I really want to stay at your house
  • Fly Me to The Moon
  • One Last Kiss
  • November Rain
  • 孤独与吉他与蓝色星球

Ukulele

考虑到便携易学,放寝室里也不会占太多空间,入了尤克里里(虽然貌似ysn前不久还在wb吐槽过)。300块在闲鱼收了一架单板相思木的尤克里里。
下面就暂且记录一下尤克里里的学习过程吧。

基础

教程:https://www.bilibili.com/video/BV1st411q7yc/?spm_id_from=333.337.search-card.all.click&vd_source=45fc7197aaca220eec8fef4c2711efe3
进度:
7/18:p5

曲

使一颗心免于悲伤

https://www.bilibili.com/video/BV1d2421T7xJ/?spm_id_from=333.337.search-card.all.click&vd_source=45fc7197aaca220eec8fef4c2711efe3
进度:
7/19:11小节,前奏的速度终于可以跟上了。好好听。
7/20:17小节,后面的指弹琶音好难,横按也按不到位。
7/27:27小节,横按还是效果不好,但至少能出音了,就是不是很稳定。录了个小视频。
9/20:卡在38小节扫弦,节奏掌握不好

穿越时空的思念

泛音扫弦到底是怎么做到的。。

人生的旋转木马

easy啦

电吉他

海鲜市场在众多鲁琴中找到一把GRG220PA1 classic拾音器的电吉他,遂购入。音箱用marshell的ms2迷你音箱,方便寝室里使用,暂且不连效果器。

看到学吉他分为这么些个级别:

  • 皮毛
  • 入门
  • 吉他运动员
  • 高级吉他运动员
  • 吉他手
  • 吉他大师
  • 吉他英雄(?

我要做吉他🦸!

曲

春日影

https://www.bilibili.com/video/BV1gu41137cg/?spm_id_from=333.337.search-card.all.click&vd_source=45fc7197aaca220eec8fef4c2711efe3

God Knows

Posted 2024-04-25Updated 2025-06-26Notea minute read (About 219 words)

Graduate Project

拟题:
基于混合现实的智能体交互

具体功能:
通过hololens2获取场景数据(识别小车/其他物体的位置,网格信息)。
通过hololens2的立体空间交互能力,指挥小车进行移动,执行任务(譬如抓取柱体并移动到相应位置)。

  • 关于移动,可以是在眼镜中通过手部动作画一条路径
  • 关于执行任务,可以是眼镜识别出物体的位置后规划小车移动和动作序列(A*or强化学习)->相关信息发给小车->小车收到后执行
    通过hololens2的虚拟物体放置功能,譬如可以放置小车的车库,柱体移动到的目标位置等
    可以通过hololens2显示小车将要移动的意图
Posted 2024-04-20Updated 2025-06-26Note2 minutes read (About 358 words)

Docusaurus

The example site: https://chen-yulin.github.io/Besiege-Modern-Docs/

Initialize the local project

node -v >= 18.0

1
npm init docusaurus@latest Besiege-Modern-Mod-docs classic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
✔ Which language do you want to use? › JavaScript
[INFO] Creating new Docusaurus project...
[INFO] Installing dependencies with npm...
...
[SUCCESS] Created Besiege-Modern-Mod-docs.
[INFO] Inside that directory, you can run several commands:

`npm start`
Starts the development server.

`npm run build`
Bundles your website into static files for production.

`npm run serve`
Serves the built website locally.

`npm run deploy`
Publishes the website to GitHub pages.

We recommend that you begin by typing:

`cd Besiege-Modern-Mod-docs`
`npm start`

Happy building awesome websites!

Configuration

Add a source code button

src/pages/index.js,in function HomepageHeader(), add a <div>.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
function HomepageHeader() {
const {siteConfig} = useDocusaurusContext();
return (
<header className={clsx('hero hero--primary', styles.heroBanner)}>
<div className="container">
<Heading as="h1" className="hero__title">
{siteConfig.title}
</Heading>
<p className="hero__subtitle">{siteConfig.tagline}</p>
<div className={styles.buttons}>
<Link
className="button button--secondary button--lg"
to="/docs/intro">
Getting Started ⏱️
</Link>
</div>
// +++++++++[[
<div className={styles.buttons}>
<Link
className="button button--secondary button--lg"
to="https://github.com/Chen-Yulin/Besiege-Modern-Mod">
Source code
</Link>
</div>
// ]]+++++++++
</div>
</header>
);
}

Two button too close to each other, change the css style for button.
In src/pages/index.module.css

1
2
3
4
5
6
.buttons {
display: flex;
align-items: center;
justify-content: center;
margin-top: 1rem; // +++
}

Deployment

Add the remote repository on github.

1
git remote add origin git@github.com:Chen-Yulin/Besiege-Modern-Docs.git

Change the deployment configurations

1
2
3
4
5
6
7
8
9
10
11
12
// Set the production url of your site here
url: 'https://chen-yulin.github.io',
// Set the /<baseUrl>/ pathname under which your site is served
// For GitHub pages deployment, it is often '/<projectName>/'
baseUrl: '/Besiege-Modern-Docs/',

// GitHub pages deployment config.
// If you aren't using GitHub pages, you don't need these.
organizationName: 'Chen-Yulin', // Usually your GitHub org/user name.
projectName: 'Besiege-Modern-Docs', // Usually your repo name.
deploymentBranch: 'deploy',
trailingSlash: false,

Change the page setting in repository settings, Branch set to deploy branch.

Deploy command: yarn deploy

1
2
3
4
5
[INFO] `git commit -m "Deploy website - based on aa492c3f0934f0177ca946345c2d32940c1900c3"` code: 0
To github.com:Chen-Yulin/Besiege-Modern-Docs.git
* [new branch] deploy -> deploy
[INFO] `git push --force origin deploy` code: 0
Website is live at "https://Chen-Yulin.github.io/Besiege-Modern-Docs/".
Posted 2024-04-19Updated 2025-06-26Note11 minutes read (About 1579 words)

Automate OpenROAD testing

Purpose:

We use OpenROAD to generate timing analysis reports for each design. However, manually modifying parameters, running commands, and intercepting important information will be too arduous work. It is mainly due to the following points.

  • First of all, the report generated by OpenROAD for each design is too long, and the report file may be as large as hundreds of megabytes. It is almost impossible to open and find tns, wns data using a text editor.
  • Secondly, the locations of the configuration files running OpenROAD are very scattered. Moreover, the configuration file directory for timing modification is stored in the tcl script. Manual search and modification are too anti-human and prone to misoperation.
  • Furthermore, the amount of data we need is very large. For each design, we hope to test its performance under 7 different clock cycles and 5 different core area sizes. In other words, for each design, it is necessary to manually modify parameters, run commands, and intercept important information 35 times, which is unbearable, not to mention that we have 7 designs.
    Due to these drawbacks, I decided to use shell script to automate the process of OpenROAD testing. I have the following requirements for the script.
  • The script can modify the core_area, die_area parameter in the tcl script given the path to the tcl script and the desired scale of area.
  • The script can modify the create_clock‘s -period parameter in the sdc configuration file referred by the tcl script, given the path to the tcl script and the desired clock period.
  • The script can set all the parameters and run OpenROAD analysis one by one, given the choice set of clock period and area scale.
  • After the OpenROAD generated the report file, the script can read the report and extract the information of tns & wns for each stop point and export these data to a csv table.

Main Test Framework

The entry script is named as runit.gxy, which can receive the name of design as an argument.
For each design, the corresponding tcl script is fixed, so I decided to map the name of design to the tcl script.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
design="$1"
if [ "${design}" = "APU" ]; then
file_path_orig="../dataset/run/greedy/APU/10n.tcl"
file_path="../dataset/run/greedy/APU/10n_bak.tcl"
elif [ "${design}" = "ppu" ]; then
file_path_orig="../dataset/run/greedy/ppu/5n.tcl"
file_path="../dataset/run/greedy/ppu/5n_bak.tcl"
elif [ "${design}" = "xtea" ]; then
file_path_orig="../dataset/run/greedy/xtea/5n.tcl"
file_path="../dataset/run/greedy/xtea/5n_bak.tcl"
elif [ "${design}" = "yhuff" ]; then
file_path_orig="../dataset/run/greedy/yh/5n.tcl"
file_path="../dataset/run/greedy/yh/5n_bak.tcl"
elif [ "${design}" = "dynamic_node" ]; then
file_path_orig="../dataset/run/greedy/dy/5n2.tcl"
file_path="../dataset/run/greedy/dy/5n2_bak.tcl"
elif [ "${design}" = "ibex" ]; then
file_path_orig="../dataset/run/ibex_tcl/C0A0.tcl"
file_path="../dataset/run/ibex_tcl/C0A0_bak.tcl"
elif [ "${design}" = "salsa20" ]; then
file_path_orig="../dataset/run/greedy/sal/5n.tcl"
file_path="../dataset/run/greedy/sal/5n_bak.tcl"
else
echo "no such design"
exit 1
fi

if [ ! -f "$file_path" ]; then
echo "File $file_path not found."
if [ ! -f "$file_path_orig" ]; then
echo "Origin file ${file_path_orig} not found."
exit 1
fi
cp $file_path_orig $file_path
fi

The reason I use _bak post-fix is that, I want to reserve the original core_area and die_area configuration in the origin tcl file, since the original configuration is needed in the following steps.

Then I use nested loop to change the configuration one by one. The choice set can be modified in the condition statement of each for loop.

1
2
3
4
5
6
7
8
9
10
11
for period in 2 4 6 8 10 12 14
do
# set clk period
for scale in 0.2 0.4 0.6 0.8 1
do
# set area scale
#run openroad
timeout 5 ../../OpenROAD-flow-scripts/tools/OpenROAD/build/src/openroad $file_path > $output_path
# collect data and export to csv
done
done

The set clk period, set area scale, export to csv function will be covered in the following steps.

Set the Period of Clock

I create a new shell script called set_clk.sh to manage the automation of changing clock period.
It takes two arguments, the path to the tcl script (string) and the desired clock period (integer).
I first preprocess the period parameter, namely, divide it by 10.

1
2
3
4
5
time="$2"
period=$(echo "scale=1; $time / 10.0" | bc)
if [[ $period =~ ^\. ]]; then
period="0$period"
fi

The clock configuration can be modified in the sdc file, while the path to the sdc file can be extracted from the tcl file, with the format of set sdc_file "PATH_TO_SDC"
I decided to use grep to locate the line of set sdc_file and extract the path to sdc file using regex substitution.

1
2
tcl_path="$1"
sdc_path=$(grep 'set sdc_file' "$tcl_path" | sed 's/.*"\(.*\)".*/\1/')

In the sdc file, the configuration has a format of create_clock ... -period 0.x.
Still, use regex substitution to replace the original period with the input period and everything is done.

1
sed -i "s/^\(create_clock.*-period \)[0-9]*\.*[0-9]\(.*\)$/\1$period\2/" "$sdc_path"

Set the core_area and die_area

The area of the design is expressed in the form of {x1 y1 x2 y2}, where x1 y1 stands for the coordinate of bottom-left corner and x2 y2 stands for the coordinate of upper-right corner.
Since the area of different design varies a lot, I need to change the area proportionately. As a result I need to reserve the original area stored in tcl script as mentioned before.

First, I read the origianl core_area and die_area from the original script.

1
2
3
4
5
6
7
8
9
file_path="$1"
orig_path="${file_path//_bak}" # remove the _bak postfix_

core_area=$(grep 'set core_area' "$orig_path" | sed -n 's/.*{\([^}]*\)}.*/\1/p')
die_area=$(grep 'set die_area' "$orig_path" | sed -n 's/.*{\([^}]*\)}.*/\1/p')

IFS=' ' read -r core1 core2 core3 core4 <<< "$core_area"

IFS=' ' read -r die1 die2 die3 die4 <<< "$die_area"

Then I calculate the desired core/die area size based on the scale and original area.

1
2
3
4
5
6
7
8
9
10
11
12
13
core_x_size=$(echo "$core3" - "$core1" | bc)
core_y_size=$(echo "$core4" - "$core2" | bc)

core1=$(echo "$core1 + $core_x_size * (1 - $2) / 2" | bc)
core3=$(echo "$core3 - $core_x_size * (1 - $2) / 2" | bc)

core2=$(echo "$core2 + $core_y_size * (1 - $2) / 2" | bc)
core4=$(echo "$core4 - $core_y_size * (1 - $2) / 2" | bc)

die1=$(echo "$core1" - "10" | bc)
die2=$(echo "$core2" - "10" | bc)
die3=$(echo "$core3" + "10" | bc)
die4=$(echo "$core4" + "10" | bc)

Finally, use regex substitution to modify the area configuration in _bak.tcl script.

1
2
sed -i "s/die_area {[^}]*}/die_area {$die1 $die2 $die3 $die4}/g" "$file_path"
sed -i "s/core_area {[^}]*}/core_area {$core1 $core2 $core3 $core4}/g" "$file_path"

Collect data and export to .csv

The key information I need from the report generated by OpenROAD is tns & wns.
By observation, the block containing the data has the following pattern.

1
2
3
4
5
***
result of: stoppoint*
tns: [number1]
wns: [number2]
***

Therefore, I use the grep and awk command to get the last word in each data block. In this case, it’s stoppoint*, [number1], [number2].

1
2
input_file="$1"
tnswns=$(grep -A 2 "result of" "$input_file" | awk '/result of/{p=3} p&&p--' | awk '{print $NF}')

Each report contains totally 6 valid stop points, so I use a loop to get the desired data.

1
2
3
4
5
6
7
8
9
csv_file="${design}.csv"
for nr in 2 5 8 11 14 17
do
stoppoint=$((stoppoint+1))
tns=$(echo "$tnswns" | awk -v nr="$nr" 'NR==nr')
nr_wns=$(echo "$nr + 1" | bc)
wns=$(echo "$tnswns" | awk -v nr="$nr_wns" 'NR==nr')
# export to csv table
done

After getting the desired tns and tws, I want to export these data to a csv table.
I decided to let the table has the following columns, period, scale, stop point number, tns and wns, one such table for each design.
This function can be achieved with the following script

1
2
3
4
design="$2"
period="$3"
scale="$4"
echo "${period},${scale},stoppoint${stoppoint},${tns},${wns}" >> $csv_file

Replace the comment in the loop and everything is done.

Result

I assemble runit_gxy.sh in a single script named runit_cyl.sh to run the analysis of all designs at once.

1
2
3
./runit_gxy.sh APU
./runit_gxy.sh ppu
...

Then redirect the output to runit_cyl.log.

Here is the content of APU.csv and runit_cyl.log

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Period,Scale,Stoppoint,tns,wns
2,1,stoppoint1,-17.2309532166,-0.4609909952
2,1,stoppoint2,-13.7819681168,-0.4073848128
2,1,stoppoint3,-13.7819681168,-0.4073848128
2,1,stoppoint4,-14.1436796188,-0.3814869523
2,1,stoppoint5,-14.1436796188,-0.3814869523
2,1,stoppoint6,-14.1436796188,-0.3814869523
2,0.95,stoppoint1,-17.2309532166,-0.4609909952
2,0.95,stoppoint2,,
2,0.95,stoppoint3,,
2,0.95,stoppoint4,,
2,0.95,stoppoint5,,
2,0.95,stoppoint6,,
2,0.9,stoppoint1,-17.2309532166,-0.4609909952
2,0.9,stoppoint2,,
2,0.9,stoppoint3,,
2,0.9,stoppoint4,,
2,0.9,stoppoint5,,
2,0.9,stoppoint6,,
4,1,stoppoint1,-8.3930120468,-0.2609909773
4,1,stoppoint2,-4.7969579697,-0.2073848099
4,1,stoppoint3,-4.7969579697,-0.2073848099
4,1,stoppoint4,-4.5129084587,-0.1783644110
4,1,stoppoint5,-4.5129084587,-0.1783644110
4,1,stoppoint6,-4.5129084587,-0.1783644110
4,0.95,stoppoint1,-8.3930120468,-0.2609909773
4,0.95,stoppoint2,,
4,0.95,stoppoint3,,
4,0.95,stoppoint4,,
4,0.95,stoppoint5,,
4,0.95,stoppoint6,,
4,0.9,stoppoint1,-8.3930120468,-0.2609909773
4,0.9,stoppoint2,,
4,0.9,stoppoint3,,
4,0.9,stoppoint4,,
4,0.9,stoppoint5,,
4,0.9,stoppoint6,,
6,1,stoppoint1,-1.8987674713,-0.0609909929
6,1,stoppoint2,-0.0572821237,-0.0073847598
6,1,stoppoint3,-0.0572821237,-0.0073847598
6,1,stoppoint4,0.0000000000,0.0000000000
6,1,stoppoint5,0.0000000000,0.0000000000
6,1,stoppoint6,0.0000000000,0.0000000000
...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use design: APU
use tcl file path ../dataset/run/greedy/APU/10n_bak.tcl
get sdc path: ../dataset/run/greedy/gcd/1/gcd_nangate45.sdc
Change period to 0.2
create_clock [get_ports clk] -name core_clock -period 0.2
core area difference 60.18 59.8
set die_area {.07 1.2 80.25 81}
set core_area {10.07 11.2 70.25 71}
collecting data
core area difference 60.18 59.8
set die_area {1.07 2.2 79.25 80}
set core_area {11.07 12.2 69.25 70}
collecting data
core area difference 60.18 59.8
set die_area {3.07 3.2 77.25 79}
set core_area {13.07 13.2 67.25 69}
collecting data
get sdc path: ../dataset/run/greedy/gcd/1/gcd_nangate45.sdc
Change period to 0.4
create_clock [get_ports clk] -name core_clock -period 0.4
core area difference 60.18 59.8
set die_area {.07 1.2 80.25 81}
set core_area {10.07 11.2 70.25 71}
collecting data
core area difference 60.18 59.8
set die_area {1.07 2.2 79.25 80}
set core_area {11.07 12.2 69.25 70}
collecting data
core area difference 60.18 59.8
set die_area {3.07 3.2 77.25 79}
set core_area {13.07 13.2 67.25 69}
collecting data
get sdc path: ../dataset/run/greedy/gcd/1/gcd_nangate45.sdc
Change period to 0.6
create_clock [get_ports clk] -name core_clock -period 0.6
core area difference 60.18 59.8
set die_area {.07 1.2 80.25 81}
set core_area {10.07 11.2 70.25 71}
collecting data
...
Previous
Next
  • 1
  • …
  • 7
  • 8
  • 9
  • 10
  • 11
Chen Yulin

Chen Yulin

SJTU student

Manchester by the Sea

Posts

269

Categories

9

Tags

191

Follow

Archives

  • June 20256
  • May 202510
  • April 202517
  • March 202545
  • February 202512
  • January 202513
  • December 202412
  • November 20244
  • October 202418
  • September 202416
  • August 202413
  • July 20243
  • June 20245
  • May 202413
  • April 202417
  • March 20241
  • January 20241
  • December 20231
  • May 202346
  • August 20221
  • May 20226
  • April 20229

Recents

2025-06-22

Math6003 Hw4

Note

2025-06-16

数学HW3

Note

2025-06-11

数据挖掘考试纲要-中文

Note

2025-06-11

数据挖掘考试纲要

Note

2025-06-09

!!老友记同款!!芝士蛋糕🧀

民以食为天

Tags

3D-Scene4
6-D3
AI10
AIGC1
API1
AR2
Academic1
Algorithm1
Aliyun1
App2
Atlas1
BS41
Beautify1
Behaviorism1
Business1
C1
CADC1
CD1
CLIP5
CNN1
CV28
Capstone10
Communication2
Contrastive-Learning3
Control2
Csharp9
Css1
Cuda3
DD1
DINO4
DT1
Dataframe1
Debate5
Debugger1
Diffusion1
Discrete-Mathematics1
Disney1
Docker1
Docs2
Dynamic-programming1
ESP322
Education1
Embeded-System9
Embodied-AI8
Emoation1
Emotion12
Ethic1
FL1
FPN2
Family1
Federated-Learning1
Foundation1
Functional programming1
GPT3
Game5
Gated-NN2
Git7
Github1
Godot3
HPC1
HRI2
Haskell1
Health2
Hexo10
Hierarchical1
Html5
Humanism1
Hyprland2
IK1
Image-Grounding1
Image-Text5
Image-generation1
ImitationLearning3
Jolt1
Json1
LLM12
LSP2
Latex2
Life4
LinearAlgebra1
Linux21
Live2d1
Love3
Lua1
MBTI1
ML7
MR/AR3
Mason1
Math5
Meme1
Message-Passing1
Mod3
Motivation1
Movie1
Multi-modal6
Multi-view1
Music5
NLP4
NN4
Network2
Nodejs5
Numpy1
Nvim9
Object-Detection4
Open-Vocabulary9
OpenCV1
Oral1
PHD1
PSY5
Pandas2
Panoptic1
Path1
Philosophy3
PhysX1
Physical-Scene4
Physics-engine1
Pio2
Planning1
Plugin8
PoseEstimation3
Postgraduate1
Prefab1
Probability1
Python27
Pytorch1
QML1
Quantum1
RNN4
ROS3
Reading19
Real2Sim1
Reconstruct9
Regex2
Reinforcement-learning1
Repository5
Representation-Learning1
Research-paper86
Robot1
Robotics16
SJTU-Lecture1
SQL2
SSH2
Scene-graph29
Scene-synthesis1
Science-fiction1
Scrap1
Script2
Segmentation7
Semantic12
Shader3
Shell4
Signals and Systems1
Sim2Real1
Sklearn1
Snippets1
Society4
Star-rail1
Subgraph1
Submodule1
Supervised-learning2
Survey3
TC1
TOEFL1
Task-Planning6
Tasks4
Tech Communication1
Torch4
Transformer11
Translation-Embedding2
Travel3
Unity20
Unsupervised-learning1
VLM6
VLP2
Version-management1
ViT4
VideoEditing2
Vim1
Visual-Relation20
WSL1
Waybar1
Wayland1
Web1
Website1
Well-being1
Window-manager2
YKLL3
Zen2
🍰1
🐱2
🧀1
Chen Yulin's BlogChen Yulin's Blog

© 2025 Chen Yulin  Powered by Hexo & Icarus

×