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

Subversion Repositories mblite

[/] [mblite/] [trunk/] [designs/] [core_syn/] [testbench.vhd] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 takar
----------------------------------------------------------------------------------------------
2
--
3
--      Input file         : config_Pkg.vhd
4
--      Design name        : config_Pkg
5
--      Author             : Tamar Kranenburg
6
--      Company            : Delft University of Technology
7
--                         : Faculty EEMCS, Department ME&CE
8
--                         : Systems and Circuits group
9
--
10
--      Description        : Testbench instantiates mblite_soc and stdio
11
--
12
----------------------------------------------------------------------------------------------
13
 
14 8 takar
library ieee;
15
use ieee.std_logic_1164.all;
16
use ieee.std_logic_unsigned.all;
17 2 takar
 
18 8 takar
library std;
19
use std.textio.all;
20 2 takar
 
21 8 takar
library mblite;
22
use mblite.config_Pkg.all;
23
use mblite.core_Pkg.all;
24
use mblite.std_Pkg.all;
25 2 takar
 
26 8 takar
entity testbench is
27
end testbench;
28 2 takar
 
29 8 takar
architecture arch of testbench is
30 2 takar
 
31 8 takar
    component mblite_soc is port
32 2 takar
    (
33 8 takar
        sys_clk_i        : in std_logic := 'x';
34
        dbg_dmem_o_we_o  : out std_logic;
35
        dbg_dmem_o_ena_o : out std_logic;
36
        sys_rst_i        : in std_logic := 'x';
37
        sys_ena_i        : in std_logic := 'x';
38
        sys_int_i        : in std_logic := 'x';
39
        dbg_dmem_o_adr_o : out std_logic_vector(31 downto 0);
40
        dbg_dmem_o_dat_o : out std_logic_vector(31 downto 0);
41
        dbg_dmem_o_sel_o : out std_logic_vector( 3 downto 0)
42 2 takar
    );
43 8 takar
    end component;
44 2 takar
 
45 8 takar
    signal sys_clk_i : std_logic := '0';
46
    signal sys_int_i : std_logic := '0';
47
    signal sys_rst_i : std_logic := '0';
48
    signal sys_ena_i : std_logic := '1';
49 2 takar
 
50 8 takar
    signal dmem_o : dmem_out_type;
51 2 takar
 
52 8 takar
    constant std_out_adr : std_logic_vector(CFG_DMEM_SIZE - 1 downto 0) := X"FFFFFFC0";
53
begin
54 2 takar
 
55 8 takar
    sys_clk_i <= not sys_clk_i after 10000 ps;
56
    sys_rst_i <= '1' after 0 ps, '0' after  150000 ps;
57
    sys_int_i <= '1' after 500000000 ps, '0' after 500040000 ps;
58 2 takar
 
59 8 takar
    soc : mblite_soc port map
60 2 takar
    (
61
        sys_clk_i  => sys_clk_i,
62
        dbg_dmem_o_we_o => dmem_o.we_o,
63
        dbg_dmem_o_ena_o => dmem_o.ena_o,
64
        sys_rst_i => sys_rst_i,
65
        sys_ena_i => sys_ena_i,
66
        sys_int_i => sys_int_i,
67
        dbg_dmem_o_adr_o => dmem_o.adr_o,
68
        dbg_dmem_o_dat_o => dmem_o.dat_o,
69
        dbg_dmem_o_sel_o => dmem_o.sel_o
70
    );
71
 
72 8 takar
    timeout: process(sys_clk_i)
73
    begin
74
        if NOW = 10 ms then
75
            report "TIMEOUT" severity FAILURE;
76
        end if;
77
    end process;
78 2 takar
 
79
    -- Character device
80 8 takar
    stdio: process(sys_clk_i)
81
        variable s    : line;
82
        variable byte : std_logic_vector(7 downto 0);
83
        variable char : character;
84
    begin
85 2 takar
 
86 8 takar
        if rising_edge(sys_clk_i) then
87
            if (not sys_rst_i and dmem_o.ena_o and compare(dmem_o.adr_o, std_out_adr)) = '1' then
88
                if dmem_o.we_o = '1' then
89 2 takar
                -- WRITE STDOUT
90 8 takar
                    case dmem_o.sel_o is
91
                        when "0001" => byte := dmem_o.dat_o( 7 downto  0);
92
                        when "0010" => byte := dmem_o.dat_o(15 downto  8);
93
                        when "0100" => byte := dmem_o.dat_o(23 downto 16);
94
                        when "1000" => byte := dmem_o.dat_o(31 downto 24);
95
                        when others => null;
96
                    end case;
97 2 takar
                    char := character'val(my_conv_integer(byte));
98 8 takar
                    if byte = X"0D" then
99 2 takar
                        -- Ignore character 13
100 8 takar
                    elsif byte = X"0A" then
101 2 takar
                        -- Writeline on character 10 (newline)
102
                        writeline(output, s);
103 8 takar
                    else
104 2 takar
                        -- Write to buffer
105
                        write(s, char);
106 8 takar
                    end if;
107
                end if;
108
            end if;
109
        end if;
110 2 takar
 
111 8 takar
    end process;
112 2 takar
 
113 8 takar
end arch;

powered by: WebSVN 2.1.0

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