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

Subversion Repositories core_arm

[/] [core_arm/] [trunk/] [vhdl/] [sparc/] [ahbtest.vhd] - Blame information for rev 5

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tarookumic
 
2
 
3
 
4
 
5
----------------------------------------------------------------------------
6
--  This file is a part of the LEON VHDL model
7
--  Copyright (C) 1999  European Space Agency (ESA)
8
--
9
--  This library is free software; you can redistribute it and/or
10
--  modify it under the terms of the GNU Lesser General Public
11
--  License as published by the Free Software Foundation; either
12
--  version 2 of the License, or (at your option) any later version.
13
--
14
--  See the file COPYING.LGPL for the full details of the license.
15
 
16
 
17
 
18
library IEEE;
19
use IEEE.std_logic_1164.all;
20
use IEEE.std_logic_arith.all;
21
 
22
use work.amba.all;
23
use work.leon_iface.all;
24
 
25
 
26
entity ahbtest is
27
   port (
28
      rst             : in  std_logic;
29
      clk             : in  clk_type;
30
 
31
      -- peripheral bus
32
--      pbi             : in  APB_Slv_In_Type;   -- peripheral bus in
33
--      pbo             : out APB_Slv_Out_Type;  -- peripheral bus out
34
--      irq             : out std_logic;         -- interrupt request
35
 
36
--      ahbi1  : in  ahb_mst_in_type;   -- dma port in
37
--      ahbo1 : out ahb_mst_out_type;  -- dma port out
38
--      ahbi2  : in  ahb_mst_in_type;   -- dma port in
39
--      ahbo2 : out ahb_mst_out_type;  -- dma port out
40
      ahbi : in  ahb_slv_in_type;
41
      ahbo : out ahb_slv_out_type
42
 
43
 
44
      );
45
end;
46
 
47
architecture struct of ahbtest is
48
type slavestate is (idle, error, split, retry, ws1);
49
type reg_type is record
50
  haddr   : std_logic_vector(31 downto 0);   -- address bus
51
  hsel    : std_logic;
52
  htrans  : std_logic_vector(1 downto 0);    -- transfer type 
53
  hresp   : std_logic_vector(1 downto 0);    -- response type 
54
  hmaster : std_logic_vector(3 downto 0);    -- master
55
  smaster : std_logic_vector(3 downto 0);    -- split master
56
  hwrite  : std_logic;                       -- read/write
57
  hready  : std_logic;                       -- ready
58
  splitcnt : natural;
59
  ss : slavestate;
60
end record;
61
 
62
signal r, rin : reg_type;
63
 
64
begin
65
 
66
  comb : process(rst, ahbi, r)
67
  variable v : reg_type;
68
  variable prdata : std_logic_vector(31 downto 0);
69
  variable vsplit : std_logic_vector(15 downto 0);
70
  begin
71
 
72
    v := r; v.hready := '0'; vsplit := (others => '0');
73
 
74
    if r.splitcnt > 0 then
75
      v.splitcnt := r.splitcnt -1;
76
      if v.splitcnt = 0 then
77
        vsplit(conv_integer(unsigned(r.smaster))) := '1';
78
      end if;
79
    end if;
80
 
81
    if (ahbi.hready = '1') then
82
      v.hready := '0'; v.haddr  := ahbi.haddr; v.hwrite := ahbi.hwrite;
83
      v.hsel := ahbi.hsel; v.hwrite := ahbi.hwrite;
84
      v.hmaster := ahbi.hmaster;
85
    end if;
86
 
87
    if (ahbi.hsel and ahbi.hready) = '1' then
88
      if ((ahbi.htrans = HTRANS_NONSEQ) or (ahbi.htrans = HTRANS_SEQ))
89
          and (r.hresp = HRESP_OKAY)
90
      then
91
          if (ahbi.haddr(5 downto 4) = "01") and ((ahbi.haddr(3) xor ahbi.haddr(2)) = '1')
92
          then v.hresp := HRESP_RETRY; v.ss := retry;
93
          elsif (ahbi.haddr(5 downto 4) = "10") and ((ahbi.haddr(3) xor ahbi.haddr(2)) = '1')
94
          then v.hresp := HRESP_SPLIT; v.ss := split;
95
          elsif (ahbi.haddr(5 downto 4) = "11") and ((ahbi.haddr(3) xor ahbi.haddr(2)) = '1')
96
          then v.hresp := HRESP_ERROR; v.ss := error;
97
          else
98
            v.hresp := HRESP_OKAY;
99
            if (ahbi.haddr(3 downto 2) = "00") then v.ss := ws1;
100
            else v.hready := '1'; end if;
101
          end if;
102
      else
103
          if (r.hresp = HRESP_SPLIT) and (r.splitcnt > 2) then
104
            v.ss := split; v.hresp := HRESP_SPLIT;
105
          else
106
            v.hresp := HRESP_OKAY; v.ss := idle; v.hready := '1';
107
          end if;
108
      end if;
109
    end if;
110
    case r.ss is
111
    when idle =>
112
    when retry =>
113
          v.hresp := HRESP_RETRY; v.ss := idle; v.hready := '1';
114
    when split =>
115
          v.hresp := HRESP_SPLIT; v.ss := idle; v.hready := '1';
116
          v.smaster := r.hmaster;
117
          if r.splitcnt = 0 then v.splitcnt := 15; end if;
118
    when error =>
119
          v.hresp := HRESP_ERROR; v.ss := idle; v.hready := '1';
120
    when ws1 =>
121
          v.hresp := HRESP_OKAY; v.ss := idle; v.hready := '1';
122
    end case;
123
 
124
    ahbo.hresp  <= r.hresp;
125
    ahbo.hready <= r.hready;
126
    ahbo.hrdata <= r.haddr;
127
    ahbo.hsplit <= vsplit;
128
 
129
    if rst = '0' then
130
      v.hready := '1'; v.hsel := '0'; v.hresp := HRESP_OKAY;
131
      v.haddr := (others => '0');
132
    end if;
133
 
134
    rin <= v;
135
  end process;
136
 
137
--    ahbo1.haddr   <= (others => '0') ;
138
--    ahbo1.htrans  <= HTRANS_IDLE;
139
--    ahbo1.hbusreq <= '0';
140
--    ahbo1.hwdata  <= (others => '0');
141
--    ahbo1.hlock   <= '0';
142
--    ahbo1.hwrite  <= '0';
143
--    ahbo1.hsize   <= HSIZE_WORD;
144
--    ahbo1.hburst  <= HBURST_SINGLE;
145
--    ahbo1.hprot   <= (others => '0');      
146
 
147
 
148
  regs : process(clk)
149
  begin if rising_edge(clk) then r <= rin; end if; end process;
150
 
151
end;

powered by: WebSVN 2.1.0

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