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

Subversion Repositories test_project

[/] [test_project/] [trunk/] [rtl/] [verilog/] [components/] [ram_wb/] [ram_wb.v] - Blame information for rev 45

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 45 julius
module ram_wb ( dat_i, dat_o, adr_i, we_i, sel_i, cyc_i, stb_i, ack_o, cti_i, clk_i, rst_i);
2
 
3
   parameter dat_width = 32;
4
   parameter adr_width = 12;
5
   parameter mem_size  = 262144; // Default is 1MB (262144 32-bit words)
6
 
7
   // wishbone signals
8
   input [31:0]          dat_i;
9
   output [31:0]         dat_o;
10
   input [adr_width-1:2] adr_i;
11
   input                 we_i;
12
   input [3:0]            sel_i;
13
   input                 cyc_i;
14
   input                 stb_i;
15
   output reg            ack_o;
16
   input [2:0]            cti_i;
17
 
18
   // clock
19
   input                 clk_i;
20
   // async reset
21
   input                 rst_i;
22
 
23
   wire [31:0]            wr_data;
24
 
25
   // mux for data to ram
26
   assign wr_data[31:24] = sel_i[3] ? dat_i[31:24] : dat_o[31:24];
27
   assign wr_data[23:16] = sel_i[2] ? dat_i[23:16] : dat_o[23:16];
28
   assign wr_data[15: 8] = sel_i[1] ? dat_i[15: 8] : dat_o[15: 8];
29
   assign wr_data[ 7: 0] = sel_i[0] ? dat_i[ 7: 0] : dat_o[ 7: 0];
30
 
31
   ram_wb_sc_sw
32
     #
33
     (
34
      .dat_width(dat_width),
35
      .adr_width(adr_width),
36
      .mem_size(mem_size)
37
      )
38
     ram0
39
     (
40
      .dat_i(wr_data),
41
      .dat_o(dat_o),
42
      .adr_i({2'b00, adr_i}),
43
      .we_i(we_i & ack_o),
44
      .clk(clk_i)
45
      );
46
 
47
   // ack_o
48
   always @ (posedge clk_i or posedge rst_i)
49
     if (rst_i)
50
       ack_o <= 1'b0;
51
     else
52
       if (!ack_o)
53
         begin
54
            if (cyc_i & stb_i)
55
              ack_o <= 1'b1;
56
         end
57
       else
58
         ack_o <= 1'b0;
59
 
60
   // We did have acking logic which was sensitive to the
61
   // burst signals, cti_i, but this proved to cause problems
62
   // and we were never receiving back-to-back reads or writes
63
   // anyway. This logic which only acks one transaction at a
64
   // time appears to work well, despite not supporting burst
65
   // transactions.
66
 
67
endmodule
68
 
69
 

powered by: WebSVN 2.1.0

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