module: sat_limits_uint
description: 
timing_sensitivity: 
parameters:  int n
inputs:  int in
outputs:  int out
classes:  
static_variables:  int max_val
init:  

out = 0;

if (n < 1)
   {
    printf("error in 'sat_limits_uint':  n must be >= 1\n");
    printf("  -> in this case, n = %d\n", n);
    exit(1);
   }
else if (n > 30)
   {
    printf("error in 'sat_limits_uint':  n must be <= 30\n");
    printf("  -> in this case, n = %d\n", n);
    exit(1);
   }
max_val = (1<<n)-1;


code:
if (in < 0)
   out = 0;
else if (in > max_val)
   out = max_val;
else
   out = in;
