| 1 |
2 |
panda_emc |
-----------------------------------------------------------------------------------------------
|
| 2 |
|
|
--
|
| 3 |
|
|
-- Copyright (C) 2011 Peter Lemmens, PANDA collaboration
|
| 4 |
|
|
-- p.j.j.lemmens@rug.nl
|
| 5 |
|
|
-- http://www-panda.gsi.de
|
| 6 |
|
|
--
|
| 7 |
|
|
-- As a reference, please use:
|
| 8 |
|
|
-- E. Guliyev, M. Kavatsyuk, P.J.J. Lemmens, G. Tambave, H. Loehner,
|
| 9 |
|
|
-- "VHDL Implementation of Feature-Extraction Algorithm for the PANDA Electromagnetic Calorimeter"
|
| 10 |
|
|
-- Nuclear Inst. and Methods in Physics Research, A ....
|
| 11 |
|
|
--
|
| 12 |
|
|
--
|
| 13 |
|
|
-- This program is free software; you can redistribute it and/or modify
|
| 14 |
|
|
-- it under the terms of the GNU Lesser General Public License as published by
|
| 15 |
|
|
-- the Free Software Foundation; either version 3 of the License, or
|
| 16 |
|
|
-- (at your option) any later version.
|
| 17 |
|
|
--
|
| 18 |
|
|
-- This program is distributed in the hope that it will be useful,
|
| 19 |
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 20 |
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 21 |
|
|
-- GNU Lesser General Public License for more details.
|
| 22 |
|
|
--
|
| 23 |
|
|
-- You should have received a copy of the GNU General Public License
|
| 24 |
|
|
-- along with this program; if not, write to the Free Software
|
| 25 |
|
|
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
|
| 26 |
|
|
--
|
| 27 |
|
|
-----------------------------------------------------------------------------------------------
|
| 28 |
|
|
-- Company : KVI (Kernfysisch Versneller Instituut -- Groningen, The Netherlands
|
| 29 |
|
|
-- Author : P.J.J. Lemmens
|
| 30 |
|
|
-- Design Name : Feature Extraction
|
| 31 |
|
|
-- Module Name : adc_flow_control.vhd
|
| 32 |
|
|
-- Description : The SIS3301/2 shares memory between the ADCs and VME. On the adc side
|
| 33 |
|
|
-- each controlling fpga gets a base address and a chunk of memory to write into.
|
| 34 |
|
|
-- The memory is not directly written into but through a pair of FIFOs; one
|
| 35 |
|
|
-- for the data (32bit) and one for the address(32 bit) to which you want to
|
| 36 |
|
|
-- write. This module builds 32-bit words for the data fifo from 16-bit words
|
| 37 |
|
|
-- of data from the signal-processing. Each 2nd 32 bit data word is accompanied
|
| 38 |
|
|
-- by a 32-bit address. (also see the adc_flowcontrol describtion)
|
| 39 |
|
|
-- Data is writen twice, address only once.
|
| 40 |
|
|
--
|
| 41 |
|
|
-----------------------------------------------------------------------------------------------
|
| 42 |
|
|
library IEEE;
|
| 43 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
| 44 |
|
|
use IEEE.STD_LOGIC_ARITH.ALL;
|
| 45 |
|
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
| 46 |
|
|
|
| 47 |
|
|
entity ringbuffer_feed is
|
| 48 |
|
|
port( rst : in std_logic;
|
| 49 |
|
|
clk : in std_logic;
|
| 50 |
|
|
enable : in std_logic;
|
| 51 |
|
|
data_in : in STD_LOGIC_VECTOR(15 downto 0);
|
| 52 |
|
|
address_in : in STD_LOGIC_VECTOR(31 downto 0);
|
| 53 |
|
|
data_out_valid : out std_logic;
|
| 54 |
|
|
addr_out_valid : out std_logic;
|
| 55 |
|
|
data_out : out STD_LOGIC_VECTOR(31 downto 0);
|
| 56 |
|
|
address_out : out STD_LOGIC_VECTOR(31 downto 0)
|
| 57 |
|
|
);
|
| 58 |
|
|
end ringbuffer_feed;
|
| 59 |
|
|
|
| 60 |
|
|
architecture Behavioral of ringbuffer_feed is
|
| 61 |
|
|
|
| 62 |
|
|
type word_state_type is (word_a,word_b,word_c,word_d);
|
| 63 |
|
|
|
| 64 |
|
|
signal word_state_S : word_state_type := word_a;
|
| 65 |
|
|
|
| 66 |
|
|
signal rst_S : std_logic := '1';
|
| 67 |
|
|
signal clk_S : std_logic := '0';
|
| 68 |
|
|
signal enable_S : std_logic := '0';
|
| 69 |
|
|
signal data_in_S : std_logic_vector(15 downto 0) := (others => '0');
|
| 70 |
|
|
signal address_in_S : std_logic_vector(31 downto 0) := (others => '0');
|
| 71 |
|
|
signal data_valid_S : std_logic := '0';
|
| 72 |
|
|
signal addr_valid_S : std_logic := '0';
|
| 73 |
|
|
signal data_out_S : std_logic_vector(31 downto 0) := (others => '0');
|
| 74 |
|
|
signal address_out_S : std_logic_vector(31 downto 0) := (others => '0');
|
| 75 |
|
|
|
| 76 |
|
|
begin
|
| 77 |
|
|
|
| 78 |
|
|
rst_S <= rst;
|
| 79 |
|
|
clk_S <= clk;
|
| 80 |
|
|
enable_S <= enable;
|
| 81 |
|
|
|
| 82 |
|
|
data_out_valid <= data_valid_S;
|
| 83 |
|
|
addr_out_valid <= addr_valid_S;
|
| 84 |
|
|
data_out <= data_out_S;
|
| 85 |
|
|
address_out <= address_out_S;
|
| 86 |
|
|
|
| 87 |
|
|
|
| 88 |
|
|
fsm_ringbuffer_feed : process(rst_S, clk_S, enable_S)
|
| 89 |
|
|
begin
|
| 90 |
|
|
if rising_edge(clk_S) then
|
| 91 |
|
|
data_in_S <= data_in;
|
| 92 |
|
|
address_in_S <= address_in;
|
| 93 |
|
|
if (rst_S = '1') then
|
| 94 |
|
|
word_state_S <= word_a;
|
| 95 |
|
|
data_valid_S <= '0';
|
| 96 |
|
|
addr_valid_S <= '0';
|
| 97 |
|
|
data_in_S <= (others => '0');
|
| 98 |
|
|
address_in_S <= (others => '0');
|
| 99 |
|
|
data_out_S <= (others => '0');
|
| 100 |
|
|
address_out_S <= (others => '0');
|
| 101 |
|
|
elsif (enable_S = '1') then
|
| 102 |
|
|
|
| 103 |
|
|
case word_state_S is
|
| 104 |
|
|
when word_a =>
|
| 105 |
|
|
word_state_S <= word_b;
|
| 106 |
|
|
data_out_S(15 downto 0) <= data_in_S;
|
| 107 |
|
|
data_valid_S <= '0';
|
| 108 |
|
|
addr_valid_S <= '0';
|
| 109 |
|
|
when word_b =>
|
| 110 |
|
|
word_state_S <= word_c;
|
| 111 |
|
|
data_out_S(31 downto 16) <= data_in_S;
|
| 112 |
|
|
address_out_S <= address_in_S(31 downto 2) & b"00";
|
| 113 |
|
|
data_valid_S <= '1';
|
| 114 |
|
|
addr_valid_S <= '0';
|
| 115 |
|
|
when word_c =>
|
| 116 |
|
|
word_state_S <= word_d;
|
| 117 |
|
|
data_out_S(15 downto 0) <= data_in_S;
|
| 118 |
|
|
data_valid_S <= '0';
|
| 119 |
|
|
addr_valid_S <= '0';
|
| 120 |
|
|
when word_d =>
|
| 121 |
|
|
word_state_S <= word_a;
|
| 122 |
|
|
data_out_S(31 downto 16) <= data_in_S;
|
| 123 |
|
|
address_out_S <= address_in_S(31 downto 2) & b"00";
|
| 124 |
|
|
data_valid_S <= '1';
|
| 125 |
|
|
addr_valid_S <= '1';
|
| 126 |
|
|
when others =>
|
| 127 |
|
|
word_state_S <= word_a;
|
| 128 |
|
|
data_valid_S <= '0';
|
| 129 |
|
|
addr_valid_S <= '0';
|
| 130 |
|
|
end case;
|
| 131 |
|
|
|
| 132 |
|
|
else
|
| 133 |
|
|
data_valid_S <= '0';
|
| 134 |
|
|
addr_valid_S <= '0';
|
| 135 |
|
|
end if;
|
| 136 |
|
|
end if;
|
| 137 |
|
|
end process;
|
| 138 |
|
|
|
| 139 |
|
|
end Behavioral;
|
| 140 |
|
|
|