OpenCores
URL https://opencores.org/ocsvn/light8080/light8080/trunk

Subversion Repositories light8080

[/] [light8080/] [trunk/] [vhdl/] [test/] [light8080_tb1.vhdl] - Diff between revs 2 and 13

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 2 Rev 13
Line 1... Line 1...
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Light8080 simulation test bench 1 : Interrupt response test
-- Light8080 simulation test bench 1 : Interrupt response test
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Source for the 8080 program is in asm\tb1.asm
-- Source for the 8080 program is in asm\tb1.asm
-- Upon completion, a value of 055h in ACC means success and a 0aah means
-- Upon completion, a value of 033h in ACC means success and a 0aah means
-- failure, but the proper behavior of intr/inta/halt has to be verified
-- failure, but the proper behavior of intr/inta/halt has to be verified
-- visually.
-- visually.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
 
 
LIBRARY ieee;
LIBRARY ieee;
Line 87... Line 87...
X"01",X"c6",X"01",X"c6",X"01",X"fb",X"c6",X"01",
X"01",X"c6",X"01",X"c6",X"01",X"fb",X"c6",X"01",
X"c6",X"01",X"c6",X"01",X"fb",X"76",X"fe",X"11",
X"c6",X"01",X"c6",X"01",X"fb",X"76",X"fe",X"11",
X"c2",X"7b",X"00",X"78",X"fe",X"00",X"c2",X"7b",
X"c2",X"7b",X"00",X"78",X"fe",X"00",X"c2",X"7b",
X"00",X"79",X"fe",X"0c",X"c2",X"7b",X"00",X"7a",
X"00",X"79",X"fe",X"0c",X"c2",X"7b",X"00",X"7a",
X"fe",X"12",X"7b",X"fe",X"34",X"c2",X"7b",X"00",
X"fe",X"12",X"7b",X"fe",X"34",X"c2",X"7b",X"00",
X"3e",X"55",X"76",X"3e",X"aa",X"76",X"00",X"00",
X"3e",X"33",X"76",X"3e",X"aa",X"76",X"00",X"00",
X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",
X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",
X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",
X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",
X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",
X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",
X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",
X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",
X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",
X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",
Line 332... Line 332...
X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00"
X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00"
 
 
);
);
 
 
 
 
 
 
type t_int_vectors is array(0 to 15) of std_logic_vector(7 downto 0);
type t_int_vectors is array(0 to 15) of std_logic_vector(7 downto 0);
 
 
 
-- This ROM holds the int vectors that will be fed to the CPU along the test. 
 
-- It will be read like a progrm ROM except a special pointer (vector_counter) 
 
-- will be used instead of the PC (see below).
 
-- Of course this is a simulation trick not meant to be synthesized.
signal int_vectors : t_int_vectors := (
signal int_vectors : t_int_vectors := (
  X"00",                -- not used
  X"00",                -- not used (see below)
  X"e7",                -- rst 4 (rst 20h)
  X"e7",                -- rst 4 (rst 20h)
  X"4f",                -- mov c,a 
  X"4f",                -- mov c,a 
  X"11", X"34", X"12",  -- lxi d, 1234h
  X"11", X"34", X"12",  -- lxi d, 1234h
  X"00",                -- nop
  X"00",                -- nop
  X"00",                -- not used
  X"00",                -- not used
  X"00", X"00", X"00", X"00", X"00", X"00", X"00", X"00"
  X"00", X"00", X"00", X"00", X"00", X"00", X"00", X"00"
);
);
 
 
 
-- This will be used to read the irq vector ROM. It's a pointer that increments 
 
-- whenever the CPU fetches a byte while inta_o is high.
signal vector_counter : integer := 0;
signal vector_counter : integer := 0;
 
-- Vector byte to be fed to the CPU in inta cycles
signal int_vector : std_logic_vector(7 downto 0);
signal int_vector : std_logic_vector(7 downto 0);
 
 
BEGIN
BEGIN
 
 
        -- Instantiate the Unit Under Test (UUT)
        -- Instantiate the Unit Under Test (UUT)
Line 396... Line 402...
                wait for (sim_length - T*1.5);
                wait for (sim_length - T*1.5);
 
 
                -- Stop the clk process asserting 'done'
                -- Stop the clk process asserting 'done'
                done <= '1';
                done <= '1';
 
 
 
 
          assert (done = '1')
          assert (done = '1')
                report "Test finished."
                report "Test finished."
        severity failure;
        severity failure;
 
 
 
 
                wait;
                wait;
        end process main_test;
        end process main_test;
 
 
  -- RAM access
  -- (Code) RAM access
  process(clk)
  process(clk)
  begin
  begin
    if (clk'event and clk='1') then
    if (clk'event and clk='1') then
      data_mem <= rom(conv_integer(addr_o(10 downto 0)));
      data_mem <= rom(conv_integer(addr_o(10 downto 0)));
      if wr_o = '1' then
      if wr_o = '1' then
        rom(conv_integer(addr_o(10 downto 0))) <= data_o;
        rom(conv_integer(addr_o(10 downto 0))) <= data_o;
      end if;
      end if;
    end if;
    end if;
  end process;
  end process;
 
 
 
  -- Interrupt vector ROM pointer; update it whenever the CPU fetches a byte
 
  -- while in INTA state.
  process(clk)
  process(clk)
  begin
  begin
    if (clk'event and clk='1') then
    if (clk'event and clk='1') then
      if inta_o = '1' and vma_o = '1' and rd_o='1' then
      if inta_o = '1' and vma_o = '1' and rd_o='1' then
        vector_counter <= vector_counter + 1;
        vector_counter <= vector_counter + 1;
      end if;
      end if;
    end if;
    end if;
  end process;
  end process;
 
 
 
  -- (Since the vector pointer pre-increments and the ROM in asynchronous, the
 
  -- first byte of the ROM is never used).
  int_vector <= int_vectors(vector_counter);
  int_vector <= int_vectors(vector_counter);
 
 
  data_i <= data_mem when inta_o='0' else int_vector;
  data_i <= data_mem when inta_o='0' else int_vector;
 
 
 
  -- Trigger the IRQ input in a pattern carefully synchronized to the code of 
 
  -- the test bench (see 'asm/tb1.asm').
        int0:
        int0:
        process
        process
        begin
        begin
                intr_i <= '0';
                intr_i <= '0';
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.