EE/Digital Design

[Synopsys EDA] Post-Synthesis simulation

아이스얼그레이 2022. 11. 2. 21:40
본 게시글은 Chip 설계 프로젝트 중 EDA tool 사용법에 대해 기록한 글입니다. 틀린 내용이나 정석에서 벗어난 내용이 있을 수 있습니다.

Post-Synthesis simulation은 DTA(Dynamic Timing Analysis)와 Logic Synthesis를 마친 후에, RTL로 작성한 module과 합성 후 생성된 _syn.v module이 같은 동작을 확인하는 과정입니다.

 

Synopsys VCS를 사용한 verilog simulation은 stage 사이의 delay를 고려하지 않기 때문에 다음 사진과 같이 propagation delay가 전혀 없는 파형을 보여줍니다.

값은 보실 필요 없고, CLK의 positive edge에서 delay 없이 값이 바뀌는 것을 보시면 됩니다.

 

그래서 CLK의 period를 아무리 줄이더라도 문제없이 simulation이 돌아가는 것을 볼 수 있습니다.

 

RTL의 동작에 대한 검증이 끝났다면, 다음과 같은 순서로 Post-Synthesis simulation이 이뤄집니다.

 

1. STA(Static Timing Analysis)

Synopsys PrimeTime이라는 tool을 이용해 합성한 module의 정적 시간 분석을 할 수 있습니다. 이때 STA란 전체 Data path가 아닌, 오직 Flip Flop 사이에서 Data를 전달할 때 필요한 delay만 계산하는 과정입니다.

 

정확한 설명은 아니고 추후에 STA에 관한 게시글을 작성할 예정입니다.

 

PrimeTime sourcing을 마쳤다고 가정하고, PT.tcl을 다음과 같이 작성해야 합니다.

 sh date
remove_design -all
#design library

set tmpStr $techlib/ng45nm_tt.db
set target_library $tmpStr
set link_library "* $target_library"

set top_design sys_array_4by8

read_verilog ../02-dc/sys_array_4by8_syn.v
current_design $top_design
link

read_sdc ../02-dc/sys_array_4by8.sdc

#read_parasitics -pin_cap_included -keep_capacitive_coupling -increment "../starrc/aes_cipher_top.spef.min"

complete_net_parasitics -complete_with zero
#report_annotated_parasitiics -check

#report timing
report_timing -nets -nosplit
#source $techlib/scripts/reportTNS.tcl
source ./reportTNS.tcl
ReportTNS

set power_enable_analysis TRUE
set power_analysis_mode averaged

write_sdf $top_design.sdf
# Set default activity values.
#set inPorts [all_inputs]
#set theClocks [get_clock]
#set clockNames [get_attribute $theClocks full_name]
#set inPortsNoClock [remove_from_collection $inPorts $clockNames]
#set_switching_activity -static_probability 0.5 -toggle_rate 0.2 $inPortsNoClock -period 2
#set_switching_activity -static_probability 0.5 -toggle_rate 0.1 -type registers -hierarchy -period 2

# Report power.
update_power
check_power
report_power -verbose -nosplit

start_gui

음 대충 해석해보자면, 합성할 때 사용한 standard cell library 정보를 적어줘야 합니다.

그리고 top_design 정보와 합성된 *_syn_v의 경로, .sdc 파일의 경로를 지정해줍니다.

 

이 script는 연구실 서버의 경로에서 사용하는 것이기 때문에 그냥 이런 게 있구나 하고 넘어가시면 됩니다.

 

STA를 마쳤다면, .sdf 파일이 결과로 나오는데, 이것이 설계한 module의 Static delay 정보가 담긴 파일입니다.

그리고 다음과 같은 PrimeTime GUI가 나타납니다.

명확한 의미를 해석하지는 못했는데, 대충 4.8 ~ 4.9의 slack을 가지는 path가 제일 많다. 정도로 해석됩니다.

 

2. Simulation with VCS

.sdf 파일 추출까지 완료했다면 _syn.v 파일과 합성 전 RTL을 검증하는 데 사용했던 TestBench를 사용해 VCS simulation을 돌립니다.

 

이때 기존 VCS와 약간 다른 과정이 필요합니다. _syn.v 파일은 NOR2_X1, AND2_X1, DFF_X1 이런 standard cell로 이뤄져 있기 때문에, 이 cell들의 정보를 가지고 있는 .v 파일이 필요합니다.

 

저의 경우에 NAND45nm 공정에 사용되는 Standard cell을 사용했기 때문에 NandgateOpenCellLibrary.v라는 파일을 ./runVCS script가 있는 경로에 놔뒀습니다.

 

그리고 runVCS script도 다음과 같이 약간 수정해줍니다.

 set options = "-full64 -gui -Mupdate -timescale=1ns/1ps -v ./NangateOpenCellLibrary.v"

options에 현재 경로에 있는 NandgateOpenCellLibrary.v 정보를 추가해줬습니다.

 

그다음 testbench도 약간 수정해줍니다.

$sdf_annotate("./sys_array_4by8.sdf", top_4by8_tb.u0,,, "MAXIMUM")

위 문구를 추가해줘야 하는데, 실제 delay 정보가 포함된 simulation이기 때문에 STA의 결과 파일인 .sdf를 물려줘야 합니다. "MAXIMUM"은 아마 최대 delay를 기준으로 simulation 하겠다는 의미인 것 같습니다.

 

당연히 filelist에는 tb 경로와 _syn.v 경로를 적어줘야 합니다. 이때 _syn.v에 하위 모듈들이 포함되어 있기 때문에, 다른 module은 filelist에 작성할 필요 없습니다.

 

여기까지 왔다면 VCS simulation을 돌려주면 됩니다.

 

일부러 timing violation을 일으키기 위해 clk period를 0.2로 빡빡하게 줘보겠습니다.

그럼 이런 식으로 결과에 X 값이 쫙 뜨고 Timing violation이 발생합니다. FF 사이의 Combination Logic의 연산이 끝나기 전에 propagation이 진행되어서 값이 씹히는 걸 볼 수 있습니다.

 

이번에는 clk period를 5로 줘보겠습니다.

아름답지 않습니까???

 

실제 Gate의 Delay와 Slack까지 고려했지만 원하는 결과를 뽑은 것을 볼 수 있습니다. 참고로 위 simulation은 4 X 8 의 결과 행렬을 Output으로 내보내는 행렬 곱셈 연산입니다.

위와 같이 원하는 결과가 수행된 것을 볼 수 있습니다.

 

Delay를 고려한 Simulation이기 때문에 위와 같이 파형을 확대하면 약간(~10ps)의 어긋남은 있습니다. 정확히 CLK의 positive edge 91ps 이후에 propagation이 일어나는 것을 볼 수 있습니다.

 

이로써 Post-Synthesis simulation이 끝났습니다.

 

재밌지 않나요? 사실 이 과정 동안 상당한 삽질을 했는데 원하는 결과를 뽑아내니까 상당히 기분이 좋았습니다:)