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

Subversion Repositories mblite

[/] [mblite/] [trunk/] [designs/] [core_decoder/] [mblite_stdio.vhd] - Blame information for rev 5

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 takar
----------------------------------------------------------------------------------------------
2
--
3
--      Input file         : mblite_stdio.vhd
4
--      Design name        : mblite_stdio
5
--      Author             : Tamar Kranenburg
6
--      Company            : Delft University of Technology
7
--                         : Faculty EEMCS, Department ME&CE
8
--                         : Systems and Circuits group
9
--
10
--      Description        : Simulates standard output using stdio package
11
--
12
----------------------------------------------------------------------------------------------
13
 
14
LIBRARY ieee;
15
USE ieee.std_logic_1164.ALL;
16
USE ieee.std_logic_unsigned.ALL;
17
 
18
LIBRARY mblite;
19
USE mblite.config_Pkg.ALL;
20
USE mblite.core_Pkg.ALL;
21 5 takar
USE mblite.std_Pkg.ALL;
22 2 takar
 
23
USE std.textio.ALL;
24
 
25
ENTITY mblite_stdio IS PORT
26
(
27
    dmem_i : OUT dmem_in_type;
28
    dmem_o : IN dmem_out_type;
29
    clk_i  : IN std_ulogic
30
);
31
END mblite_stdio;
32
 
33
ARCHITECTURE arch OF mblite_stdio IS
34
BEGIN
35
    -- Character device
36
    stdio: PROCESS(clk_i)
37
            VARIABLE s    : line;
38
            VARIABLE byte : std_ulogic_vector(7 DOWNTO 0);
39
            VARIABLE char : character;
40
        BEGIN
41
            dmem_i.dat_i <= (OTHERS => '0');
42
            dmem_i.ena_i <= '1';
43
            IF rising_edge(clk_i) THEN
44
                IF dmem_o.ena_o = '1' THEN
45
                    IF dmem_o.we_o = '1' THEN
46
                    -- WRITE STDOUT
47
                        CASE dmem_o.sel_o IS
48
                            WHEN "0001" => byte := dmem_o.dat_o( 7 DOWNTO  0);
49
                            WHEN "0010" => byte := dmem_o.dat_o(15 DOWNTO  8);
50
                            WHEN "0100" => byte := dmem_o.dat_o(23 DOWNTO 16);
51
                            WHEN "1000" => byte := dmem_o.dat_o(31 DOWNTO 24);
52
                            WHEN OTHERS => NULL;
53
                        END CASE;
54
                        char := character'val(my_conv_integer(byte));
55
                        IF byte = X"0D" THEN
56
                            -- Ignore character 13
57
                        ELSIF byte = X"0A" THEN
58
                            -- Writeline on character 10 (newline)
59
                            writeline(output, s);
60
                        ELSE
61
                            -- Write to buffer
62
                            write(s, char);
63
                        END IF;
64
                    END IF;
65
                END IF;
66
            END IF;
67
    END PROCESS;
68
END arch;

powered by: WebSVN 2.1.0

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