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

Subversion Repositories mblite

[/] [mblite/] [trunk/] [designs/] [core_syn/] [testbench.vhd] - Diff between revs 6 and 8

Show entire file | Details | Blame | View Log

Rev 6 Rev 8
Line 9... Line 9...
--
--
--      Description        : Testbench instantiates mblite_soc and stdio
--      Description        : Testbench instantiates mblite_soc and stdio
--
--
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
 
 
LIBRARY ieee;
library ieee;
USE ieee.std_logic_1164.ALL;
use ieee.std_logic_1164.all;
USE ieee.std_logic_unsigned.ALL;
use ieee.std_logic_unsigned.all;
 
 
LIBRARY std;
library std;
USE std.textio.ALL;
use std.textio.all;
 
 
LIBRARY mblite;
library mblite;
USE mblite.config_Pkg.ALL;
use mblite.config_Pkg.all;
USE mblite.core_Pkg.ALL;
use mblite.core_Pkg.all;
USE mblite.std_Pkg.ALL;
use mblite.std_Pkg.all;
 
 
ENTITY testbench IS
entity testbench is
END testbench;
end testbench;
 
 
ARCHITECTURE arch OF testbench IS
architecture arch of testbench is
 
 
    COMPONENT mblite_soc IS PORT
    component mblite_soc is port
    (
    (
        sys_clk_i : in STD_LOGIC := 'X';
        sys_clk_i        : in std_logic := 'x';
        dbg_dmem_o_we_o : out STD_LOGIC;
        dbg_dmem_o_we_o  : out std_logic;
        dbg_dmem_o_ena_o : out STD_LOGIC;
        dbg_dmem_o_ena_o : out std_logic;
        sys_rst_i : in STD_LOGIC := 'X';
        sys_rst_i        : in std_logic := 'x';
        sys_ena_i : in STD_LOGIC := 'X';
        sys_ena_i        : in std_logic := 'x';
        sys_int_i : in STD_LOGIC := 'X';
        sys_int_i        : in std_logic := 'x';
        dbg_dmem_o_adr_o : out STD_LOGIC_VECTOR(31 downto 0);
        dbg_dmem_o_adr_o : out std_logic_vector(31 downto 0);
        dbg_dmem_o_dat_o : out STD_LOGIC_VECTOR(31 downto 0);
        dbg_dmem_o_dat_o : out std_logic_vector(31 downto 0);
        dbg_dmem_o_sel_o : out STD_LOGIC_VECTOR( 3 downto 0)
        dbg_dmem_o_sel_o : out std_logic_vector( 3 downto 0)
    );
    );
    END COMPONENT;
    end component;
 
 
    SIGNAL sys_clk_i : std_logic := '0';
    signal sys_clk_i : std_logic := '0';
    SIGNAL sys_int_i : std_logic := '0';
    signal sys_int_i : std_logic := '0';
    SIGNAL sys_rst_i : std_logic := '0';
    signal sys_rst_i : std_logic := '0';
    SIGNAL sys_ena_i : std_logic := '1';
    signal sys_ena_i : std_logic := '1';
 
 
    SIGNAL dmem_o : dmem_out_type;
    signal dmem_o : dmem_out_type;
 
 
    CONSTANT std_out_adr : std_logic_vector(CFG_DMEM_SIZE - 1 DOWNTO 0) := X"FFFFFFC0";
    constant std_out_adr : std_logic_vector(CFG_DMEM_SIZE - 1 downto 0) := X"FFFFFFC0";
BEGIN
begin
 
 
    sys_clk_i <= NOT sys_clk_i AFTER 10000 ps;
    sys_clk_i <= not sys_clk_i after 10000 ps;
    sys_rst_i <= '1' AFTER 0 ps, '0' AFTER  150000 ps;
    sys_rst_i <= '1' after 0 ps, '0' after  150000 ps;
    sys_int_i <= '1' AFTER 500000000 ps, '0' after 500040000 ps;
    sys_int_i <= '1' after 500000000 ps, '0' after 500040000 ps;
 
 
    soc : mblite_soc PORT MAP
    soc : mblite_soc port map
    (
    (
        sys_clk_i  => sys_clk_i,
        sys_clk_i  => sys_clk_i,
        dbg_dmem_o_we_o => dmem_o.we_o,
        dbg_dmem_o_we_o => dmem_o.we_o,
        dbg_dmem_o_ena_o => dmem_o.ena_o,
        dbg_dmem_o_ena_o => dmem_o.ena_o,
        sys_rst_i => sys_rst_i,
        sys_rst_i => sys_rst_i,
Line 67... Line 67...
        dbg_dmem_o_adr_o => dmem_o.adr_o,
        dbg_dmem_o_adr_o => dmem_o.adr_o,
        dbg_dmem_o_dat_o => dmem_o.dat_o,
        dbg_dmem_o_dat_o => dmem_o.dat_o,
        dbg_dmem_o_sel_o => dmem_o.sel_o
        dbg_dmem_o_sel_o => dmem_o.sel_o
    );
    );
 
 
    timeout: PROCESS(sys_clk_i)
    timeout: process(sys_clk_i)
    BEGIN
    begin
        IF NOW = 10 ms THEN
        if NOW = 10 ms then
            REPORT "TIMEOUT" SEVERITY FAILURE;
            report "TIMEOUT" severity FAILURE;
        END IF;
        end if;
    END PROCESS;
    end process;
 
 
    -- Character device
    -- Character device
    stdio: PROCESS(sys_clk_i)
    stdio: process(sys_clk_i)
        VARIABLE s    : line;
        variable s    : line;
        VARIABLE byte : std_logic_vector(7 DOWNTO 0);
        variable byte : std_logic_vector(7 downto 0);
        VARIABLE char : character;
        variable char : character;
    BEGIN
    begin
 
 
        IF rising_edge(sys_clk_i) THEN
        if rising_edge(sys_clk_i) then
            IF (NOT sys_rst_i AND dmem_o.ena_o AND compare(dmem_o.adr_o, std_out_adr)) = '1' THEN
            if (not sys_rst_i and dmem_o.ena_o and compare(dmem_o.adr_o, std_out_adr)) = '1' then
                IF dmem_o.we_o = '1' THEN
                if dmem_o.we_o = '1' then
                -- WRITE STDOUT
                -- WRITE STDOUT
                    CASE dmem_o.sel_o IS
                    case dmem_o.sel_o is
                        WHEN "0001" => byte := dmem_o.dat_o( 7 DOWNTO  0);
                        when "0001" => byte := dmem_o.dat_o( 7 downto  0);
                        WHEN "0010" => byte := dmem_o.dat_o(15 DOWNTO  8);
                        when "0010" => byte := dmem_o.dat_o(15 downto  8);
                        WHEN "0100" => byte := dmem_o.dat_o(23 DOWNTO 16);
                        when "0100" => byte := dmem_o.dat_o(23 downto 16);
                        WHEN "1000" => byte := dmem_o.dat_o(31 DOWNTO 24);
                        when "1000" => byte := dmem_o.dat_o(31 downto 24);
                        WHEN OTHERS => NULL;
                        when others => null;
                    END CASE;
                    end case;
                    char := character'val(my_conv_integer(byte));
                    char := character'val(my_conv_integer(byte));
                    IF byte = X"0D" THEN
                    if byte = X"0D" then
                        -- Ignore character 13
                        -- Ignore character 13
                    ELSIF byte = X"0A" THEN
                    elsif byte = X"0A" then
                        -- Writeline on character 10 (newline)
                        -- Writeline on character 10 (newline)
                        writeline(output, s);
                        writeline(output, s);
                    ELSE
                    else
                        -- Write to buffer
                        -- Write to buffer
                        write(s, char);
                        write(s, char);
                    END IF;
                    end if;
                END IF;
                end if;
            END IF;
            end if;
        END IF;
        end if;
 
 
    END PROCESS;
    end process;
 
 
END arch;
end arch;
 
 
 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.