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 8

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 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 wb_stdio is port
26 2 takar
(
27 8 takar
    wb_o : out wb_slv_out_type;
28
    wb_i : in wb_slv_in_type
29 2 takar
);
30 8 takar
end wb_stdio;
31 2 takar
 
32 8 takar
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_logic;
36
    signal chr_dat : std_logic_vector(31 downto 0);
37
    signal chr_cnt : natural := 0;
38
begin
39 2 takar
    wb_o.int_o <= '0';
40
    wb_o.dat_o <= chr_dat;
41
    -- Character device
42 8 takar
    stdio: process(wb_i.clk_i)
43
        variable s    : line;
44
        variable byte : std_logic_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 2 takar
                -- WRITE STDOUT
51 8 takar
                    wb_o.ack_o <= '1' after ack_assert_delay;
52 2 takar
                    ack <= '1';
53 8 takar
                    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 2 takar
                    char := character'val(my_conv_integer(byte));
61 8 takar
                    if byte = X"0D" then
62 2 takar
                        -- Ignore character 13
63 8 takar
                    elsif byte = X"0A" then
64 2 takar
                        -- Writeline on character 10 (newline)
65
                        writeline(output, s);
66 8 takar
                    else
67 2 takar
                        -- Write to buffer
68
                        write(s, char);
69 8 takar
                    end if;
70
                elsif ack = '0' then
71 2 takar
                -- READ stdout
72
                    ack <= '1';
73 8 takar
                    wb_o.ack_o <= '1' after ack_assert_delay;
74
                    if chr_cnt = 0 then
75 2 takar
                        chr_cnt <= 1;
76
                        chr_dat <= X"4C4C4C4C";
77 8 takar
                    elsif chr_cnt = 1 then
78 2 takar
                        chr_cnt <= 2;
79
                        chr_dat <= X"4D4D4D4D";
80 8 takar
                    elsif chr_cnt = 2 then
81 2 takar
                        chr_cnt <= 3;
82
                        chr_dat <= X"4E4E4E4E";
83 8 takar
                    elsif chr_cnt = 3 then
84 2 takar
                        chr_cnt <= 0;
85
                        chr_dat <= X"0A0A0A0A";
86 8 takar
                    end if;
87
                end if;
88
            else
89 2 takar
                ack <= '0';
90 8 takar
                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.