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

Subversion Repositories core_arm

[/] [core_arm/] [trunk/] [soft/] [cdef/] [cdef_lib_i1.el] - Blame information for rev 2

Go to most recent revision | 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 insn functions
3
;-----------------------------------------------------------------------
4
 
5
(defun is-decoder (l)
6
  (and (listp l) (eq (length l) 5) (hash-table-p (nth 3 l))))
7
 
8
(defun space-string (n c)
9
  (let ((str "")
10
        (e 0))
11
    (dotimes (e n)
12
      (setq str (concat str c))
13
    )
14
    `,str
15
  )
16
)
17
 
18
(defun print-decode-hash (dec depth)
19
  (cond
20
     ((hash-table-p dec)
21
     (let ((p ""))
22
       ( maphash (function (lambda (k v)
23
         (let ((p2 ""))
24
           (setq p2 (concat p2 (space-string (- depth 1) "|") "+" (mapconcat 'number-to-string k "" ) "=" ))
25
           (if (is-decoder v)
26
               (setq p2 (concat p2 "\n" (print-decoder v depth)))
27
               (setq p2 (concat p2 (mapconcat 'symbol-name v "," ) "\n"))
28
           )
29
           (setq p (concat p p2))
30
         ))) dec )
31
       `,p
32
     ))
33
     ((listp dec)
34
      (mapconcat 'print-list dec " ")
35
     )
36
     ((t) ('"?")))
37
)
38
 
39
(defun print-decoder (d depth)
40
  (let ((l (- 31 (nth 1 d)))
41
        (r (+ (- 31 (nth 2 d)) 1))
42
        (dec (nth 3 d))
43
        (def (nth 4 d))
44
        (p ""))
45
    (if (not (and (eq l 31) (eq r 32)))
46
        (progn
47
          (setq p (concat p (space-string depth "|") "[" (number-to-string l) "-" (number-to-string r) "]\n"  ))
48
          (setq p (concat p (print-decode-hash dec (+ 1 depth) )))
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 "|") "+" "def=" (mapconcat 'symbol-name (nth 4 def)  " ") "\n" ))
54
            (setq p (concat p (space-string depth "|") "+" "def=\n" (print-decoder def depth)))
55
        )
56
    )
57
    `,p
58
  )
59
)
60
 
61
(defun or-insn-set (insn)
62
  (let ((e '())
63
        (v '())
64
        (m '()))
65
    (dolist (e insn v)
66
      (if (eq v '())
67
        (setq v (make-setbit-groups (make-set-bitstring (symbol-value e))))
68
        (setq v (or-setbit-groups  v (make-setbit-groups (make-set-bitstring (symbol-value e))) ))
69
      )
70
    )
71
  )
72
)
73
 
74
(defun insn-max-setenc-set-acc (start end i)
75
  (let ((a '())
76
        (v '())
77
        (e '()))
78
    (mapcar (function (lambda (x)
79
       (if (cmp* (cut-copy-list (make-set-bitstring (symbol-value x)) start end) 1)
80
           (setq a (cons x a)))
81
       )) i)
82
    `,a
83
    )
84
  )
85
 
86
 
87
;cc: (( 0 0 0) (1 1) (0 0))
88
;i: 1           x
89
;(clear-setenc-set '(( 0 0 0) (1 1) (1 1)) 1)
90
(defun clear-setenc-set (cc i)
91
  (let ((e '())
92
        (v '())
93
        (j 0))
94
    (dolist (e cc v)
95
      (if (eq i j)
96
          (setq v (append `(,(make-list (length e) 0)) v))
97
          (setq v (append `(,e) v))
98
      )
99
      (setq j (1+ j))
100
    )
101
    (reverse v)
102
  )
103
)
104
 
105
(defun setenc-set-p (cc)
106
  ; check weater a setbit set is remaining
107
  (let ((e '())
108
        (v '()))
109
    (dolist (e cc v)
110
      (if (eq (nth 0 e) 1)
111
        (setq v 't)
112
      )
113
    )
114
  )
115
)
116
 
117
 
118
; returns: (ccindex ((insn set)(insn set complement)))
119
(defun insn-max-setenc-set (cc insn)
120
  "Resturn row encode set that has the most members"
121
  (let ((a (mapcar-setbit 'insn-max-setenc-set-acc cc insn))
122
        (v '())
123
        (e '())
124
        (i 0)
125
        (j -1)
126
        (off 0))
127
    (dolist (e a v)
128
      (if (not (memq 'nil e))
129
          (if (> (length e)(length v))
130
              (progn
131
                (setq v e)
132
                (setq j i)
133
              )
134
          )
135
      )
136
      (setq i (+ i 1))
137
    )
138
    `(,j ( ,v ,(remq* v insn) ) )
139
  )
140
)
141
 
142
;cc: ((0 0 0) (1 1) (1) (0 0 0))
143
;i: 1          x
144
;r: (3 5)
145
;(insn-get-encrange '((0 0 0) (1 1) (1) (0 0 0)) 1)
146
 
147
(defun insn-get-encrange (cc i)
148
  ;get range of index <i> if bitset cc
149
  (let ((j 0)
150
        (off 0)
151
        (end 0))
152
    (dotimes (j i off)
153
      (setq off (+ off (length (nth j cc)))) )
154
    (setq end (+ off (length (nth i cc))))
155
    `(,off ,end)
156
  )
157
)
158
 
159
(defun get-insn-enc (insn start end)
160
  ;get the encod value of insn
161
  (cut-copy-list (symbol-value insn) start end)
162
)
163
 
164
(defun create-decoder-setenc (cc insnset depth)
165
  (let ((i 0)
166
        (start 0)
167
        (insn '())
168
        (insnc '())
169
        (end 0)
170
        (range '())
171
        (nset '())
172
        (nkey '())
173
        (nval '())
174
        (dec)
175
        (defdec insnset)
176
        )
177
    (if (setenc-set-p cc)
178
        (progn
179
          (setq range (insn-max-setenc-set cc insnset))
180
          (setq i (nth 0 range))
181
          (setq insn (nth 0 (nth 1 range)))
182
          (setq insnc (nth 1 (nth 1 range)))
183
          (setq start (nth 0 (insn-get-encrange cc i)))
184
          (setq end (nth 1 (insn-get-encrange cc i)))
185
 
186
          (define-hash-table-test 'contents-hash 'equal 'sxhash)
187
          (setq dec (make-hash-table :test 'contents-hash))
188
          (let ((e '())
189
                (k '())
190
                (v '())
191
                )
192
            (dolist (e insn)
193
              (setq k (get-insn-enc e start end))
194
              (puthash k (cons e (gethash k dec '())) dec )
195
              )
196
            )
197
          (setq nset (clear-setenc-set cc i))
198
          (maphash (function (lambda (k v)
199
             (if (setenc-set-p (and-setbit-groups nset (or-insn-set v)))
200
                 (puthash k (create-decoder-setenc (and-setbit-groups nset (or-insn-set v) ) v (+ 1 depth)) dec)
201
             )
202
          )) dec)
203
          (setq defdec '())
204
          (if (> (length insnc) 0)
205
              (setq defdec (create-decoder-setenc (and-setbit-groups nset (or-insn-set insnc)  ) insnc (+ 1 depth)))
206
          )
207
        )
208
    )
209
    `(,i ,start ,end ,dec ,defdec ) ;defdec
210
  )
211
)
212
 
213
 
214
;-----------------------------------------------------------------------
215
 

powered by: WebSVN 2.1.0

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