• 0
Sign in to follow this  
TJ

8 bit even parity check

Question

Hello,

Does the below look like acceptable vhdl  code for the 8 bit even parity check?

 

CODE:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity pairity is
generic(n:integer:=7);
port(a:in std_logic_vector(n-1 downto 0);
b:out std_logic_vector(n downto 0));
end pairity;

architecture Behavioral of pairity is

begin
process(a)
            variable temp1:std_logic;
            variable temp2:std_logic_vector(b'range);
            begin
                        temp1:='0';
                        for i in a'range loop
                                    temp1:=temp1 xor a(i);
                                    temp2(i):=a(i);
                        end loop;
                                    temp2(b'high):=temp1;
                                    b<=temp2;
end process;


end Behavioral;

 

 

Thanks,

TJ

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 1

It looks fine - however a few questions

1) Did you mean to spell "parity" as "pairity"?

2) Why do you have the three 'use' statements - only one is really needed?

3) Only the upper bit of 'b' needs to be assigned in the process. If you assign "b(n-1 downto 0) <= a;" you can remove the 'temp2' variable.

Mike

Share this post


Link to post
Share on other sites
  • 0

Thank you very much.  Yes I did mean parity.  Spelling error.  The 3 use statements is old habits.  Good point about temp2 variable.

Thanks,

TJ

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this