Line 39... |
Line 39... |
--memory interface
|
--memory interface
|
signal MemAddr: std_logic_vector(15 downto 0); --memory address (in bytes)
|
signal MemAddr: std_logic_vector(15 downto 0); --memory address (in bytes)
|
signal MemWW: std_logic; --memory writeword
|
signal MemWW: std_logic; --memory writeword
|
signal MemWE: std_logic; --memory writeenable
|
signal MemWE: std_logic; --memory writeenable
|
signal MemOut: std_logic_vector(15 downto 0);
|
signal MemOut: std_logic_vector(15 downto 0);
|
signal MemIn: std_logic_vector(15 downto 0);
|
signal MemIn: std_logic_vector(15 downto 0):=x"0000";
|
--general interface
|
--general interface
|
signal Reset: std_logic; --When this is high, CPU will reset within 1 clock cycles.
|
signal Reset: std_logic:='0'; --When this is high, CPU will reset within 1 clock cycles.
|
--Enable: in std_logic; --When this is high, the CPU executes as normal, when low the CPU stops at the next clock cycle(maintaining all state)
|
--Enable: in std_logic; --When this is high, the CPU executes as normal, when low the CPU stops at the next clock cycle(maintaining all state)
|
signal Hold: std_logic; --when high, CPU pauses execution and places Memory interfaces into high impendance state so the memory can be used by other components
|
signal Hold: std_logic:='0'; --when high, CPU pauses execution and places Memory interfaces into high impendance state so the memory can be used by other components
|
signal HoldAck: std_logic; --when high, CPU acknowledged hold and buses are in high Z
|
signal HoldAck: std_logic; --when high, CPU acknowledged hold and buses are in high Z
|
--todo: port interface
|
--todo: port interface
|
|
|
--debug ports:
|
--debug ports:
|
signal DebugIR: std_logic_vector(15 downto 0); --current instruction
|
signal DebugIR: std_logic_vector(15 downto 0); --current instruction
|
Line 109... |
Line 109... |
wait for 10 ns;
|
wait for 10 ns;
|
assert(HoldAck = '0') report "hold state lasts longer than it should" severity error;
|
assert(HoldAck = '0') report "hold state lasts longer than it should" severity error;
|
|
|
Reset <= '0';
|
Reset <= '0';
|
MemIn <= x"0012"; --mov r0, 0xFF
|
MemIn <= x"0012"; --mov r0, 0xFF
|
wait for 10 ns;
|
wait for 30 ns; --fetcher needs two clock cycles to catch up
|
assert(MemAddr = x"0100") report "Not fetching from correct start address" severity error;
|
assert(MemAddr = x"0100") report "Not fetching from correct start address" severity error;
|
MemIn <= x"00F1"; --mov r0, 0xF1
|
MemIn <= x"00F1"; --mov r0, 0xF1
|
wait for 10 ns;
|
wait for 10 ns;
|
assert(MemAddr = x"0102") report "fetcher is not incrementing address" severity error;
|
assert(MemAddr = x"0102") report "fetcher is not incrementing address" severity error;
|
assert(DebugIR = x"00F1" and DebugR0 /= x"12") report "IR is not correct. Execution occurs during first fetch";
|
assert(DebugIR = x"00F1" and DebugR0 /= x"12") report "IR is not correct. Execution occurs during first fetch";
|