module: split_msb_lsb_uint
description: 
timing_sensitivity: 
parameters:  int n_msb, int n_lsb
inputs:  int in
outputs:  int out_msb, int out_lsb
classes:  
static_variables: int max_in_val, int max_lsb_val
init:  
int n;

if (n_msb < 1)
   {
    printf("error in 'split_msb_lsb_uint':  n_msb must be >= 1\n");
    printf("  -> in this case, n_msb = %d\n", n_msb);
    exit(1);
   }
if (n_lsb < 1)
   {
    printf("error in 'split_msb_lsb_uint':  n_lsb must be >= 1\n");
    printf("  -> in this case, n_lsb = %d\n", n_lsb);
    exit(1);
   }

n = n_msb + n_lsb;

if (n > 30)
   {
    printf("error in 'split_msb_lsb_uint':  n_msb + n_lsb must be <= 30\n");
    printf("  -> in this case, n_msb + n_lsb = %d\n", n);
    exit(1);
   }
max_in_val = (1<<n)-1;
max_lsb_val = (1<<n_lsb)-1;


code:  

if (in < 0)
   {
    printf("error in 'split_msb_lsb_uint':  in must be >= 0\n");
    printf("  -> in this case, in = %d\n", in);
    exit(1);
   }
if (in > max_in_val)
   {
    printf("error in 'split_msb_lsb_uint':  in must be <= max_in_val\n");
    printf("  -> in this case, in = %d\n", in);
    printf("     max_in_val = %d  (n_msb = %d, n_lsb = %d)\n",max_in_val,n_msb,n_lsb);
    exit(1);
   }

out_lsb = in & max_lsb_val;
out_msb = in>>n_lsb;


