Bobbyunccstudent
Newbie level 4
- Joined
- Nov 9, 2013
- Messages
- 5
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 47
This is the state machine I have to build for my project. View attachment Project4.pdf. This is my program thus far. It has no errors, but I don't know how to write the output correctly. Also I don't know how to write a testbench. Could someone give me some ideas. I'm stuck. It has took me quit a while to get this far. Im new at vhdl.
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 library IEEE; use IEEE.STD_LOGIC_1164.ALL; -- Uncomment the following library declaration if using -- arithmetic functions with Signed or Unsigned values --use IEEE.NUMERIC_STD.ALL; -- Uncomment the following library declaration if instantiating -- any Xilinx primitives in this code. --library UNISIM; --use UNISIM.VComponents.all; entity project4a is Port ( Clock : in STD_LOGIC; Resetn : in STD_LOGIC; R : in STD_LOGIC; S : in STD_LOGIC; T : in STD_LOGIC; Z : out STD_LOGIC); end project4a; architecture Behavioral of project4a is type state_type is (A, B, C, D); signal y : State_type; begin Process (Resetn, clock ) begin If resetn = '0' then y <= A; ElsIf ( clock' Event and Clock = '1') Then Case y is when A => If (s = '1' and T = '1') then y <= A; elsIf (s = '1' and T = '0') then y <= B; elsIf s = '0' then y <= C; End If; when B => If R = '0' then y <= B; ElsIf R='1' then y <= C; end if; when c => If (R='0' and T='0') then y<=B; elsif (R='1' and T='1') then y<=B; elsif (R='1' and T='0') then y<=A; elsif (R='0' and T='1') then y<=D; end if; when D=> If R='0' then y<=A; else y<=D; end if; end case; end if; end process; z<= '1' when (y = C or y = d ) Else '0'; --This is not correct just here to see if the program will work.
Last edited by a moderator: