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

Subversion Repositories mblite

[/] [mblite/] [trunk/] [designs/] [core_decoder_wb/] [wb_stdio.vhd] - Diff between revs 6 and 8

Show entire file | Details | Blame | View Log

Rev 6 Rev 8
Line 9... Line 9...
--
--
--      Description        : Simulates standard output using stdio package
--      Description        : Simulates standard output using stdio package
--
--
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
 
 
LIBRARY ieee;
library ieee;
USE ieee.std_logic_1164.ALL;
use ieee.std_logic_1164.all;
USE ieee.std_logic_unsigned.ALL;
use ieee.std_logic_unsigned.all;
 
 
LIBRARY mblite;
library mblite;
USE mblite.config_Pkg.ALL;
use mblite.config_Pkg.all;
USE mblite.core_Pkg.ALL;
use mblite.core_Pkg.all;
USE mblite.std_Pkg.ALL;
use mblite.std_Pkg.all;
 
 
USE std.textio.ALL;
use std.textio.all;
 
 
ENTITY wb_stdio IS PORT
entity wb_stdio is port
(
(
    wb_o : OUT wb_slv_out_type;
    wb_o : out wb_slv_out_type;
    wb_i : IN wb_slv_in_type
    wb_i : in wb_slv_in_type
);
);
END wb_stdio;
end wb_stdio;
 
 
ARCHITECTURE arch OF wb_stdio IS
architecture arch of wb_stdio is
    CONSTANT ack_assert_delay : TIME := 2 ns;
    constant ack_assert_delay : TIME := 2 ns;
    CONSTANT ack_deassert_delay : TIME := 2 ns;
    constant ack_deassert_delay : TIME := 2 ns;
    SIGNAL ack : std_logic;
    signal ack : std_logic;
    SIGNAL chr_dat : std_logic_vector(31 DOWNTO 0);
    signal chr_dat : std_logic_vector(31 downto 0);
    SIGNAL chr_cnt : natural := 0;
    signal chr_cnt : natural := 0;
BEGIN
begin
    wb_o.int_o <= '0';
    wb_o.int_o <= '0';
    wb_o.dat_o <= chr_dat;
    wb_o.dat_o <= chr_dat;
    -- Character device
    -- Character device
    stdio: PROCESS(wb_i.clk_i)
    stdio: process(wb_i.clk_i)
        VARIABLE s    : line;
        variable s    : line;
        VARIABLE byte : std_logic_vector(7 DOWNTO 0);
        variable byte : std_logic_vector(7 downto 0);
        VARIABLE char : character;
        variable char : character;
    BEGIN
    begin
        IF rising_edge(wb_i.clk_i) THEN
        if rising_edge(wb_i.clk_i) then
            IF (wb_i.stb_i AND wb_i.cyc_i) = '1' THEN
            if (wb_i.stb_i and wb_i.cyc_i) = '1' then
                IF wb_i.we_i = '1' AND ack = '0' THEN
                if wb_i.we_i = '1' and ack = '0' then
                -- WRITE STDOUT
                -- WRITE STDOUT
                    wb_o.ack_o <= '1' AFTER ack_assert_delay;
                    wb_o.ack_o <= '1' after ack_assert_delay;
                    ack <= '1';
                    ack <= '1';
                    CASE wb_i.sel_i IS
                    case wb_i.sel_i is
                        WHEN "0001" => byte := wb_i.dat_i( 7 DOWNTO 0);
                        when "0001" => byte := wb_i.dat_i( 7 downto 0);
                        WHEN "0010" => byte := wb_i.dat_i(15 DOWNTO 8);
                        when "0010" => byte := wb_i.dat_i(15 downto 8);
                        WHEN "0100" => byte := wb_i.dat_i(23 DOWNTO 16);
                        when "0100" => byte := wb_i.dat_i(23 downto 16);
                        WHEN "1000" => byte := wb_i.dat_i(31 DOWNTO 24);
                        when "1000" => byte := wb_i.dat_i(31 downto 24);
                        WHEN OTHERS => NULL;
                        when others => null;
                    END CASE;
                    end case;
                    char := character'val(my_conv_integer(byte));
                    char := character'val(my_conv_integer(byte));
                    IF byte = X"0D" THEN
                    if byte = X"0D" then
                        -- Ignore character 13
                        -- Ignore character 13
                    ELSIF byte = X"0A" THEN
                    elsif byte = X"0A" then
                        -- Writeline on character 10 (newline)
                        -- Writeline on character 10 (newline)
                        writeline(output, s);
                        writeline(output, s);
                    ELSE
                    else
                        -- Write to buffer
                        -- Write to buffer
                        write(s, char);
                        write(s, char);
                    END IF;
                    end if;
                ELSIF ack = '0' THEN
                elsif ack = '0' then
                -- READ stdout
                -- READ stdout
                    ack <= '1';
                    ack <= '1';
                    wb_o.ack_o <= '1' AFTER ack_assert_delay;
                    wb_o.ack_o <= '1' after ack_assert_delay;
                    IF chr_cnt = 0 THEN
                    if chr_cnt = 0 then
                        chr_cnt <= 1;
                        chr_cnt <= 1;
                        chr_dat <= X"4C4C4C4C";
                        chr_dat <= X"4C4C4C4C";
                    ELSIF chr_cnt = 1 THEN
                    elsif chr_cnt = 1 then
                        chr_cnt <= 2;
                        chr_cnt <= 2;
                        chr_dat <= X"4D4D4D4D";
                        chr_dat <= X"4D4D4D4D";
                    ELSIF chr_cnt = 2 THEN
                    elsif chr_cnt = 2 then
                        chr_cnt <= 3;
                        chr_cnt <= 3;
                        chr_dat <= X"4E4E4E4E";
                        chr_dat <= X"4E4E4E4E";
                    ELSIF chr_cnt = 3 THEN
                    elsif chr_cnt = 3 then
                        chr_cnt <= 0;
                        chr_cnt <= 0;
                        chr_dat <= X"0A0A0A0A";
                        chr_dat <= X"0A0A0A0A";
                    END IF;
                    end if;
                END IF;
                end if;
            ELSE
            else
                ack <= '0';
                ack <= '0';
                wb_o.ack_o <= '0' AFTER ack_deassert_delay;
 
            END IF;
 
        END IF;
 
    END PROCESS;
 
END arch;
 
 No newline at end of file
 No newline at end of file
 
                wb_o.ack_o <= '0' after ack_deassert_delay;
 
            end if;
 
        end if;
 
    end process;
 
end arch;
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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