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

Subversion Repositories mblite

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

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 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 mblite;
19
use mblite.config_Pkg.all;
20
use mblite.core_Pkg.all;
21
use mblite.std_Pkg.all;
22 2 takar
 
23 8 takar
use std.textio.all;
24 2 takar
 
25 8 takar
entity mblite_stdio is port
26 2 takar
(
27 8 takar
    dmem_i : out dmem_in_type;
28
    dmem_o : in dmem_out_type;
29
    clk_i  : in std_logic
30 2 takar
);
31 8 takar
end mblite_stdio;
32 2 takar
 
33 8 takar
architecture arch of mblite_stdio is
34
begin
35 2 takar
    -- Character device
36 8 takar
    stdio: process(clk_i)
37
            variable s    : line;
38
            variable byte : std_logic_vector(7 downto 0);
39
            variable char : character;
40
        begin
41
            dmem_i.dat_i <= (others => '0');
42 2 takar
            dmem_i.ena_i <= '1';
43 8 takar
            if rising_edge(clk_i) then
44
                if dmem_o.ena_o = '1' then
45
                    if dmem_o.we_o = '1' then
46 2 takar
                    -- WRITE STDOUT
47 8 takar
                        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 2 takar
                        char := character'val(my_conv_integer(byte));
55 8 takar
                        if byte = x"0d" then
56 2 takar
                            -- Ignore character 13
57 8 takar
                        elsif byte = x"0a" then
58 2 takar
                            -- Writeline on character 10 (newline)
59
                            writeline(output, s);
60 8 takar
                        else
61 2 takar
                            -- Write to buffer
62
                            write(s, char);
63 8 takar
                        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.