Add files for FIR and IIR filter - not tested
This commit is contained in:
@@ -0,0 +1,915 @@
|
||||
// -----------------------------------------------------------
|
||||
// Legal Notice: (C)2007 Altera Corporation. All rights reserved. Your
|
||||
// use of Altera Corporation's design tools, logic functions and other
|
||||
// software and tools, and its AMPP partner logic functions, and any
|
||||
// output files 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 Altera Program
|
||||
// License Subscription Agreement or other applicable license agreement,
|
||||
// including, without limitation, that your use is for the sole purpose
|
||||
// of programming logic devices manufactured by Altera and sold by Altera
|
||||
// or its authorized distributors. Please refer to the applicable
|
||||
// agreement for further details.
|
||||
//
|
||||
// Description: Single clock Avalon-ST FIFO.
|
||||
// -----------------------------------------------------------
|
||||
|
||||
`timescale 1 ns / 1 ns
|
||||
|
||||
|
||||
//altera message_off 10036
|
||||
module altera_avalon_sc_fifo
|
||||
#(
|
||||
// --------------------------------------------------
|
||||
// Parameters
|
||||
// --------------------------------------------------
|
||||
parameter SYMBOLS_PER_BEAT = 1,
|
||||
parameter BITS_PER_SYMBOL = 8,
|
||||
parameter FIFO_DEPTH = 16,
|
||||
parameter CHANNEL_WIDTH = 0,
|
||||
parameter ERROR_WIDTH = 0,
|
||||
parameter USE_PACKETS = 0,
|
||||
parameter USE_FILL_LEVEL = 0,
|
||||
parameter USE_STORE_FORWARD = 0,
|
||||
parameter USE_ALMOST_FULL_IF = 0,
|
||||
parameter USE_ALMOST_EMPTY_IF = 0,
|
||||
|
||||
// --------------------------------------------------
|
||||
// Empty latency is defined as the number of cycles
|
||||
// required for a write to deassert the empty flag.
|
||||
// For example, a latency of 1 means that the empty
|
||||
// flag is deasserted on the cycle after a write.
|
||||
//
|
||||
// Another way to think of it is the latency for a
|
||||
// write to propagate to the output.
|
||||
//
|
||||
// An empty latency of 0 implies lookahead, which is
|
||||
// only implemented for the register-based FIFO.
|
||||
// --------------------------------------------------
|
||||
parameter EMPTY_LATENCY = 3,
|
||||
parameter USE_MEMORY_BLOCKS = 1,
|
||||
|
||||
// --------------------------------------------------
|
||||
// Internal Parameters
|
||||
// --------------------------------------------------
|
||||
parameter DATA_WIDTH = SYMBOLS_PER_BEAT * BITS_PER_SYMBOL,
|
||||
parameter EMPTY_WIDTH = log2ceil(SYMBOLS_PER_BEAT)
|
||||
)
|
||||
(
|
||||
// --------------------------------------------------
|
||||
// Ports
|
||||
// --------------------------------------------------
|
||||
input clk,
|
||||
input reset,
|
||||
|
||||
input [DATA_WIDTH-1: 0] in_data,
|
||||
input in_valid,
|
||||
input in_startofpacket,
|
||||
input in_endofpacket,
|
||||
input [((EMPTY_WIDTH>0) ? (EMPTY_WIDTH-1):0) : 0] in_empty,
|
||||
input [((ERROR_WIDTH>0) ? (ERROR_WIDTH-1):0) : 0] in_error,
|
||||
input [((CHANNEL_WIDTH>0) ? (CHANNEL_WIDTH-1):0): 0] in_channel,
|
||||
output in_ready,
|
||||
|
||||
output [DATA_WIDTH-1 : 0] out_data,
|
||||
output reg out_valid,
|
||||
output out_startofpacket,
|
||||
output out_endofpacket,
|
||||
output [((EMPTY_WIDTH>0) ? (EMPTY_WIDTH-1):0) : 0] out_empty,
|
||||
output [((ERROR_WIDTH>0) ? (ERROR_WIDTH-1):0) : 0] out_error,
|
||||
output [((CHANNEL_WIDTH>0) ? (CHANNEL_WIDTH-1):0): 0] out_channel,
|
||||
input out_ready,
|
||||
|
||||
input [(USE_STORE_FORWARD ? 2 : 1) : 0] csr_address,
|
||||
input csr_write,
|
||||
input csr_read,
|
||||
input [31 : 0] csr_writedata,
|
||||
output reg [31 : 0] csr_readdata,
|
||||
|
||||
output wire almost_full_data,
|
||||
output wire almost_empty_data
|
||||
);
|
||||
|
||||
// --------------------------------------------------
|
||||
// Local Parameters
|
||||
// --------------------------------------------------
|
||||
localparam ADDR_WIDTH = log2ceil(FIFO_DEPTH);
|
||||
localparam DEPTH = FIFO_DEPTH;
|
||||
localparam PKT_SIGNALS_WIDTH = 2 + EMPTY_WIDTH;
|
||||
localparam PAYLOAD_WIDTH = (USE_PACKETS == 1) ?
|
||||
2 + EMPTY_WIDTH + DATA_WIDTH + ERROR_WIDTH + CHANNEL_WIDTH:
|
||||
DATA_WIDTH + ERROR_WIDTH + CHANNEL_WIDTH;
|
||||
|
||||
// --------------------------------------------------
|
||||
// Internal Signals
|
||||
// --------------------------------------------------
|
||||
genvar i;
|
||||
|
||||
reg [PAYLOAD_WIDTH-1 : 0] mem [DEPTH-1 : 0];
|
||||
reg [ADDR_WIDTH-1 : 0] wr_ptr;
|
||||
reg [ADDR_WIDTH-1 : 0] rd_ptr;
|
||||
reg [DEPTH-1 : 0] mem_used;
|
||||
|
||||
wire [ADDR_WIDTH-1 : 0] next_wr_ptr;
|
||||
wire [ADDR_WIDTH-1 : 0] next_rd_ptr;
|
||||
wire [ADDR_WIDTH-1 : 0] incremented_wr_ptr;
|
||||
wire [ADDR_WIDTH-1 : 0] incremented_rd_ptr;
|
||||
|
||||
wire [ADDR_WIDTH-1 : 0] mem_rd_ptr;
|
||||
|
||||
wire read;
|
||||
wire write;
|
||||
|
||||
reg empty;
|
||||
reg next_empty;
|
||||
reg full;
|
||||
reg next_full;
|
||||
|
||||
wire [PKT_SIGNALS_WIDTH-1 : 0] in_packet_signals;
|
||||
wire [PKT_SIGNALS_WIDTH-1 : 0] out_packet_signals;
|
||||
wire [PAYLOAD_WIDTH-1 : 0] in_payload;
|
||||
reg [PAYLOAD_WIDTH-1 : 0] internal_out_payload;
|
||||
reg [PAYLOAD_WIDTH-1 : 0] out_payload;
|
||||
|
||||
reg internal_out_valid;
|
||||
wire internal_out_ready;
|
||||
|
||||
reg [ADDR_WIDTH : 0] fifo_fill_level;
|
||||
reg [ADDR_WIDTH : 0] fill_level;
|
||||
|
||||
reg [ADDR_WIDTH-1 : 0] sop_ptr = 0;
|
||||
wire [ADDR_WIDTH-1 : 0] curr_sop_ptr;
|
||||
reg [23:0] almost_full_threshold;
|
||||
reg [23:0] almost_empty_threshold;
|
||||
reg [23:0] cut_through_threshold;
|
||||
reg [15:0] pkt_cnt;
|
||||
reg drop_on_error_en;
|
||||
reg error_in_pkt;
|
||||
reg pkt_has_started;
|
||||
reg sop_has_left_fifo;
|
||||
reg fifo_too_small_r;
|
||||
reg pkt_cnt_eq_zero;
|
||||
reg pkt_cnt_eq_one;
|
||||
|
||||
wire wait_for_threshold;
|
||||
reg pkt_mode;
|
||||
wire wait_for_pkt;
|
||||
wire ok_to_forward;
|
||||
wire in_pkt_eop_arrive;
|
||||
wire out_pkt_leave;
|
||||
wire in_pkt_start;
|
||||
wire in_pkt_error;
|
||||
wire drop_on_error;
|
||||
wire fifo_too_small;
|
||||
wire out_pkt_sop_leave;
|
||||
wire [31:0] max_fifo_size;
|
||||
reg fifo_fill_level_lt_cut_through_threshold;
|
||||
|
||||
// --------------------------------------------------
|
||||
// Define Payload
|
||||
//
|
||||
// Icky part where we decide which signals form the
|
||||
// payload to the FIFO with generate blocks.
|
||||
// --------------------------------------------------
|
||||
generate
|
||||
if (EMPTY_WIDTH > 0) begin : gen_blk1
|
||||
assign in_packet_signals = {in_startofpacket, in_endofpacket, in_empty};
|
||||
assign {out_startofpacket, out_endofpacket, out_empty} = out_packet_signals;
|
||||
end
|
||||
else begin : gen_blk1_else
|
||||
assign out_empty = in_error;
|
||||
assign in_packet_signals = {in_startofpacket, in_endofpacket};
|
||||
assign {out_startofpacket, out_endofpacket} = out_packet_signals;
|
||||
end
|
||||
endgenerate
|
||||
|
||||
generate
|
||||
if (USE_PACKETS) begin : gen_blk2
|
||||
if (ERROR_WIDTH > 0) begin : gen_blk3
|
||||
if (CHANNEL_WIDTH > 0) begin : gen_blk4
|
||||
assign in_payload = {in_packet_signals, in_data, in_error, in_channel};
|
||||
assign {out_packet_signals, out_data, out_error, out_channel} = out_payload;
|
||||
end
|
||||
else begin : gen_blk4_else
|
||||
assign out_channel = in_channel;
|
||||
assign in_payload = {in_packet_signals, in_data, in_error};
|
||||
assign {out_packet_signals, out_data, out_error} = out_payload;
|
||||
end
|
||||
end
|
||||
else begin : gen_blk3_else
|
||||
assign out_error = in_error;
|
||||
if (CHANNEL_WIDTH > 0) begin : gen_blk5
|
||||
assign in_payload = {in_packet_signals, in_data, in_channel};
|
||||
assign {out_packet_signals, out_data, out_channel} = out_payload;
|
||||
end
|
||||
else begin : gen_blk5_else
|
||||
assign out_channel = in_channel;
|
||||
assign in_payload = {in_packet_signals, in_data};
|
||||
assign {out_packet_signals, out_data} = out_payload;
|
||||
end
|
||||
end
|
||||
end
|
||||
else begin : gen_blk2_else
|
||||
assign out_packet_signals = 0;
|
||||
if (ERROR_WIDTH > 0) begin : gen_blk6
|
||||
if (CHANNEL_WIDTH > 0) begin : gen_blk7
|
||||
assign in_payload = {in_data, in_error, in_channel};
|
||||
assign {out_data, out_error, out_channel} = out_payload;
|
||||
end
|
||||
else begin : gen_blk7_else
|
||||
assign out_channel = in_channel;
|
||||
assign in_payload = {in_data, in_error};
|
||||
assign {out_data, out_error} = out_payload;
|
||||
end
|
||||
end
|
||||
else begin : gen_blk6_else
|
||||
assign out_error = in_error;
|
||||
if (CHANNEL_WIDTH > 0) begin : gen_blk8
|
||||
assign in_payload = {in_data, in_channel};
|
||||
assign {out_data, out_channel} = out_payload;
|
||||
end
|
||||
else begin : gen_blk8_else
|
||||
assign out_channel = in_channel;
|
||||
assign in_payload = in_data;
|
||||
assign out_data = out_payload;
|
||||
end
|
||||
end
|
||||
end
|
||||
endgenerate
|
||||
|
||||
// --------------------------------------------------
|
||||
// Memory-based FIFO storage
|
||||
//
|
||||
// To allow a ready latency of 0, the read index is
|
||||
// obtained from the next read pointer and memory
|
||||
// outputs are unregistered.
|
||||
//
|
||||
// If the empty latency is 1, we infer bypass logic
|
||||
// around the memory so writes propagate to the
|
||||
// outputs on the next cycle.
|
||||
//
|
||||
// Do not change the way this is coded: Quartus needs
|
||||
// a perfect match to the template, and any attempt to
|
||||
// refactor the two always blocks into one will break
|
||||
// memory inference.
|
||||
// --------------------------------------------------
|
||||
generate if (USE_MEMORY_BLOCKS == 1) begin : gen_blk9
|
||||
|
||||
if (EMPTY_LATENCY == 1) begin : gen_blk10
|
||||
|
||||
always @(posedge clk) begin
|
||||
if (in_valid && in_ready)
|
||||
mem[wr_ptr] = in_payload;
|
||||
|
||||
internal_out_payload = mem[mem_rd_ptr];
|
||||
end
|
||||
|
||||
end else begin : gen_blk10_else
|
||||
|
||||
always @(posedge clk) begin
|
||||
if (in_valid && in_ready)
|
||||
mem[wr_ptr] <= in_payload;
|
||||
|
||||
internal_out_payload <= mem[mem_rd_ptr];
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
assign mem_rd_ptr = next_rd_ptr;
|
||||
|
||||
end else begin : gen_blk9_else
|
||||
|
||||
// --------------------------------------------------
|
||||
// Register-based FIFO storage
|
||||
//
|
||||
// Uses a shift register as the storage element. Each
|
||||
// shift register slot has a bit which indicates if
|
||||
// the slot is occupied (credit to Sam H for the idea).
|
||||
// The occupancy bits are contiguous and start from the
|
||||
// lsb, so 0000, 0001, 0011, 0111, 1111 for a 4-deep
|
||||
// FIFO.
|
||||
//
|
||||
// Each slot is enabled during a read or when it
|
||||
// is unoccupied. New data is always written to every
|
||||
// going-to-be-empty slot (we keep track of which ones
|
||||
// are actually useful with the occupancy bits). On a
|
||||
// read we shift occupied slots.
|
||||
//
|
||||
// The exception is the last slot, which always gets
|
||||
// new data when it is unoccupied.
|
||||
// --------------------------------------------------
|
||||
for (i = 0; i < DEPTH-1; i = i + 1) begin : shift_reg
|
||||
always @(posedge clk or posedge reset) begin
|
||||
if (reset) begin
|
||||
mem[i] <= 0;
|
||||
end
|
||||
else if (read || !mem_used[i]) begin
|
||||
if (!mem_used[i+1])
|
||||
mem[i] <= in_payload;
|
||||
else
|
||||
mem[i] <= mem[i+1];
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
always @(posedge clk, posedge reset) begin
|
||||
if (reset) begin
|
||||
mem[DEPTH-1] <= 0;
|
||||
end
|
||||
else begin
|
||||
if (DEPTH == 1) begin
|
||||
if (write)
|
||||
mem[DEPTH-1] <= in_payload;
|
||||
end
|
||||
else if (!mem_used[DEPTH-1])
|
||||
mem[DEPTH-1] <= in_payload;
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
endgenerate
|
||||
|
||||
assign read = internal_out_ready && internal_out_valid && ok_to_forward;
|
||||
assign write = in_ready && in_valid;
|
||||
|
||||
// --------------------------------------------------
|
||||
// Pointer Management
|
||||
// --------------------------------------------------
|
||||
generate if (USE_MEMORY_BLOCKS == 1) begin : gen_blk11
|
||||
|
||||
assign incremented_wr_ptr = wr_ptr + 1'b1;
|
||||
assign incremented_rd_ptr = rd_ptr + 1'b1;
|
||||
assign next_wr_ptr = drop_on_error ? curr_sop_ptr : write ? incremented_wr_ptr : wr_ptr;
|
||||
assign next_rd_ptr = (read) ? incremented_rd_ptr : rd_ptr;
|
||||
|
||||
always @(posedge clk or posedge reset) begin
|
||||
if (reset) begin
|
||||
wr_ptr <= 0;
|
||||
rd_ptr <= 0;
|
||||
end
|
||||
else begin
|
||||
wr_ptr <= next_wr_ptr;
|
||||
rd_ptr <= next_rd_ptr;
|
||||
end
|
||||
end
|
||||
|
||||
end else begin : gen_blk11_else
|
||||
|
||||
// --------------------------------------------------
|
||||
// Shift Register Occupancy Bits
|
||||
//
|
||||
// Consider a 4-deep FIFO with 2 entries: 0011
|
||||
// On a read and write, do not modify the bits.
|
||||
// On a write, left-shift the bits to get 0111.
|
||||
// On a read, right-shift the bits to get 0001.
|
||||
//
|
||||
// Also, on a write we set bit0 (the head), while
|
||||
// clearing the tail on a read.
|
||||
// --------------------------------------------------
|
||||
always @(posedge clk or posedge reset) begin
|
||||
if (reset) begin
|
||||
mem_used[0] <= 0;
|
||||
end
|
||||
else begin
|
||||
if (write ^ read) begin
|
||||
if (write)
|
||||
mem_used[0] <= 1;
|
||||
else if (read) begin
|
||||
if (DEPTH > 1)
|
||||
mem_used[0] <= mem_used[1];
|
||||
else
|
||||
mem_used[0] <= 0;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if (DEPTH > 1) begin : gen_blk12
|
||||
always @(posedge clk or posedge reset) begin
|
||||
if (reset) begin
|
||||
mem_used[DEPTH-1] <= 0;
|
||||
end
|
||||
else begin
|
||||
if (write ^ read) begin
|
||||
mem_used[DEPTH-1] <= 0;
|
||||
if (write)
|
||||
mem_used[DEPTH-1] <= mem_used[DEPTH-2];
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for (i = 1; i < DEPTH-1; i = i + 1) begin : storage_logic
|
||||
always @(posedge clk, posedge reset) begin
|
||||
if (reset) begin
|
||||
mem_used[i] <= 0;
|
||||
end
|
||||
else begin
|
||||
if (write ^ read) begin
|
||||
if (write)
|
||||
mem_used[i] <= mem_used[i-1];
|
||||
else if (read)
|
||||
mem_used[i] <= mem_used[i+1];
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
endgenerate
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
// Memory FIFO Status Management
|
||||
//
|
||||
// Generates the full and empty signals from the
|
||||
// pointers. The FIFO is full when the next write
|
||||
// pointer will be equal to the read pointer after
|
||||
// a write. Reading from a FIFO clears full.
|
||||
//
|
||||
// The FIFO is empty when the next read pointer will
|
||||
// be equal to the write pointer after a read. Writing
|
||||
// to a FIFO clears empty.
|
||||
//
|
||||
// A simultaneous read and write must not change any of
|
||||
// the empty or full flags unless there is a drop on error event.
|
||||
// --------------------------------------------------
|
||||
generate if (USE_MEMORY_BLOCKS == 1) begin : gen_blk13
|
||||
|
||||
always @* begin
|
||||
next_full = full;
|
||||
next_empty = empty;
|
||||
|
||||
if (read && !write) begin
|
||||
next_full = 1'b0;
|
||||
|
||||
if (incremented_rd_ptr == wr_ptr)
|
||||
next_empty = 1'b1;
|
||||
end
|
||||
|
||||
if (write && !read) begin
|
||||
if (!drop_on_error)
|
||||
next_empty = 1'b0;
|
||||
else if (curr_sop_ptr == rd_ptr) // drop on error and only 1 pkt in fifo
|
||||
next_empty = 1'b1;
|
||||
|
||||
if (incremented_wr_ptr == rd_ptr && !drop_on_error)
|
||||
next_full = 1'b1;
|
||||
end
|
||||
|
||||
if (write && read && drop_on_error) begin
|
||||
if (curr_sop_ptr == next_rd_ptr)
|
||||
next_empty = 1'b1;
|
||||
end
|
||||
end
|
||||
|
||||
always @(posedge clk or posedge reset) begin
|
||||
if (reset) begin
|
||||
empty <= 1;
|
||||
full <= 0;
|
||||
end
|
||||
else begin
|
||||
empty <= next_empty;
|
||||
full <= next_full;
|
||||
end
|
||||
end
|
||||
|
||||
end else begin : gen_blk13_else
|
||||
// --------------------------------------------------
|
||||
// Register FIFO Status Management
|
||||
//
|
||||
// Full when the tail occupancy bit is 1. Empty when
|
||||
// the head occupancy bit is 0.
|
||||
// --------------------------------------------------
|
||||
always @* begin
|
||||
full = mem_used[DEPTH-1];
|
||||
empty = !mem_used[0];
|
||||
|
||||
// ------------------------------------------
|
||||
// For a single slot FIFO, reading clears the
|
||||
// full status immediately.
|
||||
// ------------------------------------------
|
||||
if (DEPTH == 1)
|
||||
full = mem_used[0] && !read;
|
||||
|
||||
internal_out_payload = mem[0];
|
||||
|
||||
// ------------------------------------------
|
||||
// Writes clear empty immediately for lookahead modes.
|
||||
// Note that we use in_valid instead of write to avoid
|
||||
// combinational loops (in lookahead mode, qualifying
|
||||
// with in_ready is meaningless).
|
||||
//
|
||||
// In a 1-deep FIFO, a possible combinational loop runs
|
||||
// from write -> out_valid -> out_ready -> write
|
||||
// ------------------------------------------
|
||||
if (EMPTY_LATENCY == 0) begin
|
||||
empty = !mem_used[0] && !in_valid;
|
||||
|
||||
if (!mem_used[0] && in_valid)
|
||||
internal_out_payload = in_payload;
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
endgenerate
|
||||
|
||||
// --------------------------------------------------
|
||||
// Avalon-ST Signals
|
||||
//
|
||||
// The in_ready signal is straightforward.
|
||||
//
|
||||
// To match memory latency when empty latency > 1,
|
||||
// out_valid assertions must be delayed by one clock
|
||||
// cycle.
|
||||
//
|
||||
// Note: out_valid deassertions must not be delayed or
|
||||
// the FIFO will underflow.
|
||||
// --------------------------------------------------
|
||||
assign in_ready = !full;
|
||||
assign internal_out_ready = out_ready || !out_valid;
|
||||
|
||||
generate if (EMPTY_LATENCY > 1) begin : gen_blk14
|
||||
always @(posedge clk or posedge reset) begin
|
||||
if (reset)
|
||||
internal_out_valid <= 0;
|
||||
else begin
|
||||
internal_out_valid <= !empty & ok_to_forward & ~drop_on_error;
|
||||
|
||||
if (read) begin
|
||||
if (incremented_rd_ptr == wr_ptr)
|
||||
internal_out_valid <= 1'b0;
|
||||
end
|
||||
end
|
||||
end
|
||||
end else begin : gen_blk14_else
|
||||
always @* begin
|
||||
internal_out_valid = !empty & ok_to_forward;
|
||||
end
|
||||
end
|
||||
endgenerate
|
||||
|
||||
// --------------------------------------------------
|
||||
// Single Output Pipeline Stage
|
||||
//
|
||||
// This output pipeline stage is enabled if the FIFO's
|
||||
// empty latency is set to 3 (default). It is disabled
|
||||
// for all other allowed latencies.
|
||||
//
|
||||
// Reason: The memory outputs are unregistered, so we have to
|
||||
// register the output or fmax will drop if combinatorial
|
||||
// logic is present on the output datapath.
|
||||
//
|
||||
// Q: The Avalon-ST spec says that I have to register my outputs
|
||||
// But isn't the memory counted as a register?
|
||||
// A: The path from the address lookup to the memory output is
|
||||
// slow. Registering the memory outputs is a good idea.
|
||||
//
|
||||
// The registers get packed into the memory by the fitter
|
||||
// which means minimal resources are consumed (the result
|
||||
// is a altsyncram with registered outputs, available on
|
||||
// all modern Altera devices).
|
||||
//
|
||||
// This output stage acts as an extra slot in the FIFO,
|
||||
// and complicates the fill level.
|
||||
// --------------------------------------------------
|
||||
generate if (EMPTY_LATENCY == 3) begin : gen_blk15
|
||||
always @(posedge clk or posedge reset) begin
|
||||
if (reset) begin
|
||||
out_valid <= 0;
|
||||
out_payload <= 0;
|
||||
end
|
||||
else begin
|
||||
if (internal_out_ready) begin
|
||||
out_valid <= internal_out_valid & ok_to_forward;
|
||||
out_payload <= internal_out_payload;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else begin : gen_blk15_else
|
||||
always @* begin
|
||||
out_valid = internal_out_valid;
|
||||
out_payload = internal_out_payload;
|
||||
end
|
||||
end
|
||||
endgenerate
|
||||
|
||||
// --------------------------------------------------
|
||||
// Fill Level
|
||||
//
|
||||
// The fill level is calculated from the next write
|
||||
// and read pointers to avoid unnecessary latency
|
||||
// and logic.
|
||||
//
|
||||
// However, if the store-and-forward mode of the FIFO
|
||||
// is enabled, the fill level is an up-down counter
|
||||
// for fmax optimization reasons.
|
||||
//
|
||||
// If the output pipeline is enabled, the fill level
|
||||
// must account for it, or we'll always be off by one.
|
||||
// This may, or may not be important depending on the
|
||||
// application.
|
||||
//
|
||||
// For now, we'll always calculate the exact fill level
|
||||
// at the cost of an extra adder when the output stage
|
||||
// is enabled.
|
||||
// --------------------------------------------------
|
||||
generate if (USE_FILL_LEVEL) begin : gen_blk16
|
||||
wire [31:0] depth32;
|
||||
assign depth32 = DEPTH;
|
||||
|
||||
if (USE_STORE_FORWARD) begin
|
||||
|
||||
reg [ADDR_WIDTH : 0] curr_packet_len_less_one;
|
||||
|
||||
// --------------------------------------------------
|
||||
// We only drop on endofpacket. As long as we don't add to the fill
|
||||
// level on the dropped endofpacket cycle, we can simply subtract
|
||||
// (packet length - 1) from the fill level for dropped packets.
|
||||
// --------------------------------------------------
|
||||
always @(posedge clk or posedge reset) begin
|
||||
if (reset) begin
|
||||
curr_packet_len_less_one <= 0;
|
||||
end else begin
|
||||
if (write) begin
|
||||
curr_packet_len_less_one <= curr_packet_len_less_one + 1'b1;
|
||||
if (in_endofpacket)
|
||||
curr_packet_len_less_one <= 0;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
always @(posedge clk or posedge reset) begin
|
||||
if (reset) begin
|
||||
fifo_fill_level <= 0;
|
||||
end else if (drop_on_error) begin
|
||||
fifo_fill_level <= fifo_fill_level - curr_packet_len_less_one;
|
||||
if (read)
|
||||
fifo_fill_level <= fifo_fill_level - curr_packet_len_less_one - 1'b1;
|
||||
end else if (write && !read) begin
|
||||
fifo_fill_level <= fifo_fill_level + 1'b1;
|
||||
end else if (read && !write) begin
|
||||
fifo_fill_level <= fifo_fill_level - 1'b1;
|
||||
end
|
||||
end
|
||||
|
||||
end else begin
|
||||
|
||||
always @(posedge clk or posedge reset) begin
|
||||
if (reset)
|
||||
fifo_fill_level <= 0;
|
||||
else if (next_full & !drop_on_error)
|
||||
fifo_fill_level <= depth32[ADDR_WIDTH:0];
|
||||
else begin
|
||||
fifo_fill_level[ADDR_WIDTH] <= 1'b0;
|
||||
fifo_fill_level[ADDR_WIDTH-1 : 0] <= next_wr_ptr - next_rd_ptr;
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
always @* begin
|
||||
fill_level = fifo_fill_level;
|
||||
|
||||
if (EMPTY_LATENCY == 3)
|
||||
fill_level = fifo_fill_level + {{ADDR_WIDTH{1'b0}}, out_valid};
|
||||
end
|
||||
end
|
||||
else begin : gen_blk16_else
|
||||
always @* begin
|
||||
fill_level = 0;
|
||||
end
|
||||
end
|
||||
endgenerate
|
||||
|
||||
generate if (USE_ALMOST_FULL_IF) begin : gen_blk17
|
||||
assign almost_full_data = (fill_level >= almost_full_threshold);
|
||||
end
|
||||
else
|
||||
assign almost_full_data = 0;
|
||||
endgenerate
|
||||
|
||||
generate if (USE_ALMOST_EMPTY_IF) begin : gen_blk18
|
||||
assign almost_empty_data = (fill_level <= almost_empty_threshold);
|
||||
end
|
||||
else
|
||||
assign almost_empty_data = 0;
|
||||
endgenerate
|
||||
|
||||
// --------------------------------------------------
|
||||
// Avalon-MM Status & Control Connection Point
|
||||
//
|
||||
// Register map:
|
||||
//
|
||||
// | Addr | RW | 31 - 0 |
|
||||
// | 0 | R | Fill level |
|
||||
//
|
||||
// The registering of this connection point means
|
||||
// that there is a cycle of latency between
|
||||
// reads/writes and the updating of the fill level.
|
||||
// --------------------------------------------------
|
||||
generate if (USE_STORE_FORWARD) begin : gen_blk19
|
||||
assign max_fifo_size = FIFO_DEPTH - 1;
|
||||
always @(posedge clk or posedge reset) begin
|
||||
if (reset) begin
|
||||
almost_full_threshold <= max_fifo_size[23 : 0];
|
||||
almost_empty_threshold <= 0;
|
||||
cut_through_threshold <= 0;
|
||||
drop_on_error_en <= 0;
|
||||
csr_readdata <= 0;
|
||||
pkt_mode <= 1'b1;
|
||||
end
|
||||
else begin
|
||||
if (csr_read) begin
|
||||
csr_readdata <= 32'b0;
|
||||
if (csr_address == 5)
|
||||
csr_readdata <= {31'b0, drop_on_error_en};
|
||||
else if (csr_address == 4)
|
||||
csr_readdata <= {8'b0, cut_through_threshold};
|
||||
else if (csr_address == 3)
|
||||
csr_readdata <= {8'b0, almost_empty_threshold};
|
||||
else if (csr_address == 2)
|
||||
csr_readdata <= {8'b0, almost_full_threshold};
|
||||
else if (csr_address == 0)
|
||||
csr_readdata <= {{(31 - ADDR_WIDTH){1'b0}}, fill_level};
|
||||
end
|
||||
else if (csr_write) begin
|
||||
if(csr_address == 3'b101)
|
||||
drop_on_error_en <= csr_writedata[0];
|
||||
else if(csr_address == 3'b100) begin
|
||||
cut_through_threshold <= csr_writedata[23:0];
|
||||
pkt_mode <= (csr_writedata[23:0] == 0);
|
||||
end
|
||||
else if(csr_address == 3'b011)
|
||||
almost_empty_threshold <= csr_writedata[23:0];
|
||||
else if(csr_address == 3'b010)
|
||||
almost_full_threshold <= csr_writedata[23:0];
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else if (USE_ALMOST_FULL_IF || USE_ALMOST_EMPTY_IF) begin : gen_blk19_else1
|
||||
assign max_fifo_size = FIFO_DEPTH - 1;
|
||||
always @(posedge clk or posedge reset) begin
|
||||
if (reset) begin
|
||||
almost_full_threshold <= max_fifo_size[23 : 0];
|
||||
almost_empty_threshold <= 0;
|
||||
csr_readdata <= 0;
|
||||
end
|
||||
else begin
|
||||
if (csr_read) begin
|
||||
csr_readdata <= 32'b0;
|
||||
if (csr_address == 3)
|
||||
csr_readdata <= {8'b0, almost_empty_threshold};
|
||||
else if (csr_address == 2)
|
||||
csr_readdata <= {8'b0, almost_full_threshold};
|
||||
else if (csr_address == 0)
|
||||
csr_readdata <= {{(31 - ADDR_WIDTH){1'b0}}, fill_level};
|
||||
end
|
||||
else if (csr_write) begin
|
||||
if(csr_address == 3'b011)
|
||||
almost_empty_threshold <= csr_writedata[23:0];
|
||||
else if(csr_address == 3'b010)
|
||||
almost_full_threshold <= csr_writedata[23:0];
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else begin : gen_blk19_else2
|
||||
always @(posedge clk or posedge reset) begin
|
||||
if (reset) begin
|
||||
csr_readdata <= 0;
|
||||
end
|
||||
else if (csr_read) begin
|
||||
csr_readdata <= 0;
|
||||
|
||||
if (csr_address == 0)
|
||||
csr_readdata <= {{(31 - ADDR_WIDTH){1'b0}}, fill_level};
|
||||
end
|
||||
end
|
||||
end
|
||||
endgenerate
|
||||
|
||||
// --------------------------------------------------
|
||||
// Store and forward logic
|
||||
// --------------------------------------------------
|
||||
// if the fifo gets full before the entire packet or the
|
||||
// cut-threshold condition is met then start sending out
|
||||
// data in order to avoid dead-lock situation
|
||||
|
||||
generate if (USE_STORE_FORWARD) begin : gen_blk20
|
||||
assign wait_for_threshold = (fifo_fill_level_lt_cut_through_threshold) & wait_for_pkt ;
|
||||
assign wait_for_pkt = pkt_cnt_eq_zero | (pkt_cnt_eq_one & out_pkt_leave);
|
||||
assign ok_to_forward = (pkt_mode ? (~wait_for_pkt | ~pkt_has_started) :
|
||||
~wait_for_threshold) | fifo_too_small_r;
|
||||
assign in_pkt_eop_arrive = in_valid & in_ready & in_endofpacket;
|
||||
assign in_pkt_start = in_valid & in_ready & in_startofpacket;
|
||||
assign in_pkt_error = in_valid & in_ready & |in_error;
|
||||
assign out_pkt_sop_leave = out_valid & out_ready & out_startofpacket;
|
||||
assign out_pkt_leave = out_valid & out_ready & out_endofpacket;
|
||||
assign fifo_too_small = (pkt_mode ? wait_for_pkt : wait_for_threshold) & full & out_ready;
|
||||
|
||||
// count packets coming and going into the fifo
|
||||
always @(posedge clk or posedge reset) begin
|
||||
if (reset) begin
|
||||
pkt_cnt <= 0;
|
||||
pkt_has_started <= 0;
|
||||
sop_has_left_fifo <= 0;
|
||||
fifo_too_small_r <= 0;
|
||||
pkt_cnt_eq_zero <= 1'b1;
|
||||
pkt_cnt_eq_one <= 1'b0;
|
||||
fifo_fill_level_lt_cut_through_threshold <= 1'b1;
|
||||
end
|
||||
else begin
|
||||
fifo_fill_level_lt_cut_through_threshold <= fifo_fill_level < cut_through_threshold;
|
||||
fifo_too_small_r <= fifo_too_small;
|
||||
|
||||
if( in_pkt_eop_arrive )
|
||||
sop_has_left_fifo <= 1'b0;
|
||||
else if (out_pkt_sop_leave & pkt_cnt_eq_zero )
|
||||
sop_has_left_fifo <= 1'b1;
|
||||
|
||||
if (in_pkt_eop_arrive & ~out_pkt_leave & ~drop_on_error ) begin
|
||||
pkt_cnt <= pkt_cnt + 1'b1;
|
||||
pkt_cnt_eq_zero <= 0;
|
||||
if (pkt_cnt == 0)
|
||||
pkt_cnt_eq_one <= 1'b1;
|
||||
else
|
||||
pkt_cnt_eq_one <= 1'b0;
|
||||
end
|
||||
else if((~in_pkt_eop_arrive | drop_on_error) & out_pkt_leave) begin
|
||||
pkt_cnt <= pkt_cnt - 1'b1;
|
||||
if (pkt_cnt == 1)
|
||||
pkt_cnt_eq_zero <= 1'b1;
|
||||
else
|
||||
pkt_cnt_eq_zero <= 1'b0;
|
||||
if (pkt_cnt == 2)
|
||||
pkt_cnt_eq_one <= 1'b1;
|
||||
else
|
||||
pkt_cnt_eq_one <= 1'b0;
|
||||
end
|
||||
|
||||
if (in_pkt_start)
|
||||
pkt_has_started <= 1'b1;
|
||||
else if (in_pkt_eop_arrive)
|
||||
pkt_has_started <= 1'b0;
|
||||
end
|
||||
end
|
||||
|
||||
// drop on error logic
|
||||
always @(posedge clk or posedge reset) begin
|
||||
if (reset) begin
|
||||
sop_ptr <= 0;
|
||||
error_in_pkt <= 0;
|
||||
end
|
||||
else begin
|
||||
// save the location of the SOP
|
||||
if ( in_pkt_start )
|
||||
sop_ptr <= wr_ptr;
|
||||
|
||||
// remember if error in pkt
|
||||
// log error only if packet has already started
|
||||
if (in_pkt_eop_arrive)
|
||||
error_in_pkt <= 1'b0;
|
||||
else if ( in_pkt_error & (pkt_has_started | in_pkt_start))
|
||||
error_in_pkt <= 1'b1;
|
||||
end
|
||||
end
|
||||
|
||||
assign drop_on_error = drop_on_error_en & (error_in_pkt | in_pkt_error) & in_pkt_eop_arrive &
|
||||
~sop_has_left_fifo & ~(out_pkt_sop_leave & pkt_cnt_eq_zero);
|
||||
|
||||
assign curr_sop_ptr = (write && in_startofpacket && in_endofpacket) ? wr_ptr : sop_ptr;
|
||||
|
||||
end
|
||||
else begin : gen_blk20_else
|
||||
assign ok_to_forward = 1'b1;
|
||||
assign drop_on_error = 1'b0;
|
||||
if (ADDR_WIDTH <= 1)
|
||||
assign curr_sop_ptr = 1'b0;
|
||||
else
|
||||
assign curr_sop_ptr = {ADDR_WIDTH - 1 { 1'b0 }};
|
||||
end
|
||||
endgenerate
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
// Calculates the log2ceil of the input value
|
||||
// --------------------------------------------------
|
||||
function integer log2ceil;
|
||||
input integer val;
|
||||
reg[31:0] i;
|
||||
|
||||
begin
|
||||
i = 1;
|
||||
log2ceil = 0;
|
||||
|
||||
while (i < val) begin
|
||||
log2ceil = log2ceil + 1;
|
||||
i = i[30:0] << 1;
|
||||
end
|
||||
end
|
||||
endfunction
|
||||
|
||||
endmodule
|
||||
@@ -0,0 +1,88 @@
|
||||
-- (C) 2001-2019 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.
|
||||
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------
|
||||
--
|
||||
-- $Revision: #1 $
|
||||
-- $Date: 2009/07/29 $
|
||||
-- Author : Boon Hong Oh
|
||||
--
|
||||
-- Project : Avalon Streaming Wrapper for HP FIR
|
||||
--
|
||||
-- Description :
|
||||
--
|
||||
-- This file is the Interface controller for the Avalon Streaming Wrapper.
|
||||
-- The control signals between sink, core, and source modules are communicated
|
||||
-- via the controller. The stall output is used as the core enable signal in
|
||||
-- the wrapper.
|
||||
--
|
||||
-- ALTERA Confidential and Proprietary
|
||||
-- Copyright 2006 (c) Altera Corporation
|
||||
-- All rights reserved
|
||||
--
|
||||
-------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.std_logic_arith.all;
|
||||
|
||||
|
||||
entity auk_dspip_avalon_streaming_controller_hpfir is
|
||||
port(
|
||||
clk : in std_logic;
|
||||
--clk_en : in std_logic := '1';
|
||||
reset_n : in std_logic;
|
||||
--ready : in std_logic;
|
||||
sink_packet_error : in std_logic_vector (1 downto 0);
|
||||
--sink_stall : in std_logic;
|
||||
source_stall : in std_logic;
|
||||
valid : in std_logic;
|
||||
reset_design : out std_logic;
|
||||
sink_ready_ctrl : out std_logic;
|
||||
source_packet_error : out std_logic_vector (1 downto 0) := (others => '0');
|
||||
source_valid_ctrl : out std_logic;
|
||||
stall : out std_logic
|
||||
);
|
||||
|
||||
-- Declarations
|
||||
|
||||
end auk_dspip_avalon_streaming_controller_hpfir;
|
||||
|
||||
-- hds interface_end
|
||||
|
||||
architecture struct of auk_dspip_avalon_streaming_controller_hpfir is
|
||||
|
||||
-- signal stall_int : std_logic;
|
||||
-- signal stall_reg : std_logic;
|
||||
|
||||
-- attribute maxfan : integer;
|
||||
-- attribute maxfan of stall_reg : signal is 500;
|
||||
|
||||
begin
|
||||
|
||||
reset_design <= not reset_n;
|
||||
|
||||
--should not stop sending data to source module when the sink module is stalled
|
||||
--should only stop sending when the source module is stalled
|
||||
|
||||
--Disable the FIR core when backpressure
|
||||
stall <= source_stall;
|
||||
source_valid_ctrl <= valid;
|
||||
|
||||
-- Sink FIFO and FIR core are disabled at the same time
|
||||
sink_ready_ctrl <= not(source_stall);
|
||||
|
||||
source_packet_error <= sink_packet_error;
|
||||
|
||||
end struct;
|
||||
@@ -0,0 +1,545 @@
|
||||
-- (C) 2001-2019 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.
|
||||
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------
|
||||
--
|
||||
-- Revision Control Information
|
||||
--
|
||||
-- $Revision: #1 $
|
||||
-- $Date: 2009/07/29 $
|
||||
-- Author : Boon Hong Oh
|
||||
--
|
||||
-- Project : Atlantic II Sink Interface with ready_latency=0
|
||||
--
|
||||
-- Description :
|
||||
--
|
||||
-- This interface is capable of handling single or multi channel streams as
|
||||
-- well as blocks of data. The at_sink_sop and at_sink_eop must be fed as
|
||||
-- described in the Atlantic II specification. The at_sink_error input is a 2-
|
||||
-- bit signal that complies with the PFC error format (by Kent Orthner). The
|
||||
-- error checking is extensively done, however the resulting information is
|
||||
-- still mapped on the available 3 error states as shown below.
|
||||
-- 00: no error
|
||||
-- 01: missing sop
|
||||
-- 10: missing eop
|
||||
-- 11: unexpected eop
|
||||
-- other types of errors also marked as 11.
|
||||
--
|
||||
-- ALTERA Confidential and Proprietary
|
||||
-- Copyright 2006 (c) Altera Corporation
|
||||
-- All rights reserved
|
||||
--
|
||||
-------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
--use ieee.std_logic_arith.all;
|
||||
use ieee.numeric_std.all;
|
||||
|
||||
use work.auk_dspip_lib_pkg_hpfir.all;
|
||||
use work.auk_dspip_math_pkg_hpfir.all;
|
||||
|
||||
library altera_mf;
|
||||
use altera_mf.altera_mf_components.all;
|
||||
|
||||
entity auk_dspip_avalon_streaming_sink_hpfir is
|
||||
|
||||
generic(
|
||||
WIDTH_g : integer := 24; -- DATA_PORT_COUNT * DATA_WIDTH
|
||||
DATA_WIDTH : integer := 8;
|
||||
DATA_PORT_COUNT : integer := 3;
|
||||
PACKET_SIZE_g : natural := 2
|
||||
--FIFO_DEPTH_g : natural := 8 --if PFC mode is selected, this generic
|
||||
--is used for passing the poly_factor.
|
||||
--MIN_DATA_COUNT_g : natural := 2;
|
||||
--PFC_MODE_g : boolean := false;
|
||||
--SOP_EOP_CALC_g : boolean := false; -- calculate sop and eop rather than
|
||||
-- reading value from fifo
|
||||
--FAMILY_g : string := "Stratix II";
|
||||
--MEM_TYPE_g : string := "Auto"
|
||||
);
|
||||
port(
|
||||
clk : in std_logic;
|
||||
reset_n : in std_logic;
|
||||
----------------- DESIGN SIDE SIGNALS
|
||||
data : out std_logic_vector(WIDTH_g-1 downto 0);
|
||||
data_valid : out std_logic_vector(0 downto 0);
|
||||
|
||||
sink_ready_ctrl : in std_logic; --the controller will tell
|
||||
--the interface whether
|
||||
--new input can be accepted.
|
||||
--sink_stall : out std_logic; --needs to stall the design
|
||||
--if no new data is coming
|
||||
packet_error : out std_logic_vector (1 downto 0); --this is for SOP and EOP check only.
|
||||
--when any of these doesn't behave as
|
||||
--expected, the error is flagged.
|
||||
--send_sop : out std_logic; -- transmit SOP signal to the design.
|
||||
-- It only transmits the legal SOP.
|
||||
--send_eop : out std_logic; -- transmit EOP signal to the design.
|
||||
-- It only transmits the legal EOP.
|
||||
----------------- ATLANTIC SIDE SIGNALS
|
||||
at_sink_ready : out std_logic; --it will be '1' whenever the
|
||||
--sink_ready_ctrl signal is high.
|
||||
at_sink_valid : in std_logic;
|
||||
at_sink_data : in std_logic_vector(WIDTH_g-1 downto 0);
|
||||
at_sink_sop : in std_logic := '0';
|
||||
at_sink_eop : in std_logic := '0';
|
||||
at_sink_error : in std_logic_vector(1 downto 0) := "00" --it indicates
|
||||
--that there is an error in the packet.
|
||||
|
||||
);
|
||||
|
||||
end auk_dspip_avalon_streaming_sink_hpfir;
|
||||
|
||||
-- hds interface_end
|
||||
architecture rtl of auk_dspip_avalon_streaming_sink_hpfir is
|
||||
|
||||
type STATE_TYPE_t is (start, stall, run1, st_err, end1); -- stall,run_once,wait1,
|
||||
type OUT_STATE_TYPE_t is (normal, empty_and_not_ready, empty_and_ready);
|
||||
constant LOG2PACKET_SIZE_c : natural := log2_ceil_one(PACKET_SIZE_g);
|
||||
|
||||
signal sink_state : STATE_TYPE_t;
|
||||
signal sink_next_state : STATE_TYPE_t;
|
||||
signal reset_count : std_logic;
|
||||
signal count_enable : std_logic;
|
||||
signal count : unsigned(LOG2PACKET_SIZE_c -1 downto 0);
|
||||
signal count_finished : boolean;
|
||||
signal at_sink_error_int : std_logic;
|
||||
signal packet_error_int : std_logic_vector (1 downto 0);
|
||||
signal packet_error_s : std_logic_vector(1 downto 0);
|
||||
|
||||
signal at_sink_ready_s : std_logic;
|
||||
--signal reset : std_logic;
|
||||
signal max_reached : boolean; -- flag to show counter has reached max value
|
||||
|
||||
-- component altera_avalon_sc_fifo is
|
||||
-- generic(
|
||||
-- SYMBOLS_PER_BEAT : integer := 1;
|
||||
-- BITS_PER_SYMBOL : integer := 8;
|
||||
-- FIFO_DEPTH : integer := 16;
|
||||
-- CHANNEL_WIDTH : integer := 0;
|
||||
-- ERROR_WIDTH : integer := 0;
|
||||
-- USE_PACKETS : integer := 0
|
||||
-- );
|
||||
-- port (
|
||||
-- -- inputs:
|
||||
-- signal clk : IN STD_LOGIC;
|
||||
-- signal in_data : IN STD_LOGIC_VECTOR (DATA_WIDTH*DATA_PORT_COUNT-1 DOWNTO 0);
|
||||
-- signal in_valid : IN STD_LOGIC;
|
||||
-- signal in_startofpacket : IN STD_LOGIC;
|
||||
-- signal in_endofpacket : IN STD_LOGIC;
|
||||
-- signal out_ready : IN STD_LOGIC;
|
||||
-- signal reset : IN STD_LOGIC;
|
||||
--
|
||||
-- signal in_empty : IN STD_LOGIC_VECTOR (log2_ceil_one(DATA_PORT_COUNT)-1 DOWNTO 0);
|
||||
-- signal in_error : IN STD_LOGIC_VECTOR (0 DOWNTO 0);
|
||||
-- signal in_channel : IN STD_LOGIC_VECTOR (0 DOWNTO 0);
|
||||
--
|
||||
-- signal csr_address : IN STD_LOGIC_VECTOR (1 DOWNTO 0);
|
||||
-- signal csr_write : IN STD_LOGIC;
|
||||
-- signal csr_read : IN STD_LOGIC;
|
||||
-- signal csr_writedata : IN STD_LOGIC_VECTOR (31 DOWNTO 0);
|
||||
--
|
||||
-- -- outputs:
|
||||
-- signal in_ready : OUT STD_LOGIC;
|
||||
-- signal out_data : OUT STD_LOGIC_VECTOR (DATA_WIDTH*DATA_PORT_COUNT-1 DOWNTO 0);
|
||||
-- signal out_valid : OUT STD_LOGIC;
|
||||
--
|
||||
-- signal out_empty : OUT STD_LOGIC_VECTOR (log2_ceil_one(DATA_PORT_COUNT)-1 DOWNTO 0);
|
||||
-- signal out_error : OUT STD_LOGIC_VECTOR (0 DOWNTO 0);
|
||||
-- signal out_channel : OUT STD_LOGIC_VECTOR (0 DOWNTO 0)
|
||||
-- );
|
||||
-- end component altera_avalon_sc_fifo;
|
||||
begin
|
||||
|
||||
valid_generate_single : if PACKET_SIZE_g = 1 generate
|
||||
signal packet_error0 : std_logic;
|
||||
begin
|
||||
at_sink_error_int <= at_sink_error(0) when at_sink_valid = '1' else
|
||||
'0';
|
||||
|
||||
packet_error_int <= '0' & packet_error0;
|
||||
|
||||
packet_error0 <= '0' when at_sink_error_int = '0' and sink_next_state /= st_err else
|
||||
'1';
|
||||
|
||||
sink_comb_update_1 : process (sink_state, at_sink_valid, at_sink_error_int, at_sink_ready_s)
|
||||
begin -- process sink_comb_update_1
|
||||
case sink_state is
|
||||
when start =>
|
||||
--fifo_wrreq <= '0';
|
||||
if at_sink_error_int = '1' then
|
||||
sink_next_state <= st_err;
|
||||
else
|
||||
if at_sink_ready_s = '0' and at_sink_valid = '0' then
|
||||
sink_next_state <= start;
|
||||
elsif at_sink_ready_s = '0' and at_sink_valid = '1' then
|
||||
sink_next_state <= start;
|
||||
elsif at_sink_ready_s = '1' and at_sink_valid = '0' then
|
||||
sink_next_state <= stall;
|
||||
elsif at_sink_ready_s = '1' and at_sink_valid = '1' then
|
||||
sink_next_state <= run1;
|
||||
else
|
||||
sink_next_state <= st_err;
|
||||
end if;
|
||||
end if;
|
||||
when stall =>
|
||||
--fifo_wrreq <= '0';
|
||||
if at_sink_error_int = '1' then
|
||||
sink_next_state <= st_err;
|
||||
else
|
||||
if at_sink_ready_s = '0' and at_sink_valid = '0' then
|
||||
sink_next_state <= start;
|
||||
elsif at_sink_ready_s = '0' and at_sink_valid = '1' then
|
||||
sink_next_state <= start;
|
||||
elsif at_sink_ready_s = '1' and at_sink_valid = '0' then
|
||||
sink_next_state <= stall;
|
||||
elsif at_sink_ready_s = '1' and at_sink_valid = '1' then
|
||||
sink_next_state <= run1;
|
||||
else
|
||||
sink_next_state <= st_err;
|
||||
end if;
|
||||
end if;
|
||||
|
||||
when run1 =>
|
||||
--fifo_wrreq <= '1';
|
||||
if at_sink_error_int = '1' then
|
||||
sink_next_state <= st_err;
|
||||
else
|
||||
if at_sink_ready_s = '0' and at_sink_valid = '0' then
|
||||
sink_next_state <= start;
|
||||
elsif at_sink_ready_s = '0' and at_sink_valid = '1' then
|
||||
sink_next_state <= start;
|
||||
elsif at_sink_ready_s = '1' and at_sink_valid = '0' then
|
||||
sink_next_state <= stall;
|
||||
elsif at_sink_ready_s = '1' and at_sink_valid = '1' then
|
||||
sink_next_state <= run1;
|
||||
else
|
||||
sink_next_state <= st_err;
|
||||
end if;
|
||||
end if;
|
||||
|
||||
when st_err =>
|
||||
--fifo_wrreq <= '0';
|
||||
if at_sink_error_int = '1' then
|
||||
sink_next_state <= st_err;
|
||||
else
|
||||
if at_sink_ready_s = '0' and at_sink_valid = '0' then
|
||||
sink_next_state <= start;
|
||||
elsif at_sink_ready_s = '0' and at_sink_valid = '1' then
|
||||
sink_next_state <= start;
|
||||
elsif at_sink_ready_s = '1' and at_sink_valid = '0' then
|
||||
sink_next_state <= stall;
|
||||
elsif at_sink_ready_s = '1' and at_sink_valid = '1' then
|
||||
sink_next_state <= run1;
|
||||
else
|
||||
sink_next_state <= st_err;
|
||||
end if;
|
||||
end if;
|
||||
|
||||
when others =>
|
||||
sink_next_state <= st_err;
|
||||
--fifo_wrreq <= '0';
|
||||
end case;
|
||||
end process sink_comb_update_1;
|
||||
end generate valid_generate_single;
|
||||
|
||||
|
||||
valid_generate_mult : if PACKET_SIZE_g > 1 generate
|
||||
|
||||
at_sink_error_int <= at_sink_error(1) or at_sink_error(0) when at_sink_valid = '1' else
|
||||
'0';
|
||||
|
||||
count_enable <= '1' when (sink_next_state = run1 or sink_next_state = end1) else --
|
||||
--or sink_next_state = run_once) else
|
||||
'0';
|
||||
reset_count <= '1' when sink_next_state = st_err else
|
||||
'0';
|
||||
|
||||
sink_comb_update_2 : process (sink_state, at_sink_ready_s, at_sink_valid,
|
||||
at_sink_error, at_sink_error_int, at_sink_sop,
|
||||
at_sink_eop, count, count_finished)
|
||||
begin -- process sink_comb_update_2
|
||||
case sink_state is
|
||||
when start =>
|
||||
--fifo_wrreq <= '0';
|
||||
|
||||
if at_sink_error_int = '1' then
|
||||
sink_next_state <= st_err;
|
||||
packet_error_int <= at_sink_error;
|
||||
else
|
||||
if at_sink_ready_s = '1' and at_sink_valid = '1' and at_sink_sop = '1' then
|
||||
sink_next_state <= run1;
|
||||
packet_error_int <= "00";
|
||||
elsif (at_sink_ready_s = '1' and at_sink_valid = '1' and at_sink_sop = '0') then
|
||||
sink_next_state <= st_err;
|
||||
packet_error_int <= "01";
|
||||
else
|
||||
sink_next_state <= start;
|
||||
packet_error_int <= "00";
|
||||
end if;
|
||||
end if;
|
||||
|
||||
when run1 =>
|
||||
--fifo_wrreq <= '1';
|
||||
|
||||
if at_sink_error_int = '1' then
|
||||
sink_next_state <= st_err;
|
||||
packet_error_int <= at_sink_error;
|
||||
elsif at_sink_sop = '1' and at_sink_valid = '1' then
|
||||
sink_next_state <= st_err;
|
||||
packet_error_int <= "01";
|
||||
elsif (count_finished = false and at_sink_eop = '1' and at_sink_valid = '1') then
|
||||
sink_next_state <= st_err;
|
||||
packet_error_int <= "11";
|
||||
else
|
||||
if at_sink_eop = '0' and count_finished = false and at_sink_valid = '1' and at_sink_ready_s = '1' then
|
||||
sink_next_state <= run1;
|
||||
packet_error_int <= "00";
|
||||
elsif at_sink_eop = '1' and count_finished = true and at_sink_valid = '1' and at_sink_ready_s = '1' then
|
||||
sink_next_state <= end1;
|
||||
packet_error_int <= "00";
|
||||
elsif (count_finished = true and at_sink_valid = '0' and at_sink_ready_s = '1') or
|
||||
(at_sink_valid = '0' and at_sink_ready_s = '1') then
|
||||
sink_next_state <= stall;
|
||||
packet_error_int <= "00";
|
||||
elsif (count_finished = true and at_sink_ready_s = '0') or (at_sink_eop = '0' and at_sink_ready_s = '0') then
|
||||
sink_next_state <= stall; --wait1;
|
||||
packet_error_int <= "00";
|
||||
elsif (count_finished = true and at_sink_eop = '0' and at_sink_valid = '1' and at_sink_ready_s = '1') then
|
||||
sink_next_state <= st_err;
|
||||
packet_error_int <= "10";
|
||||
else
|
||||
sink_next_state <= st_err;
|
||||
packet_error_int <= "11";
|
||||
end if;
|
||||
end if;
|
||||
when stall =>
|
||||
--fifo_wrreq <= '0';
|
||||
|
||||
if at_sink_error_int = '1' then
|
||||
sink_next_state <= st_err;
|
||||
packet_error_int <= at_sink_error;
|
||||
elsif at_sink_sop = '1' and at_sink_valid = '1' then
|
||||
sink_next_state <= st_err;
|
||||
packet_error_int <= "01";
|
||||
elsif (count_finished = false and at_sink_eop = '1' and at_sink_valid = '1') then
|
||||
sink_next_state <= st_err;
|
||||
packet_error_int <= "11";
|
||||
else
|
||||
if at_sink_eop = '0' and count_finished = false and at_sink_valid = '1' and at_sink_ready_s = '1' then --and at_sink_ready_int = '1' then
|
||||
sink_next_state <= run1;
|
||||
packet_error_int <= "00";
|
||||
elsif at_sink_eop = '1' and count_finished = true and at_sink_valid = '1' and at_sink_ready_s = '1' then
|
||||
sink_next_state <= end1;
|
||||
packet_error_int <= "00";
|
||||
elsif (count_finished = true and at_sink_valid = '0') or -- and at_sink_ready_s = '1') or
|
||||
(at_sink_valid = '0' and at_sink_ready_s = '1') then
|
||||
sink_next_state <= stall;
|
||||
packet_error_int <= "00";
|
||||
elsif (count_finished = true and at_sink_ready_s = '0') or (at_sink_eop = '0' and at_sink_ready_s = '0') then
|
||||
sink_next_state <= stall; --wait1;
|
||||
packet_error_int <= "00";
|
||||
elsif (count_finished = true and at_sink_eop = '0' and at_sink_valid = '1' and at_sink_ready_s = '1') then
|
||||
sink_next_state <= st_err;
|
||||
packet_error_int <= "10";
|
||||
else
|
||||
sink_next_state <= st_err;
|
||||
packet_error_int <= "11";
|
||||
end if;
|
||||
end if;
|
||||
|
||||
when end1 =>
|
||||
--fifo_wrreq <= '1';
|
||||
|
||||
if at_sink_error_int = '1' then
|
||||
sink_next_state <= st_err;
|
||||
packet_error_int <= at_sink_error;
|
||||
else
|
||||
if at_sink_ready_s = '1' and at_sink_valid = '1' and at_sink_sop = '1' then
|
||||
sink_next_state <= run1;
|
||||
packet_error_int <= "00";
|
||||
elsif (at_sink_valid = '1' and at_sink_sop = '0') then
|
||||
sink_next_state <= st_err;
|
||||
packet_error_int <= "01";
|
||||
else
|
||||
sink_next_state <= start;
|
||||
packet_error_int <= "00";
|
||||
end if;
|
||||
end if;
|
||||
when st_err =>
|
||||
--fifo_wrreq <= '0';
|
||||
if at_sink_error_int = '1' then
|
||||
sink_next_state <= st_err;
|
||||
packet_error_int <= at_sink_error;
|
||||
else
|
||||
if at_sink_ready_s = '1' and at_sink_valid = '1' and at_sink_sop = '1' then
|
||||
sink_next_state <= run1;
|
||||
packet_error_int <= "00";
|
||||
elsif (at_sink_ready_s = '1' and at_sink_valid = '1' and at_sink_sop = '0') then
|
||||
sink_next_state <= st_err;
|
||||
packet_error_int <= "01";
|
||||
else
|
||||
sink_next_state <= start;
|
||||
packet_error_int <= "00";
|
||||
end if;
|
||||
end if;
|
||||
when others => null;
|
||||
end case;
|
||||
end process sink_comb_update_2;
|
||||
|
||||
|
||||
counter : process (clk, reset_n)
|
||||
begin -- process counter
|
||||
if reset_n = '0' then
|
||||
count <= (others => '0');
|
||||
max_reached <= false;
|
||||
elsif clk'event and clk = '1' then -- rising clock edge
|
||||
if reset_count = '1' then
|
||||
count <= (others => '0');
|
||||
else
|
||||
if count_enable = '1' then
|
||||
if count = PACKET_SIZE_g-2 then
|
||||
max_reached <= true;
|
||||
else
|
||||
max_reached <= false;
|
||||
end if;
|
||||
|
||||
if max_reached = false then
|
||||
count <= count + 1;
|
||||
else
|
||||
count <= (others => '0');
|
||||
end if;
|
||||
end if;
|
||||
end if;
|
||||
end if;
|
||||
end process counter;
|
||||
|
||||
count_finished <= max_reached;
|
||||
|
||||
end generate valid_generate_mult;
|
||||
|
||||
sink_input_update : process (clk, reset_n)
|
||||
begin -- process
|
||||
if reset_n = '0' then
|
||||
sink_state <= start;
|
||||
elsif clk'event and clk = '1' then
|
||||
sink_state <= sink_next_state;
|
||||
end if;
|
||||
end process sink_input_update;
|
||||
|
||||
-- sink_output_update : process (clk, reset_n)
|
||||
-- begin -- process
|
||||
-- if reset_n = '0' then
|
||||
-- sink_out_state <= normal;
|
||||
-- elsif clk'event and clk = '1' then
|
||||
-- sink_out_state <= sink_out_next_state;
|
||||
-- end if;
|
||||
-- end process sink_output_update;
|
||||
|
||||
error_register : process (clk, reset_n)
|
||||
begin -- process
|
||||
if reset_n = '0' then
|
||||
packet_error_s <= "00";
|
||||
elsif clk'event and clk = '1' then
|
||||
packet_error_s <= packet_error_int;
|
||||
end if;
|
||||
end process;
|
||||
|
||||
packet_error <= packet_error_s;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- This was included because the vho simulations of fifo produce 'X' in
|
||||
-- reset whcih means that for the FFT, alll outputs go to X when sop = X
|
||||
-----------------------------------------------------------------------------
|
||||
--gen_calc_sop: if SOP_EOP_CALC_g = true generate
|
||||
--
|
||||
-- -- generate sop and eop separate
|
||||
-- out_cnt_p : process (clk, reset)
|
||||
-- begin -- process out_cnt_p
|
||||
-- if reset = '1' then
|
||||
-- fifo_rdreq_d <= '0';
|
||||
-- out_cnt <= 0;
|
||||
-- elsif rising_edge(clk) then
|
||||
-- fifo_rdreq_d <= fifo_rdreq;
|
||||
-- if fifo_rdreq = '1' then
|
||||
-- if out_cnt < PACKET_SIZE_g - 1 then
|
||||
-- out_cnt <= out_cnt + 1;
|
||||
-- else
|
||||
-- out_cnt <= 0;
|
||||
-- end if;
|
||||
-- end if;
|
||||
-- end if;
|
||||
-- end process out_cnt_p;
|
||||
--
|
||||
-- send_sop_eop_p : process (clk, reset)
|
||||
-- begin -- process send_sop_eop_p
|
||||
-- if reset = '1' then
|
||||
-- send_sop_s <= '0';
|
||||
-- send_eop_s <= '0';
|
||||
-- elsif rising_edge(clk) then
|
||||
-- if fifo_rdreq = '1' and sink_ready_ctrl = '1' then
|
||||
-- send_sop_s <= '0';
|
||||
-- send_eop_s <= '0';
|
||||
-- if out_cnt = 0 then
|
||||
-- send_sop_s <= '1';
|
||||
-- end if;
|
||||
-- if out_cnt = PACKET_SIZE_g - 1 then
|
||||
-- send_eop_s <= '1';
|
||||
-- end if;
|
||||
-- end if;
|
||||
-- end if;
|
||||
-- end process send_sop_eop_p;
|
||||
--
|
||||
-- end generate gen_calc_sop;
|
||||
|
||||
|
||||
|
||||
--reset <= not reset_n;
|
||||
at_sink_ready <= at_sink_ready_s;
|
||||
at_sink_ready_s <= sink_ready_ctrl;
|
||||
data <= at_sink_data;
|
||||
data_valid(0) <= at_sink_valid;
|
||||
|
||||
-- sink_scfifo : altera_avalon_sc_fifo
|
||||
-- generic map (
|
||||
-- SYMBOLS_PER_BEAT => DATA_PORT_COUNT,
|
||||
-- BITS_PER_SYMBOL => DATA_WIDTH,
|
||||
-- FIFO_DEPTH => FIFO_DEPTH_g,
|
||||
-- CHANNEL_WIDTH => 0,
|
||||
-- ERROR_WIDTH => 0,
|
||||
-- USE_PACKETS => 0)
|
||||
-- port map (
|
||||
-- clk => clk,
|
||||
-- reset => reset,
|
||||
-- in_ready => at_sink_ready_s,
|
||||
-- in_data => at_sink_data,
|
||||
-- in_valid => at_sink_valid,
|
||||
-- in_startofpacket => '0',
|
||||
-- in_endofpacket => '0',
|
||||
-- out_ready => sink_ready_ctrl,
|
||||
-- out_data => data,
|
||||
-- out_valid => data_valid(0),
|
||||
-- in_empty => (others => '0'),
|
||||
-- in_error => (others => '0'),
|
||||
-- in_channel => (others => '0'),
|
||||
-- csr_address => (others => '0'),
|
||||
-- csr_write => '0',
|
||||
-- csr_read => '0',
|
||||
-- csr_writedata => (others => '0'),
|
||||
-- out_empty => open,
|
||||
-- out_error => open,
|
||||
-- out_channel => open);
|
||||
|
||||
end rtl;
|
||||
@@ -0,0 +1,467 @@
|
||||
-- (C) 2001-2019 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.
|
||||
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------
|
||||
--
|
||||
-- Revision Control Information
|
||||
--
|
||||
-- $Revision: #1 $
|
||||
-- $Date: 2009/07/29 $
|
||||
-- Author : Boon Hong Oh
|
||||
--
|
||||
-- Project : Avalon_streaming II Source Interface with ready_latency=0
|
||||
--
|
||||
-- Description :
|
||||
--
|
||||
-- This interface is capable of handling single or multi channel streams as
|
||||
-- well as blocks of data. The at_source_sop and at_source_eop are generated as
|
||||
-- described in the Avalon_streaming II specification. The at_source_error output is a 2-
|
||||
-- bit signal that complies with the PFC error format (by Kent Orthner).
|
||||
--
|
||||
-- 00: no error
|
||||
-- 01: missing sop
|
||||
-- 10: missing eop
|
||||
-- 11: unexpected eop
|
||||
-- other types of errors also marked as 11. Any error signal is accompanied
|
||||
-- by at_sink_eop flagged high.
|
||||
--
|
||||
-- When packet_size is greater than one, this interface expects the main design
|
||||
-- to supply the count of data starting from 1 to the packet_size. When it
|
||||
-- receives the valid flag together with the data_count=1, it starts pumping
|
||||
-- out data by flagging the at_source_sop and at_source_valid both high.
|
||||
--
|
||||
-- When the data_count=packet_size, the at_source_eop is flagged high together
|
||||
-- with at_source_valid. THERE IS NO ERROR CHECKING FOR THE data_count signal.
|
||||
--
|
||||
-- If the receiver is not ready to accept any data, the interface flags the source_
|
||||
-- stall signal high to tell the design to stall. It is the designers
|
||||
-- responsibility to use this signal properly. In some design, the stall signal
|
||||
-- needs to stall all of the design so that no new data can be accepted (as in
|
||||
-- FIR), in other cases (i.e. a FIFO built on a dual port RAM),the input can
|
||||
-- still accept new data although it cannot send any output.
|
||||
--
|
||||
-- ALTERA Confidential and Proprietary
|
||||
-- Copyright 2006 (c) Altera Corporation
|
||||
-- All rights reserved
|
||||
--
|
||||
-------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
--use ieee.std_logic_arith.all;
|
||||
use ieee.numeric_std.all;
|
||||
|
||||
library altera_mf;
|
||||
use altera_mf.altera_mf_components.all;
|
||||
|
||||
use work.auk_dspip_math_pkg_hpfir.all;
|
||||
|
||||
entity auk_dspip_avalon_streaming_source_hpfir is
|
||||
generic(
|
||||
WIDTH_g : integer := 8; -- DATA_PORT_COUNT * DATA_WIDTH
|
||||
DATA_WIDTH : integer := 8;
|
||||
DATA_PORT_COUNT : integer := 1;
|
||||
PACKET_SIZE_g : natural := 2;
|
||||
FIFO_DEPTH_g : natural := 0;
|
||||
HAVE_COUNTER_g : boolean := false;
|
||||
COUNTER_LIMIT_g : natural := 4;
|
||||
--MULTI_CHANNEL_g : boolean := true;
|
||||
USE_PACKETS : integer := 1;
|
||||
--FAMILY_g : string := "Stratix II";
|
||||
--MEM_TYPE_g : string := "Auto";
|
||||
ENABLE_BACKPRESSURE_g : boolean := true
|
||||
);
|
||||
port(
|
||||
clk : in std_logic;
|
||||
reset_n : in std_logic;
|
||||
----------------- DESIGN SIDE SIGNALS
|
||||
data_in : in std_logic_vector (WIDTH_g-1 downto 0);
|
||||
data_count : in std_logic_vector (log2_ceil_one(PACKET_SIZE_g)-1 downto 0) := (others => '0');
|
||||
source_valid_ctrl : in std_logic;
|
||||
source_stall : out std_logic;
|
||||
packet_error : in std_logic_vector (1 downto 0);
|
||||
----------------- AVALON_STREAMING SIDE SIGNALS
|
||||
at_source_ready : in std_logic;
|
||||
at_source_valid : out std_logic;
|
||||
at_source_data : out std_logic_vector (WIDTH_g-1 downto 0);
|
||||
at_source_channel : out std_logic_vector (log2_ceil_one(PACKET_SIZE_g)-1 downto 0);
|
||||
at_source_error : out std_logic_vector (1 downto 0);
|
||||
at_source_sop : out std_logic;
|
||||
at_source_eop : out std_logic
|
||||
);
|
||||
|
||||
-- Declarations
|
||||
|
||||
end auk_dspip_avalon_streaming_source_hpfir;
|
||||
|
||||
-- hds interface_end
|
||||
architecture rtl of auk_dspip_avalon_streaming_source_hpfir is
|
||||
|
||||
--constant FIFO_HINT_c : string := "RAM_BLOCK_TYPE="& MEM_TYPE_g;
|
||||
constant FIFO_DEPTH_c : natural := FIFO_DEPTH_g;
|
||||
constant LOG2PACKET_SIZE_c : natural := log2_ceil_one(PACKET_SIZE_g);
|
||||
constant MIN_DATA_COUNT_g : natural := 2;
|
||||
type STATE_TYPE_t is (start, sop, run1, st_err, end1); --wait1, stall,
|
||||
signal source_state : STATE_TYPE_t;
|
||||
signal source_next_state : STATE_TYPE_t;
|
||||
signal packet_error0 : std_logic;
|
||||
signal at_source_error_int : std_logic_vector(1 downto 0);
|
||||
signal at_source_sop_int : std_logic := '0';
|
||||
signal at_source_eop_int : std_logic := '0';
|
||||
signal count_finished : boolean := false;
|
||||
signal count_started : boolean := false;
|
||||
signal at_source_valid_s : std_logic;
|
||||
|
||||
signal data_valid : std_logic;
|
||||
signal data_out : std_logic_vector(WIDTH_g-1 downto 0);
|
||||
signal fifo_count : std_logic_vector(DATA_PORT_COUNT*log2_ceil(FIFO_DEPTH_g)-1 downto 0);
|
||||
signal fifo_empty : std_logic_vector(DATA_PORT_COUNT-1 downto 0); -- multichan, multiinout
|
||||
signal fifo_alm_empty : std_logic_vector(DATA_PORT_COUNT-1 downto 0);
|
||||
signal fifo_alm_full : std_logic_vector(DATA_PORT_COUNT-1 downto 0);
|
||||
signal fifo_full : std_logic_vector(DATA_PORT_COUNT-1 downto 0);
|
||||
signal clear_fifo : std_logic;
|
||||
signal fifo_rdreq : std_logic;
|
||||
signal fifo_rdreq_d : std_logic;
|
||||
signal fifo_wrreq : std_logic;
|
||||
signal fifo_empty_d : std_logic;
|
||||
signal reset_design_int : std_logic;
|
||||
signal channel_out : std_logic_vector(log2_ceil_one(PACKET_SIZE_g)-1 downto 0) := (others => '0');
|
||||
|
||||
signal fifo_sop_in : std_logic := '0';
|
||||
signal fifo_eop_in : std_logic := '0';
|
||||
signal fifo_error_in : std_logic_vector(1 downto 0);
|
||||
signal at_source_sop_s : std_logic := '0';
|
||||
signal at_source_eop_s : std_logic := '0';
|
||||
signal at_source_error_s : std_logic_vector(1 downto 0);
|
||||
signal in_ready : std_logic;
|
||||
|
||||
component altera_avalon_sc_fifo is
|
||||
generic(
|
||||
SYMBOLS_PER_BEAT : integer := 1;
|
||||
BITS_PER_SYMBOL : integer := 8;
|
||||
FIFO_DEPTH : integer := 16;
|
||||
CHANNEL_WIDTH : integer := 2;
|
||||
ERROR_WIDTH : integer := 2;
|
||||
--EMPTY_LATENCY : integer := 0;
|
||||
USE_PACKETS : integer := 0
|
||||
);
|
||||
port (
|
||||
-- inputs:
|
||||
signal clk : IN STD_LOGIC;
|
||||
signal in_channel : IN STD_LOGIC_VECTOR (log2_ceil_one(PACKET_SIZE_g)-1 DOWNTO 0);
|
||||
signal in_data : IN STD_LOGIC_VECTOR (DATA_WIDTH*DATA_PORT_COUNT-1 DOWNTO 0);
|
||||
signal in_error : IN STD_LOGIC_VECTOR (1 DOWNTO 0);
|
||||
signal in_endofpacket : IN STD_LOGIC;
|
||||
signal in_startofpacket : IN STD_LOGIC;
|
||||
signal in_valid : IN STD_LOGIC;
|
||||
signal out_ready : IN STD_LOGIC;
|
||||
signal reset : IN STD_LOGIC;
|
||||
|
||||
signal in_empty : IN STD_LOGIC_VECTOR (log2_ceil_one(DATA_PORT_COUNT)-1 DOWNTO 0);
|
||||
|
||||
signal csr_address : IN STD_LOGIC_VECTOR (1 DOWNTO 0);
|
||||
signal csr_write : IN STD_LOGIC;
|
||||
signal csr_read : IN STD_LOGIC;
|
||||
signal csr_writedata : IN STD_LOGIC_VECTOR (31 DOWNTO 0);
|
||||
|
||||
-- outputs:
|
||||
signal in_ready : OUT STD_LOGIC;
|
||||
signal out_channel : OUT STD_LOGIC_VECTOR (log2_ceil_one(PACKET_SIZE_g)-1 DOWNTO 0);
|
||||
signal out_data : OUT STD_LOGIC_VECTOR (DATA_WIDTH*DATA_PORT_COUNT-1 DOWNTO 0);
|
||||
signal out_error : OUT STD_LOGIC_VECTOR (1 DOWNTO 0);
|
||||
signal out_endofpacket : OUT STD_LOGIC;
|
||||
signal out_startofpacket : OUT STD_LOGIC;
|
||||
signal out_valid : OUT STD_LOGIC;
|
||||
signal out_empty : OUT STD_LOGIC_VECTOR (log2_ceil_one(DATA_PORT_COUNT)-1 DOWNTO 0)
|
||||
);
|
||||
end component altera_avalon_sc_fifo;
|
||||
|
||||
begin
|
||||
single_channel : if USE_PACKETS = 0 generate
|
||||
at_source_sop_int <= '0';
|
||||
at_source_eop_int <= '0';
|
||||
packet_error0 <= packet_error(0);
|
||||
at_source_error_int(1) <= '0';
|
||||
at_source_error_int(0) <= packet_error0;
|
||||
end generate single_channel;
|
||||
|
||||
packet_multi : if USE_PACKETS = 1 generate
|
||||
packet_error0 <= packet_error(1) or packet_error(0);
|
||||
|
||||
counter_no : if HAVE_COUNTER_g = false generate
|
||||
signal data_counter : unsigned(LOG2PACKET_SIZE_c-1 downto 0);
|
||||
begin
|
||||
count_finished <= true when data_counter = to_unsigned(PACKET_SIZE_g-1, LOG2PACKET_SIZE_c) else
|
||||
false;
|
||||
data_counter <= unsigned(data_count);
|
||||
|
||||
count_started <= true when data_counter = 0 else
|
||||
false;
|
||||
end generate counter_no;
|
||||
|
||||
counter_yes : if HAVE_COUNTER_g = true generate
|
||||
signal data_counter : unsigned(log2_ceil(COUNTER_LIMIT_g)-1 downto 0);
|
||||
begin
|
||||
count_finished <= true when data_counter = to_unsigned(COUNTER_LIMIT_g-1, log2_ceil(COUNTER_LIMIT_g)) else
|
||||
false;
|
||||
count_started <= true when data_counter = 0 else
|
||||
false;
|
||||
|
||||
packet_counter : process (clk, reset_n)
|
||||
begin -- process packet_counter
|
||||
if reset_n = '0' then
|
||||
data_counter <= (others => '0');
|
||||
elsif rising_edge(clk) then
|
||||
if source_state = start and source_next_state = sop then
|
||||
data_counter <= --(others => '0'); --
|
||||
data_counter +1;
|
||||
elsif data_valid = '1' and at_source_ready = '1' and (data_counter < COUNTER_LIMIT_g-1) then
|
||||
data_counter <= data_counter +1;
|
||||
elsif count_finished = true then
|
||||
data_counter <= (others => '0');
|
||||
end if;
|
||||
end if;
|
||||
end process packet_counter;
|
||||
end generate counter_yes;
|
||||
|
||||
source_comb_update : process (--at_source_ready,
|
||||
count_finished, count_started,
|
||||
packet_error, packet_error0, source_state,
|
||||
--at_source_valid_s
|
||||
in_ready,
|
||||
source_valid_ctrl)
|
||||
|
||||
begin -- process source_comb_update
|
||||
|
||||
case source_state is
|
||||
when start =>
|
||||
if packet_error0 = '1' then
|
||||
source_next_state <= st_err;
|
||||
at_source_error_int <= packet_error;
|
||||
at_source_sop_int <= '0';
|
||||
at_source_eop_int <= '1';
|
||||
else
|
||||
at_source_eop_int <= '0';
|
||||
at_source_error_int <= "00";
|
||||
if source_valid_ctrl = '1' and count_started = true then --and at_source_ready='1' then
|
||||
source_next_state <= sop;
|
||||
at_source_sop_int <= '1';
|
||||
else
|
||||
source_next_state <= start;
|
||||
at_source_sop_int <= '0';
|
||||
end if;
|
||||
end if;
|
||||
|
||||
when sop =>
|
||||
if packet_error0 = '1' then
|
||||
source_next_state <= st_err;
|
||||
at_source_error_int <= packet_error;
|
||||
at_source_sop_int <= '0';
|
||||
at_source_eop_int <= '1';
|
||||
else
|
||||
at_source_error_int <= "00";
|
||||
at_source_eop_int <= '0';
|
||||
--if source_valid_ctrl = '1' and at_source_ready = '1' and count_finished = false then
|
||||
if source_valid_ctrl = '1' and in_ready = '1' and count_finished = false then
|
||||
if PACKET_SIZE_g > 2 then
|
||||
source_next_state <= run1;
|
||||
else
|
||||
source_next_state <= end1;
|
||||
end if;
|
||||
at_source_sop_int <= '0';
|
||||
--elsif (at_source_ready = '1' and source_valid_ctrl = '1' and count_finished = true) or
|
||||
elsif (in_ready = '1' and source_valid_ctrl = '1' and count_finished = true) or
|
||||
(source_valid_ctrl = '0' and count_finished = true) then --valid_ctrl_int = '1' and
|
||||
source_next_state <= end1;
|
||||
at_source_error_int <= "00";
|
||||
at_source_eop_int <= '1';
|
||||
at_source_sop_int <= '0';
|
||||
else
|
||||
source_next_state <= sop;
|
||||
at_source_sop_int <= '1';
|
||||
end if;
|
||||
end if;
|
||||
|
||||
when run1 =>
|
||||
at_source_sop_int <= '0';
|
||||
|
||||
if packet_error0 = '1' then
|
||||
source_next_state <= st_err;
|
||||
at_source_error_int <= packet_error;
|
||||
at_source_eop_int <= '1';
|
||||
else
|
||||
--if (at_source_ready = '1' and source_valid_ctrl = '1' and count_finished = true) or
|
||||
if (in_ready = '1' and source_valid_ctrl = '1' and count_finished = true) or
|
||||
(source_valid_ctrl = '0' and count_finished = true) then --valid_ctrl_int = '1' and
|
||||
source_next_state <= end1;
|
||||
at_source_error_int <= "00";
|
||||
at_source_eop_int <= '1';
|
||||
else
|
||||
source_next_state <= run1;
|
||||
at_source_error_int <= "00";
|
||||
at_source_eop_int <= '0';
|
||||
end if;
|
||||
end if;
|
||||
|
||||
when end1 =>
|
||||
|
||||
if packet_error0 = '1' then
|
||||
source_next_state <= st_err;
|
||||
at_source_error_int <= packet_error;
|
||||
at_source_sop_int <= '0';
|
||||
at_source_eop_int <= '1';
|
||||
else
|
||||
at_source_error_int <= "00";
|
||||
--if source_valid_ctrl = '1' and count_started = true and at_source_ready = '1' then
|
||||
if source_valid_ctrl = '1' and count_started = true and in_ready = '1' then
|
||||
source_next_state <= sop;
|
||||
at_source_sop_int <= '1';
|
||||
at_source_eop_int <= '0';
|
||||
--elsif source_valid_ctrl = '1' and at_source_ready = '1' then
|
||||
elsif source_valid_ctrl = '1' and in_ready = '1' then
|
||||
source_next_state <= start;
|
||||
at_source_sop_int <= '0';
|
||||
at_source_eop_int <= '0';
|
||||
else
|
||||
source_next_state <= end1;
|
||||
at_source_sop_int <= '0';
|
||||
at_source_eop_int <= '1';
|
||||
end if;
|
||||
end if;
|
||||
|
||||
when st_err =>
|
||||
at_source_sop_int <= '0';
|
||||
at_source_eop_int <= '0';
|
||||
if packet_error0 = '1' then
|
||||
source_next_state <= st_err;
|
||||
at_source_error_int <= packet_error;
|
||||
else
|
||||
source_next_state <= start;
|
||||
at_source_error_int <= "00";
|
||||
end if;
|
||||
when others =>
|
||||
source_next_state <= st_err;
|
||||
at_source_sop_int <= '0';
|
||||
at_source_eop_int <= '1';
|
||||
at_source_error_int <= "11";
|
||||
|
||||
end case;
|
||||
end process source_comb_update;
|
||||
|
||||
source_state_update : process (clk, reset_n)
|
||||
begin -- process
|
||||
if reset_n = '0' then
|
||||
source_state <= start;
|
||||
elsif clk'event and clk = '1' then
|
||||
source_state <= source_next_state;
|
||||
end if;
|
||||
end process source_state_update;
|
||||
end generate packet_multi;
|
||||
|
||||
at_source_sop <= at_source_sop_s;
|
||||
at_source_eop <= at_source_eop_s;
|
||||
at_source_error <= at_source_error_s;
|
||||
|
||||
channel_info_exists : if USE_PACKETS = 1 generate
|
||||
at_source_channel <= channel_out;
|
||||
end generate channel_info_exists;
|
||||
|
||||
no_channel_info : if USE_PACKETS = 0 generate
|
||||
at_source_channel <= (others => '0');
|
||||
end generate no_channel_info;
|
||||
|
||||
at_source_data <= data_out;
|
||||
at_source_valid <= data_valid;
|
||||
|
||||
|
||||
backpressure_support: if ENABLE_BACKPRESSURE_g = true generate
|
||||
reset_design_int <= not reset_n;
|
||||
|
||||
--source_stall <= not(in_ready);
|
||||
source_stall <= not(at_source_ready);
|
||||
|
||||
fifo_sop_in <= '0' when USE_PACKETS = 0 else
|
||||
at_source_sop_int;
|
||||
|
||||
fifo_eop_in <= '0' when USE_PACKETS = 0 else
|
||||
at_source_eop_int;
|
||||
|
||||
fifo_error_in <= "00" when USE_PACKETS = 0 else
|
||||
at_source_error_int;
|
||||
|
||||
scfifo : altera_avalon_sc_fifo
|
||||
generic map (
|
||||
SYMBOLS_PER_BEAT => DATA_PORT_COUNT,
|
||||
BITS_PER_SYMBOL => DATA_WIDTH,
|
||||
FIFO_DEPTH => FIFO_DEPTH_c,
|
||||
CHANNEL_WIDTH => log2_ceil_one(PACKET_SIZE_g),
|
||||
ERROR_WIDTH => 2,
|
||||
--EMPTY_LATENCY => 1,
|
||||
USE_PACKETS => USE_PACKETS)
|
||||
port map (
|
||||
clk => clk,
|
||||
reset => reset_design_int,
|
||||
in_ready => in_ready,
|
||||
--in_data => fifo_datain(((0*DATA_WIDTH)+DATA_WIDTH-1) downto (0*DATA_WIDTH)),
|
||||
in_data => data_in,
|
||||
in_valid => source_valid_ctrl,
|
||||
in_error => fifo_error_in,
|
||||
in_channel => data_count,
|
||||
in_startofpacket => fifo_sop_in,
|
||||
in_endofpacket => fifo_eop_in,
|
||||
|
||||
in_empty => (others => '0'),
|
||||
csr_address => (others => '0'),
|
||||
csr_write => '0',
|
||||
csr_read => '0',
|
||||
csr_writedata => (others => '0'),
|
||||
out_ready => at_source_ready,
|
||||
--out_data => fifo_dataout(((0*DATA_WIDTH)+DATA_WIDTH-1) downto (0*DATA_WIDTH)),
|
||||
out_data => data_out,
|
||||
out_valid => data_valid,
|
||||
out_error => at_source_error_s,
|
||||
out_channel => channel_out,
|
||||
out_startofpacket => at_source_sop_s,
|
||||
out_endofpacket => at_source_eop_s,
|
||||
out_empty => open);
|
||||
|
||||
end generate backpressure_support;
|
||||
|
||||
|
||||
backpressure_no_support: if ENABLE_BACKPRESSURE_g = false generate
|
||||
in_ready <= '1';
|
||||
source_stall <= '0';
|
||||
|
||||
output_registers : process (clk, reset_n)
|
||||
begin
|
||||
if reset_n = '0' then
|
||||
channel_out <= (others => '0');
|
||||
data_out <= (others => '0');
|
||||
data_valid <= '0';
|
||||
at_source_error_s <= "00";
|
||||
at_source_sop_s <= '0';
|
||||
at_source_eop_s <= '0';
|
||||
elsif rising_edge(clk) then
|
||||
channel_out <= data_count;
|
||||
data_out <= data_in;
|
||||
data_valid <= source_valid_ctrl;
|
||||
at_source_error_s <= at_source_error_int;
|
||||
at_source_sop_s <= at_source_sop_int;
|
||||
at_source_eop_s <= at_source_eop_int;
|
||||
end if;
|
||||
end process output_registers;
|
||||
end generate backpressure_no_support;
|
||||
|
||||
end rtl;
|
||||
|
||||
@@ -0,0 +1,583 @@
|
||||
-- (C) 2001-2019 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.
|
||||
|
||||
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
|
||||
-- Alex, 02-10-07, this package declaration results in error at built time on a new machine
|
||||
--
|
||||
use work.auk_dspip_math_pkg_hpfir.all;
|
||||
|
||||
package auk_dspip_lib_pkg_hpfir is
|
||||
--Component names:
|
||||
--auk_dspip_atlantic_sink
|
||||
--auk_dspip_atlantic_source
|
||||
--auk_dspip_interface_controller
|
||||
--auk_dspip_avalon_streaming_controller_hpfir
|
||||
--auk_dspip_avalon_streaming_controller_pe_fir_91
|
||||
--auk_dspip_avalon_streaming_sink_hpfir
|
||||
--auk_dspip_avalon_streaming_source_hpfir
|
||||
--auk_dspip_delay_fir_91
|
||||
--auk_dspip_fastadd_fir_91
|
||||
--auk_dspip_fastaddsub_fir_91
|
||||
--auk_dspip_pipelined_adder_fir_91
|
||||
--auk_dspip_fast_accumulator_fir_91
|
||||
--auk_dspip_fifo_pfc_fir_91
|
||||
--auk_dspip_fpcompiler_alufp
|
||||
--auk_dspip_fpcompiler_aslf
|
||||
--auk_dspip_fpcompiler_asrf
|
||||
--auk_dspip_fpcompiler_castftox
|
||||
--auk_dspip_fpcompiler_castxtof
|
||||
--auk_dspip_fpcompiler_clzf
|
||||
--auk_dspip_fpcompiler_mulfp
|
||||
--auk_dspip_pfc_fir_91
|
||||
--auk_dspip_roundsat_fir_91
|
||||
component auk_dspip_atlantic_sink is
|
||||
|
||||
generic(
|
||||
WIDTH : integer := 16;
|
||||
PACKET_SIZE : natural := 4;
|
||||
log2packet_size : integer := 2
|
||||
);
|
||||
port(
|
||||
clk : in std_logic;
|
||||
reset_n : in std_logic;
|
||||
----------------- DESIGN SIDE SIGNALS
|
||||
data_available : out std_logic; --goes high when new data is available
|
||||
data : out std_logic_vector(WIDTH-1 downto 0);
|
||||
sink_ready_ctrl : in std_logic; --the controller will tell
|
||||
--the interface whether
|
||||
--new input can be accepted.
|
||||
sink_stall : out std_logic; --needs to stall the design
|
||||
--if no new data is coming
|
||||
packet_error : out std_logic_vector (1 downto 0); --this is for SOP and EOP check only.
|
||||
--when any of these doesn't behave as
|
||||
--expected, the error is flagged.
|
||||
send_sop : out std_logic; -- transmit SOP signal to the design.
|
||||
-- It only transmits the legal SOP.
|
||||
send_eop : out std_logic; -- transmit EOP signal to the design.
|
||||
-- It only transmits the legal EOP.
|
||||
----------------- ATLANTIC SIDE SIGNALS
|
||||
at_sink_ready : out std_logic; --it will be '1' whenever the
|
||||
--sink_ready_ctrl signal is high.
|
||||
at_sink_valid : in std_logic;
|
||||
at_sink_data : in std_logic_vector(WIDTH-1 downto 0);
|
||||
at_sink_sop : in std_logic := '0';
|
||||
at_sink_eop : in std_logic := '0';
|
||||
at_sink_error : in std_logic_vector(1 downto 0) --it indicates to the data source
|
||||
--that the SOP and EOP signals
|
||||
--are not received as expected.
|
||||
|
||||
);
|
||||
|
||||
end component auk_dspip_atlantic_sink;
|
||||
|
||||
component auk_dspip_atlantic_source is
|
||||
generic(
|
||||
WIDTH : integer := 16;
|
||||
packet_size : natural := 4;
|
||||
LOG2packet_size : integer := 2;
|
||||
multi_channel : BOOLEAN := TRUE
|
||||
);
|
||||
port(
|
||||
clk : in std_logic;
|
||||
reset_n : in std_logic;
|
||||
----------------- DESIGN SIDE SIGNALS
|
||||
data : in std_logic_vector (WIDTH-1 downto 0);
|
||||
data_count : in std_logic_vector (LOG2packet_size-1 downto 0) := (others => '0');
|
||||
source_valid_ctrl : in std_logic; --the controller will tell
|
||||
--the interface whether
|
||||
--new input can be accepted.
|
||||
source_stall : out std_logic; --needs to stall the design
|
||||
--if no new data is coming
|
||||
packet_error : in std_logic_vector (1 downto 0);
|
||||
----------------- ATLANTIC SIDE SIGNALS
|
||||
at_source_ready : in std_logic;
|
||||
at_source_valid : out std_logic;
|
||||
at_source_data : out std_logic_vector (WIDTH-1 downto 0);
|
||||
at_source_channel : out std_logic_vector (log2packet_size-1 downto 0);
|
||||
at_source_error : out std_logic_vector (1 downto 0);
|
||||
at_source_sop : out std_logic;
|
||||
at_source_eop : out std_logic
|
||||
);
|
||||
|
||||
-- Declarations
|
||||
|
||||
end component auk_dspip_atlantic_source;
|
||||
|
||||
|
||||
component auk_dspip_interface_controller IS
|
||||
PORT(
|
||||
clk : in std_logic;
|
||||
reset : IN std_logic;
|
||||
ready : in std_logic;
|
||||
sink_packet_error : IN std_logic_vector (1 DOWNTO 0);
|
||||
sink_stall : IN std_logic;
|
||||
source_stall : IN std_logic;
|
||||
valid : IN std_logic;
|
||||
reset_design : OUT std_logic;
|
||||
reset_n : OUT std_logic;
|
||||
sink_ready_ctrl : OUT std_logic;
|
||||
source_packet_error : OUT std_logic_vector (1 DOWNTO 0);
|
||||
source_valid_ctrl : OUT std_logic;
|
||||
stall : OUT std_logic
|
||||
);
|
||||
|
||||
-- Declarations
|
||||
|
||||
end component auk_dspip_interface_controller ;
|
||||
|
||||
|
||||
component auk_dspip_avalon_streaming_controller_hpfir is
|
||||
port(
|
||||
clk : in std_logic;
|
||||
--clk_en : in std_logic := '1';
|
||||
reset_n : in std_logic;
|
||||
--ready : in std_logic;
|
||||
sink_packet_error : in std_logic_vector (1 downto 0);
|
||||
--sink_stall : in std_logic;
|
||||
source_stall : in std_logic;
|
||||
valid : in std_logic;
|
||||
reset_design : out std_logic;
|
||||
sink_ready_ctrl : out std_logic;
|
||||
source_packet_error : out std_logic_vector (1 downto 0);
|
||||
source_valid_ctrl : out std_logic;
|
||||
stall : out std_logic
|
||||
);
|
||||
|
||||
-- Declarations
|
||||
|
||||
end component auk_dspip_avalon_streaming_controller_hpfir;
|
||||
|
||||
component auk_dspip_avalon_streaming_controller_pe_fir_91 is
|
||||
generic (
|
||||
FIFO_WIDTH_g : natural := 8;
|
||||
ENABLE_PIPELINE_DEPTH_g : natural := 0; -- this value should match the depth of the enable pipeline in the core
|
||||
FAMILY_g : string := "Stratix II";
|
||||
MEM_TYPE_g : string := "Auto"
|
||||
);
|
||||
port(
|
||||
clk : in std_logic;
|
||||
clk_en : in std_logic := '1';
|
||||
reset_n : in std_logic;
|
||||
ready : in std_logic;
|
||||
sink_packet_error : in std_logic_vector (1 downto 0);
|
||||
sink_stall : in std_logic;
|
||||
source_stall : in std_logic;
|
||||
valid : in std_logic;
|
||||
reset_design : out std_logic;
|
||||
sink_ready_ctrl : out std_logic;
|
||||
source_packet_error : out std_logic_vector (1 downto 0);
|
||||
source_valid_ctrl : out std_logic;
|
||||
stall : out std_logic;
|
||||
data_in : in std_logic_vector(FIFO_WIDTH_g-1 downto 0);
|
||||
data_out : out std_logic_vector(FIFO_WIDTH_g-1 downto 0);
|
||||
design_stall : out std_logic
|
||||
);
|
||||
|
||||
-- Declarations
|
||||
|
||||
end component auk_dspip_avalon_streaming_controller_pe_fir_91;
|
||||
|
||||
component auk_dspip_avalon_streaming_sink_hpfir is
|
||||
|
||||
generic(
|
||||
WIDTH_g : integer := 16;
|
||||
DATA_WIDTH : integer := 8;
|
||||
DATA_PORT_COUNT : integer := 3;
|
||||
PACKET_SIZE_g : natural := 4
|
||||
--FIFO_DEPTH_g : natural := 5 --if PFC mode is selected, this generic
|
||||
--is used for passing the poly_factor.
|
||||
--MIN_DATA_COUNT_g : natural := 2;
|
||||
--PFC_MODE_g : boolean := false;
|
||||
--SOP_EOP_CALC_g : boolean := false; -- calculate sop and eop rather than
|
||||
-- reading value from fifo
|
||||
--FAMILY_g : string := "Stratix II";
|
||||
--MEM_TYPE_g : string := "Auto"
|
||||
);
|
||||
port(
|
||||
clk : in std_logic;
|
||||
reset_n : in std_logic;
|
||||
----------------- DESIGN SIDE SIGNALS
|
||||
data : out std_logic_vector(WIDTH_g-1 downto 0);
|
||||
data_valid : out std_logic_vector(0 downto 0);
|
||||
sink_ready_ctrl : in std_logic; --the controller will tell
|
||||
--the interface whether
|
||||
--new input can be accepted.
|
||||
--sink_stall : out std_logic; --needs to stall the design
|
||||
--if no new data is coming
|
||||
packet_error : out std_logic_vector (1 downto 0); --this is for SOP and EOP check only.
|
||||
--when any of these doesn't behave as
|
||||
--expected, the error is flagged.
|
||||
--send_sop : out std_logic; -- transmit SOP signal to the design.
|
||||
-- It only transmits the legal SOP.
|
||||
--send_eop : out std_logic; -- transmit EOP signal to the design.
|
||||
-- It only transmits the legal EOP.
|
||||
----------------- ATLANTIC SIDE SIGNALS
|
||||
at_sink_ready : out std_logic; --it will be '1' whenever the
|
||||
--sink_ready_ctrl signal is high.
|
||||
at_sink_valid : in std_logic;
|
||||
at_sink_data : in std_logic_vector(WIDTH_g-1 downto 0);
|
||||
at_sink_sop : in std_logic := '0';
|
||||
at_sink_eop : in std_logic := '0';
|
||||
at_sink_error : in std_logic_vector(1 downto 0) := "00" --it indicates
|
||||
--that there is an error in the packet.
|
||||
|
||||
);
|
||||
|
||||
end component auk_dspip_avalon_streaming_sink_hpfir;
|
||||
|
||||
component auk_dspip_avalon_streaming_source_hpfir is
|
||||
generic(
|
||||
WIDTH_g : integer := 8;
|
||||
DATA_WIDTH : integer := 8;
|
||||
DATA_PORT_COUNT : integer := 1;
|
||||
PACKET_SIZE_g : natural := 2;
|
||||
FIFO_DEPTH_g : natural := 0;
|
||||
HAVE_COUNTER_g : boolean := false;
|
||||
COUNTER_LIMIT_g : natural := 4;
|
||||
--MULTI_CHANNEL_g : boolean := true;
|
||||
USE_PACKETS : integer := 1;
|
||||
--FAMILY_g : string := "Stratix II";
|
||||
--MEM_TYPE_g : string := "Auto";
|
||||
ENABLE_BACKPRESSURE_g : boolean := true
|
||||
);
|
||||
port(
|
||||
clk : in std_logic;
|
||||
reset_n : in std_logic;
|
||||
----------------- DESIGN SIDE SIGNALS
|
||||
data_in : in std_logic_vector (WIDTH_g-1 downto 0);
|
||||
data_count : in std_logic_vector (log2_ceil_one(PACKET_SIZE_g)-1 downto 0) := (others => '0');
|
||||
source_valid_ctrl : in std_logic;
|
||||
source_stall : out std_logic;
|
||||
packet_error : in std_logic_vector (1 downto 0);
|
||||
----------------- AVALON_STREAMING SIDE SIGNALS
|
||||
at_source_ready : in std_logic;
|
||||
at_source_valid : out std_logic;
|
||||
at_source_data : out std_logic_vector (WIDTH_g-1 downto 0);
|
||||
at_source_channel : out std_logic_vector (log2_ceil_one(PACKET_SIZE_g)-1 downto 0);
|
||||
at_source_error : out std_logic_vector (1 downto 0);
|
||||
at_source_sop : out std_logic;
|
||||
at_source_eop : out std_logic
|
||||
);
|
||||
|
||||
-- Declarations
|
||||
|
||||
end component auk_dspip_avalon_streaming_source_hpfir;
|
||||
|
||||
component auk_dspip_roundsat_hpfir is
|
||||
generic (
|
||||
IN_WIDTH_g : natural := 8; -- i/p data width
|
||||
REM_LSB_BIT_g : natural := 2; -- no. of lsb to be removed
|
||||
REM_LSB_TYPE_g : string := "trunc"; -- trunc/round
|
||||
REM_MSB_BIT_g : natural := 2; -- no. of msb to be removed
|
||||
REM_MSB_TYPE_g : string := "trunc" -- trunc/sat
|
||||
);
|
||||
port (
|
||||
clk : in std_logic;
|
||||
reset_n : in std_logic;
|
||||
enable : in std_logic;
|
||||
datain : in std_logic_vector(IN_WIDTH_g-1 downto 0);
|
||||
valid : out std_logic;
|
||||
dataout : out std_logic_vector(IN_WIDTH_g-REM_LSB_BIT_g-REM_MSB_BIT_g-1 downto 0)
|
||||
);
|
||||
end component auk_dspip_roundsat_hpfir;
|
||||
|
||||
component auk_dspip_delay_fir_91 is
|
||||
generic (
|
||||
WIDTH_g : natural := 8; -- data width
|
||||
DELAY_g : natural := 8;
|
||||
-- number of clock cycles the input
|
||||
-- will be delayed by
|
||||
MEMORY_TYPE_g : string := "AUTO";
|
||||
-- possible values are "m4k", "m512",
|
||||
-- "register", "mram", "auto",
|
||||
-- "lutram", "M9K", "M144K".
|
||||
-- Any other string will be interpreted
|
||||
-- as "auto"
|
||||
REGISTER_FIRST_g : natural := 1;
|
||||
-- if "1", the first delay is guaranteed
|
||||
-- to be in registers
|
||||
REGISTER_LAST_g : natural := 1); -- if "1", the last delay is guaranteed
|
||||
-- to be in registers
|
||||
port (
|
||||
clk : in std_logic;
|
||||
reset : in std_logic;
|
||||
enable : in std_logic; -- global clock enable
|
||||
datain : in std_logic_vector(WIDTH_g-1 downto 0);
|
||||
dataout : out std_logic_vector(WIDTH_g-1 downto 0)
|
||||
);
|
||||
end component auk_dspip_delay_fir_91;
|
||||
|
||||
|
||||
component auk_dspip_fastadd_fir_91 is
|
||||
generic (
|
||||
INWIDTH_g : natural := 18;
|
||||
LABWIDTH_g : natural := 16);
|
||||
-- width of lab in selected device ( 10 or 16 in Cyclone,
|
||||
-- Cylone II, Stratix and Stratix II. Don't know
|
||||
-- Stratix III yet.
|
||||
port (
|
||||
datain1 : in std_logic_vector(INWIDTH_g-1 downto 0);
|
||||
datain2 : in std_logic_vector(INWIDTH_g-1 downto 0);
|
||||
clk : in std_logic;
|
||||
enable : in std_logic;
|
||||
reset : in std_logic;
|
||||
dataout : out std_logic_vector(INWIDTH_g downto 0));
|
||||
end component auk_dspip_fastadd_fir_91;
|
||||
|
||||
|
||||
component auk_dspip_fastaddsub_fir_91 is
|
||||
generic (
|
||||
INWIDTH_g : natural := 18;
|
||||
LABWIDTH_g : natural := 16);
|
||||
-- width of lab in selected device ( 10 or 16 in Cyclone,
|
||||
-- Cylone II, Stratix and Stratix II. Don't know
|
||||
-- Stratix III yet.
|
||||
port (
|
||||
datain1 : in std_logic_vector(INWIDTH_g-1 downto 0);
|
||||
datain2 : in std_logic_vector(INWIDTH_g-1 downto 0);
|
||||
add_nsub : in std_logic;
|
||||
clk : in std_logic;
|
||||
enable : in std_logic;
|
||||
reset : in std_logic;
|
||||
dataout : out std_logic_vector(INWIDTH_g downto 0));
|
||||
end component auk_dspip_fastaddsub_fir_91;
|
||||
|
||||
|
||||
component auk_dspip_pipelined_adder_fir_91 is
|
||||
generic (
|
||||
INWIDTH_g : natural := 42;
|
||||
-- width of lab in selected device ( 10 or 16 in Cyclone,
|
||||
-- Cylone II, Stratix and Stratix II.
|
||||
-- Alex : should I use 19 bits for Stratix III?
|
||||
-- The rational being 10 ALM (2 bits x ALM + the carry chain inside the same LAB for efficiency.
|
||||
LABWIDTH_g : natural := 38);
|
||||
port (
|
||||
datain1 : in std_logic_vector(INWIDTH_g-1 downto 0);
|
||||
datain2 : in std_logic_vector(INWIDTH_g-1 downto 0);
|
||||
clk : in std_logic;
|
||||
enable : in std_logic;
|
||||
reset : in std_logic;
|
||||
dataout : out std_logic_vector(INWIDTH_g downto 0));
|
||||
end component auk_dspip_pipelined_adder_fir_91;
|
||||
|
||||
|
||||
component auk_dspip_fast_accumulator_fir_91 is
|
||||
generic (
|
||||
DATA_WIDTH_g : natural := 42;
|
||||
-- width of lab in selected device ( 10 or 16 in Cyclone,
|
||||
-- Cylone II, Stratix and Stratix II.
|
||||
-- for Stratix III is 20 so labwidth should be set to 18.
|
||||
-- The rational being 10 ALM (2 bits x ALM + the carry chain inside the same LAB for efficiency.
|
||||
LABWIDTH_g : natural := 38;
|
||||
NUM_OF_CHANNELS_g : natural := 1;
|
||||
ACCUM_OUT_WIDTH_g : natural := 48;
|
||||
ACCUM_MEM_TYPE_g : string := "auto");
|
||||
port (
|
||||
reset : in std_logic;
|
||||
clk : in std_logic;
|
||||
enb : in std_logic;
|
||||
add_to_zero : in std_logic;
|
||||
datai : in std_logic_vector(DATA_WIDTH_g-1 downto 0);
|
||||
datao : out std_logic_vector(ACCUM_OUT_WIDTH_g-1 downto 0));
|
||||
end component auk_dspip_fast_accumulator_fir_91;
|
||||
|
||||
|
||||
component auk_dspip_fifo_pfc_fir_91 is
|
||||
generic (
|
||||
NUM_CHANNELS_g : integer := 5;
|
||||
POLY_FACTOR_g : integer := 3;
|
||||
DATA_WIDTH_g : integer := 16;
|
||||
ALMOST_FULL_VALUE_g : integer := 2;
|
||||
RAM_TYPE_g : string := "AUTO";
|
||||
CALCULATE_USED_WORDS_ONCE : boolean := true
|
||||
);
|
||||
port (
|
||||
|
||||
datai : in std_logic_vector(DATA_WIDTH_g-1 downto 0);
|
||||
datao : out std_logic_vector(DATA_WIDTH_g-1 downto 0);
|
||||
channel_out : out std_logic_vector(log2_ceil(NUM_CHANNELS_g)-1 downto 0);
|
||||
used_w : out std_logic_vector(log2_ceil(POLY_FACTOR_g * NUM_CHANNELS_g)+1 downto 0);
|
||||
|
||||
wrreq : in std_logic;
|
||||
rdreq : in std_logic;
|
||||
almost_full : out std_logic;
|
||||
empty : out std_logic;
|
||||
sclr : in std_logic;
|
||||
clk : in std_logic;
|
||||
reset : in std_logic;
|
||||
enable : in std_logic
|
||||
);
|
||||
end component auk_dspip_fifo_pfc_fir_91;
|
||||
component auk_dspip_fpcompiler_alufp is
|
||||
port (
|
||||
sysclk : in std_logic;
|
||||
reset : in std_logic;
|
||||
enable : in std_logic;
|
||||
addsub : in std_logic;
|
||||
aa : in std_logic_vector (42 downto 1);
|
||||
aasat, aazip : in std_logic;
|
||||
bb : in std_logic_vector (42 downto 1);
|
||||
bbsat, bbzip : in std_logic;
|
||||
cc : out std_logic_vector (42 downto 1);
|
||||
ccsat, cczip : out std_logic
|
||||
);
|
||||
end component auk_dspip_fpcompiler_alufp;
|
||||
component auk_dspip_fpcompiler_aslf is
|
||||
port (
|
||||
inbus : in std_logic_vector (32 downto 1);
|
||||
shift : in std_logic_vector (5 downto 1);
|
||||
|
||||
outbus : out std_logic_vector (32 downto 1)
|
||||
);
|
||||
end component auk_dspip_fpcompiler_aslf;
|
||||
component auk_dspip_fpcompiler_asrf is
|
||||
port (
|
||||
inbus : in std_logic_vector (32 downto 1);
|
||||
shift : in std_logic_vector (5 downto 1);
|
||||
|
||||
outbus : out std_logic_vector (32 downto 1)
|
||||
);
|
||||
end component auk_dspip_fpcompiler_asrf;
|
||||
|
||||
component auk_dspip_fpcompiler_castftox is
|
||||
port (
|
||||
aa : in std_logic_vector (32 downto 1);
|
||||
cc : out std_logic_vector (42 downto 1);
|
||||
ccsat, cczip : out std_logic
|
||||
);
|
||||
end component auk_dspip_fpcompiler_castftox;
|
||||
|
||||
component auk_dspip_fpcompiler_castxtof is
|
||||
port (
|
||||
sysclk : in std_logic;
|
||||
reset : in std_logic;
|
||||
enable : in std_logic;
|
||||
aa : in std_logic_vector (42 downto 1);
|
||||
aasat, aazip : in std_logic;
|
||||
cc : out std_logic_vector (32 downto 1)
|
||||
);
|
||||
end component auk_dspip_fpcompiler_castxtof;
|
||||
|
||||
component auk_dspip_fpcompiler_clzf is
|
||||
port (
|
||||
frac : in std_logic_vector (32 downto 1);
|
||||
count : out std_logic_vector (5 downto 1)
|
||||
);
|
||||
end component auk_dspip_fpcompiler_clzf;
|
||||
component auk_dspip_fpcompiler_mulfp is
|
||||
port (
|
||||
sysclk : in std_logic;
|
||||
reset : in std_logic;
|
||||
enable : in std_logic;
|
||||
aa : in std_logic_vector (42 downto 1);
|
||||
aasat, aazip : in std_logic;
|
||||
bb : in std_logic_vector (42 downto 1);
|
||||
bbsat, bbzip : in std_logic;
|
||||
cc : out std_logic_vector (42 downto 1);
|
||||
ccsat, cczip : out std_logic
|
||||
);
|
||||
end component auk_dspip_fpcompiler_mulfp;
|
||||
|
||||
component auk_dspip_pfc_fir_91 is
|
||||
generic (
|
||||
NUM_CHANNELS_g : integer := 5;
|
||||
POLY_FACTOR_g : integer := 3;
|
||||
DATA_WIDTH_g : integer := 16;
|
||||
RAM_TYPE_g : string := "AUTO"
|
||||
);
|
||||
port (
|
||||
|
||||
datai : in std_logic_vector(DATA_WIDTH_g-1 downto 0);
|
||||
datao : out std_logic_vector(DATA_WIDTH_g-1 downto 0);
|
||||
channel_out : out std_logic_vector(log2_ceil(NUM_CHANNELS_g)-1 downto 0);
|
||||
|
||||
in_valid : in std_logic;
|
||||
out_valid : out std_logic;
|
||||
clk : in std_logic;
|
||||
reset : in std_logic;
|
||||
enable : in std_logic
|
||||
);
|
||||
end component auk_dspip_pfc_fir_91;
|
||||
|
||||
|
||||
component auk_dspip_roundsat_fir_91 is
|
||||
generic (
|
||||
IN_WIDTH_g : natural := 8; -- data width
|
||||
OUT_WIDTH_g : natural := 8; -- data width
|
||||
ROUNDING_TYPE_g : string := "TRUNCATE_LOW"
|
||||
);
|
||||
|
||||
port (
|
||||
clk : in std_logic;
|
||||
reset : in std_logic;
|
||||
enable : in std_logic; -- global clock enable
|
||||
datain : in std_logic_vector(IN_WIDTH_g-1 downto 0);
|
||||
dataout : out std_logic_vector(OUT_WIDTH_g-1 downto 0));
|
||||
end component auk_dspip_roundsat_fir_91;
|
||||
|
||||
component auk_dspip_avalon_streaming_block_source_fir_91 is
|
||||
generic (
|
||||
MAX_BLK_g : natural;
|
||||
DATAWIDTH_g : natural);
|
||||
port (
|
||||
clk : in std_logic;
|
||||
reset : in std_logic;
|
||||
in_blk : in std_logic_vector(log2_ceil(MAX_BLK_g) downto 0);
|
||||
in_valid : in std_logic;
|
||||
source_stall : out std_logic;
|
||||
in_data : in std_logic_vector(DATAWIDTH_g - 1 downto 0);
|
||||
source_valid : out std_logic;
|
||||
source_ready : in std_logic;
|
||||
source_sop : out std_logic;
|
||||
source_eop : out std_logic;
|
||||
source_data : out std_logic_vector(DATAWIDTH_g - 1 downto 0));
|
||||
end component auk_dspip_avalon_streaming_block_source_fir_91;
|
||||
|
||||
component auk_dspip_avalon_streaming_block_sink_fir_91 is
|
||||
generic (
|
||||
MAX_BLK_g : natural;
|
||||
STALL_g : natural;
|
||||
DATAWIDTH_g : natural;
|
||||
-- this generic is specific for the FFT.
|
||||
NUM_STAGES_g : natural);
|
||||
port (
|
||||
clk : in std_logic;
|
||||
reset : in std_logic;
|
||||
in_blk : in std_logic_vector(log2_ceil(MAX_BLK_g) downto 0);
|
||||
in_sop : in std_logic;
|
||||
in_eop : in std_logic;
|
||||
in_inverse : in std_logic;
|
||||
sink_valid : in std_logic;
|
||||
sink_ready : out std_logic;
|
||||
source_stall : in std_logic;
|
||||
in_data : in std_logic_vector(DATAWIDTH_g - 1 downto 0);
|
||||
processing : in std_logic;
|
||||
in_error : in std_logic_vector(1 downto 0);
|
||||
out_error : out std_logic_vector(1 downto 0);
|
||||
out_valid : out std_logic;
|
||||
out_sop : out std_logic;
|
||||
out_eop : out std_logic;
|
||||
out_data : out std_logic_vector(DATAWIDTH_g - 1 downto 0);
|
||||
curr_blk : out std_logic_vector(log2_ceil(MAX_BLK_g) downto 0);
|
||||
-- these are specific to the FFT, no effort has been made to optimize!
|
||||
curr_pwr_2 : out std_logic;
|
||||
curr_inverse : out std_logic;
|
||||
curr_input_sel : out std_logic_vector(NUM_STAGES_g - 1 downto 0));
|
||||
end component auk_dspip_avalon_streaming_block_sink_fir_91;
|
||||
|
||||
|
||||
|
||||
end package auk_dspip_lib_pkg_hpfir;
|
||||
@@ -0,0 +1,370 @@
|
||||
-- (C) 2001-2019 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.
|
||||
|
||||
|
||||
-- (C) 2001-2009 Altera Corporation. All rights reserved.
|
||||
-- Your use of Altera Corporation's design tools, logic functions and other
|
||||
-- software and tools, and its AMPP partner logic functions, and any output
|
||||
-- files 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 Altera Program License Subscription
|
||||
-- Agreement, Altera MegaCore Function License Agreement, or other applicable
|
||||
-- license agreement, including, without limitation, that your use is for the
|
||||
-- sole purpose of programming logic devices manufactured by Altera and sold by
|
||||
-- Altera or its authorized distributors. Please refer to the applicable
|
||||
-- agreement for further details.
|
||||
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------
|
||||
--
|
||||
-- Revision Control Information
|
||||
--
|
||||
-- $Revision: #1 $
|
||||
-- $Date: 2009/07/29 $
|
||||
-- Check in by : $Author: max $
|
||||
-- Author : DSP_IP
|
||||
--
|
||||
-- Project : <project name>
|
||||
--
|
||||
-- Description :
|
||||
--
|
||||
-- Common functions for DSP_IP cores.
|
||||
--
|
||||
--
|
||||
-- ALTERA Confidential and Proprietary
|
||||
-- Copyright 2006 (c) Altera Corporation
|
||||
-- All rights reserved
|
||||
--
|
||||
-------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
LIBRARY ieee;
|
||||
USE ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
PACKAGE auk_dspip_math_pkg_hpfir IS
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- NOTE that these log functions are not intended to synthesize directly
|
||||
-- into hardware, rather they are used to generate constants for
|
||||
-- synthesized hardware.
|
||||
-----------------------------------------------------------------------------
|
||||
---------------------------------------------------------------------------
|
||||
-- LOG2_CEIL Function.
|
||||
-- Effectively performs log2() followed by ceil()
|
||||
-- e.g. CEIL_LOG2(255) returns 8
|
||||
-- CEIL_LOG2(256) returns 8
|
||||
-- CEIL_LOG2(257) returns 9
|
||||
---------------------------------------------------------------------------
|
||||
function log2_ceil(arg : in integer) return integer;
|
||||
function log2_ceil_one(arg : in integer) return integer; -- log2_ceil(1)=0
|
||||
---------------------------------------------------------------------------
|
||||
-- LOG2_FLOOR Function.
|
||||
-- Effectively performs log2() followed by floor()
|
||||
-- e.g. CEIL_LOG2(255) returns 7
|
||||
-- CEIL_LOG2(256) returns 8
|
||||
-- CEIL_LOG2(257) returns 8
|
||||
---------------------------------------------------------------------------
|
||||
function log2_floor(arg : in integer) return integer;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- SIGN functions
|
||||
-----------------------------------------------------------------------------
|
||||
-- returns the sign bit of a vector
|
||||
function sign (arg : in signed) return std_logic;
|
||||
|
||||
-- sign extends ARG to size SIZE.
|
||||
function sign_extend (arg : signed; size : positive) return signed;
|
||||
|
||||
-- sign extend one bit
|
||||
function xt1 (arg : signed) return signed;
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
-- Arithmetic FUNCTIONs.
|
||||
---------------------------------------------------------------------------
|
||||
-- Check integer for odd-ness
|
||||
function is_odd(arg : integer) return boolean;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Logical functions
|
||||
-----------------------------------------------------------------------------
|
||||
-- Result of and'ing all of the bits of the vector.
|
||||
function and_reduce(arg : std_logic_vector) return std_logic;
|
||||
function and_reduce(arg : unsigned) return std_logic;
|
||||
|
||||
-- Result of or'ing all of the bits of the vector.
|
||||
function or_reduce(arg : std_logic_vector) return std_logic;
|
||||
function or_reduce(arg : unsigned) return std_logic;
|
||||
|
||||
-- returns index+1 of the highest asserted bit.
|
||||
function highest_one(arg : unsigned) return natural;
|
||||
|
||||
-- returns index+1 of the lowest asserted bit.
|
||||
function lowest_one(arg : unsigned) return natural;
|
||||
|
||||
-- returns the count of number of ones.
|
||||
function count_ones(arg : unsigned) return natural;
|
||||
|
||||
-- Bit reverse
|
||||
function bit_reverse(arg : unsigned) return unsigned;
|
||||
|
||||
-- Invert the argument bitwise
|
||||
function invert(arg : unsigned) return unsigned;
|
||||
|
||||
--Halve towards up
|
||||
function halve_ceil(arg:natural) return natural;
|
||||
|
||||
function div_ceil(a:natural;b:natural) return natural;
|
||||
|
||||
END PACKAGE auk_dspip_math_pkg_hpfir;
|
||||
|
||||
package body auk_dspip_math_pkg_hpfir is
|
||||
---------------------------------------------------------------------------
|
||||
-- LOG2_CEIL Function.
|
||||
---------------------------------------------------------------------------
|
||||
function log2_ceil(arg : in integer) return integer is
|
||||
variable res : integer;
|
||||
begin
|
||||
res := 0;
|
||||
for i in 0 to 30 loop
|
||||
if (arg > (2**i)) then
|
||||
res := i+1;
|
||||
end if;
|
||||
end loop; -- i
|
||||
return res;
|
||||
end log2_ceil;
|
||||
---------------------------------------------------------------------------
|
||||
-- LOG2_CEIL_ONE Function.
|
||||
---------------------------------------------------------------------------
|
||||
function log2_ceil_one(arg : in integer) return integer is
|
||||
variable res : integer;
|
||||
begin
|
||||
res := 0;
|
||||
for i in 0 to 30 loop
|
||||
if (arg > (2**i)) then
|
||||
res := i+1;
|
||||
end if;
|
||||
end loop; -- i
|
||||
if res = 0 then
|
||||
res := 1;
|
||||
end if;
|
||||
return res;
|
||||
end log2_ceil_one;
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
-- LOG2_FLOOR Function.
|
||||
-----------------------------------------------------------------------------
|
||||
function log2_floor(arg : in integer) return integer is
|
||||
variable res : integer;
|
||||
begin
|
||||
res := 0;
|
||||
for i in 0 to 30 loop
|
||||
if (arg >= (2**i)) then
|
||||
res := i;
|
||||
end if;
|
||||
end loop; -- i
|
||||
return res;
|
||||
end log2_floor;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- SIGN Function
|
||||
-----------------------------------------------------------------------------
|
||||
function sign (arg : in signed) return std_logic is
|
||||
variable res : std_logic;
|
||||
begin
|
||||
res := arg(arg'left);
|
||||
return(res);
|
||||
end sign;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- SIGN_EXTEND Function
|
||||
-----------------------------------------------------------------------------
|
||||
function sign_extend (arg : signed; size : positive) return signed is
|
||||
variable res : signed(size-1 downto 0);
|
||||
begin
|
||||
if arg'length > size then
|
||||
assert arg'length < size report "WARNING, can't sign extend" severity warning;
|
||||
end if;
|
||||
for i in arg'length to size-1 loop
|
||||
res(i) := arg(arg'left);
|
||||
end loop; -- i
|
||||
res(arg'length-1 downto 0) := arg;
|
||||
return(res);
|
||||
end sign_extend;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- XT1 Function
|
||||
-----------------------------------------------------------------------------
|
||||
function xt1 (arg : signed) return signed is
|
||||
variable res : signed(arg'length downto 0);
|
||||
begin
|
||||
res := arg(arg'left) & arg;
|
||||
return(res);
|
||||
end xt1;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- IS_ODD Function
|
||||
-----------------------------------------------------------------------------
|
||||
function is_odd(arg : integer) return boolean is
|
||||
begin
|
||||
return ((arg mod 2) = 1);
|
||||
end is_odd;
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- AND_REDUCE Function
|
||||
-----------------------------------------------------------------------------
|
||||
function and_reduce(arg : std_logic_vector) return std_logic is
|
||||
variable res : std_logic;
|
||||
begin
|
||||
res := '1';
|
||||
for i in arg'range loop
|
||||
res := res and arg(i);
|
||||
end loop;
|
||||
return res;
|
||||
end;
|
||||
|
||||
function and_reduce(arg : unsigned) return std_logic is
|
||||
variable res : std_logic;
|
||||
begin
|
||||
res := '1';
|
||||
for i in arg'range loop
|
||||
res := res and arg(i);
|
||||
end loop;
|
||||
return res;
|
||||
end;
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- OR_REDUCE Function
|
||||
-----------------------------------------------------------------------------
|
||||
function or_reduce(arg : unsigned) return std_logic is
|
||||
variable res : std_logic;
|
||||
begin
|
||||
res := '0';
|
||||
for i in arg'range loop
|
||||
res := res or arg(i);
|
||||
end loop;
|
||||
return res;
|
||||
end;
|
||||
|
||||
function or_reduce(arg : std_logic_vector) return std_logic is
|
||||
variable res : std_logic;
|
||||
begin
|
||||
res := '0';
|
||||
for i in arg'range loop
|
||||
res := res or arg(i);
|
||||
end loop;
|
||||
return res;
|
||||
end;
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
-- HIGHEST_ONE Function.
|
||||
---------------------------------------------------------------------------
|
||||
-- Returns index+1 of the highest asserted bit, or 0 if no bit set.
|
||||
-- Vector is evaluated from left to right, not high to low!
|
||||
function highest_one(arg : unsigned) return natural is
|
||||
begin
|
||||
for i in arg'range loop
|
||||
if arg(i) = '1' then
|
||||
return i+1;
|
||||
end if;
|
||||
end loop;
|
||||
return 0;
|
||||
end;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- LOWEST_ONE Function
|
||||
-----------------------------------------------------------------------------
|
||||
-- Returns index+1 of the lowest asserted bit, or 0 if no bit set.
|
||||
-- Vector is evaluated from left to right, not high to low!
|
||||
function lowest_one(arg : unsigned) return natural is
|
||||
begin
|
||||
for i in 0 to arg'length-1 loop
|
||||
if (arg(i) = '1') then
|
||||
return(i+1);
|
||||
end if;
|
||||
end loop;
|
||||
return(0);
|
||||
end;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- COUNT_ONES
|
||||
---------------------------------------------------------------------------
|
||||
-- Returns the count of the number of ones.
|
||||
function count_ones(arg : unsigned) return natural is
|
||||
variable count : integer;
|
||||
begin
|
||||
count := 0;
|
||||
for i in 0 to arg'length-1 loop
|
||||
if (arg(i) = '1') then
|
||||
count := count + 1;
|
||||
end if;
|
||||
end loop;
|
||||
return count;
|
||||
end;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- BIT_REVERSE function
|
||||
-----------------------------------------------------------------------------
|
||||
function bit_reverse(arg : unsigned) return unsigned is
|
||||
variable res : unsigned(arg'range);
|
||||
begin
|
||||
for i in arg'range loop
|
||||
res(i) := arg(arg'high - i);
|
||||
end loop;
|
||||
return(res);
|
||||
end;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- INVERT Function
|
||||
-----------------------------------------------------------------------------
|
||||
function invert(arg : unsigned)
|
||||
return unsigned -- (word'high downto 0)
|
||||
is
|
||||
variable res : unsigned(arg'high downto 0);
|
||||
begin
|
||||
|
||||
for i in arg'range loop
|
||||
res(i) := not arg(i);
|
||||
end loop;
|
||||
return (res);
|
||||
end invert;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- HALVE_CEIL Function
|
||||
-----------------------------------------------------------------------------
|
||||
function halve_ceil(arg : natural) return natural is
|
||||
variable res : natural;
|
||||
begin
|
||||
if is_odd(arg) then
|
||||
res := (arg+1)/2;
|
||||
else
|
||||
res := arg/2;
|
||||
end if;
|
||||
return (res);
|
||||
end halve_ceil;
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- DIV_CEIL function
|
||||
-------------------------------------------------------------------------------
|
||||
function div_ceil(a : natural; b : natural) return natural is
|
||||
variable res : natural := a/b;
|
||||
begin
|
||||
if res*b /= a then
|
||||
res := res +1;
|
||||
end if;
|
||||
return res;
|
||||
end div_ceil;
|
||||
|
||||
end package body auk_dspip_math_pkg_hpfir;
|
||||
@@ -0,0 +1,187 @@
|
||||
-- (C) 2001-2019 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.
|
||||
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------
|
||||
--
|
||||
-- Revision Control Information
|
||||
--
|
||||
-- $RCSfile: auk_dspip_roundsat_hpfir.vhd,v $
|
||||
--
|
||||
-- $Revision: #1 $
|
||||
-- $Date: 2010/08/19 $
|
||||
-- Check in by : $Author: max $
|
||||
--
|
||||
-- Description :
|
||||
-- Implement output options for HP-FIR
|
||||
--
|
||||
-- ALTERA Confidential and Proprietary
|
||||
-- Copyright 2006 (c) Altera Corporation
|
||||
-- All rights reserved
|
||||
--
|
||||
-------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
|
||||
|
||||
entity auk_dspip_roundsat_hpfir is
|
||||
generic (
|
||||
IN_WIDTH_g : natural := 8; -- i/p data width
|
||||
REM_LSB_BIT_g : natural := 2; -- no. of lsb to be removed
|
||||
REM_LSB_TYPE_g : string := "trunc"; -- trunc/round
|
||||
REM_MSB_BIT_g : natural := 2; -- no. of msb to be removed
|
||||
REM_MSB_TYPE_g : string := "trunc" -- trunc/sat
|
||||
);
|
||||
port (
|
||||
clk : in std_logic;
|
||||
reset_n : in std_logic;
|
||||
enable : in std_logic;
|
||||
datain : in std_logic_vector(IN_WIDTH_g-1 downto 0);
|
||||
valid : out std_logic;
|
||||
dataout : out std_logic_vector(IN_WIDTH_g-REM_LSB_BIT_g-REM_MSB_BIT_g-1 downto 0)
|
||||
);
|
||||
end entity auk_dspip_roundsat_hpfir;
|
||||
|
||||
architecture beh of auk_dspip_roundsat_hpfir is
|
||||
|
||||
signal data_lsb : std_logic_vector(IN_WIDTH_g-REM_LSB_BIT_g-1 downto 0);
|
||||
signal valid_lsb : std_logic;
|
||||
|
||||
signal data_msb : std_logic_vector(IN_WIDTH_g-REM_LSB_BIT_g-REM_MSB_BIT_g-1 downto 0);
|
||||
|
||||
constant zero_vec : std_logic_vector := std_logic_vector(to_signed(0, REM_LSB_BIT_g));
|
||||
|
||||
begin -- architecture beh
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- lsb : trunc/round-up (symmetric)
|
||||
-----------------------------------------------------------------------------
|
||||
remove_lsb: if REM_LSB_BIT_g > 0 generate
|
||||
begin
|
||||
trunc_lsb: if REM_LSB_TYPE_g = "trunc" generate
|
||||
begin
|
||||
data_lsb <= datain(IN_WIDTH_g-1 downto REM_LSB_BIT_g);
|
||||
valid_lsb <= enable;
|
||||
end generate trunc_lsb;
|
||||
rndup_lsb: if REM_LSB_TYPE_g = "round" generate
|
||||
round_up_sym_p : process (clk, reset_n)
|
||||
variable OR_accu : std_logic := '0';
|
||||
begin
|
||||
if reset_n = '0' then
|
||||
data_lsb <= (others => '0');
|
||||
valid_lsb <= '0';
|
||||
elsif rising_edge(clk) then
|
||||
if enable = '1' then
|
||||
OR_accu := '0';
|
||||
for i in 0 to REM_LSB_BIT_g-2 loop
|
||||
OR_accu := OR_accu or datain(i);
|
||||
end loop;
|
||||
-- negative value
|
||||
if (datain(IN_WIDTH_g-1) = '1') then
|
||||
-- larger than -x.5 : rounded to -x
|
||||
if (datain(REM_LSB_BIT_g-1)='1' and OR_accu='1') then
|
||||
data_lsb <= std_logic_vector(signed(datain(IN_WIDTH_g-1 downto REM_LSB_BIT_g))+1);
|
||||
-- less than or equal -x.5 : rounded to -x + 1
|
||||
else
|
||||
data_lsb <= datain(IN_WIDTH_g-1 downto REM_LSB_BIT_g);
|
||||
end if;
|
||||
-- positive value
|
||||
else
|
||||
-- maximum positive value
|
||||
if datain(IN_WIDTH_g-1 downto REM_LSB_BIT_g-1) = std_logic_vector(to_signed(2**(IN_WIDTH_g-REM_LSB_BIT_g)-1, IN_WIDTH_g-REM_LSB_BIT_g+1)) then
|
||||
data_lsb <= std_logic_vector(to_signed( 2**(IN_WIDTH_g-REM_LSB_BIT_g-1)-1, IN_WIDTH_g-REM_LSB_BIT_g));
|
||||
-- larger than or equal x.5 : rounded to x + 1
|
||||
elsif datain(REM_LSB_BIT_g-1) = '1' then
|
||||
data_lsb <= std_logic_vector(signed(datain(IN_WIDTH_g-1 downto REM_LSB_BIT_g))+1);
|
||||
-- less than x.5 : rounded to x
|
||||
else
|
||||
data_lsb <= datain(IN_WIDTH_g-1 downto REM_LSB_BIT_g);
|
||||
end if;
|
||||
end if;
|
||||
end if;
|
||||
valid_lsb <= enable;
|
||||
end if;
|
||||
end process round_up_sym_p;
|
||||
end generate rndup_lsb;
|
||||
end generate remove_lsb;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- keep lsb
|
||||
-----------------------------------------------------------------------------
|
||||
keep_lsb: if REM_LSB_BIT_g = 0 generate
|
||||
begin
|
||||
data_lsb <= datain;
|
||||
valid_lsb <= enable;
|
||||
end generate keep_lsb;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- msb : trunc/saturation
|
||||
-----------------------------------------------------------------------------
|
||||
remove_msb: if REM_MSB_BIT_g > 0 generate
|
||||
signal min_val, max_val : std_logic_vector(IN_WIDTH_g-REM_LSB_BIT_g-REM_MSB_BIT_g-1 downto 0);
|
||||
begin
|
||||
trunc_msb: if REM_MSB_TYPE_g = "trunc" generate
|
||||
begin
|
||||
data_msb <= data_lsb(IN_WIDTH_g-REM_LSB_BIT_g-REM_MSB_BIT_g-1 downto 0);
|
||||
dataout <= data_msb;
|
||||
valid <= valid_lsb;
|
||||
end generate trunc_msb;
|
||||
|
||||
sat_msb: if REM_MSB_TYPE_g = "sat" generate
|
||||
max_val(IN_WIDTH_g-REM_LSB_BIT_g-REM_MSB_BIT_g-1) <= '0';
|
||||
max_val(IN_WIDTH_g-REM_LSB_BIT_g-REM_MSB_BIT_g-2 downto 0) <= (others => '1');
|
||||
min_val(IN_WIDTH_g-REM_LSB_BIT_g-REM_MSB_BIT_g-1) <= '1';
|
||||
min_val(IN_WIDTH_g-REM_LSB_BIT_g-REM_MSB_BIT_g-2 downto 0) <= (others => '0');
|
||||
data_msb <= std_logic_vector(max_val) when signed(data_lsb) > signed(max_val) else
|
||||
std_logic_vector(min_val) when signed(data_lsb) < signed(min_val) else
|
||||
data_lsb(IN_WIDTH_g-REM_LSB_BIT_g-REM_MSB_BIT_g-1 downto 0);
|
||||
msb_p : process (clk, reset_n)
|
||||
begin
|
||||
if reset_n = '0' then
|
||||
dataout <= (others => '0');
|
||||
valid <= '0';
|
||||
elsif rising_edge(clk) then
|
||||
if valid_lsb = '1' then
|
||||
dataout <= data_msb;
|
||||
end if;
|
||||
valid <= valid_lsb;
|
||||
end if;
|
||||
end process msb_p;
|
||||
end generate sat_msb;
|
||||
end generate remove_msb;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- keep msb
|
||||
-----------------------------------------------------------------------------
|
||||
keep_msb: if REM_MSB_BIT_g = 0 generate
|
||||
begin
|
||||
data_msb <= data_lsb;
|
||||
dataout <= data_msb;
|
||||
valid <= valid_lsb;
|
||||
end generate keep_msb;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- error checking:
|
||||
-- Have we got a valid round mode?
|
||||
-- Is the input greater than the output?
|
||||
-----------------------------------------------------------------------------
|
||||
assert (REM_LSB_TYPE_g = "trunc" or
|
||||
REM_LSB_TYPE_g = "round" or
|
||||
REM_MSB_TYPE_g = "trunc" or
|
||||
REM_MSB_TYPE_g = "sat"
|
||||
) report "Please check your round type and its spelling. Currently, we only support trunc, and round for LSB, trunc and sat for MSB" severity error;
|
||||
|
||||
|
||||
end architecture beh;
|
||||
@@ -0,0 +1,377 @@
|
||||
-- Legal Notice: Copyright 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 any of the foregoing device programming or simulation files), and
|
||||
-- any associated documentation or information are expressly subject to the
|
||||
-- terms and conditions of the Intel FPGA Software License Agreement,
|
||||
-- Intel MegaCore Function 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.
|
||||
|
||||
|
||||
library IEEE;
|
||||
use IEEE.std_logic_1164.all;
|
||||
use work.dspba_library_package.all;
|
||||
|
||||
entity dspba_delay is
|
||||
generic (
|
||||
width : natural := 8;
|
||||
depth : natural := 1;
|
||||
reset_high : std_logic := '1';
|
||||
reset_kind : string := "ASYNC"
|
||||
);
|
||||
port (
|
||||
clk : in std_logic;
|
||||
aclr : in std_logic;
|
||||
ena : in std_logic := '1';
|
||||
xin : in std_logic_vector(width-1 downto 0);
|
||||
xout : out std_logic_vector(width-1 downto 0)
|
||||
);
|
||||
end dspba_delay;
|
||||
|
||||
architecture delay of dspba_delay is
|
||||
type delay_array is array (depth downto 0) of std_logic_vector(width-1 downto 0);
|
||||
signal delay_signals : delay_array;
|
||||
begin
|
||||
delay_signals(depth) <= xin;
|
||||
|
||||
delay_block: if 0 < depth generate
|
||||
begin
|
||||
delay_loop: for i in depth-1 downto 0 generate
|
||||
begin
|
||||
async_reset: if reset_kind = "ASYNC" generate
|
||||
process(clk, aclr)
|
||||
begin
|
||||
if aclr=reset_high then
|
||||
delay_signals(i) <= (others => '0');
|
||||
elsif clk'event and clk='1' then
|
||||
if ena='1' then
|
||||
delay_signals(i) <= delay_signals(i + 1);
|
||||
end if;
|
||||
end if;
|
||||
end process;
|
||||
end generate;
|
||||
|
||||
sync_reset: if reset_kind = "SYNC" generate
|
||||
process(clk)
|
||||
begin
|
||||
if clk'event and clk='1' then
|
||||
if aclr=reset_high then
|
||||
delay_signals(i) <= (others => '0');
|
||||
elsif ena='1' then
|
||||
delay_signals(i) <= delay_signals(i + 1);
|
||||
end if;
|
||||
end if;
|
||||
end process;
|
||||
end generate;
|
||||
|
||||
no_reset: if reset_kind = "NONE" generate
|
||||
process(clk)
|
||||
begin
|
||||
if clk'event and clk='1' then
|
||||
if ena='1' then
|
||||
delay_signals(i) <= delay_signals(i + 1);
|
||||
end if;
|
||||
end if;
|
||||
end process;
|
||||
end generate;
|
||||
end generate;
|
||||
end generate;
|
||||
|
||||
xout <= delay_signals(0);
|
||||
end delay;
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
library IEEE;
|
||||
use IEEE.std_logic_1164.all;
|
||||
use IEEE.NUMERIC_STD.all;
|
||||
use work.dspba_library_package.all;
|
||||
|
||||
entity dspba_sync_reg is
|
||||
generic (
|
||||
width1 : natural := 8;
|
||||
init_value : std_logic_vector;
|
||||
width2 : natural := 8;
|
||||
depth : natural := 2;
|
||||
pulse_multiplier : natural := 1;
|
||||
counter_width : natural := 8;
|
||||
reset1_high : std_logic := '1';
|
||||
reset2_high : std_logic := '1';
|
||||
reset_kind : string := "ASYNC"
|
||||
);
|
||||
port (
|
||||
clk1 : in std_logic;
|
||||
aclr1 : in std_logic;
|
||||
ena : in std_logic_vector(0 downto 0);
|
||||
xin : in std_logic_vector(width1-1 downto 0);
|
||||
xout : out std_logic_vector(width1-1 downto 0);
|
||||
clk2 : in std_logic;
|
||||
aclr2 : in std_logic;
|
||||
sxout : out std_logic_vector(width2-1 downto 0)
|
||||
);
|
||||
end entity;
|
||||
|
||||
architecture sync_reg of dspba_sync_reg is
|
||||
type bit_array is array (depth-1 downto 0) of std_logic;
|
||||
|
||||
signal iclk_enable : std_logic;
|
||||
signal iclk_data : std_logic_vector(width1-1 downto 0);
|
||||
signal oclk_data : std_logic_vector(width2-1 downto 0);
|
||||
|
||||
-- For Synthesis this means: preserve this registers and do not merge any other flip-flops with synchronizer flip-flops
|
||||
-- For TimeQuest this means: identify these flip-flops as synchronizer to enable automatic MTBF analysis
|
||||
signal sync_regs : bit_array;
|
||||
attribute altera_attribute : string;
|
||||
attribute altera_attribute of sync_regs : signal is "-name ADV_NETLIST_OPT_ALLOWED NEVER_ALLOW; -name SYNCHRONIZER_IDENTIFICATION FORCED_IF_ASYNCHRONOUS; -name DONT_MERGE_REGISTER ON; -name PRESERVE_REGISTER ON";
|
||||
|
||||
signal oclk_enable : std_logic;
|
||||
|
||||
constant init_value_internal : std_logic_vector(width1-1 downto 0) := init_value;
|
||||
|
||||
signal counter : UNSIGNED(counter_width-1 downto 0);
|
||||
signal ena_internal : std_logic;
|
||||
begin
|
||||
oclk_enable <= sync_regs(depth-1);
|
||||
|
||||
no_multiplication: if pulse_multiplier=1 generate
|
||||
ena_internal <= ena(0);
|
||||
end generate;
|
||||
|
||||
async_reset: if reset_kind="ASYNC" generate
|
||||
|
||||
multiply_ena: if pulse_multiplier>1 generate
|
||||
ena_internal <= '1' when counter>0 else ena(0);
|
||||
process (clk1, aclr1)
|
||||
begin
|
||||
if aclr1=reset1_high then
|
||||
counter <= (others => '0');
|
||||
elsif clk1'event and clk1='1' then
|
||||
if counter>0 then
|
||||
if counter=pulse_multiplier-1 then
|
||||
counter <= (others => '0');
|
||||
else
|
||||
counter <= counter + TO_UNSIGNED(1, counter_width);
|
||||
end if;
|
||||
else
|
||||
if ena(0)='1' then
|
||||
counter <= TO_UNSIGNED(1, counter_width);
|
||||
end if;
|
||||
end if;
|
||||
end if;
|
||||
end process;
|
||||
end generate;
|
||||
|
||||
process (clk1, aclr1)
|
||||
begin
|
||||
if aclr1=reset1_high then
|
||||
iclk_enable <= '0';
|
||||
iclk_data <= init_value_internal;
|
||||
elsif clk1'event and clk1='1' then
|
||||
iclk_enable <= ena_internal;
|
||||
if ena(0)='1' then
|
||||
iclk_data <= xin;
|
||||
end if;
|
||||
end if;
|
||||
end process;
|
||||
|
||||
sync_reg_loop: for i in 0 to depth-1 generate
|
||||
process (clk2, aclr2)
|
||||
begin
|
||||
if aclr2=reset2_high then
|
||||
sync_regs(i) <= '0';
|
||||
elsif clk2'event and clk2='1' then
|
||||
if i>0 then
|
||||
sync_regs(i) <= sync_regs(i-1);
|
||||
else
|
||||
sync_regs(i) <= iclk_enable;
|
||||
end if;
|
||||
end if;
|
||||
end process;
|
||||
end generate;
|
||||
|
||||
process (clk2, aclr2)
|
||||
begin
|
||||
if aclr2=reset2_high then
|
||||
oclk_data <= init_value_internal(width2-1 downto 0);
|
||||
elsif clk2'event and clk2='1' then
|
||||
if oclk_enable='1' then
|
||||
oclk_data <= iclk_data(width2-1 downto 0);
|
||||
end if;
|
||||
end if;
|
||||
end process;
|
||||
end generate;
|
||||
|
||||
sync_reset: if reset_kind="SYNC" generate
|
||||
|
||||
multiply_ena: if pulse_multiplier>1 generate
|
||||
ena_internal <= '1' when counter>0 else ena(0);
|
||||
process (clk1)
|
||||
begin
|
||||
if clk1'event and clk1='1' then
|
||||
if aclr1=reset1_high then
|
||||
counter <= (others => '0');
|
||||
else
|
||||
if counter>0 then
|
||||
if counter=pulse_multiplier-1 then
|
||||
counter <= (others => '0');
|
||||
else
|
||||
counter <= counter + TO_UNSIGNED(1, counter_width);
|
||||
end if;
|
||||
else
|
||||
if ena(0)='1' then
|
||||
counter <= TO_UNSIGNED(1, counter_width);
|
||||
end if;
|
||||
end if;
|
||||
end if;
|
||||
end if;
|
||||
end process;
|
||||
end generate;
|
||||
|
||||
process (clk1)
|
||||
begin
|
||||
if clk1'event and clk1='1' then
|
||||
if aclr1=reset1_high then
|
||||
iclk_enable <= '0';
|
||||
iclk_data <= init_value_internal;
|
||||
else
|
||||
iclk_enable <= ena_internal;
|
||||
if ena(0)='1' then
|
||||
iclk_data <= xin;
|
||||
end if;
|
||||
end if;
|
||||
end if;
|
||||
end process;
|
||||
|
||||
sync_reg_loop: for i in 0 to depth-1 generate
|
||||
process (clk2)
|
||||
begin
|
||||
if clk2'event and clk2='1' then
|
||||
if aclr2=reset2_high then
|
||||
sync_regs(i) <= '0';
|
||||
else
|
||||
if i>0 then
|
||||
sync_regs(i) <= sync_regs(i-1);
|
||||
else
|
||||
sync_regs(i) <= iclk_enable;
|
||||
end if;
|
||||
end if;
|
||||
end if;
|
||||
end process;
|
||||
end generate;
|
||||
|
||||
process (clk2)
|
||||
begin
|
||||
if clk2'event and clk2='1' then
|
||||
if aclr2=reset2_high then
|
||||
oclk_data <= init_value_internal(width2-1 downto 0);
|
||||
elsif oclk_enable='1' then
|
||||
oclk_data <= iclk_data(width2-1 downto 0);
|
||||
end if;
|
||||
end if;
|
||||
end process;
|
||||
end generate;
|
||||
|
||||
none_reset: if reset_kind="NONE" generate
|
||||
|
||||
multiply_ena: if pulse_multiplier>1 generate
|
||||
ena_internal <= '1' when counter>0 else ena(0);
|
||||
process (clk1, aclr1)
|
||||
begin
|
||||
if clk1'event and clk1='1' then
|
||||
if counter>0 then
|
||||
if counter=pulse_multiplier-1 then
|
||||
counter <= (others => '0');
|
||||
else
|
||||
counter <= counter + TO_UNSIGNED(1, counter_width);
|
||||
end if;
|
||||
else
|
||||
if ena(0)='1' then
|
||||
counter <= TO_UNSIGNED(1, counter_width);
|
||||
end if;
|
||||
end if;
|
||||
end if;
|
||||
end process;
|
||||
end generate;
|
||||
|
||||
process (clk1)
|
||||
begin
|
||||
if clk1'event and clk1='1' then
|
||||
iclk_enable <= ena_internal;
|
||||
if ena(0)='1' then
|
||||
iclk_data <= xin;
|
||||
end if;
|
||||
end if;
|
||||
end process;
|
||||
|
||||
sync_reg_loop: for i in 0 to depth-1 generate
|
||||
process (clk2)
|
||||
begin
|
||||
if clk2'event and clk2='1' then
|
||||
if i>0 then
|
||||
sync_regs(i) <= sync_regs(i-1);
|
||||
else
|
||||
sync_regs(i) <= iclk_enable;
|
||||
end if;
|
||||
end if;
|
||||
end process;
|
||||
end generate;
|
||||
|
||||
process (clk2)
|
||||
begin
|
||||
if clk2'event and clk2='1' then
|
||||
if oclk_enable='1' then
|
||||
oclk_data <= iclk_data(width2-1 downto 0);
|
||||
end if;
|
||||
end if;
|
||||
end process;
|
||||
end generate;
|
||||
|
||||
xout <= iclk_data;
|
||||
sxout <= oclk_data;
|
||||
|
||||
end sync_reg;
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
|
||||
entity dspba_pipe is
|
||||
generic(
|
||||
num_bits : positive := 8;
|
||||
num_stages : natural := 0;
|
||||
init_value : std_logic := 'X'
|
||||
);
|
||||
port(
|
||||
clk: in std_logic;
|
||||
d : in std_logic_vector(num_bits-1 downto 0);
|
||||
q : out std_logic_vector(num_bits-1 downto 0)
|
||||
);
|
||||
end entity dspba_pipe;
|
||||
|
||||
architecture rtl of dspba_pipe is
|
||||
attribute altera_attribute : string;
|
||||
attribute altera_attribute of rtl : architecture is "-name AUTO_SHIFT_REGISTER_RECOGNITION off";
|
||||
|
||||
type stage_array_type is array(0 to num_stages) of std_logic_vector(num_bits-1 downto 0);
|
||||
signal stage_array : stage_array_type := (others => (others => init_value));
|
||||
begin
|
||||
stage_array(0) <= d;
|
||||
|
||||
g_pipe : for i in 1 to num_stages generate
|
||||
p_stage : process (clk) is
|
||||
begin
|
||||
if rising_edge(clk) then
|
||||
stage_array(i) <= stage_array(i-1);
|
||||
end if;
|
||||
end process p_stage;
|
||||
end generate g_pipe;
|
||||
|
||||
q <= stage_array(num_stages);
|
||||
|
||||
end rtl;
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
-- Legal Notice: Copyright 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 any of the foregoing device programming or simulation files), and
|
||||
-- any associated documentation or information are expressly subject to the
|
||||
-- terms and conditions of the Intel FPGA Software License Agreement,
|
||||
-- Intel MegaCore Function 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.
|
||||
|
||||
|
||||
library IEEE;
|
||||
use IEEE.std_logic_1164.all;
|
||||
|
||||
package dspba_library_package is
|
||||
|
||||
component dspba_delay is
|
||||
generic (
|
||||
width : natural := 8;
|
||||
depth : natural := 1;
|
||||
reset_high : std_logic := '1';
|
||||
reset_kind : string := "ASYNC"
|
||||
);
|
||||
port (
|
||||
clk : in std_logic;
|
||||
aclr : in std_logic;
|
||||
ena : in std_logic := '1';
|
||||
xin : in std_logic_vector(width-1 downto 0);
|
||||
xout : out std_logic_vector(width-1 downto 0)
|
||||
);
|
||||
end component;
|
||||
|
||||
component dspba_sync_reg is
|
||||
generic (
|
||||
width1 : natural := 8;
|
||||
width2 : natural := 8;
|
||||
depth : natural := 2;
|
||||
init_value : std_logic_vector;
|
||||
pulse_multiplier : natural := 1;
|
||||
counter_width : natural := 8;
|
||||
reset1_high : std_logic := '1';
|
||||
reset2_high : std_logic := '1';
|
||||
reset_kind : string := "ASYNC"
|
||||
);
|
||||
port (
|
||||
clk1 : in std_logic;
|
||||
aclr1 : in std_logic;
|
||||
ena : in std_logic_vector(0 downto 0);
|
||||
xin : in std_logic_vector(width1-1 downto 0);
|
||||
xout : out std_logic_vector(width1-1 downto 0);
|
||||
clk2 : in std_logic;
|
||||
aclr2 : in std_logic;
|
||||
sxout : out std_logic_vector(width2-1 downto 0)
|
||||
);
|
||||
end component;
|
||||
|
||||
component dspba_pipe is
|
||||
generic(
|
||||
num_bits : positive;
|
||||
num_stages : natural;
|
||||
init_value : std_logic := 'X'
|
||||
);
|
||||
port(
|
||||
clk: in std_logic;
|
||||
d : in std_logic_vector(num_bits-1 downto 0);
|
||||
q : out std_logic_vector(num_bits-1 downto 0)
|
||||
);
|
||||
end component dspba_pipe;
|
||||
|
||||
end dspba_library_package;
|
||||
@@ -0,0 +1,82 @@
|
||||
-- (C) 2001-2019 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.
|
||||
|
||||
|
||||
library IEEE;
|
||||
use IEEE.std_logic_1164.all;
|
||||
use work.auk_dspip_lib_pkg_hpfir.all;
|
||||
use work.auk_dspip_math_pkg_hpfir.all;
|
||||
|
||||
entity fir_0002 is
|
||||
port (
|
||||
clk : in STD_LOGIC;
|
||||
reset_n : in STD_LOGIC;
|
||||
ast_sink_data : in STD_LOGIC_VECTOR((0 + 1*16) * 1 + 0 - 1 downto 0);
|
||||
ast_sink_valid : in STD_LOGIC;
|
||||
ast_sink_error : in STD_LOGIC_VECTOR(1 downto 0);
|
||||
ast_source_data : out STD_LOGIC_VECTOR(37 * 1*1 - 1 downto 0);
|
||||
ast_source_valid : out STD_LOGIC;
|
||||
ast_source_error : out STD_LOGIC_VECTOR(1 downto 0)
|
||||
);
|
||||
end fir_0002;
|
||||
|
||||
|
||||
architecture syn of fir_0002 is
|
||||
component fir_0002_ast
|
||||
port (
|
||||
clk : in STD_LOGIC;
|
||||
reset_n : in STD_LOGIC;
|
||||
ast_sink_data : in STD_LOGIC_VECTOR((0 + 1*16) * 1 + 0 - 1 downto 0);
|
||||
ast_sink_valid : in STD_LOGIC;
|
||||
ast_sink_ready : out STD_LOGIC;
|
||||
ast_sink_sop : in STD_LOGIC;
|
||||
ast_sink_eop : in STD_LOGIC;
|
||||
ast_sink_error : in STD_LOGIC_VECTOR(1 downto 0);
|
||||
ast_source_data : out STD_LOGIC_VECTOR(1*37 * 1 - 1 downto 0);
|
||||
ast_source_ready : in STD_LOGIC;
|
||||
ast_source_valid : out STD_LOGIC;
|
||||
ast_source_sop : out STD_LOGIC;
|
||||
ast_source_eop : out STD_LOGIC;
|
||||
ast_source_channel : out STD_LOGIC_VECTOR(log2_ceil_one(1) - 1 downto 0);
|
||||
ast_source_error : out STD_LOGIC_VECTOR(1 downto 0)
|
||||
);
|
||||
end component;
|
||||
|
||||
signal coeff_in_read_sig : std_logic;
|
||||
|
||||
begin
|
||||
|
||||
coeff_in_read_sig <= '1';
|
||||
|
||||
|
||||
|
||||
fir_0002_ast_inst : fir_0002_ast
|
||||
port map (
|
||||
clk => clk,
|
||||
reset_n => reset_n,
|
||||
ast_sink_data => ast_sink_data,
|
||||
ast_source_data => ast_source_data,
|
||||
ast_sink_valid => ast_sink_valid,
|
||||
ast_sink_ready => open,
|
||||
ast_source_ready => '1',
|
||||
ast_source_valid => ast_source_valid,
|
||||
ast_sink_sop => '0',
|
||||
ast_sink_eop => '0',
|
||||
ast_sink_error => ast_sink_error,
|
||||
ast_source_sop => open,
|
||||
ast_source_eop => open,
|
||||
ast_source_channel => open,
|
||||
ast_source_error => ast_source_error
|
||||
);
|
||||
end syn;
|
||||
|
||||
|
||||
@@ -0,0 +1,273 @@
|
||||
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
|
||||
use work.auk_dspip_lib_pkg_hpfir.all;
|
||||
use work.auk_dspip_math_pkg_hpfir.all;
|
||||
|
||||
entity fir_0002_ast is
|
||||
generic (
|
||||
INWIDTH : integer := 16;
|
||||
OUT_WIDTH_UNTRIMMED : integer := 37;
|
||||
BANKINWIDTH : integer := 0;
|
||||
REM_LSB_BIT_g : integer := 0;
|
||||
REM_LSB_TYPE_g : string := "trunc";
|
||||
REM_MSB_BIT_g : integer := 0;
|
||||
REM_MSB_TYPE_g : string := "trunc";
|
||||
PHYSCHANIN : integer := 1;
|
||||
PHYSCHANOUT : integer := 1;
|
||||
CHANSPERPHYIN : natural := 1;
|
||||
CHANSPERPHYOUT : natural := 1;
|
||||
OUTPUTFIFODEPTH : integer := 8;
|
||||
USE_PACKETS : integer := 0;
|
||||
MODE_WIDTH : integer := 0;
|
||||
ENABLE_BACKPRESSURE : boolean := false;
|
||||
LOG2_CHANSPERPHYOUT : natural := log2_ceil_one(1);
|
||||
NUMCHANS : integer := 1;
|
||||
DEVICE_FAMILY : string := "Cyclone V";
|
||||
COMPLEX_CONST : integer := 1
|
||||
);
|
||||
port(
|
||||
clk : in std_logic;
|
||||
reset_n : in std_logic;
|
||||
ast_sink_ready : out std_logic;
|
||||
ast_source_data : out std_logic_vector(COMPLEX_CONST*(OUT_WIDTH_UNTRIMMED - REM_LSB_BIT_g - REM_MSB_BIT_g) * PHYSCHANOUT - 1 downto 0);
|
||||
ast_sink_data : in std_logic_vector( COMPLEX_CONST*(INWIDTH + BANKINWIDTH) * PHYSCHANIN + MODE_WIDTH - 1 downto 0);
|
||||
ast_sink_valid : in std_logic;
|
||||
ast_source_valid : out std_logic;
|
||||
ast_source_ready : in std_logic;
|
||||
ast_source_eop : out std_logic;
|
||||
ast_source_sop : out std_logic;
|
||||
ast_source_channel : out std_logic_vector (LOG2_CHANSPERPHYOUT - 1 downto 0);
|
||||
ast_sink_eop : in std_logic;
|
||||
ast_sink_sop : in std_logic;
|
||||
ast_sink_error : in std_logic_vector (1 downto 0);
|
||||
ast_source_error : out std_logic_vector (1 downto 0)
|
||||
);
|
||||
attribute altera_attribute : string;
|
||||
attribute altera_attribute of fir_0002_ast:entity is "-name MESSAGE_DISABLE 15400; -name MESSAGE_DISABLE 14130; -name MESSAGE_DISABLE 12020; -name MESSAGE_DISABLE 12030; -name MESSAGE_DISABLE 12010; -name MESSAGE_DISABLE 12110; -name MESSAGE_DISABLE 14320; -name MESSAGE_DISABLE 13410; -name MESSAGE_DISABLE 10036";
|
||||
end fir_0002_ast;
|
||||
|
||||
-- Warnings Suppression On
|
||||
-- altera message_off 10036
|
||||
|
||||
architecture struct of fir_0002_ast is
|
||||
|
||||
constant OUTWIDTH : integer := OUT_WIDTH_UNTRIMMED - REM_LSB_BIT_g - REM_MSB_BIT_g;
|
||||
|
||||
signal channel_out : std_logic_vector(LOG2_CHANSPERPHYOUT - 1 downto 0);
|
||||
|
||||
signal core_channel_out : std_logic_vector(2 -1 downto 0);
|
||||
signal at_source_channel : std_logic_vector(2 -1 downto 0);
|
||||
signal sink_packet_error : std_logic_vector(1 downto 0);
|
||||
signal data_in : std_logic_vector((COMPLEX_CONST*INWIDTH + BANKINWIDTH) * PHYSCHANIN + MODE_WIDTH - 1 downto 0);
|
||||
signal data_valid : std_logic_vector(0 downto 0);
|
||||
|
||||
signal data_out : std_logic_vector(COMPLEX_CONST*OUTWIDTH * PHYSCHANOUT -1 downto 0);
|
||||
signal reset_fir : std_logic;
|
||||
signal sink_ready_ctrl : std_logic;
|
||||
signal source_packet_error : std_logic_vector(1 downto 0);
|
||||
signal source_stall : std_logic;
|
||||
signal source_valid_ctrl : std_logic;
|
||||
signal stall : std_logic;
|
||||
signal valid : std_logic;
|
||||
signal core_valid : std_logic;
|
||||
signal enable_in : std_logic_vector(0 downto 0);
|
||||
|
||||
signal outp_out : std_logic_vector(COMPLEX_CONST*OUTWIDTH * PHYSCHANOUT - 1 downto 0);
|
||||
signal outp_blk_valid : std_logic_vector(PHYSCHANOUT - 1 downto 0);
|
||||
|
||||
signal core_out : std_logic_vector(OUT_WIDTH_UNTRIMMED * PHYSCHANOUT - 1 downto 0);
|
||||
signal core_out_valid : std_logic_vector(0 downto 0);
|
||||
signal core_out_channel : std_logic_vector(7 downto 0);
|
||||
|
||||
signal core_out_channel_0 : std_logic_vector(7 downto 0);
|
||||
|
||||
|
||||
begin
|
||||
sink : auk_dspip_avalon_streaming_sink_hpfir
|
||||
generic map (
|
||||
WIDTH_g => (COMPLEX_CONST*INWIDTH + BANKINWIDTH) * PHYSCHANIN + MODE_WIDTH,
|
||||
DATA_WIDTH => (COMPLEX_CONST*INWIDTH + BANKINWIDTH) * PHYSCHANIN + MODE_WIDTH,
|
||||
DATA_PORT_COUNT => 1,
|
||||
PACKET_SIZE_g => CHANSPERPHYIN)
|
||||
port map (
|
||||
clk => clk,
|
||||
reset_n => reset_n,
|
||||
data => data_in,
|
||||
data_valid => data_valid,
|
||||
sink_ready_ctrl => sink_ready_ctrl,
|
||||
packet_error => sink_packet_error,
|
||||
at_sink_ready => ast_sink_ready,
|
||||
at_sink_valid => ast_sink_valid,
|
||||
at_sink_data => ast_sink_data,
|
||||
at_sink_sop => ast_sink_sop,
|
||||
at_sink_eop => ast_sink_eop,
|
||||
at_sink_error => ast_sink_error);
|
||||
|
||||
source : auk_dspip_avalon_streaming_source_hpfir
|
||||
generic map (
|
||||
WIDTH_g => COMPLEX_CONST*OUTWIDTH * PHYSCHANOUT,
|
||||
DATA_WIDTH => COMPLEX_CONST*OUTWIDTH,
|
||||
DATA_PORT_COUNT => PHYSCHANOUT,
|
||||
FIFO_DEPTH_g => OUTPUTFIFODEPTH,
|
||||
USE_PACKETS => USE_PACKETS,
|
||||
HAVE_COUNTER_g => false,
|
||||
PACKET_SIZE_g => CHANSPERPHYOUT,
|
||||
COUNTER_LIMIT_g => CHANSPERPHYOUT,
|
||||
ENABLE_BACKPRESSURE_g => ENABLE_BACKPRESSURE)
|
||||
port map (
|
||||
clk => clk,
|
||||
reset_n => reset_n,
|
||||
data_in => data_out,
|
||||
data_count => channel_out,
|
||||
source_valid_ctrl => source_valid_ctrl,
|
||||
source_stall => source_stall,
|
||||
packet_error => source_packet_error,
|
||||
at_source_ready => ast_source_ready,
|
||||
at_source_valid => ast_source_valid,
|
||||
at_source_data => ast_source_data,
|
||||
at_source_channel => ast_source_channel,
|
||||
at_source_sop => ast_source_sop,
|
||||
at_source_eop => ast_source_eop,
|
||||
at_source_error => ast_source_error);
|
||||
|
||||
|
||||
intf_ctrl : auk_dspip_avalon_streaming_controller_hpfir
|
||||
port map (
|
||||
clk => clk,
|
||||
reset_n => reset_n,
|
||||
sink_packet_error => sink_packet_error,
|
||||
source_stall => source_stall,
|
||||
valid => valid,
|
||||
reset_design => reset_fir,
|
||||
sink_ready_ctrl => sink_ready_ctrl,
|
||||
source_packet_error => source_packet_error,
|
||||
source_valid_ctrl => source_valid_ctrl,
|
||||
stall => stall);
|
||||
|
||||
|
||||
|
||||
multi_data_out: for m in PHYSCHANOUT-1 downto 0 generate
|
||||
data_out(((m*OUTWIDTH)+OUTWIDTH-1) downto (m*OUTWIDTH)) <= outp_out(((m*OUTWIDTH)+OUTWIDTH-1) downto (m*OUTWIDTH));
|
||||
end generate multi_data_out;
|
||||
|
||||
channel_pipe_lsb: if REM_LSB_TYPE_g = "round" and REM_LSB_BIT_g > 0 generate
|
||||
begin
|
||||
out_lsb_p : process (clk, reset_n)
|
||||
begin
|
||||
if reset_n = '0' then
|
||||
core_out_channel_0 <= (others => '0');
|
||||
elsif rising_edge(clk) then
|
||||
core_out_channel_0 <= core_out_channel;
|
||||
end if;
|
||||
end process out_lsb_p;
|
||||
end generate channel_pipe_lsb;
|
||||
|
||||
channel_wire_lsb: if REM_LSB_TYPE_g = "trunc" or REM_LSB_BIT_g = 0 generate
|
||||
begin
|
||||
core_out_channel_0 <= core_out_channel;
|
||||
end generate channel_wire_lsb;
|
||||
|
||||
channel_pipe_msb: if REM_MSB_TYPE_g = "sat" and REM_MSB_BIT_g > 0 generate
|
||||
begin
|
||||
out_p : process (clk, reset_n)
|
||||
begin
|
||||
if reset_n = '0' then
|
||||
channel_out <= (others => '0');
|
||||
elsif rising_edge(clk) then
|
||||
channel_out <= core_out_channel_0(LOG2_CHANSPERPHYOUT-1 downto 0);
|
||||
end if;
|
||||
end process out_p;
|
||||
end generate channel_pipe_msb;
|
||||
|
||||
channel_wire_msb: if REM_MSB_TYPE_g = "trunc" or REM_MSB_BIT_g = 0 generate
|
||||
begin
|
||||
channel_out <= core_out_channel_0(LOG2_CHANSPERPHYOUT-1 downto 0);
|
||||
end generate channel_wire_msb;
|
||||
|
||||
|
||||
real_passthrough : if COMPLEX_CONST = 1 generate
|
||||
|
||||
component fir_0002_rtl_core is
|
||||
port (
|
||||
xIn_v : in std_logic_vector(0 downto 0);
|
||||
xIn_c : in std_logic_vector(7 downto 0);
|
||||
xIn_0 : in std_logic_vector(16 - 1 downto 0);
|
||||
xOut_v : out std_logic_vector(0 downto 0);
|
||||
xOut_c : out std_logic_vector(7 downto 0);
|
||||
xOut_0 : out std_logic_vector(37- 1 downto 0);
|
||||
clk : in std_logic;
|
||||
areset : in std_logic
|
||||
);
|
||||
end component fir_0002_rtl_core;
|
||||
|
||||
|
||||
--Complex data re-ordering
|
||||
signal core_channel_out_core : std_logic_vector(2 -1 downto 0);
|
||||
signal data_in_core : std_logic_vector((COMPLEX_CONST*INWIDTH + BANKINWIDTH) * PHYSCHANIN + MODE_WIDTH - 1 downto 0);
|
||||
signal data_valid_core : std_logic_vector(0 downto 0);
|
||||
signal core_out_core : std_logic_vector(OUT_WIDTH_UNTRIMMED * PHYSCHANOUT - 1 downto 0);
|
||||
signal core_out_valid_core : std_logic_vector(0 downto 0);
|
||||
signal core_out_channel_core : std_logic_vector(7 downto 0);
|
||||
|
||||
|
||||
|
||||
begin
|
||||
hpfircore_core: fir_0002_rtl_core
|
||||
port map (
|
||||
xIn_v => data_valid_core,
|
||||
xIn_c => "00000000",
|
||||
xIn_0 => data_in_core((0 + 16) * 0 + 16 - 1 downto (0 + 16) * 0),
|
||||
xOut_v => core_out_valid_core,
|
||||
xOut_c => core_out_channel_core,
|
||||
xOut_0 => core_out_core(37* 0 + 37- 1 downto 37* 0),
|
||||
clk => clk,
|
||||
areset => reset_fir
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
core_channel_out <= core_channel_out_core;
|
||||
data_in_core <= data_in;
|
||||
data_valid_core <= data_valid;
|
||||
core_out <= core_out_core;
|
||||
core_out_valid(0) <= core_out_valid_core(0);
|
||||
core_out_channel <= core_out_channel_core;
|
||||
|
||||
|
||||
|
||||
gen_outp_blk : for i in PHYSCHANOUT-1 downto 0 generate
|
||||
begin
|
||||
outp_blk : auk_dspip_roundsat_hpfir
|
||||
generic map (
|
||||
IN_WIDTH_g => OUT_WIDTH_UNTRIMMED ,
|
||||
REM_LSB_BIT_g => REM_LSB_BIT_g ,
|
||||
REM_LSB_TYPE_g => REM_LSB_TYPE_g ,
|
||||
REM_MSB_BIT_g => REM_MSB_BIT_g ,
|
||||
REM_MSB_TYPE_g => REM_MSB_TYPE_g
|
||||
)
|
||||
port map (
|
||||
clk => clk,
|
||||
reset_n => reset_n,
|
||||
enable => core_out_valid(0),
|
||||
datain => core_out(((i*OUT_WIDTH_UNTRIMMED)+OUT_WIDTH_UNTRIMMED-1) downto (i*OUT_WIDTH_UNTRIMMED)),
|
||||
valid => outp_blk_valid(i),
|
||||
dataout => outp_out(((i*OUTWIDTH)+OUTWIDTH-1) downto (i*OUTWIDTH))
|
||||
);
|
||||
end generate gen_outp_blk;
|
||||
end generate real_passthrough;
|
||||
|
||||
|
||||
|
||||
valid <= outp_blk_valid(0);
|
||||
|
||||
enable_in(0) <= not stall;
|
||||
|
||||
end struct;
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user