OpenCores
URL https://opencores.org/ocsvn/core_arm/core_arm/trunk

Subversion Repositories core_arm

[/] [core_arm/] [trunk/] [soft/] [cdef/] [cdef_lib_pv.el] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tarookumic
; Konrad Eisele <eiselekd@web.de>
2
; cdef_lib_i1.el: Some vhdl printing functions
3
;-----------------------------------------------------------------------
4
 
5
; binary list to hex string
6
; (conv-hex-vhd '(0 0 1 1 1 ))
7
; (conv-hex-vhd (make-list 10 1))
8
(defun conv-hex-vhd (k)
9
  (concat "\"" (mapconcat 'number-to-string k "") "\"")
10
)
11
 
12
(defun print-decode-vhd-hash (dec depth)
13
  (cond
14
     ((hash-table-p dec)
15
     (let ((p ""))
16
       ( maphash (function (lambda (k v)
17
         (let ((p2 ""))
18
           (setq p2 (concat p2 (space-string (- depth 1) " ") "when " (conv-hex-vhd k) "=>\n"   ))
19
           (if (is-decoder v)
20
               (setq p2 (concat p2 (print-decoder-vhd v depth)))
21
               (setq p2 (concat p2 (space-string depth  " ") "return " (mapconcat 'symbol-name v "," ) ";\n"))
22
           )
23
           (setq p (concat p p2))
24
         ))) dec )
25
       `,p
26
     ))
27
     ((listp dec)
28
      (mapconcat 'print-list dec " ")
29
     )
30
     ((t) ('"?")))
31
)
32
 
33
;(print-insnrange-vhd 10 1)
34
(defun print-insnrange-vhd (l r)
35
  (concat "insn(" (number-to-string l) " downto " (number-to-string r) ")")
36
)
37
 
38
(defun print-decoder-vhd (d depth)
39
  (let ((l (- 31 (nth 1 d)))
40
        (r (+ (- 31 (nth 2 d)) 1))
41
        (dec (nth 3 d))
42
        (def (nth 4 d))
43
        (p ""))
44
    (if (not (and (eq l 31) (eq r 32)))
45
        (progn
46
          (setq p (concat p (space-string depth " ") "case " (print-insnrange-vhd l r) " is  \n"  ))
47
          (setq p (concat p (print-decode-vhd-hash dec (+ 1 depth) ) ))
48
          (setq p (concat p (space-string depth " ") "when others =>\n" (space-string depth " ") "end case;\n"))
49
        )
50
    )
51
    (if (eq (length def) 5)
52
        (if (and (eq (nth 0 def) 0) (eq (nth 1 def) 0) (> (length (nth 4 def)) 0))
53
            (setq p (concat p (space-string depth " ")  "return " (mapconcat 'symbol-name (nth 4 def)  " ") "; --default\n" ))
54
            (setq p (concat p (space-string depth " ")  " -- default:\n" (space-string depth " ") (print-decoder-vhd def depth)  ) )
55
        )
56
    )
57
    `,p
58
  )
59
)
60
 
61
(defun print-decoder-vhd-pre (d)
62
  (let ((v ""))
63
    (setq v (print-decoder-vhd d 0))
64
    ;(setq v (concat "unsigned int decode(unsigned int insn, insn_union *s) {\n" v "\n};"))
65
    `,v
66
  )
67
)
68
 
69
;-----------------------------------------------------------------------
70
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.