마이크로프로세서 설계 무작정 따라하기 – Part 3

IDEC Newsletter에 2002년 4월부터 2002년 12월까지 연재한 내용입니다.

6년이 흘렀지만 개발환경에는 큰 변화는 없습니다. 여전히 합성을 위해 Synopsys Design Compiler를 사용하고 있고, P&R을 위해선 Apollo의 후속 버젼인 Astro를, 시뮬레이션은 Verilog-XL과 기능자체는 큰 차이없는 NC-Verilog를  사용하고 있습니다. 큰 차이는 없다고는 해도 그대로 따라할 수는 없기때문에 아쉬움도 있고 또 일부 내용은 개선하고 싶은 부분도 있네요.

3부-1편: 합성 가능한 설계 (Synthesiable Design)

3부-2편: 합성 (Synthesis), Synopsys DesignCompiler, 최적화

3부-3편: 순차회로의 최적화 (입/출력 지연시간, 홀드 타임, 클럭 버퍼링)

3부-4편: SimpleCore의 합성

3부-1편: 후단계 설계, Appllo를 이용한 SimpleCore의 P&R

Synopsys Design Compiler Reference Methodoloty

요새 Tape-Out을 앞두고 있다보니 주로 Synthesis나 Back-end에 대한 글을 많이 쓰게 되네요.

Logic Deginer들이 가장 의존적인 Tool은 Synthesizer가 아닐까 합니다.
그중에서도 Synopsys의 Design Compiler가 Golden Rererence라고 할 수 있겠습니다.

하지만, Design Compiler도 버젼마다 명령이나 constraint가 추가되기고 없어지기도 하는데, 더 좋은 기능이 만들어진 이유이긴 하겠지만 잘 사용하던 기능들이 없어지면 당혹스럽지요.

제품을 만드는 입장에서는 최신기술보다는 안정적인(stable)기술을 더 선호하게되기 때문에 안쓰던 기능을 처음 쓰기는 쉽지않습니다.

Design Compiler는 일년에 두어차레 upgrade가 되는데 최근 버젼보다는 SP(Service Pack)이 한두번 나온 한세대 이전 version을 쓰는게 좋다고 봅니다.

아무튼 최근 version이 나오면 그때마나 reference manual을 보고 새로 추가된 기능을 확인할 수는 없는 것이기에 Synopsys에서는 Reference Methodology라는 것을 제공합니다.
쉽게말하자면 version별로 제거된 기능과 추가된 기능을 반영한 script sample이라고 할 수 있습니다.

아래 주소에서 download하실 수 있습니다. (SolvNet ID가 필요합니다)

Astro에서 지원되는 Synopsys Design Constraints

Supported SDC Constraints
    all_clocks
    all_inputs
    all_outputs
    create_clock
    create_generated_clock
    current_design
    expr
    get_cells
    get_clocks
    get_lib_cells
    get_lib_pins
    get_libs
    get_ports
    list
    set
    set_case_analysis
    set_clock_gating_check
    set_clock_latency
    set_clock_transition
    set_clock_uncertainty
    set_disable_timing
    set_drive
    set_driving_cell
    set_false_path
    set_hierarchy_separator
    set_input_delay
    set_input_transition
    set_load
    set_logic_one
    set_logic_zero
    set_max_capacitance
    set_max_delay
    set_max_time_borrow
    set_max_transition
    set_min_capacitance
    set_min_delay
    set_muticycle_path
    set_output_delay
    set_propagated_clock

Not-supported SDC Constraints
    current_instance (If you use “*” as the argument, the current_instance command can be used.)
    get_nets
    get_pins
    set_fanout_load
    set_logic_dc
    set_max_area
    set_max_fanout
    set_operating_conditions
    set_resistance
    set_wire_load_min_block_size
    set_wire_load_mode
    set_wire_load_model
    set_wire_load_selection_group
    set_port_fanout_number

Astro Tip: netWeight

Astro에서 Timing이 민감한 cell들을 인접하게 place하거나 output buffer를 output port에 최대한 가깝게 place할 때 유용한 기능.
Thanks to Dr. Choi~

Donny’s Guideline: 직접 P&R을 할 줄 알면 더 좋지만 그렇지 않더라도 P&R툴의 기능을 알아야 back-end engineer에게 요구를 할 수 있으므로 유용한 기능들은 알아두는 것이 좋다. 또, Astro의 command까진 아니더라도, 합성에 사용한 synopsys의 constraints들이 P&R에 어떤 영향을 주는지를 파악해 두는 것도 유용하다.

————————————————————
netWeight

The netWeight function sets the net priorities (or weights) for placing cells. During placement, the Milkyway-based tool attempts to place cells connected to high-priority nets closer together.

The primary goal of your Synopsys application, regardless of the specified net weights, is to achieve the minimum total net length for the design. Therefore, the Synopsys application weighs any reduction in the length of a high-priority net against the effect on the overall net length.

Nets with no priority set have the lowest priority (net weight of 1).

You can set net weights while running a Synopsys application by using Constraints > Set Net Weight.

Syntax

netWeight netName netWtHorizontal netWtVertical 

where the arguments are as follows:

netName
         Name of the net to be prioritized.

         Valid values: Name of any net in the design
netWtHorizontal
         Weight to be given to horizontal wires on the net. The higher the value, the greater priority the Synopsys application gives the net.

         Valid values: Any positive integer
netWtVertical
         Weight to be given to vertical wires on the net. The higher the value, the greater priority the Synopsys application gives the net.

         Valid values: Any positive integer

Example

netWeight “CTL2″ 10 8
netWeight “CTL3″ 4 2
netWeight “CTL4″ 6 6

Using these net priority directives, the Synopsys application gives the highest priority to horizontal wires on the CTL2 net and the lowest priority to vertical wires on the CTL3 net (except for nets not specified, which receive the lowest priority). For nets CTL2 and CTL3, horizontal
wires are given higher priority than vertical wires. For net CTL4, horizontal and vertical wires are given equal priority.

출처: Astro 2007.03-SP4 Help

Verilog Coding Style for Synthesis

Verilog Coding Style for Synthesis[download]

“full_case parallel_case”, the Evil Twins of Verilog Synthesis와 마찬가지로 C. E. Cummings씨가 SNUG99에 publish한 것이다.

빠듯한 일정속에서 RTL simulation을 마치고 합성 후 gate-level simulation을 했을 때, waveform view에 unknown value들이 빨간색으로 화면 가득채우고 있다면? OTL….

이 문서는 그런상황이 최소화되도록하기 위한 Verilog Coding방법을 설명하고 있다. 그러나, 몇가지 내용은 글쎄…

1. Incomplete sensitivity list
always블록의 sensitivity list에 입력 signal을 빠뜨려 latch가 발생된 경우는 칩 설계경험이 있다면 알만한 내용이다.

2. Complete sensitivity list with mis-ordered assignment
always블록 내에서 assignment의 순서가 뒤바뀐 경우. 즉, assignment들의 순서에 따라 결과가 달라지는 경우를 설명. 먼저 기술된 assignment의 결과가 나중 기술된 assignment에 사용되지않도록 순서를 정하라고하는데, 이것은 Non-blocking assignment를 사용하면 근본적으로 해결된다.

Donny’s Guideline: always블록내의 모든 assignment는 non-blocking assignment를 사용한다.

즉, ‘=’ 가 아니라 ‘<=’를 사용하라는 의미이다. Concurrent한 동작이 일어나는 hardware을 sequential하게 기술하는 것 자체가 말이 안되기 때문이다.

3. Functions
Function을 잘못기술하면 latch가 발생된다는 내용. 그러나, 합성할 회로에 굳이 function을 사용할 필요가 있을까? 합성후 function은 말그대로 기능블록이 되어야하므로 차라리 별도의 module로 만드는 것이 구조적인 이해나 analisys가 쉽다고 생각한다.
Donny’s Guideline: Synthesis할 부분에 대해서는 function을 사용하지 않는다.

4. Full Case / Parallel Case
“full_case parallel_case”, the Evil Twins of Verilog Synthesis에 기술된 내용의 요약판.
Donny’s Guideline: synopsys full_case나 parallel case directive를 사용하지 말자.

5. casex, casez
casex 대신 casez를 사용하라. casex의 경우 입력이 unknown(‘x’)일 때도 정상적으로 동작하는 경우가 존재한다는 내용이다. casez의 경우에도 입력이 floating (‘z’)인 경우는 동작하지만 이런 경우는 덜 빈번하므로 casez를 쓰는 것이 좋다고 하는데… 과연??
RTL simulation만 할 경우에는 입력이 unknown상태가 될 가능성이 없으므로, RTL과 gate-level을 혼합하여 simulation하는 경우만 해당되는 내용이다.
반대로 casez를 사용하려면 don’t care를 표기하기위해 ‘x’대신 ‘?’를 사용해야하는데, 복잡한 case문을 즐겨사용하는 내 경우엔 ‘?’사이에 섞여있는 ’0′을 발견하기란 쉽지 않기 때문에 casex를 더 선호한다.

6. Assigning ‘x’
‘x’값을 입력시키면 simulator에선 ‘unkown’으로 인식되고, synthesizer에서는 ‘don’t care’로 인식한다. 특별한 경우가 아니라면 일부러 ‘x’를 입력하는 일은 안하는게 상책.

7. translate_off/translate_on
이 directive를 사용하면 synthesizer에서 해당부분을 읽지(translate)도 않으므로 당연히 주의해서 사용해야한다. 주로 debugging과 관련된 code나 simulation model을 사용할 때 사용되는데, 가급적 debugging code는 testbench쪽으로 옮기면 위 directive를 사용할 일이 매우 적다.
Donny’s Guideline: 합성할 code와 시뷸레이션할 code를 분리하여 가급적 translate_off / translate_on를 쓰지 말자.

8. Timing Delays
합성시 모든 timing 정보는 무시된다. (두말 하면 잔소리)
Donny’s Guideline: Timing정보를 합성에 반영하고 싶다면 dc_script_begin/dc_script_end를 이용하여 code상에 constraint를 함께 기술하는 방법도 있다.

정리하자면 복잡하거나 특별해보이는 기능을 사용하여 설계하면 그만큼 문제가 발생할 소지가 크다는 것이다. 이러한 guideline을 준수하여 code를 작성한다면 시행착오를 어느정도 줄일 수 있다.

하지만, 아무리 HDL이란 언어를 잘 사용하더라도 회로를 설계하는 것은 C프로그램을 작성하는 것은 차이가 많기 때문에 언어이외에 회로에 대한 개념을 숙지하는 것이 필수적이다.

이러한 복잡한 Guideline보다도 더 강력한 방법이 있는데 Synopsys의 HDL Compiler를 사용하는 것이다. Design Compiler에서 Verilog코드를 읽어들이면 화면에 글씨들이 잔뜩지나가는데 처음에는 대개 이 내용을 무시한다. 하지만, 그 내용이 HDL Compiler의 합성결과이고 합성시 문제가 될만 한부분을 미리 다 알려준다. 즉, case statement가 full case인가 parallel한가 latch가 생성되는가 flipflop이 생성되는가 모든 정보를 알 수 있다.

따라서, 이 내용을 무시하고 합성후 gate-level simulation을 하는 것은 미리 알 수 있는 문제를 확인사살하는 시간 낭비일 뿐이고, 주의깊게 결과를 확인하지않으면 문제를 방치한채로 Tape-out하는 최악의 상황에 이를 수 있다.

의도치 않게 latch가 생성되었는데 이 latch의 입력을 testbench에서 바꾸어보지 않는다면, latch의 영향이 나타나지 않는다. Code Coverage를 확인하여 문제를 찾는 방법도 있겠지만, 처음부터 RTL 코드 작성을 잘하고 합성시 HDL Compiler결과만 확인한다면 근본적으로 문제를 해결할 수 있다.
Donny’s Guideline: HDL Compiler결과를 꼼꼼히 확인하자

사악한 쌍둥이 full_case와 parallel_case

원제은 “full_case parallel_case”, the Evil Twins of Verilog Synthesis 이다. [download]

RTL 시뮬레이션과 gate-level 시뮬레이션 결과가 달라지는 이유가 무엇일까? 그 중 한가지는 case문의 잘못된 사용때문이다. 이것이 얼마나 중요한 것인가는 저 페이퍼의 제목만 봐도 알 수 있다. 오죽하면 ‘사악한 쌍둥이’라고 했겠는가? 또 이 페이퍼는 SNUG-1999에서 Best Paper로 선정된 것을 봐도 짐작할 수 있다.

Verilog를 잘 다루는 설계자라면 분명 if-else문보다는 case문을 선호할 것이다.
Design Compiler에서 합성을 해보면 초기 HDL Compile단계에서 각 case문에 대하여 아래와 같은 내용을 출력한다.

Verilog합성을 하면서 이 내용을 그동안 눈여겨보지 않았다면 앞으로는 꼭 확인하길 바란다.
case문은 잘 사용하면 매우 강력한 능력을 발휘한다. 하지만 잘못사용하면 그만큼 애를 먹이는 존재이다. 근본적으로는 RTL 기술을 잘하면 문제가 없지만, 이를 돕기 위해서 Synopsys는 “//synopsys full_case parallel_case” 와 같이 RTL내에 directive를 사용할 수 있도록 하였다.

문제는 이 directive들을 어떻게 사용함에 따라 같은 RTL코드라도 합성결과가 달라진다. 설계자를 돕기위한 이 기능이 ‘사악한 쌍둥이’가 된 이유는 시뮬레이션시에는 이 directive들이 반영되지 않기 때문에 gate-level시뮬레이션과 차이를 만들기 때문일 것이다.

더 자세한 설명은 다음 기회로 미루고, 쉽게 설명되어있는 내용이므로 직접 읽어보길 권한다.  [download]