| 1 |
2 |
zguig52 |
-------------------------------
|
| 2 |
|
|
---- Project: EurySPACE CCSDS RX/TX with wishbone interface
|
| 3 |
|
|
---- Design Name: ccsds_tx_synchronizer
|
| 4 |
|
|
---- Version: 1.0.0
|
| 5 |
|
|
---- Description:
|
| 6 |
|
|
---- Add an Attached Synchronization Marker to an input frame
|
| 7 |
|
|
-------------------------------
|
| 8 |
|
|
---- Author(s):
|
| 9 |
|
|
---- Guillaume REMBERT
|
| 10 |
|
|
-------------------------------
|
| 11 |
|
|
---- Licence:
|
| 12 |
|
|
---- MIT
|
| 13 |
|
|
-------------------------------
|
| 14 |
|
|
---- Changes list:
|
| 15 |
|
|
---- 2016/11/05: initial release
|
| 16 |
|
|
-------------------------------
|
| 17 |
|
|
|
| 18 |
|
|
-- libraries used
|
| 19 |
|
|
library ieee;
|
| 20 |
|
|
use ieee.std_logic_1164.all;
|
| 21 |
|
|
|
| 22 |
|
|
--=============================================================================
|
| 23 |
|
|
-- Entity declaration for ccsds_tx / unitary tx synchronizer inputs and outputs
|
| 24 |
|
|
--=============================================================================
|
| 25 |
|
|
entity ccsds_tx_synchronizer is
|
| 26 |
|
|
generic(
|
| 27 |
|
|
constant CCSDS_TX_ASM_LENGTH: integer := 4; -- Attached Synchronization Marker length / in Bytes
|
| 28 |
|
|
constant CCSDS_TX_ASM_PATTERN: std_logic_vector := "00011010110011111111110000011101"; -- ASM Pattern used
|
| 29 |
|
|
constant CCSDS_TX_ASM_DATA_BUS_SIZE: integer -- in bits
|
| 30 |
|
|
);
|
| 31 |
|
|
port(
|
| 32 |
|
|
-- inputs
|
| 33 |
|
|
clk_i: in std_logic;
|
| 34 |
|
|
dat_i: in std_logic_vector(CCSDS_TX_ASM_DATA_BUS_SIZE-1 downto 0);
|
| 35 |
|
|
dat_val_i: in std_logic;
|
| 36 |
|
|
rst_i: in std_logic;
|
| 37 |
|
|
-- outputs
|
| 38 |
|
|
dat_o: out std_logic_vector(CCSDS_TX_ASM_DATA_BUS_SIZE+CCSDS_TX_ASM_LENGTH*8-1 downto 0);
|
| 39 |
|
|
dat_val_o: out std_logic
|
| 40 |
|
|
);
|
| 41 |
|
|
end ccsds_tx_synchronizer;
|
| 42 |
|
|
|
| 43 |
|
|
--=============================================================================
|
| 44 |
|
|
-- architecture declaration / internal components and connections
|
| 45 |
|
|
--=============================================================================
|
| 46 |
|
|
architecture structure of ccsds_tx_synchronizer is
|
| 47 |
|
|
|
| 48 |
|
|
-- internal constants
|
| 49 |
|
|
-- internal variable signals
|
| 50 |
|
|
-- components instanciation and mapping
|
| 51 |
|
|
begin
|
| 52 |
|
|
-- presynthesis checks
|
| 53 |
|
|
CHKSYNCHRONIZERP0 : if ((CCSDS_TX_ASM_LENGTH*8) /= CCSDS_TX_ASM_PATTERN'length) generate
|
| 54 |
|
|
process
|
| 55 |
|
|
begin
|
| 56 |
|
|
report "ERROR: SYNCHRONIZER ASM LENGTH IS DIFFERENT FROM PATTERN SIZE" severity failure;
|
| 57 |
|
|
wait;
|
| 58 |
|
|
end process;
|
| 59 |
|
|
end generate CHKSYNCHRONIZERP0;
|
| 60 |
|
|
-- internal processing
|
| 61 |
|
|
--=============================================================================
|
| 62 |
|
|
-- Begin of asmp
|
| 63 |
|
|
-- Apped ASM sequence to frame
|
| 64 |
|
|
--=============================================================================
|
| 65 |
|
|
-- read: rst_i, dat_val_i, dat_i
|
| 66 |
|
|
-- write: dat_o, dat_val_o
|
| 67 |
|
|
-- r/w:
|
| 68 |
|
|
ASMP: process (clk_i)
|
| 69 |
|
|
variable data_synchronized: std_logic := '0';
|
| 70 |
|
|
begin
|
| 71 |
|
|
-- on each clock rising edge
|
| 72 |
|
|
if rising_edge(clk_i) then
|
| 73 |
|
|
-- reset signal received
|
| 74 |
|
|
if (rst_i = '1') then
|
| 75 |
|
|
dat_o <= (others => '0');
|
| 76 |
|
|
data_synchronized := '0';
|
| 77 |
|
|
dat_val_o <= '0';
|
| 78 |
|
|
else
|
| 79 |
|
|
if (dat_val_i = '1') then
|
| 80 |
|
|
dat_o(CCSDS_TX_ASM_DATA_BUS_SIZE+CCSDS_TX_ASM_LENGTH*8-1 downto CCSDS_TX_ASM_DATA_BUS_SIZE) <= CCSDS_TX_ASM_PATTERN;
|
| 81 |
|
|
dat_o(CCSDS_TX_ASM_DATA_BUS_SIZE-1 downto 0) <= dat_i;
|
| 82 |
|
|
data_synchronized := '1';
|
| 83 |
|
|
dat_val_o <= '1';
|
| 84 |
|
|
else
|
| 85 |
|
|
dat_val_o <= '0';
|
| 86 |
|
|
if (data_synchronized = '0') then
|
| 87 |
|
|
dat_o <= (others => '0');
|
| 88 |
|
|
end if;
|
| 89 |
|
|
end if;
|
| 90 |
|
|
end if;
|
| 91 |
|
|
end if;
|
| 92 |
|
|
end process;
|
| 93 |
|
|
end structure;
|