|
무료 Verilog Simulator - Icarus
Lecture |
2009/11/05 22:26
|
|
|
gEDA는 GPL을 따르는 EDA툴킷 개발 프로젝트로 2002년에 시작되어 지금까지 꾸준히 업데이트가 되고 있으며 오픈소스프로그램으로는 높은 완성도를 갖고 있다.
http://www.gpleda.org/
이중에서도 Icarus Verilog Simulator는 무료로 사용할 수 있는 시뮬레이터 중에 가장 유명하다. gEDA 프로젝트도 Stephen William이 개발한 Icarus로 부터 시작되었다.
오픈소스프로그램들은 직접 컴파일을 해서 사용하는 번거로움이 있지만 다행히 Icarus와 gtkwave(waveform view)를 간단히 설치할 수 있는 intall package가 있으며 아래링크에서 받을 수 있다.
iverilog-0.9.1_setup.exe [5.33MB]
설치과정
1. iverilog-0.9.1_setup.exe실행, Next
2. License Agreement에 동의(필수), Next
3. 설치위치 변경(선택). 기본 값인 "C:\Program Files\Icarus Verilog" 대신 "C:\Icarus"입력.
변경하지 않을 경우 환경변수의 PATH값을 "c:\progra~1\icarus~1\bin"으로 변경해야함.
(환경변수 변경 방법은 10번 과정 참조)
4. waveform view인 GTKWave설치 (필수)
5. 시작메뉴폴더 생성 (선택)
6. 바탕화면 아이콘 추가 (선택)
7. 설치준비완료
8. 설치
9. 설치 완료. 환경변수 추가 선택(필수)
10. 환경 변수 설정. 3번과정대로 설치위치를 변경하지 않고 긴 이름의 디렉토리를 사용할 경우는 아래와 같이 직접 환경변수를 설정해주어야 정상적으로 사용이 가능하다.
"C:\Program Files\Icarus Verilog Simulator\bin" 부분을 "C:\progra~1\icarus~1\bin"과 같이 변경하여 저장한다.
11. Command창 실행. '시작->실행' 메뉴 실행후 'cmd', 확인
12. 디렉토리 변경후 Icarus실행.
icarus가 설치된 디렉토리로 이동 (cd c:\icarus) 후
예제파일인 lfsr16.v실행
iverilog lfsr16.v <enter>
vvp a.out <enter>
gtkwave <enter>
13. waveform확인 (결과파일'dump.vcd' 로드)
14. waveform확인 (신호선택)
|
Verilog,
시뮬레이터,
집적회로설계 |
|
|
|
 |
| Trackback http://www.donny.co.kr/tt/trackback/106 |
|
 |
|
|
(Verilog) Setting a Net to a Logic Value
Verification |
2009/03/04 18:21
|
|
|
The $deposit system task allows you to set a net to a particular value and then to simulate
with the net set to that new value. The value change is propagated throughout the nets and
registers being driven by the variable that has been set. The syntax is as follows:
$deposit(variable, value);
The $deposit task can be used within any Verilog-XL procedural block. You can define the time at which the net is to be given a new value using the standard procedural constructs. The task can also be used on the interactive command line.
Use this system task as a debugging or design initialization aid. You should not use it as a
representation of actual circuitry.
Common uses for the $deposit system task include the following:
- To initialize large portions or all of a circuit either at the beginning of or during a simulation. You can select the nodes to be deposited to yourself, or use PLI code to extract the node names.
- To stop the simulator during a debugging session and to use the command on the interactive command line to set a new value.
- To reset a circuit to a known state after simulation in order to retry a different debug route.
- To set parts of a circuit to analyze intricate circuit details (common for switch level simulation).
- To break feedback loops to set them to a known state.
In the syntax, variable is the name of the net or register whose value is being changed. The variable can be a net or register type but not a parameter, and it can be a vector or scalar object that can be expanded or compacted.
The second parameter, value, is a numerical or logical value in standard Verilog-XL notation. Bit and part selects are not allowed.
If the width of the value is smaller than the range of the variable, an error message is generated. If the width of the value is larger than the range of the variable, the MSBs are truncated and a warning is issued.
X and Z states can also be deposited.
Here are some examples of using $deposit:
$deposit(sig, 1);
$deposit(bus, ’hA2);
$deposit(bus4, ’bZ01x);
p.s. 좋은 Tip알려준 yangk에게 감사.. ^^
|
Verilog |
|
|
|
 |
| Trackback http://www.donny.co.kr/tt/trackback/64 |
|
 |
|
|
Verilog Coding Style for Synthesis
Design |
2008/03/26 15:48
|
|
|
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결과를 꼼꼼히 확인하자
|
coding style,
Simulation,
Synthesis,
Verilog |
|
|
|
 |
| Trackback http://www.donny.co.kr/tt/trackback/7 |
|
 |
|
|
사악한 쌍둥이 full_case와 parallel_case
Design |
2008/03/15 16:57
|
|
|
원제은 "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]
|
Case,
coding style,
RTL,
Synthesis,
Verilog |
|
|
|
 |
| Trackback http://www.donny.co.kr/tt/trackback/6 |
|
 |
|
|
| A Mixed-Signal Chip Designer, Donny
(drdonny@gmail.com) |
|
|
<<
2010/09
>>
| S |
M |
T |
W |
T |
F |
S |
|
|
|
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 |
|
|
|
 |
| 121 |
| 76 |
| 65590 |
 |
|
|
|