Guest
can anyone help me and tell me what this program exactly do please?
1 ENTITY EX8 IS
2 GENERIC (n : NATURAL :=4);
3 PORT (clk, rst : IN BIT;
4 in1, in2 : IN BIT_VECTOR (n-1 DOWNTO 0);
5 opt : OUT BIT_VECTOR (n-1 DOWNTO 0));
6 END EX8;
7 ARCHITECTURE behave OF EX8 IS
8 SIGNAL sopt : BIT_VECTOR (n-1 DOWNTO 0);
9 SIGNAL chng : BIT;
10 BEGIN
11 P0: PROCESS (clk, rst)
12 BEGIN
13 IF rst='1' THEN chng<='0';
14 ELSIF clk'EVENT AND clk='1' THEN
15 IF sopt=in2 THEN chng<='1';
16 ELSIF sopt=in1 THEN chng<='0';
17 END IF;
18 END IF;
19 END PROCESS;
20 P1: PROCESS (clk)
21 BEGIN
22 IF clk'EVENT AND clk='1' THEN
23 IF rst='1' THEN sopt<=in2;
24 ELSE
25 IF chng='0' THEN
26 IF sopt/=in2 THEN sopt<=in2;
27 END IF;
28 ELSE
29 IF sopt/=in1 THEN sopt<=in1;
30 END IF;
31 END IF;
32 END IF;
33 END IF;
34 END PROCESS;
35 opt<=sopt;
36 END behave;
1 ENTITY EX8 IS
2 GENERIC (n : NATURAL :=4);
3 PORT (clk, rst : IN BIT;
4 in1, in2 : IN BIT_VECTOR (n-1 DOWNTO 0);
5 opt : OUT BIT_VECTOR (n-1 DOWNTO 0));
6 END EX8;
7 ARCHITECTURE behave OF EX8 IS
8 SIGNAL sopt : BIT_VECTOR (n-1 DOWNTO 0);
9 SIGNAL chng : BIT;
10 BEGIN
11 P0: PROCESS (clk, rst)
12 BEGIN
13 IF rst='1' THEN chng<='0';
14 ELSIF clk'EVENT AND clk='1' THEN
15 IF sopt=in2 THEN chng<='1';
16 ELSIF sopt=in1 THEN chng<='0';
17 END IF;
18 END IF;
19 END PROCESS;
20 P1: PROCESS (clk)
21 BEGIN
22 IF clk'EVENT AND clk='1' THEN
23 IF rst='1' THEN sopt<=in2;
24 ELSE
25 IF chng='0' THEN
26 IF sopt/=in2 THEN sopt<=in2;
27 END IF;
28 ELSE
29 IF sopt/=in1 THEN sopt<=in1;
30 END IF;
31 END IF;
32 END IF;
33 END IF;
34 END PROCESS;
35 opt<=sopt;
36 END behave;