CMX
CMX firmware code in-line documentation
 All Classes Namespaces Files Functions Variables
parity_chk.vhd
Go to the documentation of this file.
1 
17 
18 LIBRARY ieee ;
19 USE ieee.std_logic_1164.all;
20 USE ieee.numeric_std.all;
21 
22 
23 ENTITY parity_chk IS
24  GENERIC(
25  width : integer := 120
26  );
27  PORT(
28  din : IN std_logic_vector (width-1 DOWNTO 0);
29  parity : IN std_logic;
30  mask : IN std_logic;
31  -- disable signal
32  dout : OUT std_logic_vector (width-1 DOWNTO 0);
33  perr : OUT std_logic
34  );
35 
36 -- Declarations
37 
38 END parity_chk ;
39 
40 -- hds interface_end
41 --------------------------------------------------------------------------------
42 ARCHITECTURE rtl OF parity_chk IS
43 --------------------------------------------------------------------------------
44 -- Calculate the parity of incoming data and compere to received parity bit.
45 -- If error found, dout is zeroed and perr is set high.
46 -- If mask is set high, dout and perr are held low.
47 --
48 -- NOTE: this logic is not obviously optimised for latency, but in practice
49 -- it has a latency as low as anything that is.
50 
51 
52  signal iperr: std_logic;
53  signal idout: std_logic_vector (width-1 DOWNTO 0);
54 --------------------------------------------------------------------------------
55 BEGIN
56 
57 
58 
59  parity_check: process (din, parity, mask)
60  variable ourparity: std_logic;
61  begin
62  ourparity:= '1'; -- odd parity
63  for i in 0 to (width - 1) loop
64  ourparity := ourparity xor din(i);
65  end loop;
66  iperr <= (ourparity xor parity) and not mask;
67  end process;
68 
69 
70  data_gater: process (din, iperr, mask)
71  begin
72  if (iperr = '0' and mask = '0') then
73  idout <= din;
74  else
75  idout <= (others=>'0');
76  end if;
77  end process;
78 
79  perr <= iperr;
80  dout <= idout;
81 
82 END rtl;
data_gaterdin,iperr,mask
Definition: parity_chk.vhd:70
widthinteger :=120
Definition: parity_chk.vhd:25
out perrstd_logic
Definition: parity_chk.vhd:33
in dinstd_logic_vector (width - 1 downto 0)
Definition: parity_chk.vhd:28
std_logic_vector (width - 1 downto 0) idout
Definition: parity_chk.vhd:53
in maskstd_logic
Definition: parity_chk.vhd:30
out doutstd_logic_vector (width - 1 downto 0)
Definition: parity_chk.vhd:32
parity_checkdin,parity,mask
Definition: parity_chk.vhd:59
_library_ ieeeieee
Definition: main_sys.vhd:17
std_logic iperr
Definition: parity_chk.vhd:52
in paritystd_logic
Definition: parity_chk.vhd:29