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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [fpga/] [altera_de0_nano_soc/] [doc/] [Terasic/] [DE0_NANO_SOC/] [Demonstrations/] [FPGA/] [DE0_NANO_SOC_ADC/] [DE0_NANO_SOC_QSYS/] [synthesis/] [submodules/] [DE0_NANO_SOC_QSYS_mm_interconnect_0_router_001.sv] - Blame information for rev 221

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 221 olivier.gi
// (C) 2001-2014 Altera Corporation. All rights reserved.
2
// Your use of Altera Corporation's design tools, logic functions and other
3
// software and tools, and its AMPP partner logic functions, and any output
4
// files any of the foregoing (including device programming or simulation
5
// files), and any associated documentation or information are expressly subject
6
// to the terms and conditions of the Altera Program License Subscription
7
// Agreement, Altera MegaCore Function License Agreement, or other applicable
8
// license agreement, including, without limitation, that your use is for the
9
// sole purpose of programming logic devices manufactured by Altera and sold by
10
// Altera or its authorized distributors.  Please refer to the applicable
11
// agreement for further details.
12
 
13
 
14
 
15
// Your use of Altera Corporation's design tools, logic functions and other
16
// software and tools, and its AMPP partner logic functions, and any output
17
// files any of the foregoing (including device programming or simulation
18
// files), and any associated documentation or information are expressly subject
19
// to the terms and conditions of the Altera Program License Subscription
20
// Agreement, Altera MegaCore Function License Agreement, or other applicable
21
// license agreement, including, without limitation, that your use is for the
22
// sole purpose of programming logic devices manufactured by Altera and sold by
23
// Altera or its authorized distributors.  Please refer to the applicable
24
// agreement for further details.
25
 
26
 
27
// $Id: //acds/rel/14.0/ip/merlin/altera_merlin_router/altera_merlin_router.sv.terp#1 $
28
// $Revision: #1 $
29
// $Date: 2014/02/16 $
30
// $Author: swbranch $
31
 
32
// -------------------------------------------------------
33
// Merlin Router
34
//
35
// Asserts the appropriate one-hot encoded channel based on
36
// either (a) the address or (b) the dest id. The DECODER_TYPE
37
// parameter controls this behaviour. 0 means address decoder,
38
// 1 means dest id decoder.
39
//
40
// In the case of (a), it also sets the destination id.
41
// -------------------------------------------------------
42
 
43
`timescale 1 ns / 1 ns
44
 
45
module DE0_NANO_SOC_QSYS_mm_interconnect_0_router_001_default_decode
46
  #(
47
     parameter DEFAULT_CHANNEL = 1,
48
               DEFAULT_WR_CHANNEL = -1,
49
               DEFAULT_RD_CHANNEL = -1,
50
               DEFAULT_DESTID = 3
51
   )
52
  (output [82 - 80 : 0] default_destination_id,
53
   output [6-1 : 0] default_wr_channel,
54
   output [6-1 : 0] default_rd_channel,
55
   output [6-1 : 0] default_src_channel
56
  );
57
 
58
  assign default_destination_id =
59
    DEFAULT_DESTID[82 - 80 : 0];
60
 
61
  generate begin : default_decode
62
    if (DEFAULT_CHANNEL == -1) begin
63
      assign default_src_channel = '0;
64
    end
65
    else begin
66
      assign default_src_channel = 6'b1 << DEFAULT_CHANNEL;
67
    end
68
  end
69
  endgenerate
70
 
71
  generate begin : default_decode_rw
72
    if (DEFAULT_RD_CHANNEL == -1) begin
73
      assign default_wr_channel = '0;
74
      assign default_rd_channel = '0;
75
    end
76
    else begin
77
      assign default_wr_channel = 6'b1 << DEFAULT_WR_CHANNEL;
78
      assign default_rd_channel = 6'b1 << DEFAULT_RD_CHANNEL;
79
    end
80
  end
81
  endgenerate
82
 
83
endmodule
84
 
85
 
86
module DE0_NANO_SOC_QSYS_mm_interconnect_0_router_001
87
(
88
    // -------------------
89
    // Clock & Reset
90
    // -------------------
91
    input clk,
92
    input reset,
93
 
94
    // -------------------
95
    // Command Sink (Input)
96
    // -------------------
97
    input                       sink_valid,
98
    input  [96-1 : 0]    sink_data,
99
    input                       sink_startofpacket,
100
    input                       sink_endofpacket,
101
    output                      sink_ready,
102
 
103
    // -------------------
104
    // Command Source (Output)
105
    // -------------------
106
    output                          src_valid,
107
    output reg [96-1    : 0] src_data,
108
    output reg [6-1 : 0] src_channel,
109
    output                          src_startofpacket,
110
    output                          src_endofpacket,
111
    input                           src_ready
112
);
113
 
114
    // -------------------------------------------------------
115
    // Local parameters and variables
116
    // -------------------------------------------------------
117
    localparam PKT_ADDR_H = 55;
118
    localparam PKT_ADDR_L = 36;
119
    localparam PKT_DEST_ID_H = 82;
120
    localparam PKT_DEST_ID_L = 80;
121
    localparam PKT_PROTECTION_H = 86;
122
    localparam PKT_PROTECTION_L = 84;
123
    localparam ST_DATA_W = 96;
124
    localparam ST_CHANNEL_W = 6;
125
    localparam DECODER_TYPE = 0;
126
 
127
    localparam PKT_TRANS_WRITE = 58;
128
    localparam PKT_TRANS_READ  = 59;
129
 
130
    localparam PKT_ADDR_W = PKT_ADDR_H-PKT_ADDR_L + 1;
131
    localparam PKT_DEST_ID_W = PKT_DEST_ID_H-PKT_DEST_ID_L + 1;
132
 
133
 
134
 
135
    // -------------------------------------------------------
136
    // Figure out the number of bits to mask off for each slave span
137
    // during address decoding
138
    // -------------------------------------------------------
139
    localparam PAD0 = log2ceil(64'h10 - 64'h0);
140
    localparam PAD1 = log2ceil(64'h80000 - 64'h40000);
141
    localparam PAD2 = log2ceil(64'h81000 - 64'h80800);
142
    localparam PAD3 = log2ceil(64'h81008 - 64'h81000);
143
    localparam PAD4 = log2ceil(64'h81010 - 64'h81008);
144
    localparam PAD5 = log2ceil(64'h81018 - 64'h81010);
145
    // -------------------------------------------------------
146
    // Work out which address bits are significant based on the
147
    // address range of the slaves. If the required width is too
148
    // large or too small, we use the address field width instead.
149
    // -------------------------------------------------------
150
    localparam ADDR_RANGE = 64'h81018;
151
    localparam RANGE_ADDR_WIDTH = log2ceil(ADDR_RANGE);
152
    localparam OPTIMIZED_ADDR_H = (RANGE_ADDR_WIDTH > PKT_ADDR_W) ||
153
                                  (RANGE_ADDR_WIDTH == 0) ?
154
                                        PKT_ADDR_H :
155
                                        PKT_ADDR_L + RANGE_ADDR_WIDTH - 1;
156
 
157
    localparam RG = RANGE_ADDR_WIDTH-1;
158
    localparam REAL_ADDRESS_RANGE = OPTIMIZED_ADDR_H - PKT_ADDR_L;
159
 
160
      reg [PKT_ADDR_W-1 : 0] address;
161
      always @* begin
162
        address = {PKT_ADDR_W{1'b0}};
163
        address [REAL_ADDRESS_RANGE:0] = sink_data[OPTIMIZED_ADDR_H : PKT_ADDR_L];
164
      end
165
 
166
    // -------------------------------------------------------
167
    // Pass almost everything through, untouched
168
    // -------------------------------------------------------
169
    assign sink_ready        = src_ready;
170
    assign src_valid         = sink_valid;
171
    assign src_startofpacket = sink_startofpacket;
172
    assign src_endofpacket   = sink_endofpacket;
173
    wire [PKT_DEST_ID_W-1:0] default_destid;
174
    wire [6-1 : 0] default_src_channel;
175
 
176
 
177
 
178
 
179
    // -------------------------------------------------------
180
    // Write and read transaction signals
181
    // -------------------------------------------------------
182
    wire read_transaction;
183
    assign read_transaction  = sink_data[PKT_TRANS_READ];
184
 
185
 
186
    DE0_NANO_SOC_QSYS_mm_interconnect_0_router_001_default_decode the_default_decode(
187
      .default_destination_id (default_destid),
188
      .default_wr_channel   (),
189
      .default_rd_channel   (),
190
      .default_src_channel  (default_src_channel)
191
    );
192
 
193
    always @* begin
194
        src_data    = sink_data;
195
        src_channel = default_src_channel;
196
        src_data[PKT_DEST_ID_H:PKT_DEST_ID_L] = default_destid;
197
 
198
        // --------------------------------------------------
199
        // Address Decoder
200
        // Sets the channel and destination ID based on the address
201
        // --------------------------------------------------
202
 
203
    // ( 0x0 .. 0x10 )
204
    if ( {address[RG:PAD0],{PAD0{1'b0}}} == 20'h0   ) begin
205
            src_channel = 6'b100000;
206
            src_data[PKT_DEST_ID_H:PKT_DEST_ID_L] = 4;
207
    end
208
 
209
    // ( 0x40000 .. 0x80000 )
210
    if ( {address[RG:PAD1],{PAD1{1'b0}}} == 20'h40000   ) begin
211
            src_channel = 6'b000010;
212
            src_data[PKT_DEST_ID_H:PKT_DEST_ID_L] = 3;
213
    end
214
 
215
    // ( 0x80800 .. 0x81000 )
216
    if ( {address[RG:PAD2],{PAD2{1'b0}}} == 20'h80800   ) begin
217
            src_channel = 6'b000001;
218
            src_data[PKT_DEST_ID_H:PKT_DEST_ID_L] = 2;
219
    end
220
 
221
    // ( 0x81000 .. 0x81008 )
222
    if ( {address[RG:PAD3],{PAD3{1'b0}}} == 20'h81000   ) begin
223
            src_channel = 6'b001000;
224
            src_data[PKT_DEST_ID_H:PKT_DEST_ID_L] = 1;
225
    end
226
 
227
    // ( 0x81008 .. 0x81010 )
228
    if ( {address[RG:PAD4],{PAD4{1'b0}}} == 20'h81008  && read_transaction  ) begin
229
            src_channel = 6'b000100;
230
            src_data[PKT_DEST_ID_H:PKT_DEST_ID_L] = 5;
231
    end
232
 
233
    // ( 0x81010 .. 0x81018 )
234
    if ( {address[RG:PAD5],{PAD5{1'b0}}} == 20'h81010   ) begin
235
            src_channel = 6'b010000;
236
            src_data[PKT_DEST_ID_H:PKT_DEST_ID_L] = 0;
237
    end
238
 
239
end
240
 
241
 
242
    // --------------------------------------------------
243
    // Ceil(log2()) function
244
    // --------------------------------------------------
245
    function integer log2ceil;
246
        input reg[65:0] val;
247
        reg [65:0] i;
248
 
249
        begin
250
            i = 1;
251
            log2ceil = 0;
252
 
253
            while (i < val) begin
254
                log2ceil = log2ceil + 1;
255
                i = i << 1;
256
            end
257
        end
258
    endfunction
259
 
260
endmodule
261
 
262
 

powered by: WebSVN 2.1.0

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