| 1 |
32 |
redbear |
// (C) 2001-2017 Intel Corporation. All rights reserved.
|
| 2 |
|
|
// Your use of Intel 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 Intel Program License Subscription
|
| 7 |
|
|
// Agreement, Intel 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 Intel and sold by
|
| 10 |
|
|
// Intel 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/17.0std/ip/merlin/altera_merlin_router/altera_merlin_router.sv.terp#1 $
|
| 28 |
|
|
// $Revision: #1 $
|
| 29 |
|
|
// $Date: 2017/01/22 $
|
| 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 ulight_fifo_mm_interconnect_0_router_002_default_decode
|
| 46 |
|
|
#(
|
| 47 |
|
|
parameter DEFAULT_CHANNEL = -1,
|
| 48 |
|
|
DEFAULT_WR_CHANNEL = 0,
|
| 49 |
|
|
DEFAULT_RD_CHANNEL = 1,
|
| 50 |
|
|
DEFAULT_DESTID = 0
|
| 51 |
|
|
)
|
| 52 |
|
|
(output [104 - 100 : 0] default_destination_id,
|
| 53 |
|
|
output [22-1 : 0] default_wr_channel,
|
| 54 |
|
|
output [22-1 : 0] default_rd_channel,
|
| 55 |
|
|
output [22-1 : 0] default_src_channel
|
| 56 |
|
|
);
|
| 57 |
|
|
|
| 58 |
|
|
assign default_destination_id =
|
| 59 |
|
|
DEFAULT_DESTID[104 - 100 : 0];
|
| 60 |
|
|
|
| 61 |
|
|
generate
|
| 62 |
|
|
if (DEFAULT_CHANNEL == -1) begin : no_default_channel_assignment
|
| 63 |
|
|
assign default_src_channel = '0;
|
| 64 |
|
|
end
|
| 65 |
|
|
else begin : default_channel_assignment
|
| 66 |
|
|
assign default_src_channel = 22'b1 << DEFAULT_CHANNEL;
|
| 67 |
|
|
end
|
| 68 |
|
|
endgenerate
|
| 69 |
|
|
|
| 70 |
|
|
generate
|
| 71 |
|
|
if (DEFAULT_RD_CHANNEL == -1) begin : no_default_rw_channel_assignment
|
| 72 |
|
|
assign default_wr_channel = '0;
|
| 73 |
|
|
assign default_rd_channel = '0;
|
| 74 |
|
|
end
|
| 75 |
|
|
else begin : default_rw_channel_assignment
|
| 76 |
|
|
assign default_wr_channel = 22'b1 << DEFAULT_WR_CHANNEL;
|
| 77 |
|
|
assign default_rd_channel = 22'b1 << DEFAULT_RD_CHANNEL;
|
| 78 |
|
|
end
|
| 79 |
|
|
endgenerate
|
| 80 |
|
|
|
| 81 |
|
|
endmodule
|
| 82 |
|
|
|
| 83 |
|
|
|
| 84 |
|
|
module ulight_fifo_mm_interconnect_0_router_002
|
| 85 |
|
|
(
|
| 86 |
|
|
// -------------------
|
| 87 |
|
|
// Clock & Reset
|
| 88 |
|
|
// -------------------
|
| 89 |
|
|
input clk,
|
| 90 |
|
|
input reset,
|
| 91 |
|
|
|
| 92 |
|
|
// -------------------
|
| 93 |
|
|
// Command Sink (Input)
|
| 94 |
|
|
// -------------------
|
| 95 |
|
|
input sink_valid,
|
| 96 |
|
|
input [129-1 : 0] sink_data,
|
| 97 |
|
|
input sink_startofpacket,
|
| 98 |
|
|
input sink_endofpacket,
|
| 99 |
|
|
output sink_ready,
|
| 100 |
|
|
|
| 101 |
|
|
// -------------------
|
| 102 |
|
|
// Command Source (Output)
|
| 103 |
|
|
// -------------------
|
| 104 |
|
|
output src_valid,
|
| 105 |
|
|
output reg [129-1 : 0] src_data,
|
| 106 |
|
|
output reg [22-1 : 0] src_channel,
|
| 107 |
|
|
output src_startofpacket,
|
| 108 |
|
|
output src_endofpacket,
|
| 109 |
|
|
input src_ready
|
| 110 |
|
|
);
|
| 111 |
|
|
|
| 112 |
|
|
// -------------------------------------------------------
|
| 113 |
|
|
// Local parameters and variables
|
| 114 |
|
|
// -------------------------------------------------------
|
| 115 |
|
|
localparam PKT_ADDR_H = 65;
|
| 116 |
|
|
localparam PKT_ADDR_L = 36;
|
| 117 |
|
|
localparam PKT_DEST_ID_H = 104;
|
| 118 |
|
|
localparam PKT_DEST_ID_L = 100;
|
| 119 |
|
|
localparam PKT_PROTECTION_H = 119;
|
| 120 |
|
|
localparam PKT_PROTECTION_L = 117;
|
| 121 |
|
|
localparam ST_DATA_W = 129;
|
| 122 |
|
|
localparam ST_CHANNEL_W = 22;
|
| 123 |
|
|
localparam DECODER_TYPE = 1;
|
| 124 |
|
|
|
| 125 |
|
|
localparam PKT_TRANS_WRITE = 68;
|
| 126 |
|
|
localparam PKT_TRANS_READ = 69;
|
| 127 |
|
|
|
| 128 |
|
|
localparam PKT_ADDR_W = PKT_ADDR_H-PKT_ADDR_L + 1;
|
| 129 |
|
|
localparam PKT_DEST_ID_W = PKT_DEST_ID_H-PKT_DEST_ID_L + 1;
|
| 130 |
|
|
|
| 131 |
|
|
|
| 132 |
|
|
|
| 133 |
|
|
// -------------------------------------------------------
|
| 134 |
|
|
// Figure out the number of bits to mask off for each slave span
|
| 135 |
|
|
// during address decoding
|
| 136 |
|
|
// -------------------------------------------------------
|
| 137 |
|
|
// -------------------------------------------------------
|
| 138 |
|
|
// Work out which address bits are significant based on the
|
| 139 |
|
|
// address range of the slaves. If the required width is too
|
| 140 |
|
|
// large or too small, we use the address field width instead.
|
| 141 |
|
|
// -------------------------------------------------------
|
| 142 |
|
|
localparam ADDR_RANGE = 64'h0;
|
| 143 |
|
|
localparam RANGE_ADDR_WIDTH = log2ceil(ADDR_RANGE);
|
| 144 |
|
|
localparam OPTIMIZED_ADDR_H = (RANGE_ADDR_WIDTH > PKT_ADDR_W) ||
|
| 145 |
|
|
(RANGE_ADDR_WIDTH == 0) ?
|
| 146 |
|
|
PKT_ADDR_H :
|
| 147 |
|
|
PKT_ADDR_L + RANGE_ADDR_WIDTH - 1;
|
| 148 |
|
|
|
| 149 |
|
|
localparam RG = RANGE_ADDR_WIDTH;
|
| 150 |
|
|
localparam REAL_ADDRESS_RANGE = OPTIMIZED_ADDR_H - PKT_ADDR_L;
|
| 151 |
|
|
|
| 152 |
|
|
reg [PKT_DEST_ID_W-1 : 0] destid;
|
| 153 |
|
|
|
| 154 |
|
|
// -------------------------------------------------------
|
| 155 |
|
|
// Pass almost everything through, untouched
|
| 156 |
|
|
// -------------------------------------------------------
|
| 157 |
|
|
assign sink_ready = src_ready;
|
| 158 |
|
|
assign src_valid = sink_valid;
|
| 159 |
|
|
assign src_startofpacket = sink_startofpacket;
|
| 160 |
|
|
assign src_endofpacket = sink_endofpacket;
|
| 161 |
|
|
wire [22-1 : 0] default_rd_channel;
|
| 162 |
|
|
wire [22-1 : 0] default_wr_channel;
|
| 163 |
|
|
|
| 164 |
|
|
|
| 165 |
|
|
|
| 166 |
|
|
|
| 167 |
|
|
// -------------------------------------------------------
|
| 168 |
|
|
// Write and read transaction signals
|
| 169 |
|
|
// -------------------------------------------------------
|
| 170 |
|
|
wire write_transaction;
|
| 171 |
|
|
assign write_transaction = sink_data[PKT_TRANS_WRITE];
|
| 172 |
|
|
wire read_transaction;
|
| 173 |
|
|
assign read_transaction = sink_data[PKT_TRANS_READ];
|
| 174 |
|
|
|
| 175 |
|
|
|
| 176 |
|
|
ulight_fifo_mm_interconnect_0_router_002_default_decode the_default_decode(
|
| 177 |
|
|
.default_destination_id (),
|
| 178 |
|
|
.default_wr_channel (default_wr_channel),
|
| 179 |
|
|
.default_rd_channel (default_rd_channel),
|
| 180 |
|
|
.default_src_channel ()
|
| 181 |
|
|
);
|
| 182 |
|
|
|
| 183 |
|
|
always @* begin
|
| 184 |
|
|
src_data = sink_data;
|
| 185 |
|
|
src_channel = write_transaction ? default_wr_channel : default_rd_channel;
|
| 186 |
|
|
|
| 187 |
|
|
// --------------------------------------------------
|
| 188 |
|
|
// DestinationID Decoder
|
| 189 |
|
|
// Sets the channel based on the destination ID.
|
| 190 |
|
|
// --------------------------------------------------
|
| 191 |
|
|
destid = sink_data[PKT_DEST_ID_H : PKT_DEST_ID_L];
|
| 192 |
|
|
|
| 193 |
|
|
|
| 194 |
|
|
|
| 195 |
|
|
if (destid == 0 && write_transaction) begin
|
| 196 |
|
|
src_channel = 22'b01;
|
| 197 |
|
|
end
|
| 198 |
|
|
|
| 199 |
|
|
if (destid == 0 && read_transaction) begin
|
| 200 |
|
|
src_channel = 22'b10;
|
| 201 |
|
|
end
|
| 202 |
|
|
|
| 203 |
|
|
|
| 204 |
|
|
end
|
| 205 |
|
|
|
| 206 |
|
|
|
| 207 |
|
|
// --------------------------------------------------
|
| 208 |
|
|
// Ceil(log2()) function
|
| 209 |
|
|
// --------------------------------------------------
|
| 210 |
|
|
function integer log2ceil;
|
| 211 |
|
|
input reg[65:0] val;
|
| 212 |
|
|
reg [65:0] i;
|
| 213 |
|
|
|
| 214 |
|
|
begin
|
| 215 |
|
|
i = 1;
|
| 216 |
|
|
log2ceil = 0;
|
| 217 |
|
|
|
| 218 |
|
|
while (i < val) begin
|
| 219 |
|
|
log2ceil = log2ceil + 1;
|
| 220 |
|
|
i = i << 1;
|
| 221 |
|
|
end
|
| 222 |
|
|
end
|
| 223 |
|
|
endfunction
|
| 224 |
|
|
|
| 225 |
|
|
endmodule
|
| 226 |
|
|
|
| 227 |
|
|
|