Skip to content

Commit

Permalink
WIP: Starting with compilation regexps
Browse files Browse the repository at this point in the history
  • Loading branch information
gmlarumbe committed May 10, 2023
1 parent abbf150 commit 09f75b7
Showing 1 changed file with 142 additions and 0 deletions.
142 changes: 142 additions & 0 deletions verilog-ext-compile.el
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,148 @@
(require 'verilog-mode)


;;;; Additional faces
(defvar verilog-ext-compile-gray-face 'verilog-ext-compile-gray-face)
(defface verilog-ext-compile-gray-face
'((t (:foreground "gray55")))
"Gray face."
:group 'verilog-ext-compile)

(defvar verilog-ext-compile-binary-face 'verilog-ext-compile-binary-face)
(defface verilog-ext-compile-binary-face
'((t (:foreground "goldenrod")))
"Binary face."
:group 'verilog-ext-compile)


;;;; Variables
;;;;; Simulators
(defvar verilog-ext-compile-re-xrun
'((xrun-fatal "\\(?1:^[a-z]+\\): \\(?2:\\*F\\),\\(?3:[0-9A-Z]+\\)\\(?:\\(?:\\[[0-9A-Z_,]+\\]\\)? (\\(?4:[^ \t,]+\\),\\(?5:[0-9]+\\)|\\(?6:[0-9]+\\)\\)" 4 5 6 2 nil (1 verilog-ext-compile-binary-face) (2 compilation-error-face) (3 verilog-ext-compile-gray-face))
(xrun-fatal2 "\\(?1:^[a-z]+\\): \\(?2:\\*F\\),\\(?3:[0-9A-Z]+\\)\\(?:\\(?:\\[[0-9A-Z_,]+\\]\\)? (\\(?4:[^ \t,]+\\),\\(?5:[0-9]+\\)\\)" 4 5 nil 2 nil (1 verilog-ext-compile-binary-face) (2 compilation-error-face) (3 verilog-ext-compile-gray-face))
(xrun-fatal3 "\\(?1:^[a-z]+\\): \\(?2:\\*F\\),\\(?3:[0-9A-Z]+\\):" 1 nil nil 2 nil (1 verilog-ext-compile-binary-face) (2 compilation-error-face) (3 verilog-ext-compile-gray-face))
(xrun-error "\\(?1:^[a-z]+\\): \\(?2:\\*E\\),\\(?3:[0-9A-Z]+\\)\\(?:\\(?:\\[[0-9A-Z_,]+\\]\\)? (\\(?4:[^ \t,]+\\),\\(?5:[0-9]+\\)|\\(?6:[0-9]+\\)\\)" 4 5 6 2 nil (1 verilog-ext-compile-binary-face) (2 compilation-error-face) (3 verilog-ext-compile-gray-face))
(xrun-error2 "\\(?1:^[a-z]+\\): \\(?2:\\*E\\),\\(?3:[0-9A-Z]+\\)\\(?:\\(?:\\[[0-9A-Z_,]+\\]\\)? (\\(?4:[^ \t,]+\\),\\(?5:[0-9]+\\)\\)" 4 5 nil 2 nil (1 verilog-ext-compile-binary-face) (2 compilation-error-face) (3 verilog-ext-compile-gray-face))
(xrun-error3 "\\(?1:^[a-z]+\\): \\(?2:\\*E\\),\\(?3:[0-9A-Z]+\\):" 1 nil nil 2 nil (1 verilog-ext-compile-binary-face) (2 compilation-error-face) (3 verilog-ext-compile-gray-face))
(xrun-warning "\\(?1:^[a-z]+\\): \\(?2:\\*W\\),\\(?3:[0-9A-Z]+\\)\\(?:\\(?:\\[[0-9A-Z_,]+\\]\\)? (\\(?4:[^ \t,]+\\),\\(?5:[0-9]+\\)|\\(?6:[0-9]+\\)\\)" 4 5 6 1 nil (1 verilog-ext-compile-binary-face) (2 compilation-warning-face) (3 verilog-ext-compile-gray-face))
(xrun-warning2 "\\(?1:^[a-z]+\\): \\(?2:\\*W\\),\\(?3:[0-9A-Z]+\\)\\(?:\\(?:\\[[0-9A-Z_,]+\\]\\)? (\\(?4:[^ \t,]+\\),\\(?5:[0-9]+\\)\\)" 4 5 nil 1 nil (1 verilog-ext-compile-binary-face) (2 compilation-warning-face) (3 verilog-ext-compile-gray-face))
(xrun-warning3 "\\(?1:^[a-z]+\\): \\(?2:\\*W\\),\\(?3:[0-9A-Z]+\\):" 1 nil nil 1 nil (1 verilog-ext-compile-binary-face) (2 compilation-warning-face) (3 verilog-ext-compile-gray-face))
(xrun-note "\\(?1:^[a-z]+\\): \\(?2:\\*N\\),\\(?3:[0-9A-Z]+\\)\\(?:\\(?:\\[[0-9A-Z_,]+\\]\\)? (\\(?4:[^ \t,]+\\),\\(?5:[0-9]+\\)|\\(?6:[0-9]+\\)\\)" 4 5 6 0 nil (1 verilog-ext-compile-binary-face) (2 compilation-info-face) (3 verilog-ext-compile-gray-face))
(xrun-note2 "\\(?1:^[a-z]+\\): \\(?2:\\*N\\),\\(?3:[0-9A-Z]+\\)\\(?:\\(?:\\[[0-9A-Z_,]+\\]\\)? (\\(?4:[^ \t,]+\\),\\(?5:[0-9]+\\)\\)" 4 5 nil 0 nil (1 verilog-ext-compile-binary-face) (2 compilation-info-face) (3 verilog-ext-compile-gray-face))
(xrun-note3 "\\(?1:^[a-z]+\\): \\(?2:\\*N\\),\\(?3:[0-9A-Z]+\\):" 1 nil nil 0 nil (1 verilog-ext-compile-binary-face) (2 compilation-info-face) (3 verilog-ext-compile-gray-face)))
"Xcelium regexps:
- xrun-error: errors with line number and column number
- xrun-error2: errors with line number
- xrun-error3: errors without file/line number.")

;; TODO: Add Questa/Vsim

(defvar verilog-ext-compile-re-uvm
'((uvm-fatal "^\\(?1:UVM_FATAL\\) \\(?2:[a-zA-Z0-9\./_-]+\\)(\\(?3:[0-9]+\\))" 2 3 nil 2 nil (1 compilation-error-face))
(uvm-fatal2 "^\\(?1:UVM_FATAL\\) @" 1 nil nil 2 nil)
(uvm-error "^\\(?1:UVM_ERROR\\) \\(?2:[a-zA-Z0-9\./_-]+\\)(\\(?3:[0-9]+\\))" 2 3 nil 2 nil (1 compilation-error-face))
(uvm-error2 "^\\(?1:UVM_ERROR\\) @" 1 nil nil 2 nil)
(uvm-warning "^\\(?1:UVM_WARNING\\) \\(?2:[a-zA-Z0-9\./_-]+\\)(\\(?3:[0-9]+\\))" 2 3 nil 1 nil (1 compilation-warning-face))
(uvm-warning2 "^\\(?1:UVM_WARNING\\) @" 1 nil nil 1 nil)
(uvm-info "^\\(?1:UVM_INFO\\) \\(?2:[a-zA-Z0-9\./_-]+\\)(\\(?3:[0-9]+\\))" 2 3 nil 0 nil (1 compilation-info-face))
(uvm-info2 "^\\(?1:UVM_INFO\\) @" 1 nil nil 0 nil))
"UVM regexps:
- uvm-error: errors with line number and column number
- uvm-error2: errors without file/line number")

(defvar verilog-ext-compile-re-ovm
'((ovm-fatal "^\\(?1:OVM_FATAL\\) @ \\(?2:[0-9]+\\): " 1 nil nil 2 nil (2 compilation-line-face))
(ovm-error "^\\(?1:OVM_ERROR\\) @ \\(?2:[0-9]+\\): " 1 nil nil 2 nil (2 compilation-line-face))
(ovm-warning "^\\(?1:OVM_WARNING\\) @ \\(?2:[0-9]+\\): " 1 nil nil 1 nil (2 compilation-line-face))
(ovm-info "^\\(?1:OVM_INFO\\) @ \\(?2:[0-9]+\\): " 1 nil nil 0 nil (2 compilation-line-face)))
"OVM regexps:
- No line/column numbers.")

;; TODO: Update according to the ones at flycheck
;; TODO: Add notes?
(defvar verilog-ext-compile-re-verilator
'((verilator-error "%?\\(Error\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 4 nil 2 nil (1 compilation-error-face) (2 compilation-line-face))
(verilator-warning "%?\\(Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 4 nil 1 nil (1 compilation-warning-face) (2 compilation-line-face)))
"Verilator regexps.")

(defvar verilog-ext-compile-re-iverilog
'((iverilog-unsupported "\\(?1:.*\\):\\(?2:[0-9]+\\):.*sorry:" 1 2 nil 0 nil (1 compilation-info-face) (2 compilation-line-face))
(iverilog-warning "\\(?1:.*\\):\\(?2:[0-9]+\\):.*warning:" 1 2 nil 1 nil (1 compilation-warning-face) (2 compilation-line-face))
(iverilog-warning2 "^\\(?1:warning\\):" 1 nil nil 1 nil)
(iverilog-error "\\(?1:.*\\):\\(?2:[0-9]+\\):.*error:" 1 2 nil 2 nil (1 compilation-error-face) (2 compilation-line-face))
(vvp-warning "^\\(?1:WARNING\\): \\(?2:.*\\):\\(?3:[0-9]+\\):" 2 3 nil 1 nil (1 compilation-warning-face) (2 compilation-warning-face) (3 compilation-line-face))
(vvp-error "^\\(?1:ERROR\\): \\(?2:.*\\):\\(?3:[0-9]+\\):" 2 3 nil 2 nil (1 compilation-warning-face) (2 compilation-warning-face) (3 compilation-line-face))
(vvp-info "^\\(?1:LXT2 info\\):" 1 nil nil 0 nil))
"Icarus Verilog regexps.")

;; TODO: Add slang/svlint and others...

;;;; Synthesis
(defvar verilog-ext-compile-re-vivado
'((vivado-error "^\\(?1:^ERROR:\\) \\(?2:\\[[ a-zA-Z0-9\./_-]+\\]\\)\\(?3:.*\\[\\(?4:.*\\):\\(?5:[0-9]+\\)\\]\\)" 4 5 nil 2 nil (1 compilation-error-face) (2 verilog-ext-compile-gray-face))
(vivado-error2 "^\\(?1:^ERROR:\\) \\(?2:\\[[ a-zA-Z0-9\./_-]+\\]\\)" 1 nil nil 2 nil (1 compilation-error-face) (2 verilog-ext-compile-gray-face))
(vivado-critical "^\\(?1:^CRITICAL WARNING:\\) \\(?2:\\[[ a-zA-Z0-9\./_-]+\\]\\)\\(?3:.*\\[\\(?4:.*\\):\\(?5:[0-9]+\\)\\]\\)" 4 5 nil 1 nil (1 compilation-error-face) (2 verilog-ext-compile-gray-face))
(vivado-critical2 "^\\(?1:^CRITICAL WARNING:\\) \\(?2:\\[[ a-zA-Z0-9\./_-]+\\]\\)" 1 nil nil 1 nil (1 compilation-error-face) (2 verilog-ext-compile-gray-face))
(vivado-warning "^\\(?1:^WARNING:\\) \\(?2:\\[[ a-zA-Z0-9\./_-]+\\]\\)\\(?3:.*\\[\\(?4:.*\\):\\(?5:[0-9]+\\)\\]\\)" 4 5 nil 1 nil (1 compilation-warning-face) (2 verilog-ext-compile-gray-face))
(vivado-warning2 "^\\(?1:^WARNING:\\) \\(?2:\\[[ a-zA-Z0-9\./_-]+\\]\\)" 1 nil nil 1 nil (1 compilation-warning-face) (2 verilog-ext-compile-gray-face))
(vivado-info "^\\(?1:^INFO:\\) \\(?2:\\[[ a-zA-Z0-9\./_-]+\\]\\)\\(?3:.*\\[\\(?4:.*\\):\\(?5:[0-9]+\\)\\]\\)" 4 5 nil 0 nil (1 compilation-info-face) (2 verilog-ext-compile-gray-face))
(vivado-info2 "^\\(?1:^INFO:\\) \\(?2:\\[[ a-zA-Z0-9\./_-]+\\]\\)" 1 nil nil 0 nil (1 compilation-info-face) (2 verilog-ext-compile-gray-face)))
"Xilinx Vivado regexps:
- vivado-error: errors with line number and column number
- vivado-error2: errors without file/line number.")

;; TODO: Intel/Altera
;; (defvar verilog-ext-compile-re-quartus
;; '())

(defvar verilog-ext-compile-re-diamond
'((lattice-error "\\(?1:^ERROR\\) -" 1 nil nil 2 nil (1 compilation-error-face))
(lattice-warning "\\(?1:^WARNING\\) - \\(?2:[a-z0-9]+:\\) \\(?3:[a-zA-Z0-9\./_-]+\\)(\\(?4:[0-9]+\\)):" 3 4 nil 1 nil (1 compilation-warning-face) (2 verilog-ext-compile-binary-face))
(lattice-warning2 "\\(?1:^WARNING\\) - \\(?2:[a-z0-9]+:\\)" 1 nil nil 1 nil (1 compilation-warning-face) (2 verilog-ext-compile-binary-face))
(lattice-warning3 "\\(?1:^WARNING\\) -" 1 nil nil 1 nil (1 compilation-warning-face)))
"Lattice Diamond regexps.")

(defvar verilog-ext-compile-re-synplify
'((synp-error "^@\\(?1:E\\): \\(?2:[A-Z0-9]+\\) :\"\\(?3:[0-9a-zA-Z./_-]+\\)\":\\(?4:[0-9]+\\):\\(?5:[0-9]+\\):" 3 4 5 2 nil (1 compilation-error-face) (2 verilog-ext-compile-gray-face))
(synp-error2 "^@\\(?1:E\\): \\(?2:[A-Z0-9]+\\) [:]?|" 1 nil nil 2 nil (2 verilog-ext-compile-gray-face))
(synp-error3 "^@\\(?1:E\\):" 1 nil nil 2 nil)
(synp-warning "^@\\(?1:W\\): \\(?2:[A-Z0-9]+\\) :\"\\(?3:[0-9a-zA-Z./_-]+\\)\":\\(?4:[0-9]+\\):\\(?5:[0-9]+\\):" 3 4 5 1 nil (1 compilation-warning-face) (2 verilog-ext-compile-gray-face))
(synp-warning2 "^@\\(?1:W\\): \\(?2:[A-Z0-9]+\\) [:]?|" 1 nil nil 1 nil (2 verilog-ext-compile-gray-face))
(synp-warning3 "^@\\(?1:W\\):" 1 nil nil 1 nil)
(synp-note "^@\\(?1:N\\): \\(?2:[A-Z0-9]+\\) :\"\\(?3:[0-9a-zA-Z./_-]+\\)\":\\(?4:[0-9]+\\):\\(?5:[0-9]+\\):" 3 4 5 0 nil (1 compilation-info-face) (2 verilog-ext-compile-gray-face))
(synp-note2 "^@\\(?1:N\\): \\(?2:[A-Z0-9]+\\) [:]?|" 1 nil nil 0 nil (2 verilog-ext-compile-gray-face))
;; Did not find what those meant online, so set as warnings
(synp-alt-info "^@\\(?1:A\\): \\(?2:[A-Z0-9]+\\) :\"\\(?3:[0-9a-zA-Z./_-]+\\)\":\\(?4:[0-9]+\\):\\(?5:[0-9]+\\):" 3 4 5 0 nil (1 compilation-info-face) (2 verilog-ext-compile-gray-face))
(synp-alt-info2 "^@\\(?1:A\\): \\(?2:[A-Z0-9]+\\) [:]?|" 1 nil nil 0 nil (2 verilog-ext-compile-gray-face))
(synp-alt-info3 "^@\\(?1:A\\):" 1 nil nil 0 nil)
(synp-note3 "^@\\(?1:N\\):" 1 nil nil 0 nil)
(synp-info "^@\\(?1:I\\):" nil nil nil 0 nil (1 compilation-line-face))
(synp-log "^@\\(?1:L\\):" nil nil nil 0 nil (1 compilation-line-face)))
"Synopsys Synplify regexps.")

(defvar verilog-ext-compile-re-design-compiler
'((dc-error "\\(?1:^Error\\): \\(?2:[0-9a-zA-Z./_-]+\\):\\(?3:[0-9]+\\): " 2 3 nil 2 nil (1 compilation-error-face))
(dc-error-2 "\\(?1:^Error\\): .*" 1 nil nil 2 nil)
(dc-warning "\\(?1:^Warning\\): \\(?2:[0-9a-zA-Z./_-]+\\):\\(?3:[0-9]+\\): " 2 3 nil 1 nil (1 compilation-warning-face))
(dc-warning-2 "\\(?1:^Warning\\): .*" 1 nil nil 1 nil)
(dc-info "\\(?1:^Information\\): \\(?2:[0-9a-zA-Z./_-]+\\):\\(?3:[0-9]+\\): " 2 3 nil 0 nil (1 compilation-info-face))
(dc-info-2 "\\(?1:^Information\\): .*" 1 nil nil 0 nil))
"Synopsys Design Compiler regexps.")


;; TODO: Define macro that sets the proper variables


;;;; Compilation-derived modes
(define-compilation-mode synplify-log-mode "Synplify Log"
"Synplify log compilation mode"
(setq-local compilation-skip-threshold 2) ; Default to check errors
(setq-local compilation-error-regexp-alist (mapcar 'car verilog-ext-compile-re-synplify))
(setq-local compilation-error-regexp-alist-alist verilog-ext-compile-re-synplify))



;;;; Other compilation commands
(defun verilog-ext-preprocess ()
"Preprocess current file.
Choose among different available programs and update `verilog-preprocessor'
Expand Down

0 comments on commit 09f75b7

Please sign in to comment.