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

Subversion Repositories zpu

[/] [zpu/] [trunk/] [zpu/] [zpu4/] [src/] [io.vhd] - Blame information for rev 93

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 93 oharboe
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.numeric_std.all;
4
 
5
use std.textio.all;
6
 
7
library work;
8
use work.zpu_config.all;
9
use work.zpupkg.all;
10
use work.txt_util.all;
11
 
12
entity  zpu_io is
13
  generic (
14
           log_file:       string  := "log.txt"
15
          );
16
  port(
17
        clk         : in std_logic;
18
        areset        : in std_logic;
19
                busy : out std_logic;
20
                writeEnable : in std_logic;
21
                readEnable : in std_logic;
22
                write   : in std_logic_vector(wordSize-1 downto 0);
23
                read    : out std_logic_vector(wordSize-1 downto 0);
24
                addr : in std_logic_vector(maxAddrBit downto minAddrBit)
25
                );
26
end zpu_io;
27
 
28
 
29
architecture behave of zpu_io is
30
 
31
 
32
 
33
signal timer_read : std_logic_vector(7 downto 0);
34
--signal timer_write : std_logic_vector(7 downto 0);
35
signal timer_we : std_logic;
36
 
37
signal serving : std_logic;
38
 
39
file            l_file          : TEXT open write_mode is log_file;
40
constant lowAddrBits: std_logic_vector(minAddrBit-1 downto 0) := (others=>'0');
41
constant tx_full: std_logic := '0';
42
constant rx_empty: std_logic := '1';
43
 
44
begin
45
 
46
 
47
        timerinst: timer port map (
48
       clk => clk,
49
                 areset => areset,
50
                 we => timer_we,
51
                 din => write(7 downto 0),
52
                 adr => addr(4 downto 2),
53
                 dout => timer_read);
54
 
55
        busy <= writeEnable or readEnable;
56
        timer_we <= writeEnable and addr(12);
57
 
58
        process(areset, clk)
59
        variable taddr  : std_logic_vector(maxAddrBit downto 0);
60
        begin
61
                taddr := (others => '0');
62
                taddr(maxAddrBit downto minAddrBit) := addr;
63
 
64
                if (areset = '1') then
65
--                      timer_we <= '0';
66
                elsif (clk'event and clk = '1') then
67
--                      timer_we <= '0';
68
                        if writeEnable = '1' then
69
                                -- external interface (fixed address)
70
                                --<JK> extend compare to avoid waring messages
71
                                if ("1" & addr & lowAddrBits)=x"80a000c" then
72
                                        report "Write to UART[0]" & " :0x" & hstr(write);
73
                                        -- Write to UART
74
                                        -- report "" & character'image(conv_integer(memBint)) severity note;
75
                                    print(l_file, character'val(to_integer(unsigned(write))));
76
                                elsif addr(12)='1' then
77
                                        report "Write to TIMER" & " :0x" & hstr(write);
78
--                                  report "xxx" severity failure;
79
--                                      timer_we <= '1';
80
                                else
81
                                        print(l_file, character'val(to_integer(unsigned(write))));
82
                                        report "Illegal IO write @" & "0x" & hstr(taddr) severity warning;
83
                                end if;
84
 
85
                        end if;
86
                        read <= (others => '0');
87
                        if (readEnable = '1') then
88
                                --<JK> extend compare to avoid waring messages
89
                                if ("1" & addr & lowAddrBits)=x"80a000c" then
90
                                        report "Read UART[0]";
91
                                        read(8) <= not tx_full; -- output fifo not full
92
                                        read(9) <= not rx_empty; -- receiver not empty
93
                                elsif ("1" & addr & lowAddrBits)=x"80a0010" then
94
                                        report "Read UART[1]";
95
                                        read(8) <= not rx_empty; -- receiver not empty
96
                                        read(7 downto 0) <= (others => '0');
97
                                elsif addr(12)='1' then
98
                                        report "Read TIMER";
99
                                        read(7 downto 0) <= timer_read;
100
                                elsif addr(11)='1' then
101
                                        report "Read ZPU Freq";
102
                                        read(7 downto 0) <= ZPU_Frequency;
103
                                else
104
                                        report "Illegal IO read @" & "0x" & hstr(taddr) severity warning;
105
                                end if;
106
                        end if;
107
                end if;
108
        end process;
109
 
110
 
111
end behave;
112
 

powered by: WebSVN 2.1.0

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