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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.7/] [rtl/] [vlib/] [rbus/] [rbd_bram.vhd] - Blame information for rev 33

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 wfjm
-- $Id: rbd_bram.vhd 593 2014-09-14 22:21:33Z mueller $
2 10 wfjm
--
3 27 wfjm
-- Copyright 2010-2014 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4 10 wfjm
--
5
-- This program is free software; you may redistribute and/or modify it under
6
-- the terms of the GNU General Public License as published by the Free
7
-- Software Foundation, either version 2, or at your option any later version.
8
--
9
-- This program is distributed in the hope that it will be useful, but
10
-- WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
11
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
-- for complete details.
13
--
14
------------------------------------------------------------------------------
15
-- Module Name:    rbd_bram - syn
16
-- Description:    rbus dev: rbus bram test target
17
--
18
-- Dependencies:   memlib/ram_1swsr_wfirst_gen
19
--
20
-- Test bench:     rlink/tb/tb_rlink_tba_ttcombo
21
--
22
-- Target Devices: generic
23 27 wfjm
-- Tool versions:  xst 12.1-14.7; ghdl 0.29-0.31
24 10 wfjm
--
25
-- Synthesized (xst):
26
-- Date         Rev  ise         Target      flop lutl lutm slic t peri
27
-- 2010-12-26   349 12.1    M53d xc3s1000-4    23   61    -   34 s  6.3
28
--
29
-- Revision History: 
30
-- Date         Rev Version  Comment
31 27 wfjm
-- 2014-09-13   593   4.1    no default rbus addess anymore, def=0
32
-- 2014-08-15   583   4.0    rb_mreq addr now 16 bit
33 13 wfjm
-- 2011-11-19   427   1.0.3  now numeric_std clean
34 10 wfjm
-- 2010-12-31   352   1.0.2  simplify irb_ack logic
35
-- 2010-12-29   351   1.0.1  default addr 1111001x->1111010x
36
-- 2010-12-26   349   1.0    Initial version 
37
------------------------------------------------------------------------------
38
--
39
-- rbus registers:
40
--
41 27 wfjm
-- Addr   Bits  Name        r/w/f  Function
42
--    0         cntl        r/w/-  Control register
43
--       15:10    nbusy     r/w/-    busy cycles
44
--        9:00    addr      r/w/-    bram address (will auto-increment)
45
--    1  15:00  data        r/w/-  Data register (read/write to bram via addr)
46 10 wfjm
--
47
 
48
library ieee;
49
use ieee.std_logic_1164.all;
50 13 wfjm
use ieee.numeric_std.all;
51 10 wfjm
 
52
use work.slvtypes.all;
53
use work.memlib.all;
54
use work.rblib.all;
55
 
56
entity rbd_bram is                      -- rbus dev: rbus bram test target
57
                                        -- complete rrirp_aif interface
58
  generic (
59 27 wfjm
    RB_ADDR : slv16 := (others=>'0'));
60 10 wfjm
  port (
61
    CLK  : in slbit;                    -- clock
62
    RESET : in slbit;                   -- reset
63
    RB_MREQ : in rb_mreq_type;          -- rbus: request
64
    RB_SRES : out rb_sres_type          -- rbus: response
65
  );
66
end entity rbd_bram;
67
 
68
 
69
architecture syn of rbd_bram is
70
 
71
  constant rbaddr_cntl : slv1 := "0";   -- cntl address offset
72
  constant rbaddr_data : slv1 := "1";   -- data address offset
73
 
74
  subtype  cntl_rbf_nbusy   is integer range 15 downto 10;
75
  subtype  cntl_rbf_addr    is integer range  9 downto  0;
76
 
77
  type regs_type is record              -- state registers
78
    rbsel : slbit;                      -- rbus select
79
    addr : slv10;                       -- addr register
80
    nbusy : slv6;                       -- nbusy setting
81
    cntbusy : slv6;                     -- busy timer
82
  end record regs_type;
83
 
84
  constant regs_init : regs_type := (
85
    '0',                                -- rbsel
86
    (others=>'0'),                      -- addr
87
    (others=>'0'),                      -- nbusy
88
    (others=>'0')                       -- cntbusy
89
  );
90
 
91
  signal R_REGS : regs_type := regs_init;
92
  signal N_REGS : regs_type := regs_init;
93
 
94
  signal BRAM_EN : slbit := '0';
95
  signal BRAM_WE : slbit := '0';
96
  signal BRAM_DO : slv16 := (others=>'0');
97
 
98
begin
99
 
100
  BRAM : ram_1swsr_wfirst_gen
101
    generic map (
102
      AWIDTH => 10,
103
      DWIDTH => 16)
104
    port map (
105
      CLK   => CLK,
106
      EN    => BRAM_EN,
107
      WE    => BRAM_WE,
108
      ADDR  => R_REGS.addr,
109
      DI    => RB_MREQ.din,
110
      DO    => BRAM_DO
111
    );
112
 
113
  proc_regs: process (CLK)
114
  begin
115 13 wfjm
    if rising_edge(CLK) then
116 10 wfjm
      if RESET = '1' then
117
        R_REGS <= regs_init;
118
      else
119
        R_REGS <= N_REGS;
120
      end if;
121
    end if;
122
  end process proc_regs;
123
 
124
  proc_next : process (R_REGS, RB_MREQ, BRAM_DO)
125
    variable r : regs_type := regs_init;
126
    variable n : regs_type := regs_init;
127
    variable irb_ack  : slbit := '0';
128
    variable irb_busy : slbit := '0';
129
    variable irb_dout : slv16 := (others=>'0');
130
    variable irbena : slbit := '0';
131
    variable isbusy : slbit := '0';
132
    variable ibramen : slbit := '0';
133
    variable ibramwe : slbit := '0';
134
  begin
135
 
136
    r := R_REGS;
137
    n := R_REGS;
138
 
139
    irb_ack  := '0';
140
    irb_busy := '0';
141
    irb_dout := (others=>'0');
142
 
143
    irbena  := RB_MREQ.re or RB_MREQ.we;
144
 
145
    isbusy := '0';
146
    if unsigned(r.cntbusy) /= 0 then
147
      isbusy := '1';
148
    end if;
149
 
150
    ibramen := '0';
151
    ibramwe := '0';
152
 
153
    -- rbus address decoder
154
    n.rbsel := '0';
155 27 wfjm
    if RB_MREQ.aval='1' and RB_MREQ.addr(15 downto 1)=RB_ADDR(15 downto 1) then
156 10 wfjm
 
157
      n.rbsel := '1';
158
      ibramen := '1';
159
 
160
      if irbena = '0' then              -- addr valid and selected, but no req
161
        n.cntbusy := r.nbusy;             -- preset busy timer
162
      end if;
163
 
164
    end if;
165
 
166
    -- rbus transactions
167
    if r.rbsel = '1' then
168
 
169
      if irbena = '1' then              -- if request active
170
        if unsigned(r.cntbusy) /= 0 then  -- if busy timer > 0
171 13 wfjm
          n.cntbusy := slv(unsigned(r.cntbusy) - 1); -- decrement busy timer
172 10 wfjm
        end if;
173
      end if;
174
 
175
      irb_ack := irbena;                  -- ack all accesses
176
 
177
      case RB_MREQ.addr(0 downto 0) is
178
 
179
        when rbaddr_cntl =>
180
          if RB_MREQ.we = '1' then
181
            n.nbusy  := RB_MREQ.din(cntl_rbf_nbusy);
182
            n.addr   := RB_MREQ.din(cntl_rbf_addr);
183
          end if;
184
 
185
        when rbaddr_data =>
186
          irb_busy := irbena and isbusy;
187
          if isbusy = '0' then
188
            if RB_MREQ.we = '1' then
189
              ibramwe := '1';
190
            end if;
191
            if irbena = '1' then
192 13 wfjm
              n.addr := slv(unsigned(r.addr) + 1);
193 10 wfjm
            end if;
194
          end if;
195
 
196
        when others => null;
197
      end case;
198
    end if;
199
 
200
    -- rbus output driver
201
    if r.rbsel = '1' then
202
      case RB_MREQ.addr(0 downto 0) is
203
        when rbaddr_cntl =>
204
          irb_dout(cntl_rbf_nbusy) := r.nbusy;
205
          irb_dout(cntl_rbf_addr)  := r.addr;
206
        when rbaddr_data =>
207
          irb_dout := BRAM_DO;
208
        when others => null;
209
      end case;
210
    end if;
211
 
212
    N_REGS <= n;
213
 
214
    BRAM_EN <= ibramen;
215
    BRAM_WE <= ibramwe;
216
 
217
    RB_SRES.dout <= irb_dout;
218
    RB_SRES.ack  <= irb_ack;
219
    RB_SRES.err  <= '0';
220
    RB_SRES.busy <= irb_busy;
221
 
222
  end process proc_next;
223
 
224
end syn;

powered by: WebSVN 2.1.0

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