2024년 2월 24일 토요일

Yosys 합성기는 장난감 일까?

Yosys 합성기는 장난감 일까?

디지털 반도체 설계에 하드웨어 기술언어가 선택됨에 따라 필연적으로 등장한 도구가 시뮬레이터와 합성기(synthesizer)다. 합성기는 레지스터 전송 수준(RTL, Register-Transfer Level)에서 기술된 행위를 디지털 하드웨어로 합성 해준다. "합성기"는 행위 묘사로부터 디지털 회로의 기초요소(각종 게이트와 플립플롭)의 연결도(netlist)를 출력해 준다. 반도체를 제작하려면 회로도(schematic)가 필요한데 그림으로 그려내는 대신 언어로 작성했다면 합성기가 반드시 필요하다. 합성기가 내놓은 연결도가 바로 회로도인 셈이다.

디지털 회로 요소들이 연결된 구조에 따라 조합회로 또는/그리고 순차회로로 분류된다. 조합회로 요소의 연속적인 연결은 지연을 동반한다. 한 행위를 두고도 설계자의 경험과 능력치에 따라 여러 설계가 가능하다. 속도와 크기는 행위묘사로 부터 회로 설계도를 대신 뽑아낼 합성기의 성능을 평가하는 척도다. 이때 논리식을 도출해 내는 능력은 당연한 것이므로 논외로 한다.

시놉시스(Synopsys)사의 디자인 컴파일러(Design Compiler)는 언어 기반 반도체 설계가 태동기부터 등장하여 이제는 독보적인 도구가 되었다. 합성기의 표준으로서 디지털 반도체 설계 방법론에 끼친 영향은 이루 말할 수 없을 정도다. 특히 합성 옵션을 설정하는 SDC(Synopsys Design Constraints)는 모든 반도체 설계 도구가 따르고 있다고 해도 과언이 아니다.

디지털 회로 합성 옵션을 크게 둘로 나누면 크기(area)와 지연(delay)으로 두 플립-플롭 사이에 놓일 조합회로의 구조에 의해 결정된다. 등가의 논리식을 두고도 여러 구성의 조합논리 회로 구성이 가능하다. 논리적 등가이면서 최소의 논리소자를 동원하는 기능적 최적화와 다수의 게이트들을 병렬로 둠으로써 지연 최소화를 수행한다. 지연을 평가하는 기준은 좀더 복잡하다. 전기 신호가 게이트를 통과하면서 수반되는 지연은 물론 배선 선로의 지연도 고려되어야 한다. 다수의 선로가 한 값을 표현하는 데이터 패스(data-path) 디지털 회로의 경우 균등한 선로 배분 역시 매우 중요한 요소다. 배치와 배선에 따라 지연이 달라지기 때문에 합성 단계에서 지연을 고려하기는 쉽지 않다. 수많은 논리소자들의 배치와 배선 역시 자동화 도구를 사용하게 될 것이므로 합성기는 이와 연동 되어야 한다.

디지털 신호가 지나갈 경로상의 논리 소자들의 조합과 배선 지연을 고려한 합성을 시간 구동 합성(timing-driven synthesis)이라 한다. 배선이 아직 이뤄지지 않았지만 공정의 물리적 특성으로부터 단위 길이당 배선 지연 모형(wire load model)을 합성에 적용한다. 결국 합성기의 성능은 하드웨어 언어로 묘사된 디지털 행위로 부터 논리식을 추출해 내는 원론적 기능은 물론이고 최종 레이아웃을 생산 했을 때 면적과 속도를 충실히 반영 할 수 있는지의 여부에 달렸다. 상용 시높시스사의 디자인 컴파일러는 이 부분에서 독보적인 지위에 있다. 하지만 매우 고가의 소프트웨로 쉽게 접근하기 어렵다.

Yosys는 오픈-소스 베릴로그 합성기다. 깃-허브를 통해 원시 파일로 배포되고 설치와 사용은 무료다. 약간의 비용을 지불하면 원작자로 부터 기술 지원을 받을 수 있다. 반도체 설계가 소프트웨어 개발 만큼이나 전문가의 영역에서 취미가의 영역으로 확대되어가고 있다. 구글은 무료 디자인 킷 Skywater FreePDK를 공개하였고 eFalbess.com 은 9천 달러에 칩을 제작해 주는 서비스를 실시하고 있다. 이에 Yosys 합성기가 널리 활용되고 있다. 특히 자유 반도체 설계 The OpenROAD (https://theopenroadproject.org/)의 활동이 활발한데 오늘의 리눅스를 이끈 자유 소프트웨어 운동 FSF(Free Software Foundation)을 보는 듯하다.

Yosys가 등장한 지는 십여년이 넘었고 여전히 발전하고 있다. 이 합성기가 주목을 받으면서 상용 합성기와 비교하는 논란이 있었다. 그중 몇가지를 아래 링크에 걸었으니 참고하기 바란다.

https://www.reddit.com/r/FPGA/comments/x2iwoe/yosys_is_toy_i_dont_believe_it/

아래와 같은 질문에

"Yosys 는 장난감 수준이라고 하는데 그런가요?"

답변을 요약하면,

- 처리할 수 있는 설계의 규모가 상용 도구에 못미친다. 백만게이트 급 설계를 취급할 생각마라.
- 시간 기반 합성 개념은 없다.
- 시간대 면적 옵션을 구분하는 옵션은 없다. (리소스 쉐어, 파이프라인 재구성 안 됨)
- 기본 논리식 외의 특수 매크로(곱셈, 쉬프트 등 고효율 데이터 패스)는 없다.
- 멀티 클럭 영역 설계 않된다.
- 와이어 로드 모델을 취급하지 않는다.
- 배치와 배선 도구와 연계되어있지 않다.

위 내용으로보면 상용 칩 제작은 곤란한 듯이 보인다. 게다가 Synopsys 합성기의 탁월함을 보여주는 SDC(Synopsys Design Constraint)를 못쓴다는 의미 이기도 하다. 시높시스의 합성기는 업계 표준이 되었기에 향후 반도체 설계로 진출하려면 반드시 SDC를 배워야 하는 것처럼 말한다.

Yosys를 활용하여 몇가지 예제들을 합성해본 바로는 논리식 기능 합성에 전혀 문제가 없었다. ETRI의 0.5um CMOS 공정용 표준 셀을 제작하고 이를 가지고 Yosys 합성한 후 네트 시뮬레이션, LVS, LVL을 무난히 수행 할 수 있었다.

ETRI 공정 3중 메탈에 불과한데다 면적도 좁은데서 속도와 시간의 밸런스를 맞추고 클럭 속도를 쥐어짜 봐야 제아무리 상용의 합성기와 배치배선 도구라도 할 수 있는게 거의 없다고 본다. 소규모 칩의 RTL 설계 플로우에 Yosys 를 비롯한 오픈-소스 도구들의 활용으로도 교육적인 목적에 충분 할 것이다.

덧붙이자면, 설계와 공정에 비중을 두고 있는 교육과정도 편협하다고 본다. 설계도구와 표준셀 라이브러리 제작도 반도체 산업의 매우 중요한 분야다. 공정의 디자인 룰만 가지고 팹리스 회사들마다 고유의 셀 라이브러리를 확보하여 경쟁력있는 칩을 만들고 있다. 특히 기본적인 표준 셀 이외에 고집적 저전력 매크로 셀은 아주 중요한 자산이다.

학생들이 현업에 나가면 유명 상표의 설계 툴을 쓰게 되므로 이를 대비한다는 의미는 있겠지만 사실 상용 툴의 사용법을 위해 MPW를 운용하는 것은 바람직 하지 않다고 본다. 상용 툴의 사용법은 단기 실무 교육으로도 충분 하기 때문에 학교에서도 굳이 상용 도구 사용법을 가르치지 않는다. 툴의 사용법보다 "설계"에 방점을 두어야 할 것이다.

-----------------------------------------------------------------------------------------

"yosys is toy, i dont believe it"

[출처: https://www.reddit.com/r/FPGA/comments/x2iwoe/yosys_is_toy_i_dont_believe_it/ ]

Some people said yosys is toy but without given solid example. I think they said that because of everyone know synopsys/cadence are too big, that all. They done really know what yosys can/cant do. So now i want to ask, if you think yosys is toy. What it cant do? what chip it cant design? thx

tverbeure / 2y ago

I've used Yosys for a ton of projects (and blogged a couple of times about it.)

Yosys is a decent tool for FPGA hobby use (but I still prefer Quartus for most FPGA work) and a fantastic basis for research purposes. It's entirely unsuitable for professional use. Just a few flaws from the top of my head:

- Its capacity is way too low. Try synthesizing something as small as a Western Digital Swerv CPU with it and weep. Forget about using it to do top-down synthesis of million gate units.
- It has close to no ability to do timing driven synthesis. That's just an entry level feature for all commercial tools.
- There's very limited support for repipelining.
- It has no support trade off area vs timing.
- It has no concept of multiple clock domains.
- It has no support for different architectures of fundamental building blocks such as multipliers etc.
- It has no concept of power-aware synthesis
- It has no concept of wire load models.
- It has not concept of physical/floorplan aware synthesis.

It's relatively easy to write your own processing passes to add functionality to Yosys. E.g. a talented intern should be able to write an extension for different types multipliers in a few months. But when I use something like Design Compiler, all the things that I mention above work out of the box. And they are critical to make real chips.


"Preventing/fixing hold time problems"
[출처: https://www.reddit.com/r/yosys/comments/98kcld/preventingfixing_hold_time_problems/ ]

Regor191 / 6 yr. ago

How do you guys deal with hold time issues in standard cell synthesis? Depending on temperature and clock skew some libraries will violate their own hold time when the Q of one FF is connected directly to the D of another. Last time I did a large ASIC (almost 20 years ago) I had a way to find all those direct connects and add a buffer or pair of inverters in between to create some hold time margin. It's not clear to me how I can automate that with Yosys / ABC.

ZipCPU / 6 yr. ago

What you are missing is that Yosys is a synthesizer only, it is not a complete toolchain. Yosys maps Verilog to a set of component cells. These cells are defined by the library given to Yosys. As a result, Yosys does not make any timing aware decisions. It just maps logic to logic elements. Timing aware decisions need to be made by a follow-on tool.

The follow-on tool may choose to add an inverter between the two FF's, or the two FF's may be separated on the chip far enough that the inverter is not required. Yosys has no knowledge of the information necessary to make any such decision/optimization.

The same applies to pin assignments. These are relevant to the tool following the synthesizer, but not the synthesis tool itself.


"Timing constraints in yosys, abc"
[출처: https://www.reddit.com/r/yosys/comments/3djedt/timing_constraints_in_yosys_abc/ ]

edvinshehu / 9 yr. ago

Hi Clifford. I have a circuit that uses two clocks, one 200MHz and one 50MHz. How can I put that information in yosys or abc so that the circuit can meet timing? Practically, how can I put timing constraints? I am using one of the liberty files with all the parasitics and timing information for the cells you have in the website. Thanks.

CliffordVienna / 9y ago

I like those questions that make me find bugs. The following script only works with yosys git head because it requires this bug fix.

To answer your question..

Yosys itself does know nothing about timing constraints. All we can do is use some timing constraints in ABC logic mapping. However: This is only half of the story because ABC does know nothing about path delays. So ultimately timing constraints must be handled by the place&route tool. How this is done depends on the P&R back-end that you are using.

If you want to support multiple timing constraints in synthesis, you need to use "select" expressions to partition your design into clock domains and then pass each clock domain separately to ABC. At the moment there is no dedicated command that allows you to do this in a simple and convenient way. So this ends up being an exercise in Yosys select expressions.

The following script demonstrates how to do that by running synthesis on the svo_vdma_crossclock_fifo module from my SimpleVOut Project. (Remember: You need current git head.)

------

echo on

! wget -O svo_vdma.v https://raw.githubusercontent.com/cliffordwolf/SimpleVOut/master/svosrc/svo_vdma.v

! wget -O svo_defines.vh https://raw.githubusercontent.com/cliffordwolf/SimpleVOut/master/svosrc/svo_defines.vh

! wget -O osu018_stdcells.lib http://vlsiarch.ecen.okstate.edu/flows/MOSIS_SCMOS/latest/cadence/lib/tsmc018/signalstorm/osu018_stdcells.lib

write_file osu018_stdcells.constr <<EOT
set_driving_cell DFFPOSX1
set_load 0.01
EOT

read_verilog svo_vdma.v
hierarchy -check -top svo_vdma_crossclock_fifo
synth; flatten; check -assert

# select FFs from the two domains
select -set ffs_1 n:in_clk %co
select -set ffs_2 n:out_clk %co
select -set ffs @ffs_1 @ffs_2

# assert: the FF sets must not intersect
select -assert-none @ffs_1 @ffs_2 %i

# grow @ffs_1 into @domain_1
select -set domain_1 @ffs_1 %x @ffs %d %xe* @ffs_1

# grow @ffs_2 into @domain_2
select -set domain_2 @ffs_2 %x @ffs %d %xe* @ffs_2

# cells in the inter-domain space belong to the faster domain (@domain_1)
select -set domain_2 @domain_2 @domain_1 %d

# assert: the domain sets must not intersect
select -assert-none @domain_1 @domain_2 %i

# assert: the domains must be a full cover
select -assert-none * @domain_1 %d @domain_2 %d

abc -dff -constr osu018_stdcells.constr -liberty osu018_stdcells.lib -D  5000 @domain_1  # 200 MHz

abc -dff -constr osu018_stdcells.constr -liberty osu018_stdcells.lib -D 20000 @domain_2  #  50 MHz

dfflibmap -liberty osu018_stdcells.lib

write_blif synth.blif

stat