-
Notifications
You must be signed in to change notification settings - Fork 10
/
signed.lv
41 lines (33 loc) · 1.05 KB
/
signed.lv
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
31
32
33
34
35
36
37
38
39
40
41
;;; Computations involving sign bits
(module signed
(register r 8'b11110000)
(register rpos 8'b01110000)
(register rneg 8'b11110000)
(register r16 16'b0)
(register rneg_asr_0 8'b0)
(register rneg_asr_3 8'b0)
(register rneg_sext_4 8'b0)
(register rneg_sext_16 16'b0)
(register rpos_asr_0 8'b0)
(register rpos_asr_3 8'b0)
(register rpos_sext_4 8'b0)
(register rpos_sext_16 16'b0)
(register rrepeat16 80'b0)
(register rrepeat1 16'b0)
(rule test
(let ((rposv (read.0 rpos))
(rnegv (read.0 rneg)))
(write.0 rpos_asr_0 (asr rposv 1'b0))
(write.0 rpos_asr_3 (asr rposv 2'3))
(write.0 rpos_sext_4 (sext 4 rposv))
(write.0 rpos_sext_16 (sext 16 rposv))
(write.0 rneg_asr_0 (asr rnegv 1'b0))
(write.0 rneg_asr_3 (asr rnegv 2'3))
(write.0 rneg_sext_4 (sext 4 rnegv))
(write.0 rneg_sext_16 (sext 16 rnegv))
(write.0 rrepeat16 (repeat 10 rposv))
(write.0 rrepeat1 (repeat 16 1'b1))))
(rule simple
(write.1 r16 (sext 16 (read.0 r))))
(scheduler main
(sequence test)))