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

Subversion Repositories mblite

[/] [mblite/] [trunk/] [designs/] [core_decoder_wb/] [wb_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         : wb_stdio.vhd
4
--      Design name        : wb_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
USE mblite.std_Pkg.ALL;
22
 
23
USE std.textio.ALL;
24
 
25
ENTITY wb_stdio IS PORT
26
(
27
    wb_o : OUT wb_slv_out_type;
28
    wb_i : IN wb_slv_in_type
29
);
30
END wb_stdio;
31
 
32
ARCHITECTURE arch OF wb_stdio IS
33
    CONSTANT ack_assert_delay : TIME := 2 ns;
34
    CONSTANT ack_deassert_delay : TIME := 2 ns;
35
    SIGNAL ack : std_ulogic;
36
    SIGNAL chr_dat : std_ulogic_vector(31 DOWNTO 0);
37
    SIGNAL chr_cnt : natural := 0;
38
BEGIN
39
    wb_o.int_o <= '0';
40
    wb_o.dat_o <= chr_dat;
41
    -- Character device
42
    stdio: PROCESS(wb_i.clk_i)
43
        VARIABLE s    : line;
44
        VARIABLE byte : std_ulogic_vector(7 DOWNTO 0);
45
        VARIABLE char : character;
46
    BEGIN
47
        IF rising_edge(wb_i.clk_i) THEN
48
            IF (wb_i.stb_i AND wb_i.cyc_i) = '1' THEN
49
                IF wb_i.we_i = '1' AND ack = '0' THEN
50
                -- WRITE STDOUT
51
                    wb_o.ack_o <= '1' AFTER ack_assert_delay;
52
                    ack <= '1';
53
                    CASE wb_i.sel_i IS
54
                        WHEN "0001" => byte := wb_i.dat_i( 7 DOWNTO 0);
55
                        WHEN "0010" => byte := wb_i.dat_i(15 DOWNTO 8);
56
                        WHEN "0100" => byte := wb_i.dat_i(23 DOWNTO 16);
57
                        WHEN "1000" => byte := wb_i.dat_i(31 DOWNTO 24);
58
                        WHEN OTHERS => NULL;
59
                    END CASE;
60
                    char := character'val(my_conv_integer(byte));
61
                    IF byte = X"0D" THEN
62
                        -- Ignore character 13
63
                    ELSIF byte = X"0A" THEN
64
                        -- Writeline on character 10 (newline)
65
                        writeline(output, s);
66
                    ELSE
67
                        -- Write to buffer
68
                        write(s, char);
69
                    END IF;
70
                ELSIF ack = '0' THEN
71
                -- READ stdout
72
                    ack <= '1';
73
                    wb_o.ack_o <= '1' AFTER ack_assert_delay;
74
                    IF chr_cnt = 0 THEN
75
                        chr_cnt <= 1;
76
                        chr_dat <= X"4C4C4C4C";
77
                    ELSIF chr_cnt = 1 THEN
78
                        chr_cnt <= 2;
79
                        chr_dat <= X"4D4D4D4D";
80
                    ELSIF chr_cnt = 2 THEN
81
                        chr_cnt <= 3;
82
                        chr_dat <= X"4E4E4E4E";
83
                    ELSIF chr_cnt = 3 THEN
84
                        chr_cnt <= 0;
85
                        chr_dat <= X"0A0A0A0A";
86
                    END IF;
87
                END IF;
88
            ELSE
89
                ack <= '0';
90
                wb_o.ack_o <= '0' AFTER ack_deassert_delay;
91
            END IF;
92
        END IF;
93
    END PROCESS;
94
END arch;

powered by: WebSVN 2.1.0

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