Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
std:start [2022/07/16 16:22]
rajit created
std:start [2023/04/08 12:16] (current)
rajit [Nested namespaces]
Line 1: Line 1:
 ====== Namespace std ====== ====== Namespace std ======
 +
 +The ''std'' namespace contains a collection of standard definitions for channels, data types, and other components. This can be viewed as ACT's equivalent of the C++ standard template library.
 +
 +====== Functions ======
 +
 +===== Parameter-type functions =====
 +
 +<code act>
 +export function max(pint a, b) : pint;
 +</code>
 +Returns the larger of the two ''pint''s.
 +
 +<code act>
 +export function min(pint a, b) : pint;
 +</code>
 +Returns the smaller of the two ''pint''s.
 +
 +<code act>
 +export function ceil_log2 (pint a) : pint;
 +</code>
 +Computes the smallest power of two that is at least as large as ''a''.
 +
 +<code act>
 +export function pow(pint n, m) : pint;
 +</code>
 +Computes the quantity ''n'' to the power of ''m''. Note that ''pint''s use 64-bit representation. 
 +
 +===== Runtime Functions =====
 +
 +<code act>
 +export template<pint W; pint N; pint taps[N]> function fib_lfsr (int<W> state) : int<W>;
 +</code>
 +Given the current ''W''-bit state of a Fibonacci-style linear feedback shift register (LFSR), compute the next state. The LFSR has ''N'' taps, and the ith tap is at location ''taps[i]''.
 +
 +
 +
 +
 +
 +====== Definitions ======
 +
 +<code act>
 +export template<pint ID, N,W>
 +defproc rom (chan?(int<std::ceil_log2(N)>) addr; chan!(int<W>) dout);
 +</code>
 +(This can be used after ''actsim'' is installed.)
 +
 +<code act>
 +export template<pint N, W>
 +defproc ram (chan?(int<2>) rd; chan?(int<std::ceil_log2(N)>) addr;  
 +             chan?(int<W>) din;  chan!(int<W>) dout);
 +</code>
 +
 +<code act>
 +export defcell buf_arbiter(bool? a, b; bool! u, v) ;
 +</code>
 +
 +<code act>
 +export defcell ideal_arbiter(bool? a, b; bool! u, v) ;
 +</code>
 +
 +<code act>
 +export template<pint N, M>
 +defproc arbiter(chan?(int<N>) A; chan?(int<M>) B; chan!(int<N>) Ap; chan!(int<M>) Bp);
 +</code>
 +
 +====== Nested namespaces ======
 +
 +The ''std'' namespace contains a number of nested namespaces:
 +
 +  * [[data|data]]: Standard data types
 +  * [[channels|channels]]: Standard channel definitions
 +  * [[gates|gates]]: Commonly used gates
 +  * [[cells|cells]]: A simple synchronous standard-cell library
 +  * [[io|io]]: Standard I/O primitives
 +  * [[bit|bit]]: Bit-manipulation functions
 +