OpenCores
URL https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [cli/] [util/] [util_bits.c] - Blame information for rev 22

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 22 qaztronic
/*-----------------------------------------------------------*/
2
 
3
#include "util_bits.h"
4
 
5
 
6
/*-----------------------------------------------------------*/
7
void inline
8
  util_set_bits
9
  (
10
    unsigned int address,
11
    unsigned int bit_offset,
12
    unsigned int bit_mask,
13
    unsigned int data
14
  )
15
{
16
  volatile unsigned int *word_pointer = (volatile unsigned int *)(address);
17
  unsigned int buffer;
18
 
19
  data <<= bit_offset;
20
  data &= bit_mask;
21
 
22
  buffer = *word_pointer;
23
  buffer &= ~bit_mask;
24
  buffer |= data;
25
 
26
  *word_pointer = buffer;
27
}
28
 
29
 
30
/*-----------------------------------------------------------*/
31
unsigned int inline
32
  util_get_bits
33
  (
34
    unsigned int address,
35
    unsigned int bit_offset,
36
    unsigned int bit_mask
37
  )
38
{
39
  volatile unsigned int *word_pointer = (volatile unsigned int *)(address);
40
  unsigned int buffer;
41
 
42
  buffer = *word_pointer;
43
  buffer &= bit_mask;
44
  buffer >>= bit_offset;
45
 
46
  return(buffer);
47
}
48
 
49
 
50
/*-----------------------------------------------------------*/
51
unsigned char ReverseBits7ops32bit(unsigned char v)
52
{
53
    return ((v * 0x0802LU & 0x22110LU) |
54
            (v * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16;
55
}
56
 
57
 
58
 

powered by: WebSVN 2.1.0

© copyright 1999-2020 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.