Belle II KLM Scint Firmware
1
run_ctrl.vhd
1
--*********************************************************************************
2
-- Indiana University
3
-- Center for Exploration of Energy and Matter (CEEM)
4
-- Project: Belle-II
5
-- Author: Brandon Kunkler
6
-- Date: 06/09/2014
7
--*********************************************************************************
8
-- ### run_ctrl.vhd
9
-- ##### Description:
10
-- Run control interface. Shifts in 16 bit run-ctrl words when rx_src_rdy_n is asserted.
11
-- rx_src_rdy_n is asserted by rx_ll_pdu_datapath.vhd "when there is data in storage and
12
-- incomiming data or the end of a frame."
13
14
--
15
-- Change Log:
16
-- 2020/07/29 Linting code. Added documentation. Commented out unused ports. (CK)
17
-- Fixed Xst:638 - Conflict on KEEP property on signal tmp48 and rcl_fifo_din_32.
18
--
19
--
20
-- Deficiencies/Issues:
21
-- 1. rx_sof_n, rx_eof_n, and rx_dst_rdy_n are useless at this time. All are wired
22
-- through klm_intfc.vhd, to FFs conc_intfc.vhd, then back to klm_intfc.vhd. The first two
23
-- originate in rx_ll_pdu_datapath.vhd as part of the Aurora core. Perhaps intention
24
-- was to verify integrity of run-ctrl words. For now, the integrity check involves
25
-- matching our own SOF/EOF before writting to rcl_fifo. Further, we count the number
26
-- of received words and report it to a status register. This is then checked in software
27
-- for a match to number of words sent. Standard practice thus far has been to just resend
28
-- if there is a mismatch between nubmer of sent and received words.
29
--*********************************************************************************
30
library
ieee
;
31
use
ieee.std_logic_1164.
all
;
32
use
ieee.std_logic_misc.
all
;
33
library
work
;
34
use
work.
conc_intfc_pkg
.
all
;
35
use
work.
klm_scint_pkg
.
all
;
36
entity
run_ctrl
is
37
port
(
38
clk
:
in
std_logic
;
39
-- rx_dst_rdy_n : out std_logic; --goes to FF in conc_intfc then back one level and nothing . . .
40
-- rx_sof_n : in std_logic; --which means that this is useless
41
-- rx_eof_n : in std_logic; --and this
42
rx_src_rdy_n
:
in
std_logic
;
43
rx_data
:
in
std_logic_vector
(
15
downto
0
)
;
44
rcl_fifo_rd_clk
:
in
std_logic
;
45
rcl_fifo_rd_en
:
in
std_logic
;
46
rcl_fifo_data
:
out
std_logic_vector
(
31
downto
0
)
;
47
rcl_fifo_empty
:
out
std_logic
48
)
;
49
end
run_ctrl
;
50
51
52
architecture
behave
of
run_ctrl
is
53
54
-- signal intfc_bit : std_logic;
55
signal
rcl_fifo_frame_set_q
:
std_logic_vector
(
1
downto
0
)
:=
"10"
;
56
signal
rcl_fifo_frame_set
:
std_logic
:=
'
0
'
;
57
58
signal
rx_data_sr
:
std_logic_vector
(
47
downto
0
)
;
59
alias
ic
:
std_logic_vector
(
7
downto
0
)
is
rx_data_sr
(
35
downto
28
)
;
60
alias
addr
:
std_logic_vector
(
7
downto
0
)
is
rx_data_sr
(
27
downto
20
)
;
61
alias
val
:
std_logic_vector
(
15
downto
0
)
is
rx_data_sr
(
19
downto
4
)
;
62
signal
rcl_fifo_din_32
:
std_logic_vector
(
31
downto
0
)
;
63
64
65
signal
rcl_fifo_wr_en_32
:
std_logic
:=
'
0
'
;
66
signal
rcl_fifo_rst
:
std_logic
;
67
68
69
begin
70
71
---------------------------------------------------------------------------------------------------------
72
73
74
75
76
u_runctrl_fifo :
entity
work.
fifo_cc
--
1024
depth
77
generic
map
(
78
DATA_WIDTH =>
32
,
79
DEPTH =>
10
-- bit
80
)
81
PORT
MAP
(
82
clk => clk,
83
rst => '0',
84
din => rcl_fifo_din_32,
85
wen => rcl_fifo_wr_en_32,
86
ren => rcl_fifo_rd_en,
87
dout => rcl_fifo_data,
88
full =>
open
,
89
empty => rcl_fifo_empty
90
)
;
91
92
-- Run control(RCL) data format:
93
-- | SOF(4)=0xF | TYPE(3) | LANE(4) | IC(8) | ADDR(8) | VALUE(16) | EOF(4)=0x8 |
94
95
-- Type and Lane parsed by Data concentrator.
96
97
-- 32-bit run-ctrl word is (IC & ADDR & VALUE)
98
-- |--------------------------------------|----|------|------|
99
-- | Description | IC | Addr | Val |
100
-- |--------------------------------------|----|------|------|
101
-- | set SCROD reg=XX to val=YYYY | AF | XX | YYYY |
102
-- | set ASIC=X reg=YY to val=ZZZ | BX | YY | 0ZZZ |
103
-- | set HV DAC for ASIC=X ch=Y to val=ZZ | C0 | XY | 00ZZ |
104
-- | pause rcl fsm for XXXX00 clocks | AE | 00 | XXXX |
105
-- |--------------------------------------|----|------|------|
106
107
rcl_fifo_din_32
<=
ic
&
addr
&
val
;
108
rcl_fifo_frame_set
<=
'
1
'
when
rx_data_sr
(
47
downto
44
)
=
"1111"
and
rx_data_sr
(
3
downto
0
)
=
"1000"
else
'
0
'
;
-- we have a full frame with start and end bits in place- data driven, not ideal really
109
rcl_fifo_wr_en_32
<=
'
1
'
when
rcl_fifo_frame_set_q
=
"01"
else
'
0
'
;
110
111
shift_pcs :
process
(clk)
112
begin
113
if
(
clk
'
event
and
clk
=
'
1
'
)
then
114
115
rcl_fifo_frame_set_q
<=
rcl_fifo_frame_set_q
(
0
)
&
rcl_fifo_frame_set
;
116
117
if
rx_src_rdy_n
=
'
0
'
then
118
rx_data_sr
<=
rx_data_sr
(
31
downto
0
)
&
rx_data
;
119
end
if
;
120
121
-- intfc_bit <= rx_sof_n xor rx_eof_n xor rx_src_rdy_n;
122
-- rx_dst_rdy_n <= intfc_bit;
123
end
if
;
124
end
process
;
125
126
127
128
129
130
end
behave
;
fifo_cc
Definition:
mem.vhd:103
conc_intfc_pkg
Definition:
conc_intfc_pkg.vhd:24
klm_scint_pkg
Definition:
klm_scint_pkg.vhd:7
run_ctrl
Definition:
run_ctrl.vhd:36
klm_scrod
source
run_ctrl.vhd
Generated by
1.8.13