diff --git a/test/unit_tests/helper.scm b/test/unit_tests/helper.scm index 5acebcd..8a0879e 100644 --- a/test/unit_tests/helper.scm +++ b/test/unit_tests/helper.scm @@ -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) + ) + ) + ) +) \ No newline at end of file