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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [orpsocv2/] [rtl/] [verilog/] [ram_wb/] [ram_wb.v] - Blame information for rev 434

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

Line No. Rev Author Line
1 412 julius
module ram_wb
2
  (
3
   // Inputs
4
   wbm0_adr_i, wbm0_bte_i, wbm0_cti_i, wbm0_cyc_i, wbm0_dat_i, wbm0_sel_i,
5
   wbm0_stb_i, wbm0_we_i,
6
   // Outputs
7
   wbm0_ack_o, wbm0_err_o, wbm0_rty_o, wbm0_dat_o,
8
 
9
   // Inputs
10
   wbm1_adr_i, wbm1_bte_i, wbm1_cti_i, wbm1_cyc_i, wbm1_dat_i, wbm1_sel_i,
11
   wbm1_stb_i, wbm1_we_i,
12
   // Outputs
13
   wbm1_ack_o, wbm1_err_o, wbm1_rty_o, wbm1_dat_o,
14 6 julius
 
15 412 julius
   // Clock, reset
16
   wb_clk_i, wb_rst_i
17
   );
18
   // Bus parameters
19
   parameter dw = 32;
20
   parameter aw = 32;
21
   // Memory parameters
22
   parameter mem_span = 32'h0000_0400;
23
   parameter adr_width_for_span = 11; //(log2(mem_span));
24
 
25
 
26
   input [aw-1:0]        wbm0_adr_i;
27
   input [1:0]           wbm0_bte_i;
28
   input [2:0]           wbm0_cti_i;
29
   input                wbm0_cyc_i;
30
   input [dw-1:0]        wbm0_dat_i;
31
   input [3:0]           wbm0_sel_i;
32
   input                wbm0_stb_i;
33
   input                wbm0_we_i;
34 6 julius
 
35 412 julius
   output               wbm0_ack_o;
36
   output               wbm0_err_o;
37
   output               wbm0_rty_o;
38
   output [dw-1:0]       wbm0_dat_o;
39
 
40
   input [aw-1:0]        wbm1_adr_i;
41
   input [1:0]           wbm1_bte_i;
42
   input [2:0]           wbm1_cti_i;
43
   input                wbm1_cyc_i;
44
   input [dw-1:0]        wbm1_dat_i;
45
   input [3:0]           wbm1_sel_i;
46
   input                wbm1_stb_i;
47
   input                wbm1_we_i;
48 6 julius
 
49 412 julius
   output               wbm1_ack_o;
50
   output               wbm1_err_o;
51
   output               wbm1_rty_o;
52
   output [dw-1:0]       wbm1_dat_o;
53 6 julius
 
54 412 julius
 
55
   input                wb_clk_i;
56
   input                wb_rst_i;
57
 
58
   // Internal wires to actual RAM
59
   wire [aw-1:0]         wb_ram_adr_i;
60
   wire [1:0]            wb_ram_bte_i;
61
   wire [2:0]            wb_ram_cti_i;
62
   wire                 wb_ram_cyc_i;
63
   wire [dw-1:0]         wb_ram_dat_i;
64
   wire [3:0]            wb_ram_sel_i;
65
   wire                 wb_ram_stb_i;
66
   wire                 wb_ram_we_i;
67 6 julius
 
68 412 julius
   wire                 wb_ram_ack_o;
69
   wire                 wb_ram_err_o;
70
   wire                 wb_ram_rty_o;
71
   wire [dw-1:0]         wb_ram_dat_o;
72
 
73
   reg [1:0]             input_select, last_selected;
74
   wire                 arb_for_wbm0, arb_for_wbm1;
75
   // Wires allowing selection of new input
76
   assign arb_for_wbm0 = (last_selected[1] | !wbm1_cyc_i) & !(|input_select);
77
   assign arb_for_wbm1 = (last_selected[0] | !wbm0_cyc_i) & !(|input_select);
78 6 julius
 
79 412 julius
   // Master select logic
80
   always @(posedge wb_clk_i)
81
     if (wb_rst_i)
82
       input_select <= 0;
83
     else if ((input_select[0] & !wbm0_cyc_i) | (input_select[1] & !wbm1_cyc_i))
84
       input_select <= 0;
85
     else if (!(&input_select) & wbm0_cyc_i & arb_for_wbm0)
86
       input_select <= 2'b01;
87
     else if (!(&input_select) & wbm1_cyc_i & arb_for_wbm1)
88
       input_select <= 2'b10;
89
 
90
   always @(posedge wb_clk_i)
91
     if (wb_rst_i)
92
       last_selected <= 0;
93
     else if (!(&input_select) & wbm0_cyc_i & arb_for_wbm0)
94
       last_selected <= 2'b01;
95
     else if (!(&input_select) & wbm1_cyc_i & arb_for_wbm1)
96
       last_selected <= 2'b10;
97
 
98
   // Mux input signals to RAM (default to wbm0)
99
   assign wb_ram_adr_i = (input_select[1]) ? wbm1_adr_i :
100
                         (input_select[0]) ? wbm0_adr_i : 0;
101
   assign wb_ram_bte_i = (input_select[1]) ? wbm1_bte_i :
102
                         (input_select[0]) ? wbm0_bte_i : 0;
103
   assign wb_ram_cti_i = (input_select[1]) ? wbm1_cti_i :
104
                         (input_select[0]) ? wbm0_cti_i : 0;
105
   assign wb_ram_cyc_i = (input_select[1]) ? wbm1_cyc_i :
106
                         (input_select[0]) ? wbm0_cyc_i : 0;
107
   assign wb_ram_dat_i = (input_select[1]) ? wbm1_dat_i :
108
                         (input_select[0]) ? wbm0_dat_i : 0;
109
   assign wb_ram_sel_i = (input_select[1]) ? wbm1_sel_i :
110
                         (input_select[0]) ? wbm0_sel_i : 0;
111
   assign wb_ram_stb_i = (input_select[1]) ? wbm1_stb_i :
112
                         (input_select[0]) ? wbm0_stb_i : 0;
113
   assign wb_ram_we_i  = (input_select[1]) ? wbm1_we_i  :
114
                         (input_select[0]) ? wbm0_we_i : 0;
115
 
116
   // Output from RAM, gate the ACK, ERR, RTY signals appropriately
117
   assign wbm0_dat_o = wb_ram_dat_o;
118
   assign wbm0_ack_o = wb_ram_ack_o & input_select[0];
119
   assign wbm0_err_o = wb_ram_err_o & input_select[0];
120
   assign wbm0_rty_o = wb_ram_rty_o & input_select[0];
121
 
122
   assign wbm1_dat_o = wb_ram_dat_o;
123
   assign wbm1_ack_o = wb_ram_ack_o & input_select[1];
124
   assign wbm1_err_o = wb_ram_err_o & input_select[1];
125
   assign wbm1_rty_o = wb_ram_rty_o & input_select[1];
126
 
127
   ram_wb_b3 ram_wb_b3_0
128 6 julius
     (
129 412 julius
      // Outputs
130
      .wb_ack_o                         (wb_ram_ack_o),
131
      .wb_err_o                         (wb_ram_err_o),
132
      .wb_rty_o                         (wb_ram_rty_o),
133
      .wb_dat_o                         (wb_ram_dat_o),
134
      // Inputs
135
      .wb_adr_i                         (wb_ram_adr_i),
136
      .wb_bte_i                         (wb_ram_bte_i),
137
      .wb_cti_i                         (wb_ram_cti_i),
138
      .wb_cyc_i                         (wb_ram_cyc_i),
139
      .wb_dat_i                         (wb_ram_dat_i),
140
      .wb_sel_i                         (wb_ram_sel_i),
141
      .wb_stb_i                         (wb_ram_stb_i),
142
      .wb_we_i                          (wb_ram_we_i),
143
      .wb_clk_i                         (wb_clk_i),
144
      .wb_rst_i                         (wb_rst_i));
145 6 julius
 
146 412 julius
   defparam ram_wb_b3_0.aw = aw;
147
   defparam ram_wb_b3_0.dw = dw;
148
   defparam ram_wb_b3_0.mem_span = mem_span;
149
   defparam ram_wb_b3_0.adr_width_for_span = adr_width_for_span;
150
 
151
endmodule // ram_wb
152
 
153
 

powered by: WebSVN 2.1.0

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