Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
corr_matrixpi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DG
FOFB
corr_matrixpi
Commits
4631782c
Commit
4631782c
authored
8 months ago
by
BRONES Romain
Browse files
Options
Downloads
Patches
Plain Diff
align simulation
parent
9f2c03ff
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
sim/bpmdata.txt
+200
-200
200 additions, 200 deletions
sim/bpmdata.txt
sim/corrout.txt
+200
-200
200 additions, 200 deletions
sim/corrout.txt
sim/generate_datasim.py
+23
-17
23 additions, 17 deletions
sim/generate_datasim.py
sim/tc_basic.vhd
+14
-14
14 additions, 14 deletions
sim/tc_basic.vhd
with
437 additions
and
431 deletions
sim/bpmdata.txt
+
200
−
200
View file @
4631782c
This diff is collapsed.
Click to expand it.
sim/corrout.txt
+
200
−
200
View file @
4631782c
Source diff could not be displayed: it is too large. Options to address this:
view the blob
.
This diff is collapsed.
Click to expand it.
sim/generate_datasim.py
+
23
−
17
View file @
4631782c
...
...
@@ -8,6 +8,10 @@ import numpy as np
# The inverted response matrix, we use an actual true dataset
respmat
=
np
.
load
(
"
respmat.npy
"
)
# Remove weirdcoeff and set to nm/DAC
#respmat= np.round(respmat/1.77/1717.412/170*10*0x7FFF*1e-6*2**30).astype('i4')
# write to file
with
open
(
"
respmat.txt
"
,
"
w
"
)
as
fp
:
for
r
in
respmat
.
flatten
():
...
...
@@ -35,7 +39,7 @@ N_BPM=respmat.shape[1]*2
N_PSC
=
respmat
.
shape
[
0
]
size
=
200
N_MM_RND
=
1
5
N_MM_RND
=
1
4
#############################################################################
# Generate data input
...
...
@@ -43,7 +47,7 @@ N_MM_RND=15
bpmdata
=
np
.
empty
((
N_BPM
,
size
),
dtype
=
"
int32
"
)
for
i
,
DC
,
A
,
F
,
N
in
zip
(
np
.
arange
(
N_BPM
,
dtype
=
"
int
"
),
np
.
random
.
default_rng
().
uniform
(
-
1e
6
,
1e
6
,
N_BPM
),
np
.
random
.
default_rng
().
uniform
(
-
1e
5
,
1e
5
,
N_BPM
),
np
.
random
.
default_rng
().
uniform
(
0
,
200e3
,
N_BPM
),
np
.
random
.
default_rng
().
uniform
(
2
,
2000
,
N_BPM
),
np
.
random
.
default_rng
().
uniform
(
0
,
20e3
,
N_BPM
),):
...
...
@@ -65,15 +69,15 @@ with open("bpmdata.txt", "w") as fp:
trespmat
=
np
.
zeros
((
N_PSC
,
N_BPM
),
dtype
=
"
int64
"
)
trespmat
[:
50
,:
122
]
=
respmat
[:
50
]
trespmat
[
50
:,
122
:]
=
respmat
[
50
:]
C_N_RND
=
20
C_N_
A_RND
=
8
C_N_RND
=
14
C_N_
FP
=
16
SUMSAT
=
36
K_A
=
218
K_B
=
-
186
K_
i
C
=
325
K_D
=
-
3225
K_A
=
4950
K_B
=
-
4000
K_C
=
16384
K_D
=
16300
## -----------------------
...
...
@@ -83,23 +87,25 @@ K_D = -3225
oe
=
bpmdata
-
refmat
[:,
np
.
newaxis
]
# Step 2: matrix multiplication
mm
=
np
.
empty
((
N_PSC
,
size
),
dtype
=
"
i
nt32
"
)
mm
=
np
.
empty
((
N_PSC
,
size
),
dtype
=
"
i
8
"
)
for
i
in
range
(
size
):
# Stage 1 : matmul
_mm
=
np
.
matmul
(
oe
[:,
i
].
astype
(
"
int64
"
),
trespmat
.
T
,
dtype
=
'
int64
'
)
mm
[:,
i
]
=
np
.
round
(
_mm
*
2
**-
N_MM_RND
)
.
astype
(
"
int32
"
)
mm
[:,
i
]
=
np
.
round
(
_mm
*
2
**-
N_MM_RND
)
# Step 3: correction computation
corr
=
np
.
zeros
((
N_PSC
,
size
),
dtype
=
"
i
nt64
"
)
corr
fp
=
np
.
zeros
((
N_PSC
,
size
),
dtype
=
"
i
8
"
)
_corr
=
(
np
.
round
(
mm
[:,
0
].
astype
(
'
i8
'
)
*
K_A
*
2
**-
C_N_RND
)
*
K_iC
).
astype
(
"
int64
"
)
corr
[:,
0
]
=
np
.
clip
(
np
.
round
(
_corr
/
2
**
C_N_RND
),
-
2
**
15
,
2
**
15
-
1
).
astype
(
'
i8
'
)
for
i
in
range
(
1
,
size
):
_sum
=
(
np
.
round
(
mm
[:,
i
].
astype
(
'
i8
'
)
*
K_A
*
2
**-
C_N_RND
)).
astype
(
'
i8
'
)
+
mm
[:,
i
-
1
].
astype
(
'
i8
'
)
*
K_B
+
corr
[:,
i
-
1
]
*
K_D
_corr
=
np
.
clip
(
_sum
,
-
2
**
(
SUMSAT
-
1
),
2
**
(
SUMSAT
-
1
)
-
1
)
*
K_iC
corr
[:,
i
]
=
np
.
clip
(
np
.
round
(
_corr
/
2
**
C_N_RND
),
-
2
**
15
,
2
**
15
-
1
)
corrfp
[:,
0
]
=
mm
[:,
0
]
*
K_A
*
2
**-
C_N_RND
*
K_C
*
2
**-
C_N_RND
for
i
in
range
(
1
,
size
):
corrfp
[:,
i
]
=
(
mm
[:,
i
]
*
K_A
*
2
**-
C_N_RND
+
mm
[:,
i
-
1
]
*
K_B
*
2
**-
C_N_RND
+
corrfp
[:,
i
-
1
]
*
K_D
*
2
**-
C_N_RND
)
*
K_C
*
2
**-
C_N_RND
corr
=
np
.
round
(
corrfp
*
2
**-
C_N_FP
).
astype
(
'
i2
'
)
#############################################################################
# Write partial and results to files
...
...
This diff is collapsed.
Click to expand it.
sim/tc_basic.vhd
+
14
−
14
View file @
4631782c
...
...
@@ -91,22 +91,22 @@ begin
log
(
"+-- Global Config"
,
INFO
);
-- Correction coefficients
Write
(
ManagerRec
,
f_addr
(
16
#
18
#
),
f_sdata
(
218
));
Write
(
ManagerRec
,
f_addr
(
16
#
1
C
#
),
f_sdata
(
-
186
));
Write
(
ManagerRec
,
f_addr
(
16
#
20
#
),
f_sdata
(
325
));
Write
(
ManagerRec
,
f_addr
(
16
#
24
#
),
f_sdata
(
-3225
));
Write
(
ManagerRec
,
f_addr
(
16
#
38
#
),
f_sdata
(
218
));
Write
(
ManagerRec
,
f_addr
(
16
#
3
C
#
),
f_sdata
(
-
186
));
Write
(
ManagerRec
,
f_addr
(
16
#
40
#
),
f_sdata
(
325
));
Write
(
ManagerRec
,
f_addr
(
16
#
44
#
),
f_sdata
(
-3225
));
Write
(
ManagerRec
,
f_addr
(
16
#
28
#
),
f_sdata
(
1
28
));
Write
(
ManagerRec
,
f_addr
(
16
#
18
#
),
f_sdata
(
4950
));
Write
(
ManagerRec
,
f_addr
(
16
#
1
C
#
),
f_sdata
(
-
4000
));
Write
(
ManagerRec
,
f_addr
(
16
#
20
#
),
f_sdata
(
16384
));
Write
(
ManagerRec
,
f_addr
(
16
#
24
#
),
f_sdata
(
16300
));
Write
(
ManagerRec
,
f_addr
(
16
#
38
#
),
f_sdata
(
4950
));
Write
(
ManagerRec
,
f_addr
(
16
#
3
C
#
),
f_sdata
(
-
4000
));
Write
(
ManagerRec
,
f_addr
(
16
#
40
#
),
f_sdata
(
16384
));
Write
(
ManagerRec
,
f_addr
(
16
#
44
#
),
f_sdata
(
16300
));
Write
(
ManagerRec
,
f_addr
(
16
#
28
#
),
f_sdata
(
1
6384
));
Write
(
ManagerRec
,
f_addr
(
16
#
2
C
#
),
f_sdata
(
0
));
Write
(
ManagerRec
,
f_addr
(
16
#
30
#
),
f_sdata
(
8192
));
Write
(
ManagerRec
,
f_addr
(
16
#
30
#
),
f_sdata
(
16384
));
Write
(
ManagerRec
,
f_addr
(
16
#
34
#
),
f_sdata
(
0
));
Write
(
ManagerRec
,
f_addr
(
16
#
48
#
),
f_sdata
(
1
28
));
Write
(
ManagerRec
,
f_addr
(
16
#
48
#
),
f_sdata
(
1
6384
));
Write
(
ManagerRec
,
f_addr
(
16
#
4
C
#
),
f_sdata
(
0
));
Write
(
ManagerRec
,
f_addr
(
16
#
50
#
),
f_sdata
(
8192
));
Write
(
ManagerRec
,
f_addr
(
16
#
50
#
),
f_sdata
(
16384
));
Write
(
ManagerRec
,
f_addr
(
16
#
54
#
),
f_sdata
(
0
));
-- Num BPM
...
...
@@ -151,7 +151,7 @@ begin
for
I
in
0
to
C_N_MM_BPM
-1
loop
readline
(
read_file
,
line_v
);
read
(
line_v
,
int_v
);
Write
(
ManagerRec
,
f_addr
(
16
#
1000
#+
J
*
512
+
I
*
4
),
f_sdata
(
int_v
));
Write
(
ManagerRec
,
f_addr
(
16
#
1000
#+
J
*
1024
+
I
*
4
),
f_sdata
(
int_v
));
end
loop
;
end
loop
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment