added bd helpers

This commit is contained in:
Ole Richter 2022-02-23 11:43:22 +01:00
parent 04baa491eb
commit 68f9728faa
1 changed files with 91 additions and 0 deletions

View File

@ -145,3 +145,94 @@
) )
) )
) )
(define assert-data-bit
(lambda (x i v)
(let ((tmp (string-append x (string-append ".d[" (string-append (number->string i) "]")))))
(assert tmp v)
)
)
)
(define assert-data-int
(lambda (x width value)
(letrec ((assert-one-data-bit
(lambda (v i)
(cond
((=? i width) #t)
(#t (begin
(assert-data-bit x i (% v 2))
(assert-one-data-bit (truncate (/ v 2)) (+ i 1))
)
)
)
)
))
(assert-one-data-bit value 0)
)
)
)
(define assert-bd-channel-valid
(lambda (ch width value)
(begin
(assert-data-int ch width value)
(assert (string-append ch ".r") 1)
)
)
)
(define assert-bd-channel-neutral
(lambda (ch width)
(assert (string-append ch ".r") 0)
)
)
(define set-bd-channel-neutral
(lambda (ch width)
(letrec ((ch-name (string-append ch ".d"))
(helper
(lambda (i)
(cond
((=? i width) #t)
(#t (let ((tmp (string-append ch (string-append ".d[" (string-append (number->string i) "]" )))))
(begin
(set tmp 0)
(helper (+ 1 i))
)
)
)
)
)
))
(begin
(helper 0)
(set (string-append ch ".r") 0)
)
)
)
)
(define set-bd-channel-valid
(lambda (ch width val)
(letrec ((ch-name (string-append ch ".d"))
(helper
(lambda (i v)
(cond
((=? i width) #t)
(#t (let ((tmp (string-append ch (string-append ".d[" (string-append (number->string i) "]")))))
(begin
(set tmp (% v 2))
(helper (+ 1 i) (truncate (/ v 2)))
)
))
)
)
))
(begin
(helper 0 val)
(set (string-append ch ".r") 1)
)
)
)
)