The simultaneous assignment of signals within a block is managed by
`define-synchronous-system`

. The `next-function` expressions
are functional as opposed to imperative; these expressions should not
use `set!`

or other mutators.

See Models for how to create (RAM) Arrays and FIFOs.

— Function: **array-ref**` array index1 index2 ...`

The procedure

array-refreturns the contents of thearraylocation selected byindex1index2....

— Function: **array-set**` array new-value index1 index2 ...`

The procedure

array-setreturns a copy ofarraywith the location selected byindex1index2... replaced bynew-value.

— Function: **fifo:first**` fifo`

Returns the first item of

fifo. This item will be discarded by a call to`fifo:remove-first`

.

— Function: **fifo:remove-first**` fifo`

Returns

fifowith its first item discarded. Iffifois already empty, an error is signalled.

— Function: **fifo:insert-last**` fifo datum`

Returns

fifowithdatumadded. Iffifois already full, an error is signalled.

— Function: **logand**` n1 n1`

Returns the integer which is the bit-wise AND of the two integer arguments.

Example:

(number->string (logand #b1100 #b1010) 2) ⇒ "1000"

— Function: **logior**` n1 n2`

Returns the integer which is the bit-wise OR of the two integer arguments.

Example:

(number->string (logior #b1100 #b1010) 2) ⇒ "1110"

— Function: **number-or**` name k1 ...`

The arguments to

`logior`

must be integers. Thek1... arguments to`number-or`

can be either integers or`#f`

. All the arguments to`number-or`

are evaluated. If more than onek1... argument is an integer, a warning using namenameis issued.(number-or 'ls[2..0] (and cc-litx1 #.ls-data) (and cc-litx2 #.ls-data-x2) (and cc-litx3 #.ls-data-x3))

— Function: **number-check**` name k`

Issues a warning if

kis not a number or negative.`number-check`

returns`#t`

.

— Function: **logxor**` n1 n2`

Returns the integer which is the bit-wise XOR of the two integer arguments.

Example:

(number->string (logxor #b1100 #b1010) 2) ⇒ "110"

— Function: **lognot**` n`

Returns the integer which is the 2s-complement of the integer argument.

Example:

(number->string (lognot #b10000000) 2) ⇒ "-10000001" (number->string (lognot #b0) 2) ⇒ "-1"

— Function: **bitwise-if**` mask n0 n1`

Returns an integer composed of some bits from integer

n0and some from integern1. A bit of the result is taken fromn0if the corresponding bit of integermaskis 1 and fromn1if that bit ofmaskis 0.

— Function: **logtest**` j k`

(logtest j k) == (not (zero? (logand j k))) (logtest #b0100 #b1011) ⇒ #f (logtest #b0100 #b0111) ⇒ #t

— Function: **logbit?**` index j`

Returns

`#t`

if bitindexofjis 1. Bit 0 is always the low order bit;`(logbit? 0 data[31..24])`

will be`#t`

only ifdata[31..24]'s value is odd.

— Function: **copy-bit**` index from bit`

Returns an integer the same as

fromexcept in theindexth bit, which is 1 ifbitis`#t`

and 0 ifbitis`#f`

.Example:

(number->string (copy-bit 0 0 #t) 2) ⇒ "1" (number->string (copy-bit 2 0 #t) 2) ⇒ "100" (number->string (copy-bit 2 #b1111 #f) 2) ⇒ "1011"

— Function: **bit-field**` n start end`

Returns the integer composed of the

start(inclusive) throughend(exclusive) bits ofn. Thestartth bit becomes the low order (even/odd) bit in the result. Note that theendindex is one more than the high order bit index. Thus,`(bit-field data[7..0] 0 8)`

and`(bit-field data[31..24] 0 8)`

are identity functions.This function was called

`bit-extract`

in SYNCH1a1.

— Function: **copy-bit-field**` to from start end`

Returns an integer the same as

toexcept possibly in thestart(inclusive) throughend(exclusive) bits, which are the same as those offrom. The 0-th bit offrombecomes thestartth bit of the result.Example:

(number->string (copy-bit-field #b1101101010 0 0 4) 2) ⇒ "1101100000" (number->string (copy-bit-field #b1101101010 -1 0 4) 2) ⇒ "1101101111" (number->string (copy-bit-field #b110100100010000 -1 5 9) 2) ⇒ "110100111110000"

— Function: **ash**` int count`

— Function:**arithmetic-shift**` int count`

— Function:

Returns an integer equivalent to

`(inexact->exact (floor (*`

int`(expt 2`

count`))))`

.Example:

(number->string (ash #b1 3) 2) ⇒ "1000" (number->string (ash #b1010 -1) 2) ⇒ "101"Bits shifted below the low-order bit disappear; bits shifted above the high order bit

do notdisappear. Remember to mask unused bits using`logand`

.