1 |
2 |
zguig52 |
-------------------------------
|
2 |
|
|
---- Project: EurySPACE CCSDS RX/TX with wishbone interface
|
3 |
|
|
---- Design Name: ccsds_tx_header
|
4 |
|
|
---- Version: 1.0.0
|
5 |
|
|
---- Description:
|
6 |
|
|
---- TBD
|
7 |
|
|
-------------------------------
|
8 |
|
|
---- Author(s):
|
9 |
|
|
---- Guillaume REMBERT
|
10 |
|
|
-------------------------------
|
11 |
|
|
---- Licence:
|
12 |
|
|
---- MIT
|
13 |
|
|
-------------------------------
|
14 |
|
|
---- Changes list:
|
15 |
|
|
---- 2016/02/28: initial release
|
16 |
|
|
---- 2016/10/21: rework
|
17 |
|
|
---- 2016/11/03: add idle data flag
|
18 |
|
|
-------------------------------
|
19 |
|
|
--TODO: static fixed virtual channel now - implement virtual channel service
|
20 |
|
|
--TODO: secondary header
|
21 |
|
|
--TODO: security header
|
22 |
|
|
|
23 |
|
|
--TRANSFER FRAME PRIMARY HEADER => 6 octets
|
24 |
|
|
-- \ MASTER CHANNEL ID => 12 bits
|
25 |
|
|
-- \ TRANSFER FRAME VERSION NUMBER => 2 bits
|
26 |
|
|
-- \ SPACECRAFT ID => 10 bits
|
27 |
|
|
-- \ VIRTUAL CHANNEL ID => 3 bits
|
28 |
|
|
-- \ OCF FLAG => 1 bit
|
29 |
|
|
-- \ MASTER CHANNEL FRAME COUNT => 1 octet
|
30 |
|
|
-- \ VIRTUAL CHANNEL FRAME COUNT => 1 octet
|
31 |
|
|
-- \ TRANSFER FRAME DATA FIELD STATUS => 2 octets
|
32 |
|
|
-- \ TRANSFER FRAME SECONDARY HEADER FLAG => 1 bit
|
33 |
|
|
-- \ SYNC FLAG => 1 bit
|
34 |
|
|
-- \ PACKET ORDER FLAG => 1 bit
|
35 |
|
|
-- \ SEGMENT LENGTH ID => 2 bits
|
36 |
|
|
-- \ FIRST HEADER POINTER => 11 bits
|
37 |
|
|
--[OPT] TRANSFER FRAME SECONDARY HEADER => up to 64 octets
|
38 |
|
|
-- \ TRANSFER FRAME SECONDARY HEADER ID => 1 octet
|
39 |
|
|
-- \ TRANSFER FRAME SECONDARY HEADER VERSION NUMBER => 2 bits
|
40 |
|
|
-- \ TRANSFER FRAME SECONDARY HEADER LENGTH => 6 bits
|
41 |
|
|
-- \ TRANSFER FRAME SECONDARY HEADER DATA FIELD => up to 63 octets
|
42 |
|
|
--[OPT] SECURITY HEADER
|
43 |
|
|
|
44 |
|
|
-- libraries used
|
45 |
|
|
library ieee;
|
46 |
|
|
use ieee.std_logic_1164.all;
|
47 |
|
|
use ieee.numeric_std.all;
|
48 |
|
|
|
49 |
|
|
--=============================================================================
|
50 |
|
|
-- Entity declaration for ccsds_tx / unitary tx header inputs and outputs
|
51 |
|
|
--=============================================================================
|
52 |
|
|
entity ccsds_tx_header is
|
53 |
|
|
generic(
|
54 |
|
|
CCSDS_TX_HEADER_LENGTH: integer; -- in Bytes
|
55 |
|
|
CCSDS_TX_HEADER_MCI_TFVN: std_logic_vector(2-1 downto 0) := "00"; -- Transfer Frame Version Number value
|
56 |
|
|
CCSDS_TX_HEADER_MCI_SID: std_logic_vector(10-1 downto 0) := "1100110011"; -- Spacecraft ID value
|
57 |
|
|
CCSDS_TX_HEADER_MCFC_LENGTH: integer := 8; -- Master Channel Frame Count length - in bits
|
58 |
|
|
CCSDS_TX_HEADER_OCFF: std_logic := '0'; -- Operationnal Control Field Flag
|
59 |
|
|
CCSDS_TX_HEADER_VCI: std_logic_vector(3-1 downto 0) := "000"; -- Virtual Channel Identifier value
|
60 |
|
|
CCSDS_TX_HEADER_VCFC_LENGTH: integer := 8; -- Virtual Channel Frame Count length - in bits
|
61 |
|
|
CCSDS_TX_HEADER_TFDFS_LENGTH: integer := 16; -- Transfer Frame Data Field Status length - in bits
|
62 |
|
|
CCSDS_TX_HEADER_TFDFS_POF: std_logic := '0'; -- Packet Order Flag
|
63 |
|
|
CCSDS_TX_HEADER_TFDFS_SF: std_logic := '0'; -- Synchronization Flag
|
64 |
|
|
CCSDS_TX_HEADER_TFDFS_SLI: std_logic_vector(1 downto 0) := "11"; -- Segment Length Identifier
|
65 |
|
|
CCSDS_TX_HEADER_TFDFS_TFSHF: std_logic := '0' -- Transfer Frame Secondary Header Flag
|
66 |
|
|
);
|
67 |
|
|
port(
|
68 |
|
|
-- inputs
|
69 |
|
|
clk_i: in std_logic;
|
70 |
|
|
idl_i: in std_logic;
|
71 |
|
|
nxt_i: in std_logic;
|
72 |
|
|
rst_i: in std_logic;
|
73 |
|
|
-- outputs
|
74 |
|
|
dat_o: out std_logic_vector(CCSDS_TX_HEADER_LENGTH*8-1 downto 0);
|
75 |
|
|
dat_val_o: out std_logic
|
76 |
|
|
);
|
77 |
|
|
end ccsds_tx_header;
|
78 |
|
|
|
79 |
|
|
--=============================================================================
|
80 |
|
|
-- architecture declaration / internal components and connections
|
81 |
|
|
--=============================================================================
|
82 |
|
|
architecture rtl of ccsds_tx_header is
|
83 |
|
|
-- internal variable signals
|
84 |
|
|
-- components instanciation and mapping
|
85 |
|
|
begin
|
86 |
|
|
|
87 |
|
|
-- presynthesis checks
|
88 |
|
|
CHKHEADERP0 : if CCSDS_TX_HEADER_LENGTH*8 /= (CCSDS_TX_HEADER_MCI_TFVN'length + CCSDS_TX_HEADER_MCI_SID'length + CCSDS_TX_HEADER_VCI'length + CCSDS_TX_HEADER_MCFC_LENGTH + CCSDS_TX_HEADER_VCFC_LENGTH + CCSDS_TX_HEADER_TFDFS_LENGTH + 1) generate
|
89 |
|
|
process
|
90 |
|
|
begin
|
91 |
|
|
report "ERROR: HEADER LENGTH IS DIFFERENT OF TOTAL SUBELEMENTS LENGTH" severity failure;
|
92 |
|
|
wait;
|
93 |
|
|
end process;
|
94 |
|
|
end generate CHKHEADERP0;
|
95 |
|
|
|
96 |
|
|
-- internal processing
|
97 |
|
|
|
98 |
|
|
--=============================================================================
|
99 |
|
|
-- Begin of headerp
|
100 |
|
|
-- Generate valid headers
|
101 |
|
|
--=============================================================================
|
102 |
|
|
-- read: rst_i, nxt_i
|
103 |
|
|
-- write: dat_val_o, dat_o
|
104 |
|
|
-- r/w:
|
105 |
|
|
HEADERP : process (clk_i)
|
106 |
|
|
variable header_mci_tfvn: std_logic_vector(CCSDS_TX_HEADER_MCI_TFVN'length-1 downto 0) := CCSDS_TX_HEADER_MCI_TFVN; -- Transfer Frame Version Number
|
107 |
|
|
variable header_mci_sid: std_logic_vector(CCSDS_TX_HEADER_MCI_SID'length-1 downto 0) := CCSDS_TX_HEADER_MCI_SID; -- Spacecraft ID
|
108 |
|
|
variable header_vci: std_logic_vector(CCSDS_TX_HEADER_VCI'length-1 downto 0) := CCSDS_TX_HEADER_VCI; -- Virtual Channel Identifier
|
109 |
|
|
variable header_ocff: std_logic := CCSDS_TX_HEADER_OCFF; -- Operationnal Control Field Flag
|
110 |
|
|
variable header_mcfc: integer range 0 to (2**CCSDS_TX_HEADER_MCFC_LENGTH)-1 := 0; -- Master Channel Frame Count
|
111 |
|
|
variable header_vcfc: integer range 0 to (2**CCSDS_TX_HEADER_VCFC_LENGTH)-1 := 0; -- Virtual Channel Frame Count
|
112 |
|
|
variable header_tfdfs_fhp: std_logic_vector(CCSDS_TX_HEADER_TFDFS_LENGTH-6 downto 0) := "00000000000"; -- First Header Pointer / 11111111110 when idle data inside only
|
113 |
|
|
begin
|
114 |
|
|
-- on each clock rising edge
|
115 |
|
|
if rising_edge(clk_i) then
|
116 |
|
|
-- reset signal received
|
117 |
|
|
if (rst_i = '1') then
|
118 |
|
|
dat_o <= (others => '0');
|
119 |
|
|
dat_val_o <= '0';
|
120 |
|
|
header_mci_tfvn := CCSDS_TX_HEADER_MCI_TFVN;
|
121 |
|
|
header_mci_sid := CCSDS_TX_HEADER_MCI_SID;
|
122 |
|
|
header_vci := CCSDS_TX_HEADER_VCI;
|
123 |
|
|
header_ocff := '1';
|
124 |
|
|
header_mcfc := 0;
|
125 |
|
|
header_vcfc := 0;
|
126 |
|
|
header_tfdfs_fhp := "00000000000";
|
127 |
|
|
else
|
128 |
|
|
if (nxt_i = '1') then
|
129 |
|
|
if(idl_i = '1') then
|
130 |
|
|
header_tfdfs_fhp := "11111111110";
|
131 |
|
|
else
|
132 |
|
|
header_tfdfs_fhp := "00000000000";
|
133 |
|
|
end if;
|
134 |
|
|
dat_val_o <= '1';
|
135 |
|
|
dat_o(CCSDS_TX_HEADER_LENGTH*8-1 downto CCSDS_TX_HEADER_LENGTH*8-CCSDS_TX_HEADER_MCI_TFVN'length) <= header_mci_tfvn;
|
136 |
|
|
dat_o(CCSDS_TX_HEADER_LENGTH*8-CCSDS_TX_HEADER_MCI_TFVN'length-1 downto CCSDS_TX_HEADER_LENGTH*8-CCSDS_TX_HEADER_MCI_TFVN'length-CCSDS_TX_HEADER_MCI_SID'length) <= header_mci_sid;
|
137 |
|
|
dat_o(CCSDS_TX_HEADER_LENGTH*8-CCSDS_TX_HEADER_MCI_TFVN'length-CCSDS_TX_HEADER_MCI_SID'length-1 downto CCSDS_TX_HEADER_LENGTH*8-CCSDS_TX_HEADER_MCI_TFVN'length-CCSDS_TX_HEADER_MCI_SID'length-CCSDS_TX_HEADER_VCI'length) <= header_vci;
|
138 |
|
|
dat_o(CCSDS_TX_HEADER_LENGTH*8-CCSDS_TX_HEADER_MCI_TFVN'length-CCSDS_TX_HEADER_MCI_SID'length-CCSDS_TX_HEADER_VCI'length-1) <= header_ocff;
|
139 |
|
|
dat_o(CCSDS_TX_HEADER_LENGTH*8-CCSDS_TX_HEADER_MCI_TFVN'length-CCSDS_TX_HEADER_MCI_SID'length-CCSDS_TX_HEADER_VCI'length-1-1 downto CCSDS_TX_HEADER_LENGTH*8-CCSDS_TX_HEADER_MCI_TFVN'length-CCSDS_TX_HEADER_MCI_SID'length-CCSDS_TX_HEADER_VCI'length-1-CCSDS_TX_HEADER_MCFC_LENGTH) <= std_logic_vector(to_unsigned(header_mcfc,CCSDS_TX_HEADER_MCFC_LENGTH));
|
140 |
|
|
dat_o(CCSDS_TX_HEADER_LENGTH*8-CCSDS_TX_HEADER_MCI_TFVN'length-CCSDS_TX_HEADER_MCI_SID'length-CCSDS_TX_HEADER_VCI'length-1-CCSDS_TX_HEADER_MCFC_LENGTH-1 downto CCSDS_TX_HEADER_LENGTH*8-CCSDS_TX_HEADER_MCI_TFVN'length-CCSDS_TX_HEADER_MCI_SID'length-CCSDS_TX_HEADER_VCI'length-1-CCSDS_TX_HEADER_MCFC_LENGTH-CCSDS_TX_HEADER_VCFC_LENGTH) <= std_logic_vector(to_unsigned(header_vcfc,CCSDS_TX_HEADER_VCFC_LENGTH));
|
141 |
|
|
dat_o(CCSDS_TX_HEADER_TFDFS_LENGTH-1 downto CCSDS_TX_HEADER_TFDFS_LENGTH-5) <= CCSDS_TX_HEADER_TFDFS_TFSHF & CCSDS_TX_HEADER_TFDFS_SF & CCSDS_TX_HEADER_TFDFS_POF & CCSDS_TX_HEADER_TFDFS_SLI;
|
142 |
|
|
dat_o(CCSDS_TX_HEADER_TFDFS_LENGTH-6 downto 0) <= header_tfdfs_fhp;
|
143 |
|
|
if (header_mcfc = (2**CCSDS_TX_HEADER_MCFC_LENGTH)-1) then
|
144 |
|
|
header_mcfc := 0;
|
145 |
|
|
else
|
146 |
|
|
header_mcfc := header_mcfc + 1;
|
147 |
|
|
end if;
|
148 |
|
|
if (header_vcfc = (2**CCSDS_TX_HEADER_VCFC_LENGTH)-1) then
|
149 |
|
|
header_vcfc := 0;
|
150 |
|
|
else
|
151 |
|
|
header_vcfc := header_vcfc + 1;
|
152 |
|
|
end if;
|
153 |
|
|
else
|
154 |
|
|
dat_val_o <= '0';
|
155 |
|
|
end if;
|
156 |
|
|
end if;
|
157 |
|
|
end if;
|
158 |
|
|
end process;
|
159 |
|
|
end rtl;
|