/[PAMELA software]/chewbacca/PamOffLineSW/forroutines/tof/graytobin.for
ViewVC logotype

Contents of /chewbacca/PamOffLineSW/forroutines/tof/graytobin.for

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Tue Sep 23 07:20:15 2008 UTC (16 years, 2 months ago) by mocchiut
Branch: v0r00, MAIN
CVS Tags: v1r02, v1r00, v1r01, start, v10RED, v9r00, v9r01, HEAD
Changes since 1.1: +0 -0 lines
Imported sources, 23/09/2008

1 C----------------------------------------------------------
2 subroutine graytobin(cg,cb,n)
3
4 c convert word of length n
5 c from Gray code Cg[0...n-1]
6 c to binary code Cb[0...n-1]
7 c 4 bits per time
8 c D.Campana - Jan. 2005
9 C----------------------------------------------------------
10 IMPLICIT NONE
11
12 integer n, bit, bi
13 integer cg,cb
14 integer*1 a,b
15 integer*1 i,j,n4
16 integer nby4,cgby4(8),cbby4(8)
17 c
18 c devo separare la parola nelle sue componenti da 4 bit
19 c ossia (0-3, 4-7, 8-11, 12-15)
20 c
21
22 cb=0
23 do i=1,8
24 cgby4(i)=0 ! componenti da 4 bit in Gray
25 cbby4(i)=0 ! componenti da 4 bit in binario
26 enddo
27 nby4 = n/4
28
29 do i=1,nby4
30 do j=1,4
31 n4= (i-1)*4+j
32 bi = ibits(cg,n4-1,1)
33 if(bi.eq.1)cgby4(i)=ibset(cgby4(i),j-1)
34 enddo
35 enddo
36 c
37 do i=1,nby4
38 bi = ibits(cgby4(i),3,1)
39 if(bi.eq.1) cbby4(i) = ibset(cbby4(i),3)
40 c
41 do bit=2,0,-1
42 bi=0
43 a=ibits(cgby4(i),bit,1)
44 b=ibits(cbby4(i),bit+1,1)
45 if(((a.eq.1).and.(b.eq.0)).or.((a.eq.0).and.(b.eq.1)))bi=1
46 if(bi.eq.1)cbby4(i)=ibset(cbby4(i),bit)
47 enddo
48 enddo
49 c
50 do i=1,nby4
51 do j=1,4
52 n4= (i-1)*4+j
53 bi=ibits(cbby4(i),j-1,1)
54 if(bi.eq.1)cb=ibset(cb,n4-1)
55 enddo
56 enddo
57 c
58 return
59 end

  ViewVC Help
Powered by ViewVC 1.1.23