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

Subversion Repositories mblite

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

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
 
22
USE std.textio.ALL;
23
 
24
ENTITY mblite_stdio IS PORT
25
(
26
    dmem_i : OUT dmem_in_type;
27
    dmem_o : IN dmem_out_type;
28
    clk_i  : IN std_ulogic
29
);
30
END mblite_stdio;
31
 
32
ARCHITECTURE arch OF mblite_stdio IS
33
BEGIN
34
    -- Character device
35
    stdio: PROCESS(clk_i)
36
            VARIABLE s    : line;
37
            VARIABLE byte : std_ulogic_vector(7 DOWNTO 0);
38
            VARIABLE char : character;
39
        BEGIN
40
            dmem_i.dat_i <= (OTHERS => '0');
41
            dmem_i.ena_i <= '1';
42
            IF rising_edge(clk_i) THEN
43
                IF dmem_o.ena_o = '1' THEN
44
                    IF dmem_o.we_o = '1' THEN
45
                    -- WRITE STDOUT
46
                        CASE dmem_o.sel_o IS
47
                            WHEN "0001" => byte := dmem_o.dat_o( 7 DOWNTO  0);
48
                            WHEN "0010" => byte := dmem_o.dat_o(15 DOWNTO  8);
49
                            WHEN "0100" => byte := dmem_o.dat_o(23 DOWNTO 16);
50
                            WHEN "1000" => byte := dmem_o.dat_o(31 DOWNTO 24);
51
                            WHEN OTHERS => NULL;
52
                        END CASE;
53
                        char := character'val(my_conv_integer(byte));
54
                        IF byte = X"0D" THEN
55
                            -- Ignore character 13
56
                        ELSIF byte = X"0A" THEN
57
                            -- Writeline on character 10 (newline)
58
                            writeline(output, s);
59
                        ELSE
60
                            -- Write to buffer
61
                            write(s, char);
62
                        END IF;
63
                    END IF;
64
                END IF;
65
            END IF;
66
    END PROCESS;
67
END arch;

powered by: WebSVN 2.1.0

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