URL
https://opencores.org/ocsvn/spacewiresystemc/spacewiresystemc/trunk
Subversion Repositories spacewiresystemc
[/] [spacewiresystemc/] [trunk/] [altera_work/] [spw_fifo_ulight/] [ulight_fifo/] [synthesis/] [submodules/] [altera_incr_burst_converter.sv] - Rev 40
Compare with Previous | Blame | View Log
// (C) 2001-2017 Intel Corporation. All rights reserved.// Your use of Intel Corporation's design tools, logic functions and other// software and tools, and its AMPP partner logic functions, and any output// files from any of the foregoing (including device programming or simulation// files), and any associated documentation or information are expressly subject// to the terms and conditions of the Intel Program License Subscription// Agreement, Intel FPGA IP License Agreement, or other applicable// license agreement, including, without limitation, that your use is for the// sole purpose of programming logic devices manufactured by Intel and sold by// Intel or its authorized distributors. Please refer to the applicable// agreement for further details.// $Id: //acds/rel/17.1std/ip/merlin/altera_merlin_burst_adapter/new_source/altera_incr_burst_converter.sv#1 $// $Revision: #1 $// $Date: 2017/07/30 $// $Author: swbranch $// ----------------------------------------------------------// This component is used for INCR Avalon slave// (slave which only supports INCR) or AXI slave.// It converts burst length of input packet// to match slave burst.// ----------------------------------------------------------`timescale 1 ns / 1 nsmodule altera_incr_burst_converter#(parameter// ----------------------------------------// Burst length Parameters// (real burst length value, not bytecount)// ----------------------------------------MAX_IN_LEN = 16,MAX_OUT_LEN = 4,NUM_SYMBOLS = 4,ADDR_WIDTH = 12,BNDRY_WIDTH = 12,BURSTSIZE_WIDTH = 3,IN_NARROW_SIZE = 0,PURELY_INCR_AVL_SYS = 0,// ------------------// Derived Parameters// ------------------LEN_WIDTH = log2ceil(MAX_IN_LEN) + 1,OUT_LEN_WIDTH = log2ceil(MAX_OUT_LEN) + 1,LOG2_NUMSYMBOLS = log2ceil(NUM_SYMBOLS))(input clk,input reset,input enable,input is_write,input [LEN_WIDTH - 1 : 0] in_len,input in_sop,input [ADDR_WIDTH - 1 : 0] in_addr,input [ADDR_WIDTH - 1 : 0] in_addr_reg,input [BNDRY_WIDTH - 1 : 0] in_burstwrap_reg,input [BURSTSIZE_WIDTH - 1 : 0] in_size_t,input [BURSTSIZE_WIDTH - 1 : 0] in_size_reg,// converted output length// out_len : compressed burst, read// uncompressed_len: uncompressed, writeoutput reg [LEN_WIDTH - 1 : 0] out_len,output reg [LEN_WIDTH - 1 : 0] uncompr_out_len,// Compressed address outputoutput reg [ADDR_WIDTH - 1 : 0] out_addr,output reg new_burst_export);// ----------------------------------------// Signals for wrapping support// ----------------------------------------reg [LEN_WIDTH - 1 : 0] remaining_len;reg [LEN_WIDTH - 1 : 0] next_out_len;reg [LEN_WIDTH - 1 : 0] next_rem_len;reg [LEN_WIDTH - 1 : 0] uncompr_remaining_len;reg [LEN_WIDTH - 1 : 0] next_uncompr_remaining_len;reg [LEN_WIDTH - 1 : 0] next_uncompr_rem_len;reg new_burst;reg uncompr_sub_burst;// Avoid QIS warningwire [OUT_LEN_WIDTH - 1 : 0] max_out_length;assign max_out_length = MAX_OUT_LEN[OUT_LEN_WIDTH - 1 : 0];always_comb beginnew_burst_export = new_burst;end// -------------------------------------------// length remaining calculation// -------------------------------------------always_comb begin : proc_uncompressed_remaining_lenif ((in_len <= max_out_length) && is_write) beginuncompr_remaining_len = in_len;end else beginuncompr_remaining_len = max_out_length;endif (uncompr_sub_burst)uncompr_remaining_len = next_uncompr_rem_len;endalways_ff @(posedge clk, posedge reset) beginif (reset) beginnext_uncompr_rem_len <= 0;endelse if (enable) beginnext_uncompr_rem_len <= uncompr_remaining_len - 1'b1; // in term of length, it just reduces 1endendalways_comb begin : proc_compressed_remaining_lenremaining_len = in_len;if (!new_burst)remaining_len = next_rem_len;endalways_ff@(posedge clk or posedge reset) begin : proc_next_uncompressed_remaining_lenif(reset) beginnext_uncompr_remaining_len <= '0;endelse if (enable) beginif (in_sop) beginnext_uncompr_remaining_len <= in_len - max_out_length;endelse if (!uncompr_sub_burst)next_uncompr_remaining_len <= next_uncompr_remaining_len - max_out_length;endendalways_comb beginnext_out_len = max_out_length;if (remaining_len < max_out_length) beginnext_out_len = remaining_len;endend // always_comb// --------------------------------------------------// Length remaining calculation : compressed// --------------------------------------------------// length remaining for compressed transaction// for wrap, need special handling for first out lengthalways_ff @(posedge clk, posedge reset) beginif (reset)next_rem_len <= 0;else if (enable) beginif (new_burst)next_rem_len <= in_len - max_out_length;elsenext_rem_len <= next_rem_len - max_out_length;endendalways_ff @(posedge clk, posedge reset) beginif (reset) beginuncompr_sub_burst <= 0;endelse if (enable && is_write) beginuncompr_sub_burst <= (uncompr_remaining_len > 1'b1);endend// --------------------------------------------------// Control signals// --------------------------------------------------wire end_compressed_sub_burst;assign end_compressed_sub_burst = (remaining_len == next_out_len);// new_burst:// the converter takes in_len for new calculationalways_ff @(posedge clk, posedge reset) beginif (reset)new_burst <= 1;else if (enable)new_burst <= end_compressed_sub_burst;end// --------------------------------------------------// Output length// --------------------------------------------------// register out_len for compressed transalways_ff @(posedge clk, posedge reset) beginif (reset) beginout_len <= 0;endelse if (enable) beginout_len <= next_out_len;endend// register uncompr_out_len for uncompressed transalways_ff @(posedge clk, posedge reset) beginif (reset) beginuncompr_out_len <= '0;endelse if (enable) beginuncompr_out_len <= uncompr_remaining_len;endend// --------------------------------------------------// Address Calculation// --------------------------------------------------reg [ADDR_WIDTH - 1 : 0] addr_incr_sel;reg [ADDR_WIDTH - 1 : 0] addr_incr_sel_reg;reg [ADDR_WIDTH - 1 : 0] addr_incr_full_size;localparam [ADDR_WIDTH - 1 : 0] ADDR_INCR = MAX_OUT_LEN << LOG2_NUMSYMBOLS;generateif (IN_NARROW_SIZE) begin : narrow_addr_incrreg [ADDR_WIDTH - 1 : 0] addr_incr_variable_size;reg [ADDR_WIDTH - 1 : 0] addr_incr_variable_size_reg;assign addr_incr_variable_size = MAX_OUT_LEN << in_size_t;assign addr_incr_variable_size_reg = MAX_OUT_LEN << in_size_reg;assign addr_incr_sel = addr_incr_variable_size;assign addr_incr_sel_reg = addr_incr_variable_size_reg;endelse begin : full_addr_incrassign addr_incr_full_size = ADDR_INCR[ADDR_WIDTH - 1 : 0];assign addr_incr_sel = addr_incr_full_size;assign addr_incr_sel_reg = addr_incr_full_size;endendgeneratereg [ADDR_WIDTH - 1 : 0] next_out_addr;reg [ADDR_WIDTH - 1 : 0] incremented_addr;always_ff @(posedge clk, posedge reset) beginif (reset) beginout_addr <= '0;end else beginif (enable) beginout_addr <= (next_out_addr);endendendgenerateif (!PURELY_INCR_AVL_SYS) begin : incremented_addr_normalalways_ff @(posedge clk, posedge reset) beginif (reset) beginincremented_addr <= '0;endelse if (enable) beginincremented_addr <= (next_out_addr + addr_incr_sel_reg);if (new_burst) beginincremented_addr <= (next_out_addr + addr_incr_sel);endendend // always_ff @always_comb beginnext_out_addr = in_addr;if (!new_burst) beginnext_out_addr = incremented_addr;endendendelse begin : incremented_addr_pure_avalways_ff @(posedge clk, posedge reset) beginif (reset) beginincremented_addr <= '0;endelse if (enable) beginincremented_addr <= (next_out_addr + addr_incr_sel_reg);endend // always_ff @always_comb beginnext_out_addr = in_addr;if (!new_burst) beginnext_out_addr = (incremented_addr);endendendendgenerate// --------------------------------------------------// Calculates the log2ceil of the input value// --------------------------------------------------function integer log2ceil;input integer val;reg[31:0] i;begini = 1;log2ceil = 0;while (i < val) beginlog2ceil = log2ceil + 1;i = i[30:0] << 1;endendendfunctionendmodule
