Task 3 Files

Task 3 Files - S EQUENCE.VH D library ieee; use...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
SEQUENCE.VHD library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; entity sequence is port( clk : in std_logic; reset : in std_logic; x: in std_logic; z : out std_logic;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
a : out std_logic; b : out std_logic; c : out std_logic; d : out std_logic; e : out std_logic; f : out std_logic; g : out std_logic; h : out std_logic; i : out std_logic; Segment: out std_logic_vector (6 downto 0)); end sequence; architecture behavioral of sequence is -- This is similar to a variable declaration. The variable names are in -- the parenthesis and they are of type 'state_type'. type state_type is (a1, b1, c1, d1, e1, f1, g1, h1, i1); -- Create signals "state" and "next_state". These signals carry 'state_type' -- signals which were declared above. signal state, next_state : state_type; begin -- This is the first of three processes we will define in our sequence
Background image of page 2
-- detector. Here we define reset and state changes occuring on the -- rising edge of a clock signal (clocked synchronous state machine). state_register: process (clk, reset) begin if (reset = '1') then --if reset is high, goto state a1 state <= a1; elsif (clk'event and clk = '1') then --if not, and rising state <= next_state; --edge, go to next state end if; end process; -- This second process steps through each state based on state diagram. -- The sequence is "11010010" next_state_func: process (x, state) begin case state is when a1 => if x = '1' then next_state <= b1; else next_state <= a1; end if; when b1 => if x = '1' then next_state <= c1;
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
else next_state <= a1; end if; when c1 => if x = '1' then next_state <= c1; else next_state <= d1; end if; when d1 => if x ='1' then next_state <= e1; else next_state <= a1; end if; when e1 => if x = '1' then next_state <= c1; else next_state <= f1; end if; when f1 => if x = '1' then next_state <= b1; else
Background image of page 4
end if; when g1 => if x = '1' then next_state <= h1; else next_state <= a1; end if; when h1 => if x = '1' then next_state <= c1; else next_state <= i1; end if; when i1 => if x = '1' then next_state <= b1; else next_state <= a1; end if; end case; end process; -- This process controls the output of the sequence detector. -- Each state has it's own output along with 'z' which indicates
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 22

Task 3 Files - S EQUENCE.VH D library ieee; use...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online