module: gain_alpha_for_hk_mash
description: 
timing_sensitivity: 
parameters:  int a, in n
inputs:  double in
outputs:  double out
classes:  
static_variables: double alpha
init:  
int max_val;

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

code:  
out = alpha*in;

