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

powered by: WebSVN 2.1.0

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