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.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_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
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'h80000 - 64'h40000);
140
    localparam PAD1 = log2ceil(64'h81000 - 64'h80800);
141
    // -------------------------------------------------------
142
    // Work out which address bits are significant based on the
143
    // address range of the slaves. If the required width is too
144
    // large or too small, we use the address field width instead.
145
    // -------------------------------------------------------
146
    localparam ADDR_RANGE = 64'h81000;
147
    localparam RANGE_ADDR_WIDTH = log2ceil(ADDR_RANGE);
148
    localparam OPTIMIZED_ADDR_H = (RANGE_ADDR_WIDTH > PKT_ADDR_W) ||
149
                                  (RANGE_ADDR_WIDTH == 0) ?
150
                                        PKT_ADDR_H :
151
                                        PKT_ADDR_L + RANGE_ADDR_WIDTH - 1;
152
 
153
    localparam RG = RANGE_ADDR_WIDTH-1;
154
    localparam REAL_ADDRESS_RANGE = OPTIMIZED_ADDR_H - PKT_ADDR_L;
155
 
156
      reg [PKT_ADDR_W-1 : 0] address;
157
      always @* begin
158
        address = {PKT_ADDR_W{1'b0}};
159
        address [REAL_ADDRESS_RANGE:0] = sink_data[OPTIMIZED_ADDR_H : PKT_ADDR_L];
160
      end
161
 
162
    // -------------------------------------------------------
163
    // Pass almost everything through, untouched
164
    // -------------------------------------------------------
165
    assign sink_ready        = src_ready;
166
    assign src_valid         = sink_valid;
167
    assign src_startofpacket = sink_startofpacket;
168
    assign src_endofpacket   = sink_endofpacket;
169
    wire [PKT_DEST_ID_W-1:0] default_destid;
170
    wire [6-1 : 0] default_src_channel;
171
 
172
 
173
 
174
 
175
 
176
 
177
    DE0_NANO_SOC_QSYS_mm_interconnect_0_router_default_decode the_default_decode(
178
      .default_destination_id (default_destid),
179
      .default_wr_channel   (),
180
      .default_rd_channel   (),
181
      .default_src_channel  (default_src_channel)
182
    );
183
 
184
    always @* begin
185
        src_data    = sink_data;
186
        src_channel = default_src_channel;
187
        src_data[PKT_DEST_ID_H:PKT_DEST_ID_L] = default_destid;
188
 
189
        // --------------------------------------------------
190
        // Address Decoder
191
        // Sets the channel and destination ID based on the address
192
        // --------------------------------------------------
193
 
194
    // ( 0x40000 .. 0x80000 )
195
    if ( {address[RG:PAD0],{PAD0{1'b0}}} == 20'h40000   ) begin
196
            src_channel = 6'b10;
197
            src_data[PKT_DEST_ID_H:PKT_DEST_ID_L] = 3;
198
    end
199
 
200
    // ( 0x80800 .. 0x81000 )
201
    if ( {address[RG:PAD1],{PAD1{1'b0}}} == 20'h80800   ) begin
202
            src_channel = 6'b01;
203
            src_data[PKT_DEST_ID_H:PKT_DEST_ID_L] = 2;
204
    end
205
 
206
end
207
 
208
 
209
    // --------------------------------------------------
210
    // Ceil(log2()) function
211
    // --------------------------------------------------
212
    function integer log2ceil;
213
        input reg[65:0] val;
214
        reg [65:0] i;
215
 
216
        begin
217
            i = 1;
218
            log2ceil = 0;
219
 
220
            while (i < val) begin
221
                log2ceil = log2ceil + 1;
222
                i = i << 1;
223
            end
224
        end
225
    endfunction
226
 
227
endmodule
228
 
229
 

powered by: WebSVN 2.1.0

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