OpenCores
URL https://opencores.org/ocsvn/ccsds_rxtxsoc/ccsds_rxtxsoc/trunk

Subversion Repositories ccsds_rxtxsoc

[/] [ccsds_rxtxsoc/] [trunk/] [ccsds_tx_coder_differential.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 zguig52
---- Design Name: ccsds_tx_coder_differential
2
---- Version: 1.0.0
3
---- Description:
4
---- Word by word differential coder
5
-------------------------------
6
---- Author(s):
7
---- Guillaume REMBERT
8
-------------------------------
9
---- Licence:
10
---- MIT
11
-------------------------------
12
---- Changes list:
13
---- 2016/11/18: initial release
14
-------------------------------
15
 
16
-- libraries used
17
library ieee;
18
use ieee.std_logic_1164.all;
19
 
20
--=============================================================================
21
-- Entity declaration for ccsds_tx / unitary tx differential coder inputs and outputs
22
--=============================================================================
23
entity ccsds_tx_coder_differential is
24
  generic(
25
    constant CCSDS_TX_CODER_DIFF_BITS_PER_CODEWORD: integer;
26
    constant CCSDS_TX_CODER_DIFF_DATA_BUS_SIZE: integer -- in bits
27
  );
28
  port(
29
    -- inputs
30
    clk_i: in std_logic;
31
    dat_i: in std_logic_vector(CCSDS_TX_CODER_DIFF_DATA_BUS_SIZE-1 downto 0);
32
    dat_val_i: in std_logic;
33
    rst_i: in std_logic;
34
    -- outputs
35
    dat_o: out std_logic_vector(CCSDS_TX_CODER_DIFF_DATA_BUS_SIZE-1 downto 0);
36
    dat_val_o: out std_logic
37
  );
38
end ccsds_tx_coder_differential;
39
 
40
--=============================================================================
41
-- architecture declaration / internal components and connections
42
--=============================================================================
43
architecture rtl of ccsds_tx_coder_differential is
44
-- internal constants
45
-- internal variable signals
46
-- components instanciation and mapping
47
  begin
48
-- presynthesis checks
49
     CHKCODERP0 : if (CCSDS_TX_CODER_DIFF_DATA_BUS_SIZE mod (CCSDS_TX_CODER_DIFF_BITS_PER_CODEWORD) /= 0) generate
50
      process
51
      begin
52
        report "ERROR: DATA BUS SIZE HAS TO BE A MULTIPLE OF BITS PER CODE WORD" severity failure;
53
              wait;
54
      end process;
55
    end generate CHKCODERP0;
56
 
57
-- internal processing
58
    --=============================================================================
59
    -- Begin of coderdiffp
60
    -- Differential encode words
61
    --=============================================================================
62
    -- read: rst_i, dat_i, dat_val_i
63
    -- write: dat_o, dat_val_o
64
    -- r/w:
65
    CODERDIFFP: process (clk_i)
66
    variable prev_sym: std_logic_vector(CCSDS_TX_CODER_DIFF_BITS_PER_CODEWORD-1 downto 0) := (others => '0');
67
    begin
68
      -- on each clock rising edge
69
      if rising_edge(clk_i) then
70
        -- reset signal received
71
        if (rst_i = '1') then
72
          dat_o <= (others => '0');
73
          dat_val_o <= '0';
74
          prev_sym := (others => '0');
75
        else
76
          if (dat_val_i = '1') then
77
            dat_val_o <= '1';
78
            dat_o(CCSDS_TX_CODER_DIFF_DATA_BUS_SIZE-1 downto CCSDS_TX_CODER_DIFF_DATA_BUS_SIZE-CCSDS_TX_CODER_DIFF_BITS_PER_CODEWORD) <= prev_sym xor dat_i(CCSDS_TX_CODER_DIFF_DATA_BUS_SIZE-1 downto CCSDS_TX_CODER_DIFF_DATA_BUS_SIZE-CCSDS_TX_CODER_DIFF_BITS_PER_CODEWORD);
79
            for i in CCSDS_TX_CODER_DIFF_DATA_BUS_SIZE/(CCSDS_TX_CODER_DIFF_BITS_PER_CODEWORD)-1 downto 1 loop
80
              dat_o(i*CCSDS_TX_CODER_DIFF_BITS_PER_CODEWORD-1 downto (i-1)*CCSDS_TX_CODER_DIFF_BITS_PER_CODEWORD) <= dat_i(i*CCSDS_TX_CODER_DIFF_BITS_PER_CODEWORD-1 downto (i-1)*CCSDS_TX_CODER_DIFF_BITS_PER_CODEWORD) xor dat_i((i+1)*CCSDS_TX_CODER_DIFF_BITS_PER_CODEWORD-1 downto i*CCSDS_TX_CODER_DIFF_BITS_PER_CODEWORD);
81
            end loop;
82
            prev_sym := dat_i(CCSDS_TX_CODER_DIFF_BITS_PER_CODEWORD-1 downto 0);
83
          else
84
            dat_val_o <= '0';
85
          end if;
86
        end if;
87
      end if;
88
    end process;
89
end rtl;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.