Commit b7a79518 authored by Theodor-Adrian Stana's avatar Theodor-Adrian Stana

Commit gateware v2.0

Signed-off-by: Theodor-Adrian Stana's avatarTheodor Stana <t.stana@cern.ch>
parent fb16540a
......@@ -24,9 +24,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.979899"
inkscape:cx="238.53388"
inkscape:cy="31.505915"
inkscape:zoom="2.8"
inkscape:cx="243.01672"
inkscape:cy="55.323408"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
......@@ -635,21 +635,81 @@
<text
sodipodi:linespacing="125%"
id="text3913"
y="187.79523"
x="458.85828"
y="186.02357"
x="387.99213"
style="font-size:10px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
xml:space="preserve"><tspan
style="text-align:end;text-anchor:end"
y="187.79523"
x="458.85828"
y="186.02357"
x="387.99213"
id="tspan3915"
sodipodi:role="line">trig_a_i</tspan></text>
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 294.46708,80.22441 26.5748,0"
d="m 223.60094,80.22441 97.44094,0"
id="path3917"
inkscape:connector-curvature="0"
transform="translate(166.16284,104.02751)"
sodipodi:nodetypes="cc" />
<path
sodipodi:type="arc"
style="fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:0.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
id="path3082"
sodipodi:cx="71.238731"
sodipodi:cy="64.279526"
sodipodi:rx="1.7716535"
sodipodi:ry="1.7716535"
d="m 73.010385,64.279526 c 0,0.978457 -0.793196,1.771653 -1.771654,1.771653 -0.978457,0 -1.771653,-0.793196 -1.771653,-1.771653 0,-0.978457 0.793196,-1.771654 1.771653,-1.771654 0.978458,0 1.771654,0.793197 1.771654,1.771654 z"
transform="translate(166.16284,104.02751)" />
<path
transform="translate(245.88725,181.98027)"
d="m 73.010385,64.279526 c 0,0.978457 -0.793196,1.771653 -1.771654,1.771653 -0.978457,0 -1.771653,-0.793196 -1.771653,-1.771653 0,-0.978457 0.793196,-1.771654 1.771653,-1.771654 0.978458,0 1.771654,0.793197 1.771654,1.771654 z"
sodipodi:ry="1.7716535"
sodipodi:rx="1.7716535"
sodipodi:cy="64.279526"
sodipodi:cx="71.238731"
id="path3852"
style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
sodipodi:type="arc" />
<path
sodipodi:type="arc"
style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="path3854"
sodipodi:cx="71.238731"
sodipodi:cy="64.279526"
sodipodi:rx="1.7716535"
sodipodi:ry="1.7716535"
d="m 73.010385,64.279526 c 0,0.978457 -0.793196,1.771653 -1.771654,1.771653 -0.978457,0 -1.771653,-0.793196 -1.771653,-1.771653 0,-0.978457 0.793196,-1.771654 1.771653,-1.771654 0.978458,0 1.771654,0.793197 1.771654,1.771654 z"
transform="translate(334.46993,181.98027)" />
<g
id="g3865"
transform="translate(1.1180648,-0.93550607)">
<g
id="g3873"
transform="translate(-1.8806337e-6,0)">
<g
id="g3878">
<rect
y="176.32916"
x="399.27563"
height="15.944878"
width="77.952759"
id="rect3085"
style="fill:#e5e5e5;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<text
sodipodi:linespacing="125%"
id="text3855"
y="187.1046"
x="438.25201"
style="font-size:10.340312px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
xml:space="preserve"><tspan
style="text-align:center;text-anchor:middle"
id="tspan3863"
y="187.1046"
x="438.25201"
sodipodi:role="line">First pulse inh.</tspan></text>
</g>
</g>
</g>
</g>
</svg>
This diff is collapsed.
This diff is collapsed.
......@@ -527,7 +527,7 @@ the input trigger is sampled with the 20~MHz clock prior to it being input to th
(see Figure~\ref{fig:hdl-bd}).
\begin{figure}[h]
\includegraphics[width=.9\textwidth]{fig/pulse-gen}
\centerline{\includegraphics[width=\textwidth]{fig/pulse-gen}}
\caption{Pulse generator block}
\label{fig:pulse-gen}
\end{figure}
......@@ -554,9 +554,15 @@ to a pulse length which is unsafe for the controlling MOSFET on the CONV-TTL-BLO
With the glitch filter enabled, the rising edge on \textit{SGF1} sets \textit{OGF1},
and this will be kept high until the counter reaches the value corresponding to the
pulse width. Note that since the external glitch filter already contains synchronization
FFs, the input trigger signal is already synchronized into the 20~MHz clock domain, and
is fed directly to the input of the FSM.
pulse width. The input trigger signal is synchronized into the 20~MHz clock domain outside
the \textit{conv\_pulse\_gen} block, and is fed directly to the input of the FSM.
Before being fed to the FSM, however, the glitch-filtered signal is passed through a \textit{pulse
inhibit circuit}, which inhibits the first pulse when the board is in TTL-BAR repetition mode.
In this mode, an unconnected channel is always HIGH and until the
\textit{no signal detect} block outside the \textit{conv\_pulse\_gen} block (see the next
subsection) triggers, the continuous HIGH signal will trigger a pulse, due to the reset
state of the rising-edge detector on the FSM input.
After the pulse generation period, the FSM goes into a pulse rejection state,
where the pulse reset is kept high. If any pulses arrive on the input while the FSM
......@@ -612,7 +618,7 @@ channel.
\end{figure}
Both the \textit{no signal detect} block and the glitch filter are generated
per each channel in the top-level VHDL file of the design.
for each channel in the top-level VHDL file of the design.
%==============================================================================
% SEC: Pulse counters
......@@ -727,10 +733,10 @@ state (Figure~\ref{fig:man-trig-fsm}).
\centerline
{
\begin{tabular}{l l l}
\begin{tabular}{l l p{.5\textwidth}}
\hline
\textbf{Entity} & \textit{pulse\_timetag} & \\
\textbf{Generics} & \textit{g\_clk\_rate} & Frequency in Hz of clk\_i signal \\
\textbf{Generics} & \textit{g\_clk\_rate} & Frequency in Hz of \textit{clk\_i} signal \\
& \textit{g\_nr\_chan} & Pulse repeater number of channels \\
\textbf{Ports} & \textit{clk\_i} & Clock signal \\
& \textit{rst\_n\_i} & Active-low reset signal \\
......@@ -747,7 +753,8 @@ state (Figure~\ref{fig:man-trig-fsm}).
& \textit{tm\_wpres\_o} & Time from WRPC is valid \\
& \textit{chan\_o} & Trigger channel to FIFO \\
& \textit{fifo\_full\_i} & FIFO status input \\
& \textit{fifo\_wr\_req\_o} & FIFO write request output \\
& \textit{fifo\_wr\_req\_o} & FIFO write request output, max. four clock cycles
delay after pulse rising edge \\
\hline
\end{tabular}
}
......@@ -755,37 +762,44 @@ state (Figure~\ref{fig:man-trig-fsm}).
\vspace*{11pt}
A simplified view of the time-tagging architecture is shown in Figure~\ref{fig:timetag-arch}.
There are two clock domains in the design. The time-tag controller and the time from the
WRPC are both in the 125~MHz clock domain, while the \textit{conv\_regs} component is in the
20~MHz clock domain. The FIFO is asynchronous and clocked by both the 125 and 20~MHz clocks.
\begin{figure}[h]
\centerline{\includegraphics[width=.97\textwidth]{fig/timetag-arch}}
\centerline{\includegraphics[width=.9\textwidth]{fig/timetag-arch}}
\caption{Time-tag architecture}
\label{fig:timetag-arch}
\end{figure}
The time-tag controller in the figure is the \textit{pulse\_timetag} VHDL component.
It is designed to be connected directly to the FIFO as shown above.
In fact, as opposed to what the simplified architecture above shows, the time-tag
controller also implements the local time counters. The block's design is presented in
Figure~\ref{fig:timetag-core}. This figure shows the functioning when the \textit{pulse\_timetag}
component is clocked from 125~MHz clock, as is the case in the converter board designs.
A free-running counter inside the block counts the ticks of the \textit{clk\_i} signal
to count the seconds. When it reaches the value \textit{g\_clk\_rate-1} (125~mega in
the figure), it resets and sends a "tick" to the TAI seconds counter, which then increments.
It is designed to be connected directly to the FIFO as shown above.As opposed to what the
simplified architecture above shows, the time-tag controller also implements the local time counters.
The block's design is presented in Figure~\ref{fig:timetag-core}. This figure shows the functioning
when the \textit{pulse\_timetag} component is clocked from the 125~MHz clock, as is the case in the
converter board designs. Note however that the component can work with any clock rate by changing
the \textit{g\_clk\_rate} generic.
\begin{figure}[h]
\centerline{\includegraphics[width=\textwidth]{fig/timetag-core}}
\centerline{\includegraphics[width=.9\textwidth]{fig/timetag-core}}
\caption{Time-tag controller logic}
\label{fig:timetag-core}
\end{figure}
A free-running counter inside the block counts the ticks of the \textit{clk\_i} signal
to count the seconds. When it reaches the value \textit{g\_clk\_rate-1} (125~mega in
the figure), it resets and sends a "tick" to the TAI seconds counter, which then increments.
As seen in Figure~\ref{fig:hdl-bd}, the pulse inputs are derived from the OR gate which
ORs together the TTL and blocking inputs. Since these pulses can be asynchronous, they
are synchronized in the 125~MHz domain and passed through rising edge detectors. A rising
edge on any channel then triggers the \textit{fifo\_wr\_req\_p\_o} output. As the port's
name suggests, this signal is a one-cycle pulse that triggers a write to the FIFO. Note
that the \textit{fifo\_full\_i} signal is also checked prior to triggering a write to the
FIFO. This is not shown in Figure~\ref{fig:timetag-core} in order to simplify it.
are synchronized in the 125~MHz domain and passed through rising edge detectors. If the
FIFO is not full, a rising edge on any channel then triggers the
\textit{fifo\_wr\_req\_p\_o} output. As the port's name suggests, this signal is a one-cycle
pulse that triggers a write to the FIFO.
Note that due to the synchronization logic, rising edge detector and the latching of the
ORed pulse rising edge detection signal, the \textit{fifo\_wr\_req\_p\_o} signal is
set between three and four cycles after the pulse signal actually arrives on the input.
All the output ports are connected externally directly to the FIFO, therefore when the
\textit{fifo\_wr\_req\_p\_o} output pulses, they are written to the FIFO. As shown in
......@@ -795,6 +809,15 @@ board status register (SR -- see Appendix~\ref{app:conv-regs-sr}).
The FIFO itself is generated using \textit{wbgen2}~\cite{wbgen2} and connected
on the top-level to the \textit{pulse\_timetag} component.
Due to the two clock domains in the design, some synchronization logic is needed. This is
achieved via \textit{gc\_sync\_ffs} components from the \textit{general-cores}
library~\cite{gencores-ohwr} in the case of the WR time valid signals storage to the SR
and in the case of the TAI time value load pulses from the \textit{conv\_regs} to the
\textit{pulse\_timetag} components.
The TAI time signal is not synchronized before being connected to the \textit{conv\_regs}
component, since its rate of change of once per second is considered too slow to present
any problem of synchronization when read by the user.
%======================================================================================
% SEC: Folder structure
......
......@@ -47,6 +47,8 @@
-- 02-08-2013 Theodor Stana Implemented rejection phase.
-- 17-02-2014 Theodor Stana Moved the glitch filter to outside the
-- module.
-- 04-03-2014 Theodor Stana Added first pulse inhibit on glitch-filtered
-- side.
--==============================================================================
-- TODO: -
--==============================================================================
......@@ -157,6 +159,9 @@ architecture behav of conv_pulse_gen is
signal pulse_gf_off : std_logic;
signal pulse_gf_off_rst : std_logic;
-- Inhibit first pulse
signal inh_fp_gf_on : std_logic;
-- Pulse length counter
signal pulse_cnt : unsigned(f_log2_size(6*g_pwidth)-1 downto 0);
......@@ -221,11 +226,22 @@ begin
pulse_gf_on <= '0';
pulse_cnt <= (others => '0');
trig_gf_on_d0 <= '0';
inh_fp_gf_on <= '1';
elsif (en_i = '1') then
-- Deglitched trigger delay
-- Deglitched trigger delay.
trig_gf_on_d0 <= trig_gf_on;
-- State machine
-- On the first cycle after the reset, the pulse channel needs to be
-- inhibited when the converter board is in TTL-BAR repetition mode,
-- since in this mode, an unconnected channel is HIGH for the first
-- 100us until the "no signal detect" block triggers, and the HIGH level
-- on the line will get interpreted by the trigger delay (due to its reset
-- state) as a rising edge on the line, thus triggering a pulse.
if inh_fp_gf_on = '1' then
inh_fp_gf_on <= '0';
end if;
-- State machine logic
case state is
---------------------------------------------------------------------
-- IDLE
......@@ -241,7 +257,8 @@ begin
state <= GEN_GF_OFF;
end if;
else
if (trig_gf_on = '1') and (trig_gf_on_d0 = '0') then
if (trig_gf_on = '1') and (trig_gf_on_d0 = '0') and
(inh_fp_gf_on = '0') then
state <= GEN_GF_ON;
end if;
end if;
......
This diff is collapsed.
......@@ -341,16 +341,16 @@
<file xil_pn:name="../../top/Release/conv_ttl_blo.ucf" xil_pn:type="FILE_UCF">
<association xil_pn:name="Implementation" xil_pn:seqID="1"/>
</file>
<file xil_pn:name="../../top/Release/conv_ttl_blo.vhd" xil_pn:type="FILE_VHDL">
<file xil_pn:name="../../ip_cores/general-cores/modules/genrams/genram_pkg.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="Implementation" xil_pn:seqID="2"/>
</file>
<file xil_pn:name="../../modules/Release/conv_regs.vhd" xil_pn:type="FILE_VHDL">
<file xil_pn:name="../../ip_cores/general-cores/modules/wishbone/wbgen2/wbgen2_pkg.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="Implementation" xil_pn:seqID="3"/>
</file>
<file xil_pn:name="../../modules/Release/conv_pulse_gen.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="Implementation" xil_pn:seqID="4"/>
</file>
<file xil_pn:name="../../modules/Release/conv_man_trig.vhd" xil_pn:type="FILE_VHDL">
<file xil_pn:name="../../ip_cores/general-cores/modules/common/gencores_pkg.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="Implementation" xil_pn:seqID="5"/>
</file>
<file xil_pn:name="../../modules/Release/pulse_timetag.vhd" xil_pn:type="FILE_VHDL">
......@@ -362,7 +362,7 @@
<file xil_pn:name="../../modules/rtm_detector.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="Implementation" xil_pn:seqID="8"/>
</file>
<file xil_pn:name="../../ip_cores/general-cores/modules/common/gencores_pkg.vhd" xil_pn:type="FILE_VHDL">
<file xil_pn:name="../../ip_cores/general-cores/modules/wishbone/wishbone_pkg.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="Implementation" xil_pn:seqID="9"/>
</file>
<file xil_pn:name="../../ip_cores/general-cores/modules/common/gc_crc_gen.vhd" xil_pn:type="FILE_VHDL">
......@@ -422,7 +422,7 @@
<file xil_pn:name="../../ip_cores/general-cores/modules/common/gc_fsm_watchdog.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="Implementation" xil_pn:seqID="28"/>
</file>
<file xil_pn:name="../../ip_cores/general-cores/modules/genrams/genram_pkg.vhd" xil_pn:type="FILE_VHDL">
<file xil_pn:name="../../modules/Release/conv_man_trig.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="Implementation" xil_pn:seqID="29"/>
</file>
<file xil_pn:name="../../ip_cores/general-cores/modules/genrams/memory_loader_pkg.vhd" xil_pn:type="FILE_VHDL">
......@@ -437,7 +437,7 @@
<file xil_pn:name="../../ip_cores/general-cores/modules/genrams/inferred_async_fifo.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="Implementation" xil_pn:seqID="33"/>
</file>
<file xil_pn:name="../../ip_cores/general-cores/modules/wishbone/wishbone_pkg.vhd" xil_pn:type="FILE_VHDL">
<file xil_pn:name="../../modules/bicolor_led_ctrl/bicolor_led_ctrl_pkg.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="Implementation" xil_pn:seqID="34"/>
</file>
<file xil_pn:name="../../ip_cores/general-cores/modules/genrams/xilinx/generic_dpram.vhd" xil_pn:type="FILE_VHDL">
......@@ -521,10 +521,10 @@
<file xil_pn:name="../../ip_cores/general-cores/modules/wishbone/wb_uart/uart_baud_gen.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="Implementation" xil_pn:seqID="61"/>
</file>
<file xil_pn:name="../../ip_cores/general-cores/modules/wishbone/wb_uart/simple_uart_wb.vhd" xil_pn:type="FILE_VHDL">
<file xil_pn:name="../../ip_cores/general-cores/modules/wishbone/wb_uart/simple_uart_pkg.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="Implementation" xil_pn:seqID="62"/>
</file>
<file xil_pn:name="../../ip_cores/general-cores/modules/wishbone/wb_uart/simple_uart_pkg.vhd" xil_pn:type="FILE_VHDL">
<file xil_pn:name="../../ip_cores/general-cores/modules/wishbone/wb_uart/simple_uart_wb.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="Implementation" xil_pn:seqID="63"/>
</file>
<file xil_pn:name="../../ip_cores/general-cores/modules/wishbone/wb_uart/wb_simple_uart.vhd" xil_pn:type="FILE_VHDL">
......@@ -569,7 +569,7 @@
<file xil_pn:name="../../ip_cores/general-cores/modules/wishbone/wb_crossbar/xwb_sdb_crossbar.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="Implementation" xil_pn:seqID="77"/>
</file>
<file xil_pn:name="../../ip_cores/general-cores/modules/wishbone/wb_irq/wb_irq_timer.vhd" xil_pn:type="FILE_VHDL">
<file xil_pn:name="../../ip_cores/general-cores/modules/wishbone/wb_irq/wb_irq_pkg.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="Implementation" xil_pn:seqID="78"/>
</file>
<file xil_pn:name="../../ip_cores/general-cores/modules/wishbone/wb_irq/irqm_core.vhd" xil_pn:type="FILE_VHDL">
......@@ -584,7 +584,7 @@
<file xil_pn:name="../../ip_cores/general-cores/modules/wishbone/wb_irq/wb_irq_master.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="Implementation" xil_pn:seqID="82"/>
</file>
<file xil_pn:name="../../ip_cores/general-cores/modules/wishbone/wb_irq/wb_irq_pkg.vhd" xil_pn:type="FILE_VHDL">
<file xil_pn:name="../../ip_cores/general-cores/modules/wishbone/wb_irq/wb_irq_timer.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="Implementation" xil_pn:seqID="83"/>
</file>
<file xil_pn:name="../../ip_cores/general-cores/modules/wishbone/wb_lm32/generated/xwb_lm32.vhd" xil_pn:type="FILE_VHDL">
......@@ -668,16 +668,16 @@
<file xil_pn:name="../../ip_cores/general-cores/modules/wishbone/wbgen2/wbgen2_fifo_sync.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="Implementation" xil_pn:seqID="110"/>
</file>
<file xil_pn:name="../../ip_cores/general-cores/modules/wishbone/wbgen2/wbgen2_pkg.vhd" xil_pn:type="FILE_VHDL">
<file xil_pn:name="../../modules/Release/conv_regs.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="Implementation" xil_pn:seqID="111"/>
</file>
<file xil_pn:name="../../ip_cores/general-cores/platform/xilinx/wb_xilinx_fpga_loader/wb_xilinx_fpga_loader.vhd" xil_pn:type="FILE_VHDL">
<file xil_pn:name="../../ip_cores/general-cores/platform/xilinx/wb_xilinx_fpga_loader/xloader_registers_pkg.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="Implementation" xil_pn:seqID="112"/>
</file>
<file xil_pn:name="../../ip_cores/general-cores/platform/xilinx/wb_xilinx_fpga_loader/xwb_xilinx_fpga_loader.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="Implementation" xil_pn:seqID="113"/>
</file>
<file xil_pn:name="../../ip_cores/general-cores/platform/xilinx/wb_xilinx_fpga_loader/xloader_registers_pkg.vhd" xil_pn:type="FILE_VHDL">
<file xil_pn:name="../../ip_cores/general-cores/platform/xilinx/wb_xilinx_fpga_loader/wb_xilinx_fpga_loader.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="Implementation" xil_pn:seqID="114"/>
</file>
<file xil_pn:name="../../ip_cores/general-cores/platform/xilinx/wb_xilinx_fpga_loader/xloader_wb.vhd" xil_pn:type="FILE_VHDL">
......@@ -695,7 +695,7 @@
<file xil_pn:name="../../ip_cores/general-cores/platform/xilinx/wb_xil_multiboot/wb_xil_multiboot.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="Implementation" xil_pn:seqID="119"/>
</file>
<file xil_pn:name="../../modules/bicolor_led_ctrl/bicolor_led_ctrl_pkg.vhd" xil_pn:type="FILE_VHDL">
<file xil_pn:name="../../top/Release/conv_ttl_blo.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="Implementation" xil_pn:seqID="120"/>
</file>
<file xil_pn:name="../../modules/bicolor_led_ctrl/bicolor_led_ctrl.vhd" xil_pn:type="FILE_VHDL">
......
......@@ -59,7 +59,8 @@ entity conv_ttl_blo is
generic
(
g_nr_ttl_chan : natural := 6;
g_nr_inv_chan : natural := 4
g_nr_inv_chan : natural := 4;
g_sim : boolean := false
);
port
(
......@@ -161,6 +162,21 @@ architecture behav of conv_ttl_blo is
type t_pulse_cnt is array (1 to g_nr_ttl_chan) of unsigned(31 downto 0);
type t_ch_pcr is array (1 to g_nr_ttl_chan) of std_logic_vector(31 downto 0);
--============================================================================
-- Function and procedure declarations
--============================================================================
function f_reset_width return positive is
variable retval : positive;
begin
retval := 2*(10**6);
if g_sim then
retval := 20;
end if;
assert false report "Reset width: " & integer'image(retval)
& "*50ns" severity Note;
return retval;
end function f_reset_width;
--============================================================================
-- Constant declarations
--============================================================================
......@@ -529,12 +545,12 @@ architecture behav of conv_ttl_blo is
signal trig_a : std_logic_vector(g_nr_ttl_chan downto 1);
signal trig_ttl_a : std_logic_vector(g_nr_ttl_chan downto 1);
signal trig_blo_a : std_logic_vector(g_nr_ttl_chan downto 1);
signal trig_degl : std_logic_vector(g_nr_ttl_chan downto 1);
signal trig_synced_r_edge_p : std_logic_vector(g_nr_ttl_chan downto 1);
signal trig_synced : std_logic_vector(g_nr_ttl_chan downto 1);
signal trig : std_logic_vector(g_nr_ttl_chan downto 1);
signal trig_degl : std_logic_vector(g_nr_ttl_chan downto 1);
signal trig_chan : std_logic_vector(g_nr_ttl_chan downto 1);
signal trig_man : std_logic_vector(g_nr_ttl_chan downto 1);
signal pgen_trig : std_logic_vector(g_nr_ttl_chan downto 1);
signal pcnt_trig_p : std_logic_vector(g_nr_ttl_chan downto 1);
-- TTL-BAR lack of signal counter
signal ttlbar_nosig_cnt : t_ttlbar_nosig_cnt;
......@@ -615,7 +631,7 @@ begin
generic map
(
-- Reset time: 50ns * 2 * (10**6) = 100 ms
g_reset_time => 2*(10**6)
g_reset_time => f_reset_width
)
port map
(
......@@ -909,35 +925,7 @@ begin
-- TTL and blocking pulse generation logic
--============================================================================
------------------------------------------------------------------------------
-- TTL and blocking inputs, input GF and input channel MUX based on GF switch
------------------------------------------------------------------------------
trig_ttl_a <= not fpga_input_ttl_n_i when (ttl_switch_n_i = '0') else
fpga_input_ttl_n_i and ttlbar_nosig_n;
trig_blo_a <= fpga_blo_in_i;
trig_a <= trig_ttl_a or trig_blo_a;
-- Input channel glitch filter
gen_glitch_filt : for i in 1 to g_nr_ttl_chan generate
cmp_inp_glitch_filt : gc_glitch_filt
generic map
(
g_len => c_pulse_gen_gf_len
)
port map
(
clk_i => clk_20_vcxo_i,
rst_n_i => rst_20_n,
dat_i => trig_a(i),
dat_o => trig_degl(i)
);
end generate gen_glitch_filt;
-- Channel trigger MUX
trig_chan <= trig_a when extra_switch_n_i(1) = '1' else
trig_degl;
------------------------------------------------------------------------------
-- Pulse time-tagging logic after input channale MUX
-- Pulse time-tagging logic after input channel MUX
------------------------------------------------------------------------------
cmp_pulse_timetag : pulse_timetag
generic map
......@@ -1001,29 +989,96 @@ begin
trig_o => trig_man
);
------------------------------------------------------------------------------
-- FINALLY, the trigger input to the pulse generator block
------------------------------------------------------------------------------
trig <= trig_chan or trig_man;
------------------------------------------------------------------------------
-- Generate pulse repetition logic
------------------------------------------------------------------------------
gen_pulse_logic : for i in 1 to g_nr_ttl_chan generate
-- First, resync the trigger signal into clk_20_vcxo_i domain
-- First, the "no signal detect" blocks
--
-- If the signal line is high for 100 us, the ttlbar_nosig_n lines disable
-- the input to the TTL side MUX and the OR gate.
--
-- The counter is disabled if the switch is set for TTL signals, to avoid
-- unnecessary power consumption by the counter.
p_ttlbar_nosig : process(clk_20_vcxo_i)
begin
if rising_edge(clk_20_vcxo_i) then
if (rst_20_n = '0') or (fpga_input_ttl_n_i(i) = '0') then
ttlbar_nosig_n(i) <= '1';
ttlbar_nosig_cnt(i) <= (others => '0');
elsif (ttl_switch_n_i = '1') then
ttlbar_nosig_cnt(i) <= ttlbar_nosig_cnt(i) + 1;
if (ttlbar_nosig_cnt(i) = 1999) then
ttlbar_nosig_n(i) <= '0';
ttlbar_nosig_cnt(i) <= (others => '0');
end if;
end if;
end if;
end process p_ttlbar_nosig;
-- The first OR gate at the channel inputs
trig_ttl_a(i) <= not fpga_input_ttl_n_i(i) when (ttl_switch_n_i = '0') else
fpga_input_ttl_n_i(i) and ttlbar_nosig_n(i);
trig_blo_a(i) <= fpga_blo_in_i(i);
trig_a(i) <= trig_ttl_a(i) or trig_blo_a(i);
-- Then, synchronize the asynchronous trigger input into the 20 MHz clock
-- domain before passing it to the glitch filter
--
-- Reset value is '1' to avoid pulses being counted by pulse counter on
-- startup, when the board is in TTL-BAR repetition mode.
cmp_trig_sync : gc_sync_ffs
generic map
(
g_sync_edge => "positive"
)
port map
(
clk_i => clk_20_vcxo_i,
rst_n_i => '1',
data_i => trig_a(i),
synced_o => trig_synced(i)
);
-- Deglitch synchronized trigger signal
--
-- Reset value is '1' to avoid pulses being counted by pulse counter on
-- startup, when the board is in TTL-BAR repetition mode.
cmp_inp_glitch_filt : gc_glitch_filt
generic map
(
g_len => c_pulse_gen_gf_len
)
port map
(
clk_i => clk_20_vcxo_i,
rst_n_i => '1',
dat_i => trig_synced(i),
dat_o => trig_degl(i)
);
-- Now that we have a deglitched signal, generate the MUX to select between
-- deglitched and direct channel input
trig_chan(i) <= trig_a(i) when extra_switch_n_i(1) = '1' else
trig_degl(i);
-- Now, sync this channel trigger signal before passing it to the counters
--
-- Reset value is '1' to avoid pulses being counted by pulse counter on
-- startup, when the board is in TTL-BAR repetition mode.
--
-- NOTE: glitch-filtered signal is also synced in 20MHz clock domain, but
-- another sync chain here avoids extra logic complication and has no
-- influence on the correctness of the pulse counter value considering the
-- max expected pulse frequency
cmp_sync_ffs: gc_sync_ffs
cmp_sync_ffs : gc_sync_ffs
port map
(
clk_i => clk_20_vcxo_i,
rst_n_i => '1',
data_i => trig_chan(i),
synced_o => trig_synced(i),
ppulse_o => trig_synced_r_edge_p(i)
ppulse_o => pcnt_trig_p(i)
);
-- Then, generate the input pulse counters
......@@ -1034,34 +1089,14 @@ begin
pulse_cnt(i) <= (others => '0');
elsif (ch_pcr_ld(i) = '1') then
pulse_cnt(i) <= unsigned(ch_pcr(i));
elsif (trig_synced_r_edge_p(i) = '1') then
elsif (pcnt_trig_p(i) = '1') then
pulse_cnt(i) <= pulse_cnt(i) + 1;
end if;
end if;
end process p_pulse_cnt;
-- Process to detect lack of signal on TTL line
--
-- If the signal line is high for 100 us, the ttlbar_nosig_n lines disable
-- the mux input.
--
-- Counter is disabled if the switch is set for TTL signals, to avoid
-- unnecessary power consumption from the counter.
p_ttlbar_nosig : process(clk_20_vcxo_i)
begin
if rising_edge(clk_20_vcxo_i) then
if (rst_20_n = '0') or (fpga_input_ttl_n_i(i) = '0') then
ttlbar_nosig_n(i) <= '1';
ttlbar_nosig_cnt(i) <= (others => '0');
elsif (ttl_switch_n_i = '1') then
ttlbar_nosig_cnt(i) <= ttlbar_nosig_cnt(i) + 1;
if (ttlbar_nosig_cnt(i) = 1999) then
ttlbar_nosig_n(i) <= '0';
ttlbar_nosig_cnt(i) <= (others => '0');
end if;
end if;
end if;
end process p_ttlbar_nosig;
-- FINALLY, the trigger input to the pulse generator block
pgen_trig(i) <= trig_chan(i) or trig_man(i);
-- Output pulse generators
cmp_pulse_gen : conv_pulse_gen
......@@ -1075,7 +1110,7 @@ begin
rst_n_i => rst_20_n,
en_i => '1',
gf_en_n_i => extra_switch_n_i(1),
trig_a_i => trig(i),
trig_a_i => pgen_trig(i),
pulse_o => pulse_outp(i)
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment