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

Subversion Repositories w11

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 wfjm
-- $Id: rbd_bram.vhd 427 2011-11-19 21:04:11Z mueller $
2 10 wfjm
--
3 13 wfjm
-- Copyright 2010-2011 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 13 wfjm
-- Tool versions:  xst 12.1, 13.1; ghdl 0.29
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 13 wfjm
-- 2011-11-19   427   1.0.3  now numeric_std clean
32 10 wfjm
-- 2010-12-31   352   1.0.2  simplify irb_ack logic
33
-- 2010-12-29   351   1.0.1  default addr 1111001x->1111010x
34
-- 2010-12-26   349   1.0    Initial version 
35
------------------------------------------------------------------------------
36
--
37
-- rbus registers:
38
--
39
-- Address   Bits Name        r/w/f  Function
40
-- bbbbbbb0       cntl        r/w/-  Control register
41
--          15:10   nbusy     r/w/-    busy cycles
42
--           9:00   addr      r/w/-    bram address (will auto-increment)
43
-- bbbbbbb1 15:00 data        r/w/-  Data register (read/write to bram via addr)
44
--
45
 
46
library ieee;
47
use ieee.std_logic_1164.all;
48 13 wfjm
use ieee.numeric_std.all;
49 10 wfjm
 
50
use work.slvtypes.all;
51
use work.memlib.all;
52
use work.rblib.all;
53
 
54
entity rbd_bram is                      -- rbus dev: rbus bram test target
55
                                        -- complete rrirp_aif interface
56
  generic (
57 13 wfjm
    RB_ADDR : slv8 := slv(to_unsigned(2#11110100#,8)));
58 10 wfjm
  port (
59
    CLK  : in slbit;                    -- clock
60
    RESET : in slbit;                   -- reset
61
    RB_MREQ : in rb_mreq_type;          -- rbus: request
62
    RB_SRES : out rb_sres_type          -- rbus: response
63
  );
64
end entity rbd_bram;
65
 
66
 
67
architecture syn of rbd_bram is
68
 
69
  constant rbaddr_cntl : slv1 := "0";   -- cntl address offset
70
  constant rbaddr_data : slv1 := "1";   -- data address offset
71
 
72
  subtype  cntl_rbf_nbusy   is integer range 15 downto 10;
73
  subtype  cntl_rbf_addr    is integer range  9 downto  0;
74
 
75
  type regs_type is record              -- state registers
76
    rbsel : slbit;                      -- rbus select
77
    addr : slv10;                       -- addr register
78
    nbusy : slv6;                       -- nbusy setting
79
    cntbusy : slv6;                     -- busy timer
80
  end record regs_type;
81
 
82
  constant regs_init : regs_type := (
83
    '0',                                -- rbsel
84
    (others=>'0'),                      -- addr
85
    (others=>'0'),                      -- nbusy
86
    (others=>'0')                       -- cntbusy
87
  );
88
 
89
  signal R_REGS : regs_type := regs_init;
90
  signal N_REGS : regs_type := regs_init;
91
 
92
  signal BRAM_EN : slbit := '0';
93
  signal BRAM_WE : slbit := '0';
94
  signal BRAM_DO : slv16 := (others=>'0');
95
 
96
begin
97
 
98
  BRAM : ram_1swsr_wfirst_gen
99
    generic map (
100
      AWIDTH => 10,
101
      DWIDTH => 16)
102
    port map (
103
      CLK   => CLK,
104
      EN    => BRAM_EN,
105
      WE    => BRAM_WE,
106
      ADDR  => R_REGS.addr,
107
      DI    => RB_MREQ.din,
108
      DO    => BRAM_DO
109
    );
110
 
111
  proc_regs: process (CLK)
112
  begin
113 13 wfjm
    if rising_edge(CLK) then
114 10 wfjm
      if RESET = '1' then
115
        R_REGS <= regs_init;
116
      else
117
        R_REGS <= N_REGS;
118
      end if;
119
    end if;
120
  end process proc_regs;
121
 
122
  proc_next : process (R_REGS, RB_MREQ, BRAM_DO)
123
    variable r : regs_type := regs_init;
124
    variable n : regs_type := regs_init;
125
    variable irb_ack  : slbit := '0';
126
    variable irb_busy : slbit := '0';
127
    variable irb_dout : slv16 := (others=>'0');
128
    variable irbena : slbit := '0';
129
    variable isbusy : slbit := '0';
130
    variable ibramen : slbit := '0';
131
    variable ibramwe : slbit := '0';
132
  begin
133
 
134
    r := R_REGS;
135
    n := R_REGS;
136
 
137
    irb_ack  := '0';
138
    irb_busy := '0';
139
    irb_dout := (others=>'0');
140
 
141
    irbena  := RB_MREQ.re or RB_MREQ.we;
142
 
143
    isbusy := '0';
144
    if unsigned(r.cntbusy) /= 0 then
145
      isbusy := '1';
146
    end if;
147
 
148
    ibramen := '0';
149
    ibramwe := '0';
150
 
151
    -- rbus address decoder
152
    n.rbsel := '0';
153
    if RB_MREQ.aval='1' and RB_MREQ.addr(7 downto 1)=RB_ADDR(7 downto 1) then
154
 
155
      n.rbsel := '1';
156
      ibramen := '1';
157
 
158
      if irbena = '0' then              -- addr valid and selected, but no req
159
        n.cntbusy := r.nbusy;             -- preset busy timer
160
      end if;
161
 
162
    end if;
163
 
164
    -- rbus transactions
165
    if r.rbsel = '1' then
166
 
167
      if irbena = '1' then              -- if request active
168
        if unsigned(r.cntbusy) /= 0 then  -- if busy timer > 0
169 13 wfjm
          n.cntbusy := slv(unsigned(r.cntbusy) - 1); -- decrement busy timer
170 10 wfjm
        end if;
171
      end if;
172
 
173
      irb_ack := irbena;                  -- ack all accesses
174
 
175
      case RB_MREQ.addr(0 downto 0) is
176
 
177
        when rbaddr_cntl =>
178
          if RB_MREQ.we = '1' then
179
            n.nbusy  := RB_MREQ.din(cntl_rbf_nbusy);
180
            n.addr   := RB_MREQ.din(cntl_rbf_addr);
181
          end if;
182
 
183
        when rbaddr_data =>
184
          irb_busy := irbena and isbusy;
185
          if isbusy = '0' then
186
            if RB_MREQ.we = '1' then
187
              ibramwe := '1';
188
            end if;
189
            if irbena = '1' then
190 13 wfjm
              n.addr := slv(unsigned(r.addr) + 1);
191 10 wfjm
            end if;
192
          end if;
193
 
194
        when others => null;
195
      end case;
196
    end if;
197
 
198
    -- rbus output driver
199
    if r.rbsel = '1' then
200
      case RB_MREQ.addr(0 downto 0) is
201
        when rbaddr_cntl =>
202
          irb_dout(cntl_rbf_nbusy) := r.nbusy;
203
          irb_dout(cntl_rbf_addr)  := r.addr;
204
        when rbaddr_data =>
205
          irb_dout := BRAM_DO;
206
        when others => null;
207
      end case;
208
    end if;
209
 
210
    N_REGS <= n;
211
 
212
    BRAM_EN <= ibramen;
213
    BRAM_WE <= ibramwe;
214
 
215
    RB_SRES.dout <= irb_dout;
216
    RB_SRES.ack  <= irb_ack;
217
    RB_SRES.err  <= '0';
218
    RB_SRES.busy <= irb_busy;
219
 
220
  end process proc_next;
221
 
222
end syn;

powered by: WebSVN 2.1.0

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