ASIC SoC2010. 10. 30. 20:39
간만에 다시 하는 코딩을 위해서
이번에는 Emacs에서 Verilog 를 사용하고 해보기로 했습니다.
- 작년에는 거의 Verilog Template language + Perl Stript Compiler만을 사용해서 이넘을 사용해 보고 싶었지만, 사용해볼 기회가 별로 없었기 때문입니다.


Emacs에서 Verilog Mode를 사용하는 것은
VHDL Mode보다는 조금 불편한데요.. 특히 Template기능이 VHDL에 비해서 약해서 그렇습니다.

VHDL은 거의 Editer + Template수준으로 만들어 내었는데 Verilog는 Syntax Highlite 기능으로만
버텨왔기 때문입니다.

요새는 많이 좋아져서 어느정도 자동화 기능을 백그라운드로 돌리면서 에디팅을 할 수 있도록 지원해주고 있습니다.

그런 기능을 활용하기 위해서는 verilog mode를 설치해야 합니다.

http://www.verilog.com/emacs_install.html

위 사이트에 가면 알수 있습니다.
최신 Linux에서는 verilog mode를 디폴트로 가지고 오는데 MAC은 없는 관계로 위의 사이트의 내용을 참조로 해서 수정해야 운용이 가능합니다.

루트 폴더에서 .emacs 파일을 만들어서
다음과 같은 내용을 넣어 둡니다.

------------- BEGIN ----
(defun prepend-path ( my-path )
(setq load-path (cons (expand-file-name my-path) load-path)))

(defun append-path ( my-path )
(setq load-path (append load-path (list (expand-file-name my-path)))))
;; Look first in the directory ~/elisp for elisp files                                                                        
(prepend-path "~/elisp")

;; Load verilog mode only when needed                                                                                        
(autoload 'verilog-mode "verilog-mode" "Verilog mode" t )

;; Any files that end in .v, .dv or .sv should be in verilog mode                                                            
(add-to-list 'auto-mode-alist '("\\.[ds]?v\\'" . verilog-mode))

;; Any files in verilog mode should have their keywords colorized                                                            
(add-hook 'verilog-mode-hook '(lambda () (font-lock-mode 1)))

;;; User customization for Verilog mode                                                                                      
 (setq verilog-indent-level             3
       verilog-indent-level-module      3
       verilog-indent-level-declaration 3
       verilog-indent-level-behavioral  3
       verilog-indent-level-directive   1
       verilog-case-indent              2
       verilog-auto-newline             t
       verilog-auto-indent-on-newline   t
       verilog-tab-always-indent        t
       verilog-auto-endcomments         t
       verilog-minimum-comment-distance 40
       verilog-indent-begin-after-if    t
       verilog-auto-lineup              'declarations
       verilog-highlight-p1800-keywords nil
       verilog-linter                   "my_lint_shell_command"
       )
---------------- END ------------
Verilog-linter는 아직 LINT해주는 툴을 OSX에서 최근에 발견했지만, 아직 테스트 하지 못해서 그냥 냅두었습니다.

사용법은 생각보다 쉽습니다.

중요한 요소에다가 Comment 처리된
/*AUTOXXXX*/
를 넣어두고

코딩이 끝나면

Control-C Control-Z

를 하면 됩니다.

예는 아래와 같습니다.
사용자 삽입 이미지












위와 같이 중요 포인트에 /*AUTOXXX*/ 를 넣고
Ctrl-C Ctrl-Z
를 넣으면

아래와 같이 변합니다.

사용자 삽입 이미지




























위에서
always @ (/*AUTOSENSE*/)
를 하여지만 약어로
always @ (/*AS*/)

하여도 됩니다.

위에서 안보이는 것으로는 /*AUTORESET*/ 기능입니다.

   always @ (posedge clk)
   if ( reset ) begin
       /*AUTORESET*/
   end
   else begin
      a <= b;
   end

위의 코드를 가지고 Ctrl-C Ctrl-Z를 하면

   always @ (posedge clk)
   if ( reset ) begin
       /*AUTORESET*/
       // Beginning of autoreset for uninitialized flops                                                                      
       a <= 1'h0;
       // End of automatics                                                                                                  
   end
   else begin
      a <= b;
   end

으로 뒤져서 초기화가 안되는 변수에 대해서 리셋 구문을 자동으로 해줍니다.

그외에


AUTOASCIIENUM

AUTOINOUTMODULE

AUTOTIEOFF

AUTOUNUSED

AUTOINSERTLISP

AUTO_TEMPLATE

AUTOINSTPARAM


과 같은 AUTOx가 있습니다.


이중에서 AUTOASCIIENUM이 좋은넘인데요

Verilog는 VHDL과 틀려서 변수를 Char로 표시하는 것이 만만찮습니다.

ENUM String을 지원하지 않아서 생긴 문제입니다.

이것때문에 디버깅시에 머리속에서 상수값을 다시 ASCII로 변환하면서 일일이 디버깅해야 하는데

요런 문제를 해결하기 위해서 나온 AUTOx가 AUTOASCIIENUM 입니다.


//== State enumeration
parameter [2:0] // synopsys enum state_info
SM_IDLE = 3'b000,
SM_SEND = 3'b001,
SM_WAIT1 = 3'b010;

//== State variables
reg [2:0] /* synopsys enum state_info */
state_r; /* synopsys state_vector state_r */
reg [2:0] /* synopsys enum state_info */
state_e1;

//== ASCII state decoding
/*AUTOASCIIENUM("state_r", "_stateascii_r", "sm_")*/

위의 코드를 AUTOx로 변환시키면


//== ASCII state decoding
/*AUTOASCIIENUM("state_r", "_stateascii_r", "sm_")*/
// Beginning of automatic ASCII enum decoding
reg [39:0] _stateascii_r; // Decode of state_r
always @(state_r) begin
casex ({state_r}) // synopsys full_case parallel_case
SM_IDLE: _stateascii_r = "idle ";
SM_SEND: _stateascii_r = "send ";
SM_WAIT1: _stateascii_r = "wait1";
default: _stateascii_r = "%Erro";
endcase
end
// End of automatics


위와 같이 됩니다. 따라서 state_r이라는 값을 모니터링하면 현재 상테를 추적해 갈 수 있습니다.


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


요새 거의 뜸했던

간만에 하는 ASIC 관련 포스팅이었습니다.


'ASIC SoC' 카테고리의 다른 글

맥에서 Verilog Simulation 하기 (2)  (0) 2010.11.13
맥에서 Verilog Simulation 하기  (0) 2010.11.13
사상 최강의 보드  (2) 2010.04.18
[MIPS] MIPS assembler simulator XSPIM  (8) 2010.03.21
HD Quad Display/Processing Engine  (1) 2010.03.12
Posted by GUNDAM_IM
MAC Life2009. 1. 17. 22:08

패러럴즈는 맥에서 사용하는 아주 좋은 가상화 프로그램입니다.

코드 퓨전과 패러럴즈를 비교하면 아무래도 패러럴즈가 더 빠르게 동작하기 때문에 점수를 더 줄 수 있습니다.

코드 퓨전의 극악에 가까운.. 성능이 문제가 되죠.. 아무래도 맥에서의 시스템 프로그래밍은 패러럴즈가 

더 좋은듯 합니다.


그런데 좋은 프로그램이라도 사용하는데 문제가 하나 있습니다.

바로  Emacs를 사용할 때에, SET-MARK-COMMAND가 안먹힌 다는 겁니다.

이유는 Control-SPACE가 맥에서 spotlight 단축키로 할당되어 있기 때문에 지정을 안한것 같습니다.


코드 퓨전에서는 이 키가 먹히는 것으로 보아서 패러럴즈를 만드는 사람들이 Emacs를 사용하지 않는다는 

추측이 가능하게 됩니다.


아래 구문을 .emacs에 추가하시면 control + , (콤마) 키가 SET-MARK-COMMNAD를 대치하게 됩니다.

꿩대신 닭이라고 이렇게 사용해야 하곘지요..


패러럴즈 프리퍼런스에 보면, 키 매핑을 할 수 있도록 되어 있는데 SPACE키만은 단축키로 사용하지 않도록 지정되어 있습니다. 아무래도 패러럴즈는 SPACE 키의 용법에 대해서는 조금 둔감한것 같습니다.

 


(global-set-key (kbd "C-,") 'set-mark-command) ;


(custom-set-variables

  ;; custom-set-variables was added by Custom.

  ;; If you edit it by hand, you could mess it up, so be careful.

  ;; Your init file should contain only one such instance.

  ;; If there is more than one, they won't work right.

 '(inhibit-startup-screen t))

(custom-set-faces

  ;; custom-set-faces was added by Custom.

  ;; If you edit it by hand, you could mess it up, so be careful.

  ;; Your init file should contain only one such instance.

  ;; If there is more than one, they won't work right.

 '(default ((t (:stipple nil :background "black" :foreground "white" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 98 :width normal :family "outline-courier new"))))

 '(cursor ((t (:background "blue")))))


'MAC Life' 카테고리의 다른 글

수치스러운 인터페이스의 명예의 전당  (0) 2009.03.05
Culture Code의 개발 이미지  (0) 2009.01.28
맥에서 히든파일 보기  (0) 2009.01.23
멋진 Key Note 09  (0) 2009.01.08
매킨토시 환경에서 개발한다는 것은  (0) 2009.01.03
Posted by GUNDAM_IM