Commit fb9e6d87 authored by pabloalvarez's avatar pabloalvarez

status and reset added.

Some details to fix, such as field drive special pins and reset width
Not simulated!

git-svn-id: http://svn.ohwr.org/cern-fip/trunk/hdl/design@14 7f0067c9-7624-46c7-bd39-3fb5400c0213
parent 0666e279
--===========================================================================
--! @file deglitcher.vhd
--! @brief Deserialises the WorldFIP data
--! @brief Glitch filter. 1 pulse adapted filter.
--===========================================================================
--! Standard library
library IEEE;
......@@ -19,10 +19,10 @@ use IEEE.NUMERIC_STD.all; --! conversion functions
--
-- unit name: deglitcher
--
--! @brief 1 microsecond pulse adapted filter
--! @brief Glitch filter. 1 pulse adapted filter.
--!
--!
--!
--! Used in the NanoFIP design. \n
--! This unit serializes the data.
--!
--!
--! @author Pablo Alvarez Sanchez (Pablo.Alvarez.Sanchez@cern.ch)
......@@ -63,11 +63,11 @@ use IEEE.NUMERIC_STD.all; --! conversion functions
--! Entity declaration for deglitcher
--============================================================================
entity deglitcher is
entity deglitcher is
Generic (C_ACULENGTH : integer := 10);
Port ( uclk_i : in STD_LOGIC;
d_i : in STD_LOGIC;
d_o : out STD_LOGIC;
d_o : out STD_LOGIC;
carrier_p_i : in STD_LOGIC;
d_ready_p_o : out STD_LOGIC);
end deglitcher;
......@@ -94,7 +94,7 @@ process(uclk_i)
begin if rising_edge(uclk_i) then
if carrier_p_i = '1' then
d_o <= s_onesc(s_onesc'left);
end if;
end if;
d_ready_p_o <= carrier_p_i;
end if;
end process;
......
......@@ -257,13 +257,26 @@ signal s_crc_ok_from_rx : std_logic;
signal fss_decoded_p_from_rx : std_logic;
signal frame_ok_from_rx : std_logic;
signal s_stat : std_logic_vector(7 downto 0);
--signal
signal s_ack_produced, s_ack_consumed, s_ack_o: std_logic;
signal s_stat_sent_p, s_sending_stat: std_logic;
signal s_mps_sent_p, s_sending_mps: std_logic;
signal s_code_violation_p : std_logic;
signal s_crc_bad_p : std_logic;
signal s_var1_rdy : std_logic;
signal s_var2_rdy : std_logic;
signal s_var3_rdy : std_logic;
signal s_var1_access_wb_clk : std_logic;
signal s_var2_access_wb_clk : std_logic;
signal s_var3_access_wb_clk : std_logic;
signal s_reset_var1_access : std_logic;
signal s_reset_var2_access : std_logic;
signal s_reset_var3_access : std_logic;
--signal s_stat : std_logic_vector(7 downto 0);
signal s_mps : std_logic_vector(7 downto 0);
begin
s_rst <= rst_i;
----! Placeholder for WorldFIP transmitter/receiver
uwf_tx_rx : wf_tx_rx
port map(
......@@ -290,6 +303,9 @@ port map(
fss_decoded_p_o => fss_decoded_p_from_rx, -- The frame decoder has detected the start of a frame
last_byte_p_o => s_last_byte_from_rx_p,
code_violation_p_o => s_code_violation_p,
crc_bad_p_o => s_crc_bad_p,
crc_ok_p_o => s_crc_ok_from_rx
);
......@@ -355,12 +371,22 @@ port map(
var_i => s_var_from_control,
add_offset_i => s_add_offset_from_control,
byte_i => s_byte_from_rx,
dat_o => open, --!
adr_i => addr_from_wb --!
var1_access_wb_clk_o => s_var1_access_wb_clk,
var2_access_wb_clk_o => s_var2_access_wb_clk,
reset_var1_access_i => s_reset_var1_access,
reset_var2_access_i => s_reset_var2_access,
wb_clk_i => wclk_i,
wb_dat_o => dat_o,
wb_adr_i => adr_i,
wb_stb_p_i => stb_i,
wb_ack_p_o => s_ack_consumed,
wb_we_p_i => we_i
);
addr_from_wb <= (others => '0');
uwf_produced_vars : wf_produced_vars
......@@ -371,18 +397,65 @@ port map(
c_id_i => c_id_i, --! Constructor identification settings
slone_i => slone_i, --! Stand-alone mode
nostat_i => nostat_i, --! No NanoFIP status transmission
stat_i => s_stat, -- NanoFIP status
sending_stat_o => s_sending_stat, --! The status register is being adressed
sending_mps_o => s_sending_mps, --! The status register is being adressed
stat_i => s_stat, -- NanoFIP status
mps_i => s_mps,
var3_access_wb_clk_o => s_var3_access_wb_clk,
reset_var3_access_i => s_reset_var3_access,
var_i => s_var_from_control,
append_status_i => s_append_status_from_control,
add_offset_i => s_add_offset_from_control,
data_length_i => s_data_length_from_control,
byte_o => s_byte_to_tx,
dat_i => dat_i, --!
adr_i => adr_i, --!
we_p_i => we_i --! Write enable
byte_o => s_byte_to_tx,
-------------------------------------------------------------------------------
--! USER INTERFACE. Data and address lines synchronized with uclk_i
-------------------------------------------------------------------------------
wb_dat_i => dat_i,
wb_clk_i => wclk_i,
wb_adr_i => adr_i,
wb_stb_p_i => stb_i,
wb_ack_p_o => s_ack_produced,
wb_we_p_i => we_i
);
ustatus_gen : status_gen
port map(
uclk_i => uclk_i,
rst_i => rst_i,
);
s_stat <= (others => '0');
fd_wdgn_i => fd_wdgn_i,
fd_txer_i => fd_txer_i,
code_violation_p_i => s_code_violation_p,
crc_bad_p_i => s_crc_bad_p,
var1_rdy_i => s_var1_rdy,
var2_rdy_i => s_var2_rdy,
var3_rdy_i => s_var3_rdy,
var1_access_a_i => s_var1_access_wb_clk,
var2_access_a_i => s_var2_access_wb_clk,
var3_access_a_i => s_var3_access_wb_clk,
reset_var1_access_o => s_reset_var1_access,
reset_var2_access_o => s_reset_var2_access,
reset_var3_access_o => s_reset_var3_access,
stat_sent_p_i => s_stat_sent_p,
mps_sent_p_i => s_mps_sent_p,
stat_o => s_stat,
mps_o => s_mps
);
s_ack_o <= s_ack_produced or s_ack_consumed;
s_stat_sent_p <= s_sending_stat and s_byte_to_tx_ready_p; --! The status register is being adressed
s_mps_sent_p <= s_sending_stat and s_byte_to_tx_ready_p; --! The status register is being adressed
end architecture struc;
--============================================================================
--============================================================================
......
--===========================================================================
--! @file reset_logic.vhd
--! @brief Reset logic
--===========================================================================
--! Standard library
library IEEE;
--! Standard packages
use IEEE.STD_LOGIC_1164.all; --! std_logic definitions
use IEEE.NUMERIC_STD.all; --! conversion functions
-------------------------------------------------------------------------------
-- --
-- reset_logic --
-- --
-- CERN, BE/CO/HT --
-- --
-------------------------------------------------------------------------------
--
-- unit name: reset_logic
--
--! @brief Reset logic.
--!
--! Used in the NanoFIP design. \n
--! The reset_logic implements the power-on reset and other resets (consumption
--! of the reset variable).
--!
--!
--! @author Erik van der Bij (Erik.van.der.Bij@cern.ch)
--
--! @date 07/07/2009
--
--! @version v0.01
--
--! @details
--!
--! <b>Dependencies:</b>\n
--! wf_engine \n
--!
--! <b>References:</b>\n
--!
--!
--!
--! <b>Modified by:</b>\n
--! Author: Erik van der Bij
-------------------------------------------------------------------------------
--! \n\n<b>Last changes:</b>\n
--! 07/07/2009 v0.01 EB First version \n
--!
-------------------------------------------------------------------------------
--! @todo Define I/O signals \n
--!
-------------------------------------------------------------------------------
--============================================================================
--! Entity declaration for reset_logic
--============================================================================
entity reset_logic is
--===========================================================================
--! @file reset_logic.vhd
--! @brief Reset logic
--===========================================================================
--! Standard library
library IEEE;
--! Standard packages
use IEEE.STD_LOGIC_1164.all; --! std_logic definitions
use IEEE.NUMERIC_STD.all; --! conversion functions
-------------------------------------------------------------------------------
-- --
-- reset_logic --
-- --
-- CERN, BE/CO/HT --
-- --
-------------------------------------------------------------------------------
--
-- unit name: reset_logic
--
--! @brief Reset logic.
--!
--! Used in the NanoFIP design. \n
--! The reset_logic implements the power-on reset and other resets (consumption
--! of the reset variable).
--!
--!
--! @author Erik van der Bij (Erik.van.der.Bij@cern.ch)
--
--! @date 07/07/2009
--
--! @version v0.01
--
--! @details
--!
--! <b>Dependencies:</b>\n
--! wf_engine \n
--!
--! <b>References:</b>\n
--!
--!
--!
--! <b>Modified by:</b>\n
--! Author: Erik van der Bij
-------------------------------------------------------------------------------
--! \n\n<b>Last changes:</b>\n
--! 07/07/2009 v0.01 EB First version \n
--!
-------------------------------------------------------------------------------
--! @todo Define I/O signals \n
--!
-------------------------------------------------------------------------------
--============================================================================
--! Entity declaration for reset_logic
--============================================================================
entity reset_logic is
port (
-------------------------------------------------------------------------------
-- Connections to wf_engine
-------------------------------------------------------------------------------
du1_i : in std_logic; --! Strobe
du2_o : out std_logic; --! Acknowledge
du3_i : in std_logic --! Write enable
uclk_i : in std_logic; --! User Clock
rstin_i : in std_logic; --! Initialisation control, active low
--! Reset output, active low. Active when the reset variable is received
--! and the second byte contains the station address.
rston_o : out std_logic; --! Reset output, active low
);
end entity reset_logic;
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- COMPONENT DECLARATIONS
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
var_i : in t_var;
rst_o : out std_logic; --! Reset ouput active high
);
end entity reset_logic;
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
--! ARCHITECTURE OF reset_logic
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
architecture rtl of reset_logic is
signal s_rstin_d : std_logic_vector(1 downto 0);
begin
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
--! ARCHITECTURE OF reset_logic
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
architecture rtl of reset_logic is
process(uclk_i)
begin
if rising_edge(uclk_i) then
s_rstin_d <= s_rstin_d(0) & (not rstin_i);
if var_i = c_var_array(c_var_reset_pos).c_st_var_reset then
rst_o <= '1';
else
rst_o <= s_rstin_d(1);
end if;
end if;
end process;
end architecture rtl;
-------------------------------------------------------------------------------
-- E N D O F F I L E
-------------------------------------------------------------------------------
rston_o <= not rst_o;
end architecture rtl;
-------------------------------------------------------------------------------
-- E N D O F F I L E
-------------------------------------------------------------------------------
This diff is collapsed.
......@@ -78,17 +78,22 @@ port (
-- data_length_i : in std_logic_vector(6 downto 0);
byte_i : in std_logic_vector(7 downto 0);
var1_access_wb_clk_o: out std_logic; --! Variable 1 access flag
var2_access_wb_clk_o: out std_logic; --! Variable 2 access flag
reset_var1_access_i: in std_logic; --! Reset Variable 1 access flag
reset_var2_access_i: in std_logic; --! Reset Variable 2 access flag
-------------------------------------------------------------------------------
--! USER INTERFACE. Data and address lines synchronized with uclk_i
-------------------------------------------------------------------------------
-- dat_i : in std_logic_vector (15 downto 0); --!
dat_o : out std_logic_vector (15 downto 0); --!
adr_i : in std_logic_vector ( 9 downto 0) --!
-- stb_p_i : in std_logic; --! Strobe
-- ack_p_o : out std_logic; --! Acknowledge
-- we_p_i : in std_logic --! Write enable
wb_clk_i : in std_logic;
wb_dat_o : out std_logic_vector (15 downto 0); --!
wb_adr_i : in std_logic_vector (9 downto 0); --!
wb_stb_p_i : in std_logic; --! Strobe
wb_ack_p_o : out std_logic; --! Acknowledge
wb_we_p_i : in std_logic --! Write enable
);
......@@ -114,21 +119,52 @@ signal s_dat_ram : std_logic_vector(7 downto 0);
signal we_ram_p : std_logic;
signal we_byte_p : std_logic_vector(1 downto 0);
signal s_dat : std_logic_vector(15 downto 0);
signal s_reset_var2_access_clkb, s_var2_access_clkb : std_logic;
signal s_reset_var1_access_clkb, s_var1_access_clkb : std_logic;
begin
production_dpram : dpblockram
generic map(dl => 8, -- Length of the data word
al => 7, -- Size of the addr map (10 = 1024 words)
nw => 2**7) -- Number of words
-- 'nw' has to be coherent with 'al'
port map(clk => uclk_i, -- Global Clock
we => we_ram_p, -- Write Enable
aw => add(6 downto 0), -- Write Address
ar => adr_i(6 downto 0), -- Read Address
di => byte_i, -- Data input
dw => open, -- Data write, normaly open
do => s_dat_ram); -- Data output
consumtion_dpram: dpblockram_clka_rd_clkb_wr
generic map(c_dl => 8, -- Length of the data word
c_al => 8) -- Number of words
-- 'nw' has to be coherent with 'c_al'
port map(clka_i => wb_clk_i, -- Global Clock
aa_i => wb_adr_i(7 downto 0),
da_o => s_dat_ram,
clkb_i => uclk_i,
ab_i => add(7 downto 0),
db_i => byte_i,
web_i => we_ram_p);
process(wb_clk_i)
begin
if rising_edge(wb_clk_i) then
if unsigned(wb_adr_i(9 downto 8)) = to_unsigned(0, 2) then
wb_ack_p_o <= wb_stb_p_i ;
else
wb_ack_p_o <= '0';
end if;
if unsigned(wb_adr_i(9 downto 7)) = to_unsigned(0, 2) then
s_var1_access_clkb <= wb_stb_p_i ;
elsif s_reset_var1_access_clkb = '1' then
s_var1_access_clkb <= '0' ;
end if;
if unsigned(wb_adr_i(9 downto 7)) = to_unsigned(1, 2) then
s_var2_access_clkb <= wb_stb_p_i ;
elsif s_reset_var2_access_clkb = '1' then
s_var2_access_clkb <= '0' ;
end if;
s_reset_var1_access_clkb <= reset_var1_access_i;
s_reset_var2_access_clkb <= reset_var2_access_i;
end if;
end process;
var1_access_wb_clk_o <= s_var1_access_clkb;
var2_access_wb_clk_o <= s_var2_access_clkb;
add <= std_logic_vector(unsigned(add_offset_i) + unsigned(base_add));
......@@ -174,11 +210,11 @@ begin
end process;
process(s_dat, s_dat_ram, slone_i)
begin
dat_o <= (others => '0');
wb_dat_o <= (others => '0');
if slone_i = '1' then
dat_o <= s_dat;
wb_dat_o <= s_dat;
else
dat_o(7 downto 0) <= s_dat_ram;
wb_dat_o(7 downto 0) <= s_dat_ram;
end if;
end process;
......
......@@ -138,6 +138,20 @@ constant c_var_array : t_var_array(0 to 5):=
array_length => 1,
byte_array => (0 => x"40", others => x"ff")));
--Status bit position
constant c_u_cacer_pos : integer := 2; --! Consumed variable access error
constant c_u_pacer_pos : integer := 3; --! Produced variable access error
constant c_r_bner_pos : integer := 4; --! Received bit number error. Replaced by code violation.
constant c_r_fcser_pos : integer := 5; --! Received FCS access error
constant c_t_txer_pos : integer := 6; --! Transmit error (FIELDDRIVE)
constant c_t_wder_pos : integer := 7; --! Watchdog error (FIELDDRIVE)
constant c_refreshment_pos : integer := 0; --! MPS refreshment bit
constant c_significance_pos : integer := 2; --! MPS significance bit
function calc_data_length(var : t_var;
p3_length : std_logic_vector(2 downto 0);
......@@ -223,6 +237,8 @@ port (
byte_o : out std_logic_vector(7 downto 0);
last_byte_p_o : out std_logic;
fss_decoded_p_o : out std_logic;
code_violation_p_o : out std_logic;
crc_bad_p_o : out std_logic;
crc_ok_p_o : out std_logic;
d_re_i : in std_logic;
......@@ -263,20 +279,20 @@ end component wf_tx;
component dpblockram
generic (dl : integer := 42; -- Length of the data word
al : integer := 10; -- Size of the addr map (10 = 1024 words)
nw : integer := 1024); -- Number of words
-- 'nw' has to be coherent with 'al'
component dpblockram_clka_rd_clkb_wr
generic (c_dl : integer := 42; -- Length of the data word
c_al : integer := 10); -- Number of words
-- 'nw' has to be coherent with 'c_al'
port (clk : in std_logic; -- Global Clock
we : in std_logic; -- Write Enable
aw : in std_logic_vector(al - 1 downto 0); -- Write Address
ar : in std_logic_vector(al - 1 downto 0); -- Read Address
di : in std_logic_vector(dl - 1 downto 0); -- Data input
dw : out std_logic_vector(dl - 1 downto 0); -- Data write, normaly open
do : out std_logic_vector(dl - 1 downto 0)); -- Data output
end component dpblockram;
port (clka_i : in std_logic; -- Global Clock
aa_i : in std_logic_vector(c_al - 1 downto 0);
da_o : out std_logic_vector(c_dl -1 downto 0);
clkb_i : in std_logic;
ab_i : in std_logic_vector(c_al - 1 downto 0);
db_i : in std_logic_vector(c_dl - 1 downto 0);
web_i : in std_logic);
end component dpblockram_clka_rd_clkb_wr;
component wf_engine_control
generic( C_QUARTZ_PERIOD : real := 25.0);
......@@ -380,27 +396,32 @@ port (
-- data_length_i : in std_logic_vector(6 downto 0);
byte_i : in std_logic_vector(7 downto 0);
var1_access_wb_clk_o: out std_logic; --! Variable 1 access flag
var2_access_wb_clk_o: out std_logic; --! Variable 2 access flag
reset_var1_access_i: in std_logic; --! Reset Variable 1 access flag
reset_var2_access_i: in std_logic; --! Reset Variable 2 access flag
-------------------------------------------------------------------------------
--! USER INTERFACE. Data and address lines synchronized with uclk_i
-------------------------------------------------------------------------------
-- dat_i : in std_logic_vector (15 downto 0); --!
dat_o : out std_logic_vector (15 downto 0); --!
adr_i : in std_logic_vector ( 9 downto 0) --!
-- stb_p_i : in std_logic; --! Strobe
-- ack_p_o : out std_logic; --! Acknowledge
-- we_p_i : in std_logic --! Write enable
wb_clk_i : in std_logic;
wb_dat_o : out std_logic_vector (15 downto 0); --!
wb_adr_i : in std_logic_vector (9 downto 0); --!
wb_stb_p_i : in std_logic; --! Strobe
wb_ack_p_o : out std_logic; --! Acknowledge
wb_we_p_i : in std_logic --! Write enable
);
end component wf_consumed_vars;
component wf_produced_vars is
port (
uclk_i : in std_logic; --! User Clock
rst_i : in std_logic;
--! Identification selection (see M_ID, C_ID)
-- s_id_o : out std_logic_vector (1 downto 0); --! Identification selection
......@@ -431,8 +452,15 @@ port (
--! the produced data.
nostat_i : in std_logic; --! No NanoFIP status transmission
stat_i : in std_logic_vector(7 downto 0); -- NanoFIP status
stat_i : in std_logic_vector(7 downto 0); --! NanoFIP status
mps_i : in std_logic_vector(7 downto 0);
sending_stat_o : out std_logic; --! The status register is being adressed
sending_mps_o : out std_logic; --! The status register is being adressed
var3_access_wb_clk_o: out std_logic; --! Variable 2 access flag
reset_var3_access_i: in std_logic; --! Reset Variable 1 access flag
-- prod_byte_i : in std_logic_vector(7 downto 0);
var_i : in t_var;
append_status_i : in std_logic;
......@@ -444,16 +472,16 @@ port (
--! USER INTERFACE. Data and address lines synchronized with uclk_i
-------------------------------------------------------------------------------
dat_i : in std_logic_vector (15 downto 0); --!
-- dat_o : out std_logic_vector (15 downto 0); --!
adr_i : in std_logic_vector ( 9 downto 0); --!
-- stb_p_i : in std_logic; --! Strobe
-- ack_p_o : out std_logic; --! Acknowledge
we_p_i : in std_logic --! Write enable
wb_dat_i : in std_logic_vector (15 downto 0); --!
wb_clk_i : in std_logic;
wb_dat_o : out std_logic_vector (15 downto 0); --!
wb_adr_i : in std_logic_vector (9 downto 0); --!
wb_stb_p_i : in std_logic; --! Strobe
wb_ack_p_o : out std_logic; --! Acknowledge
wb_we_p_i : in std_logic --! Write enable
);
end component wf_produced_vars;
component wf_tx_rx
......@@ -481,11 +509,71 @@ port (
byte_o : out std_logic_vector(7 downto 0);
last_byte_p_o : out std_logic;
fss_decoded_p_o : out std_logic;
code_violation_p_o : out std_logic;
crc_bad_p_o : out std_logic;
crc_ok_p_o : out std_logic
);
end component wf_tx_rx;
end component wf_tx_rx;
component status_gen
port (
uclk_i : in std_logic; --! User Clock
rst_i : in std_logic;
-------------------------------------------------------------------------------
-- Connections to wf_tx_rx (WorldFIP received data)
-------------------------------------------------------------------------------
fd_wdgn_i : in std_logic; --! Watchdog on transmitter
fd_txer_i : in std_logic; --! Transmitter error
code_violation_p_i : in std_logic;
crc_bad_p_i : in std_logic;
-------------------------------------------------------------------------------
-- Connections to wf_engine
-------------------------------------------------------------------------------
--! Signals new data is received and can safely be read (Consumed
--! variable 05xyh). In stand-alone mode one may sample the data on the
--! first clock edge VAR1_RDY is high.
var1_rdy_i: in std_logic; --! Variable 1 ready
--! Signals new data is received and can safely be read (Consumed
--! broadcast variable 04xyh). In stand-alone mode one may sample the
--! data on the first clock edge VAR1_RDY is high.
var2_rdy_i: in std_logic; --! Variable 2 ready
--! Signals that the variable can safely be written (Produced variable
--! 06xyh). In stand-alone mode, data is sampled on the first clock after
--! VAR_RDY is deasserted.
var3_rdy_i: in std_logic; --! Variable 3 ready
var1_access_a_i: in std_logic; --! Variable 1 access
var2_access_a_i: in std_logic; --! Variable 2 access
var3_access_a_i: in std_logic; --! Variable 3 access
reset_var1_access_o : out std_logic; --! Reset Variable 1 access flag
reset_var2_access_o : out std_logic; --! Reset Variable 2 access flag
reset_var3_access_o : out std_logic; --! Reset Variable 2 access flag
stat_sent_p_i : in std_logic;
mps_sent_p_i : in std_logic;
stat_o : out std_logic_vector(7 downto 0);
mps_o : out std_logic_vector(7 downto 0)
-------------------------------------------------------------------------------
-- Connections to data_if
-------------------------------------------------------------------------------
);
end component status_gen;
component nanofip
......
......@@ -95,8 +95,15 @@ port (
--! the produced data.
nostat_i : in std_logic; --! No NanoFIP status transmission
stat_i : in std_logic_vector(7 downto 0); -- NanoFIP status
stat_i : in std_logic_vector(7 downto 0); --! NanoFIP status
mps_i : in std_logic_vector(7 downto 0);
sending_stat_o : out std_logic; --! The status register is being adressed
sending_mps_o : out std_logic; --! The status register is being adressed
var3_access_wb_clk_o: out std_logic; --! Variable 2 access flag
reset_var3_access_i: in std_logic; --! Reset Variable 1 access flag
-- prod_byte_i : in std_logic_vector(7 downto 0);
var_i : in t_var;
append_status_i : in std_logic;
......@@ -108,13 +115,15 @@ port (
--! USER INTERFACE. Data and address lines synchronized with uclk_i
-------------------------------------------------------------------------------
dat_i : in std_logic_vector (15 downto 0); --!
wb_dat_i : in std_logic_vector (15 downto 0); --!
wb_clk_i : in std_logic;
wb_dat_o : out std_logic_vector (15 downto 0); --!
wb_adr_i : in std_logic_vector (9 downto 0); --!
wb_stb_p_i : in std_logic; --! Strobe
wb_ack_p_o : out std_logic; --! Acknowledge
wb_we_p_i : in std_logic --! Write enable
-- dat_o : out std_logic_vector (15 downto 0); --!
adr_i : in std_logic_vector ( 9 downto 0); --!
-- stb_p_i : in std_logic; --! Strobe
-- ack_p_o : out std_logic; --! Acknowledge
we_p_i : in std_logic --! Write enable
);
......@@ -139,22 +148,62 @@ signal s_byte: std_logic_vector(7 downto 0);
signal s_mem_byte : std_logic_vector(7 downto 0);
signal s_io_byte : std_logic_vector(7 downto 0);
signal base_add, add: std_logic_vector(9 downto 0);
signal s_wb_we : std_logic;
signal s_reset_var3_access_clkb, s_var3_access_clkb : std_logic;
begin
production_dpram : dpblockram
generic map(dl => 8, -- Length of the data word
al => 7, -- Size of the addr map (10 = 1024 words)
nw => 2**7) -- Number of words
-- 'nw' has to be coherent with 'al'
port map(clk => uclk_i, -- Global Clock
we => we_p_i, -- Write Enable
aw => adr_i(6 downto 0), -- Write Address
ar => add(6 downto 0), -- Read Address
di => dat_i(7 downto 0), -- Data input
dw => open, -- Data write, normaly open
do => s_mem_byte); -- Data output
production_dpram: dpblockram_clka_rd_clkb_wr
generic map(c_dl => 8, -- Length of the data word
c_al => 7) -- Number of words
-- 'nw' has to be coherent with 'c_al'
port map(clka_i => uclk_i, -- Global Clock
aa_i => add(6 downto 0),
da_o => s_mem_byte,
clkb_i => wb_clk_i,
ab_i => wb_adr_i(6 downto 0),
db_i => wb_dat_i(7 downto 0),
web_i => wb_we_p_i);
s_wb_we <= wb_stb_p_i and wb_we_p_i;
process(wb_clk_i)
begin
if rising_edge(wb_clk_i) then
if wb_adr_i(9 downto 7) = "010" then
wb_ack_p_o <= s_wb_we and wb_stb_p_i;
else
wb_ack_p_o <= '0';
end if;
if unsigned(wb_adr_i(9 downto 7)) = to_unsigned(2, 2) then
s_var3_access_clkb <= s_wb_we and wb_stb_p_i;
elsif s_reset_var3_access_clkb = '1' then
s_var3_access_clkb <= '0' ;
end if;
s_reset_var3_access_clkb <= reset_var3_access_i;
end if;
end process;
var3_access_wb_clk_o <= s_var3_access_clkb;
-- production_dpram : dpblockram
-- generic map(dl => 8, -- Length of the data word
-- al => 7, -- Size of the addr map (10 = 1024 words)
-- nw => 2**7) -- Number of words
-- -- 'nw' has to be coherent with 'al'
--
-- port map(clk => uclk_i, -- Global Clock
-- we => we_p_i, -- Write Enable
-- aw => adr_i(6 downto 0), -- Write Address
-- ar => add(6 downto 0), -- Read Address
-- di => dat_i(7 downto 0), -- Data input
-- dw => open, -- Data write, normaly open
-- do => s_mem_byte); -- Data output
-- For the moment there is only one variable produced, but I think it is nice to have
-- defined an offset for every variable in case we produce more variables in the future
......@@ -164,7 +213,9 @@ add <= std_logic_vector(unsigned(add_offset_i) + unsigned(base_add));
process(s_mem_byte, var_i, add_offset_i, s_io_byte, data_length_i, append_status_i, stat_i, slone_i, c_id_i, m_id_i)
begin
s_byte <= (others => '0');
base_add <= (others => '0');
base_add <= (others => '0');
sending_stat_o <= '0';
sending_mps_o <= '0';
for I in c_var_array'range loop
if (c_var_array(I).response = produce) then
if c_var_array(I).var = var_i then
......@@ -182,8 +233,12 @@ begin
s_byte <= c_var_array(I).byte_array(to_integer(unsigned(add_offset_i(3 downto 0))));
elsif unsigned(add_offset_i) = c_var_length_add then
s_byte(data_length_i'range) <= data_length_i;
elsif (unsigned(add_offset_i) = unsigned(data_length_i)) and append_status_i = '1' then
s_byte <= stat_i;
elsif (unsigned(add_offset_i) = (unsigned(data_length_i) - 1)) and append_status_i = '1' then
s_byte <= stat_i;
sending_stat_o <= '1';
elsif (unsigned(add_offset_i) = unsigned(data_length_i)) then
s_byte <= mps_i;
sending_mps_o <= '1';
elsif unsigned(add_offset_i) < c_var_array(I).array_length then
s_byte <= s_mem_byte;
elsif slone_i = '1' then
......@@ -197,7 +252,7 @@ begin
end loop;
end process;
s_io_byte <= dat_i(15 downto 8) when add_offset_i(0) = '1' else dat_i(7 downto 0);
s_io_byte <= wb_dat_i(15 downto 8) when add_offset_i(0) = '1' else wb_dat_i(7 downto 0);
byte_o <= s_byte;
end architecture rtl;
-------------------------------------------------------------------------------
......
......@@ -74,7 +74,9 @@ port (
byte_ready_p_o : out std_logic;
byte_o : out std_logic_vector(7 downto 0);
last_byte_p_o : out std_logic;
fss_decoded_p_o : out std_logic;
fss_decoded_p_o : out std_logic;
code_violation_p_o : out std_logic;
crc_bad_p_o : out std_logic;
crc_ok_p_o : out std_logic;
d_re_i : in std_logic;
d_fe_i : in std_logic;
......@@ -252,7 +254,7 @@ begin
s_start_pointer <= to_unsigned(0,s_start_pointer'length);
s_start_crc_p <= '0';
fss_decoded_p_o <= '0';
code_violation_p_o <= '0';
case rx_st is
when w_1 =>
load_phase_o <= '1';
......@@ -270,7 +272,9 @@ case rx_st is
s_start_pointer <= to_unsigned(QUEUE'left,s_start_pointer'length);
s_load_pointer <= s_pointer_is_zero and s_clk_bit_180_p_d;
s_start_crc_p <= '1';
fss_decoded_p_o <= s_last_frame_start_bit;
fss_decoded_p_o <= s_last_frame_start_bit;
code_violation_p_o <= s_bad_queue_bit and s_code_violation;
when w_byte =>
load_phase_o <= edge_window_i;
s_inc_pointer <= s_d_ready_p_i;
......@@ -344,8 +348,8 @@ end process;
process(uclk_i)
begin
if rising_edge(uclk_i) then
if rst_i = '1' then
if rising_edge(uclk_i) then
if rst_i = '1' then
s_crc_ok <= '0';
elsif s_byte_ok = '1' then
s_crc_ok <= '0';
......@@ -370,7 +374,7 @@ end process;
byte_o <= s_byte;
last_byte_p_o <= s_good_queue_detected_p;
crc_ok_p_o <= s_good_queue_detected_p and s_crc_ok;
crc_bad_p_o <= s_good_queue_detected_p and (not s_crc_ok);
end architecture rtl;
-------------------------------------------------------------------------------
......
......@@ -87,8 +87,10 @@ port (
byte_ready_p_o : out std_logic;
byte_o : out std_logic_vector(7 downto 0);
last_byte_p_o : out std_logic;
fss_decoded_p_o : out std_logic;
last_byte_p_o : out std_logic;
fss_decoded_p_o : out std_logic;
code_violation_p_o : out std_logic;
crc_bad_p_o : out std_logic;
crc_ok_p_o : out std_logic
);
......@@ -156,7 +158,7 @@ s_d_edge <= s_d_fe or s_d_re;
rst_i => rst_i,
byte_ready_p_o => byte_ready_p_o,
byte_o => byte_o,
last_byte_p_o => last_byte_p_o,
last_byte_p_o => last_byte_p_o,
fss_decoded_p_o => fss_decoded_p_o,
crc_ok_p_o => crc_ok_p_o,
......
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