/
businterface.vhd
98 lines (92 loc) · 3.38 KB
/
businterface.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use work.P_BUSINTERFACE.all;
entity businterface is
port (
clock : in STD_LOGIC;
reset : in STD_LOGIC;
cpu_address : in STD_LOGIC_VECTOR (31 downto 0);
cpu_bus_active : in STD_LOGIC;
cpu_cycle_width : in T_CYCLE_WIDTH;
cpu_data_out : in STD_LOGIC_VECTOR (31 downto 0);
cpu_data_in : out STD_LOGIC_VECTOR (31 downto 0);
cpu_read : in STD_LOGIC;
cpu_write : in STD_LOGIC;
businterface_address : out STD_LOGIC_VECTOR (31 downto 2);
businterface_data_in : in STD_LOGIC_VECTOR (31 downto 0);
businterface_data_out : out STD_LOGIC_VECTOR (31 downto 0);
businterface_data_strobes : out STD_LOGIC_VECTOR (3 downto 0);
businterface_error : out STD_LOGIC;
businterface_read : out STD_LOGIC;
businterface_write : out STD_LOGIC
);
end entity;
architecture behavioral of businterface is
begin
process (clock)
begin
if (clock'Event and clock = '1') then
businterface_data_strobes <= (others => '0');
businterface_error <= '0';
businterface_address <= cpu_address (31 downto 2);
if (cpu_cycle_width = CW_BYTE) then
case cpu_address (1 downto 0) is
when "00" =>
businterface_data_strobes <= "1000";
businterface_data_out <= cpu_data_out (7 downto 0) & x"ff" & x"ff" & x"ff";
cpu_data_in <= x"ff" & x"ff" & x"ff" & businterface_data_in (31 downto 24);
when "01" =>
businterface_data_strobes <= "0100";
businterface_data_out <= x"ff" & cpu_data_out (7 downto 0) & x"ff" & x"ff";
cpu_data_in <= x"ff" & x"ff" & x"ff" & businterface_data_in (23 downto 16);
when "10" =>
businterface_data_strobes <= "0010";
businterface_data_out <= x"ff" & x"ff" & cpu_data_out (7 downto 0) & x"ff";
cpu_data_in <= x"ff" & x"ff" & x"ff" & businterface_data_in (15 downto 8);
when "11" =>
businterface_data_strobes <= "0001";
businterface_data_out <= x"ff" & x"ff" & x"ff" & cpu_data_out (7 downto 0);
cpu_data_in <= x"ff" & x"ff" & x"ff" & businterface_data_in (7 downto 0);
when others =>
end case;
elsif (cpu_cycle_width = CW_WORD) then
case cpu_address (1 downto 0) is
when "00" =>
businterface_data_strobes <= "1100";
businterface_data_out <= cpu_data_out (15 downto 0) & x"ffff";
cpu_data_in <= x"ffff" & businterface_data_in (31 downto 16);
when "01" =>
businterface_error <= '1';
when "10" =>
businterface_data_strobes <= "0011";
businterface_data_out <= x"ffff" & cpu_data_out (15 downto 0);
cpu_data_in <= x"ffff" & businterface_data_in (15 downto 0);
when "11" =>
businterface_error <= '1';
when others =>
end case;
elsif (cpu_cycle_width = CW_LONG) then
case cpu_address (1 downto 0) is
when "00" =>
businterface_data_strobes <= "1111";
businterface_data_out <= cpu_data_out (31 downto 0);
cpu_data_in <= businterface_data_in (31 downto 0);
when "01" =>
businterface_error <= '1';
when "10" =>
businterface_error <= '1';
when "11" =>
businterface_error <= '1';
when others =>
end case;
else
businterface_data_out <= x"ffffffff";
cpu_data_in <= x"ffffffff";
end if;
-- could short these in the upper level, but will need them when multi-
-- cycle operation is implemented.
businterface_read <= cpu_read;
businterface_write <= cpu_write;
end if;
end process;
end architecture;