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

Subversion Repositories mlite

[/] [mlite/] [trunk/] [vhdl/] [tbench.vhd] - Diff between revs 43 and 47

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

Rev 43 Rev 47
Line 12... Line 12...
library ieee;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_1164.all;
use work.mlite_pack.all;
use work.mlite_pack.all;
 
 
entity tbench is
entity tbench is
 
   port(write_pin : out std_logic;
 
        read_pin  : in std_logic);
end; --entity tbench
end; --entity tbench
 
 
architecture logic of tbench is
architecture logic of tbench is
 
   constant memory_type : string := "GENERIC";
component mlite_cpu
--   constant memory_type : string := "ALTERA";
   port(clk         : in std_logic;
--   constant memory_type : string := "XILINX";
        reset_in    : in std_logic;
 
        intr_in     : in std_logic;
 
 
 
        mem_address : out std_logic_vector(31 downto 0);
 
        mem_data_w  : out std_logic_vector(31 downto 0);
 
        mem_data_r  : in std_logic_vector(31 downto 0);
 
        mem_byte_sel: out std_logic_vector(3 downto 0);
 
        mem_write   : out std_logic;
 
        mem_pause   : in std_logic);
 
end component;
 
 
 
component ram
 
   generic(load_file_name : string);
 
   port(clk          : in std_logic;
 
        mem_byte_sel : in std_logic_vector(3 downto 0);
 
        mem_write    : in std_logic;
 
        mem_address  : in std_logic_vector;
 
        mem_data_w   : in std_logic_vector(31 downto 0);
 
        mem_data_r   : out std_logic_vector(31 downto 0));
 
end component;
 
 
 
   signal clk         : std_logic := '1';
   signal clk         : std_logic := '1';
   signal reset       : std_logic := '1';
   signal reset       : std_logic := '1';
   signal interrupt   : std_logic := '0';
   signal interrupt   : std_logic := '0';
   signal mem_write   : std_logic;
   signal mem_write   : std_logic;
 
   signal mem_read    : std_logic;
   signal mem_address : std_logic_vector(31 downto 0);
   signal mem_address : std_logic_vector(31 downto 0);
   signal mem_data_w  : std_logic_vector(31 downto 0);
   signal mem_data    : std_logic_vector(31 downto 0);
   signal mem_data_r  : std_logic_vector(31 downto 0);
   signal mem_pause   : std_logic := '0';
   signal mem_pause   : std_logic;
 
   signal mem_byte_sel: std_logic_vector(3 downto 0);
   signal mem_byte_sel: std_logic_vector(3 downto 0);
 
   signal uart_sel    : std_logic;
begin  --architecture
begin  --architecture
   clk <= not clk after 50 ns;
   clk <= not clk after 50 ns;
   reset <= '0' after 320 ns;
   reset <= '0' after 320 ns;
   mem_pause <= '0';
--   mem_pause <= '0';
 
   mem_read <= not mem_write;
 
   uart_sel <= '1' when mem_address(12 downto 0) = ONES(12 downto 0) and mem_byte_sel /= "0000" else
 
               '0';
 
 
   --Uncomment the line below to test interrupts
   --Uncomment the line below to test interrupts
--   interrupt <= '1' after 20 us when interrupt = '0' else '0' after 400 ns;
--   interrupt <= '1' after 20 us when interrupt = '0' else '0' after 400 ns;
 
 
   u1: mlite_cpu PORT MAP (
   u1: mlite_cpu
 
      generic map (memory_type => memory_type)
 
      PORT MAP (
        clk          => clk,
        clk          => clk,
        reset_in     => reset,
        reset_in     => reset,
        intr_in      => interrupt,
        intr_in      => interrupt,
 
 
        mem_address  => mem_address,
        mem_address  => mem_address,
        mem_data_w   => mem_data_w,
         mem_data_w   => mem_data,
        mem_data_r   => mem_data_r,
         mem_data_r   => mem_data,
        mem_byte_sel => mem_byte_sel,
        mem_byte_sel => mem_byte_sel,
        mem_write    => mem_write,
        mem_write    => mem_write,
        mem_pause    => mem_pause);
        mem_pause    => mem_pause);
 
 
   u2: ram generic map ("code.txt")
   generic_ram:
 
   if memory_type /= "ALTERA" generate
 
      u2: ram
 
         generic map ("code.txt")
       PORT MAP (
       PORT MAP (
        clk          => clk,
        clk          => clk,
        mem_byte_sel => mem_byte_sel,
        mem_byte_sel => mem_byte_sel,
        mem_write    => mem_write,
        mem_write    => mem_write,
        mem_address  => mem_address(15 downto 0),
        mem_address  => mem_address(15 downto 0),
        mem_data_w   => mem_data_w,
            mem_data_w   => mem_data,
        mem_data_r   => mem_data_r);
            mem_data_r   => mem_data);
 
   end generate; --generic_ram
 
 
 
   altera_ram:
 
   if memory_type = "ALTERA" generate
 
      uart_component: uart
 
         generic map ("output.txt")
 
         port map(
 
            clk       => clk,
 
            reset     => reset,
 
            uart_sel  => uart_sel,
 
            data      => mem_data(7 downto 0),
 
            write_pin => write_pin,
 
            read_pin  => read_pin,
 
            pause     => mem_pause);
 
 
 
      lpm_ram_io_component0 : lpm_ram_io
 
         GENERIC MAP (
 
            intended_device_family => "UNUSED",
 
            lpm_width => 8,
 
            lpm_widthad => 11,
 
            lpm_indata => "REGISTERED",
 
            lpm_address_control => "UNREGISTERED",
 
            lpm_outdata => "UNREGISTERED",
 
            lpm_file => "code0.hex",
 
            use_eab => "ON",
 
            lpm_type => "LPM_RAM_DQ")
 
         PORT MAP (
 
            outenab => mem_read,
 
            address => mem_address(12 downto 2),
 
            inclock => clk,
 
            we      => mem_byte_sel(3),
 
            dio     => mem_data(31 downto 24));
 
 
 
      lpm_ram_io_component1 : lpm_ram_io
 
         GENERIC MAP (
 
            intended_device_family => "UNUSED",
 
            lpm_width => 8,
 
            lpm_widthad => 11,
 
            lpm_indata => "REGISTERED",
 
            lpm_address_control => "UNREGISTERED",
 
            lpm_outdata => "UNREGISTERED",
 
            lpm_file => "code1.hex",
 
            use_eab => "ON",
 
            lpm_type => "LPM_RAM_DQ")
 
         PORT MAP (
 
            outenab => mem_read,
 
            address => mem_address(12 downto 2),
 
            inclock => clk,
 
            we      => mem_byte_sel(2),
 
            dio     => mem_data(23 downto 16));
 
 
 
      lpm_ram_io_component2 : lpm_ram_io
 
         GENERIC MAP (
 
            intended_device_family => "UNUSED",
 
            lpm_width => 8,
 
            lpm_widthad => 11,
 
            lpm_indata => "REGISTERED",
 
            lpm_address_control => "UNREGISTERED",
 
            lpm_outdata => "UNREGISTERED",
 
            lpm_file => "code2.hex",
 
            use_eab => "ON",
 
            lpm_type => "LPM_RAM_DQ")
 
         PORT MAP (
 
            outenab => mem_read,
 
            address => mem_address(12 downto 2),
 
            inclock => clk,
 
            we      => mem_byte_sel(1),
 
            dio     => mem_data(15 downto 8));
 
 
 
      lpm_ram_io_component3 : lpm_ram_io
 
         GENERIC MAP (
 
            intended_device_family => "UNUSED",
 
            lpm_width => 8,
 
            lpm_widthad => 11,
 
            lpm_indata => "REGISTERED",
 
            lpm_address_control => "UNREGISTERED",
 
            lpm_outdata => "UNREGISTERED",
 
            lpm_file => "code3.hex",
 
            use_eab => "ON",
 
            lpm_type => "LPM_RAM_DQ")
 
         PORT MAP (
 
            outenab => mem_read,
 
            address => mem_address(12 downto 2),
 
            inclock => clk,
 
            we      => mem_byte_sel(0),
 
            dio     => mem_data(7 downto 0));
 
   end generate; --altera_ram
 
 
end; --architecture logic
end; --architecture logic
 
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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