340 likes | 420 Views
Lab 6 Program Control. Mano & Kime Sections 7-9, 7-10, 8-1. Lab6 Fall 2002 Pcontrol. Richard E. Haskell Oakland University Rochester, MI 48309. Program Controller, Pcontrol. library IEEE; use IEEE.std_logic_1164. all ; use IEEE.std_logic_arith. all ; use work.opcodes. all ;.
E N D
Lab 6 Program Control Mano & Kime Sections 7-9, 7-10, 8-1
Lab6 Fall 2002 Pcontrol Richard E. Haskell Oakland University Rochester, MI 48309
Program Controller, Pcontrol library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_arith.all; use work.opcodes.all; opcodes package Note: working directory
entity Pcontrol is port ( icode: in STD_LOGIC_VECTOR (15 downto 0); M: in STD_LOGIC_VECTOR (15 downto 0); T: in STD_LOGIC_VECTOR (15 downto 0); clr: in STD_LOGIC; clk: in STD_LOGIC; BTN4: in STD_LOGIC; fcode: out STD_LOGIC_VECTOR (5 downto 0); msel: out STD_LOGIC_VECTOR (1 downto 0); pinc: out STD_LOGIC; pload: out STD_LOGIC; tload: out STD_LOGIC; nload: out STD_LOGIC; digload: out STD_LOGIC; iload: out STD_LOGIC ); end Pcontrol;
RESET constant rom: rom_array := ( JB4HI, X"0000", JB4LO, X"0002", SFETCH, digstore, JB4HI, X"0006", JB4LO, X"0008", twotimes, DUP, twotimes, twotimes, plus, digstore, JMP, X"0000", X"0000" ); X"0000" X"0000" icode PROM I reg M X“010D" fetch pinc = ‘1’ iload = ‘1’
constant rom: rom_array := ( JB4HI, X"0000", JB4LO, X"0002", SFETCH, digstore, JB4HI, X"0006", JB4LO, X"0008", twotimes, DUP, twotimes, twotimes, plus, digstore, JMP, X"0000", X"0000" ); JB4HI X“010D" X”0001” icode PROM I reg M X"0000” fetch pinc = ‘1’ iload = ‘1’ Decode icode exec Don’t fetch
constant rom: rom_array := ( JB4HI, X"0000", JB4LO, X"0002", SFETCH, digstore, JB4HI, X"0006", JB4LO, X"0008", twotimes, DUP, twotimes, twotimes, plus, digstore, JMP, X"0000", X"0000" ); X”0002” X“010D" icode PROM I reg M X“0109" fetch pinc = ‘1’ Iload = ‘1’ Decode icode exec Don’t fetch
constant rom: rom_array := ( JB4HI, X"0000", JB4LO, X"0002", SFETCH, digstore, JB4HI, X"0006", JB4LO, X"0008", twotimes, DUP, twotimes, twotimes, plus, digstore, JMP, X"0000", X"0000" ); JB4LO X”0003” X“0109" icode PROM I reg M X"0002" fetch pinc = ‘1’ Iload = ‘1’ Decode icode exec Don’t fetch
constant rom: rom_array := ( JB4HI, X"0000", JB4LO, X"0002", SFETCH, digstore, JB4HI, X"0006", JB4LO, X"0008", twotimes, DUP, twotimes, twotimes, plus, digstore, JMP, X"0000", X"0000" ); X”0004” X“0109" icode PROM I reg M X“0037" fetch pinc = ‘1’ Iload = ‘1’ Decode icode exec Don’t fetch
constant rom: rom_array := ( JB4HI, X"0000", JB4LO, X"0002", SFETCH, digstore, JB4HI, X"0006", JB4LO, X"0008", twotimes, DUP, twotimes, twotimes, plus, digstore, JMP, X"0000", X"0000" ); SFETCH X”0005” X“0037" icode PROM I reg M X“0038" fetch pinc = ‘1’ Iload = ‘1’ exec_ fetch Decode icode exec Don’t fetch
3B T reg constant rom: rom_array := ( JB4HI, X"0000", JB4LO, X"0002", SFETCH, digstore, JB4HI, X"0006", JB4LO, X"0008", twotimes, DUP, twotimes, twotimes, plus, digstore, JMP, X"0000", X"0000" ); DIGSTORE X”0006” X“0038" icode PROM I reg M X"010D" fetch pinc = ‘1’ Iload = ‘1’ exec_ fetch Decode icode exec Don’t fetch
3B T reg constant rom: rom_array := ( JB4HI, X"0000", JB4LO, X"0002", SFETCH, digstore, JB4HI, X"0006", JB4LO, X"0008", twotimes, DUP, twotimes, twotimes, plus, digstore, JMP, X"0000", X"0000" ); JB4HI X”0007” X“010D" icode PROM I reg M X"0006" fetch pinc = ‘1’ Iload = ‘1’ exec_ fetch Decode icode exec Don’t fetch
3B T reg constant rom: rom_array := ( JB4HI, X"0000", JB4LO, X"0002", SFETCH, digstore, JB4HI, X"0006", JB4LO, X"0008", twotimes, DUP, twotimes, twotimes, plus, digstore, JMP, X"0000", X"0000" ); JB4HI X”0006” X“010D" icode PROM I reg M X"010D" fetch pinc = ‘1’ Iload = ‘1’ exec_ fetch Decode icode exec Don’t fetch
3B T reg constant rom: rom_array := ( JB4HI, X"0000", JB4LO, X"0002", SFETCH, digstore, JB4HI, X"0006", JB4LO, X"0008", twotimes, DUP, twotimes, twotimes, plus, digstore, JMP, X"0000", X"0000" ); JB4HI X”0007” X“010D" icode PROM I reg M X"0006" fetch pinc = ‘1’ Iload = ‘1’ exec_ fetch Decode icode exec Don’t fetch
3B T reg constant rom: rom_array := ( JB4HI, X"0000", JB4LO, X"0002", SFETCH, digstore, JB4HI, X"0006", JB4LO, X"0008", twotimes, DUP, twotimes, twotimes, plus, digstore, JMP, X"0000", X"0000" ); X”0008” X“0109" icode PROM I reg M X“0109" fetch pinc = ‘1’ Iload = ‘1’ exec_ fetch Decode icode exec Don’t fetch
3B T reg constant rom: rom_array := ( JB4HI, X"0000", JB4LO, X"0002", SFETCH, digstore, JB4HI, X"0006", JB4LO, X"0008", twotimes, DUP, twotimes, twotimes, plus, digstore, JMP, X"0000", X"0000" ); JB4LO X”0009” X“0109" icode PROM I reg M X"0008" fetch pinc = ‘1’ Iload = ‘1’ exec_ fetch Decode icode exec Don’t fetch
3B T reg constant rom: rom_array := ( JB4HI, X"0000", JB4LO, X"0002", SFETCH, digstore, JB4HI, X"0006", JB4LO, X"0008", twotimes, DUP, twotimes, twotimes, plus, digstore, JMP, X"0000", X"0000" ); X”0008” X“0109" icode PROM I reg M X“0109" fetch pinc = ‘1’ Iload = ‘1’ exec_ fetch Decode icode exec Don’t fetch
3B T reg constant rom: rom_array := ( JB4HI, X"0000", JB4LO, X"0002", SFETCH, digstore, JB4HI, X"0006", JB4LO, X"0008", twotimes, DUP, twotimes, twotimes, plus, digstore, JMP, X"0000", X"0000" ); JB4LO X”0009” X“0109" icode PROM I reg M X"0008" fetch pinc = ‘1’ Iload = ‘1’ exec_ fetch Decode icode exec Don’t fetch
3B T reg constant rom: rom_array := ( JB4HI, X"0000", JB4LO, X"0002", SFETCH, digstore, JB4HI, X"0006", JB4LO, X"0008", twotimes, DUP, twotimes, twotimes, plus, digstore, JMP, X"0000", X"0000" ); X”000A” X“0109" icode PROM I reg M X"0018" fetch pinc = ‘1’ Iload = ‘1’ exec_ fetch Decode icode exec Don’t fetch
3B T reg constant rom: rom_array := ( JB4HI, X"0000", JB4LO, X"0002", SFETCH, digstore, JB4HI, X"0006", JB4LO, X"0008", twotimes, DUP, twotimes, twotimes, plus, digstore, JMP, X"0000", X"0000" ); twotimes X”000B” X"0018" icode PROM I reg M X“0001" fetch M(8)=‘0’ M(8)=‘1’ exec_ fetch exec M(8)=‘0’ M(8)=‘1’
76 T reg constant rom: rom_array := ( JB4HI, X"0000", JB4LO, X"0002", SFETCH, digstore, JB4HI, X"0006", JB4LO, X"0008", twotimes, DUP, twotimes, twotimes, plus, digstore, JMP, X"0000", X"0000" ); DUP X”000C” X"0001" icode PROM I reg M X“0018" fetch M(8)=‘0’ M(8)=‘1’ exec_ fetch exec M(8)=‘0’ M(8)=‘1’
76 T reg constant rom: rom_array := ( JB4HI, X"0000", JB4LO, X"0002", SFETCH, digstore, JB4HI, X"0006", JB4LO, X"0008", twotimes, DUP, twotimes, twotimes, plus, digstore, JMP, X"0000", X"0000" ); 76 N reg twotimes X”000D” X"0018" icode PROM I reg M X“0018" fetch M(8)=‘0’ M(8)=‘1’ exec_ fetch exec M(8)=‘0’ M(8)=‘1’
EC T reg constant rom: rom_array := ( JB4HI, X"0000", JB4LO, X"0002", SFETCH, digstore, JB4HI, X"0006", JB4LO, X"0008", twotimes, DUP, twotimes, twotimes, plus, digstore, JMP, X"0000", X"0000" ); 76 N reg twotimes X”000E” X"0018" icode PROM I reg M X“0010" fetch M(8)=‘0’ M(8)=‘1’ exec_ fetch exec M(8)=‘0’ M(8)=‘1’
1D8 T reg constant rom: rom_array := ( JB4HI, X"0000", JB4LO, X"0002", SFETCH, digstore, JB4HI, X"0006", JB4LO, X"0008", twotimes, DUP, twotimes, twotimes, plus, digstore, JMP, X"0000", X"0000" ); 76 N reg plus X”000F” X"0010" icode PROM I reg M X“0038" fetch M(8)=‘0’ M(8)=‘1’ exec_ fetch exec M(8)=‘0’ M(8)=‘1’
24E T reg constant rom: rom_array := ( JB4HI, X"0000", JB4LO, X"0002", SFETCH, digstore, JB4HI, X"0006", JB4LO, X"0008", twotimes, DUP, twotimes, twotimes, plus, digstore, JMP, X"0000", X"0000" ); 76 N reg digstore X”0010” X"0038" icode PROM I reg M X“0101" fetch M(8)=‘0’ M(8)=‘1’ exec_ fetch exec M(8)=‘0’ M(8)=‘1’
24E T reg constant rom: rom_array := ( JB4HI, X"0000", JB4LO, X"0002", SFETCH, digstore, JB4HI, X"0006", JB4LO, X"0008", twotimes, DUP, twotimes, twotimes, plus, digstore, JMP, X"0000", X"0000" ); 76 N reg JMP X”0011” X“0101" icode PROM I reg M X"0000" fetch pinc = ‘1’ Iload = ‘1’ M(8)=‘0’ M(8)=‘1’ exec_ fetch Decode icode exec Don’t fetch M(8)=‘0’ M(8)=‘1’
24E T reg constant rom: rom_array := ( JB4HI, X"0000", JB4LO, X"0002", SFETCH, digstore, JB4HI, X"0006", JB4LO, X"0008", twotimes, DUP, twotimes, twotimes, plus, digstore, JMP, X"0000", X"0000" ); 76 N reg X”0000” X“0101" icode PROM I reg M X"010D" fetch pinc = ‘1’ Iload = ‘1’ M(8)=‘0’ M(8)=‘1’ exec_ fetch Decode icode exec Don’t fetch M(8)=‘0’ M(8)=‘1’
Lab6 Pcontrol ControllerMealy Machine process(current_state, icode, t, z) clr C1 C2 s(t+1) State Register M next state s(t) current state process(current_state, M) icode t z clk process(clk, clr)
architecture Pcontrol_arch of Pcontrol is type state_type is (fetch, exec, exec_fetch); signal current_state, next_state: state_type; synch: process(clk, clr) begin if clr = '1' then current_state <= fetch; elsif (clk'event and clk = '1') then current_state <= next_state; endif; endprocess synch;
fetch C1: process(current_state, M) begin case current_state is when fetch => if M(8) = ‘1’ then next_state <= exec; else next_state <= exec_fetch; end if; when exec_fetch => if M(8) = ‘1’ then next_state <= exec; else next_state <= exec_fetch; end if; when exec => next_state <= fetch; end case; end process C1; M(8)=‘0’ M(8)=‘1’ M(8)=‘0’ exec_ fetch exec M(8)=‘1’
W8X ControllerMealy Machine process(current_state, icode, t, z) clr C1 C2 s(t+1) State Register M next state s(t) current state process(current_state, M) icode t z clk process(clk, clr)
C2: process(instr, current_state, BTN4) begin alusel <= "00"; msel <= "00"; pload <= '0'; tload <= '0'; nload <= '0'; digload <= '0'; inc <= '1'; iload <= '0'; if (current_state = fetch) or (current_state = exec_fetch) then iload <= '1'; -- fetch next instruction end if; if (current_state = exec) or (current_state = exec_fetch) then case instr is when nop => null; when dup => nload <= '1'; when plus => tload <= '1';
when plus1 => tload <= '1'; fcode <= icode(5 downto 0); when invert => tload <= '1'; fcode <= icode(5 downto 0); when twotimes => tload <= '1'; fcode <= icode(5 downto 0); when sfetch => tload <= '1'; msel <= "01"; when digstore => digload <= '1'; when jmp => pload <= '1'; inc <= '0'; when jb4LO => pload <= not BTN4; inc <= BTN4; when jb4HI => pload <= BTN4; inc <= not BTN4; when others => null; end case; end if; end process C2;
Lab6 Fall 2002 Pcontrol Richard E. Haskell Oakland University Rochester, MI 48309