File: puncture.v

package info (click to toggle)
uhd 3.13.1.0-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 207,120 kB
  • sloc: cpp: 167,245; ansic: 86,841; vhdl: 53,420; python: 40,839; xml: 13,167; tcl: 5,688; makefile: 2,167; sh: 1,719; pascal: 230; csh: 94; asm: 20; perl: 11
file content (56 lines) | stat: -rw-r--r-- 2,190 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//
// Copyright 2015 Ettus Research
//
// Drop input words according to either a fixed or configurable bit mask (a.k.a puncturing vector).

module puncture #(
  parameter WIDTH                   = 32,      // Input bit width
  parameter MAX_LEN                 = 8,       // Maximum length of puncturing vector
  parameter DEFAULT_VECTOR_LEN      = 8,       // Vector length reset value
  parameter DEFAULT_PUNCTURE_VECTOR = 8'hFF)   // Puncture vector reset value
(
  input clk, input reset, input clear,
  input [$clog2(MAX_LEN):0] vector_len_tdata, input vector_len_tvalid, output vector_len_tready,
  input [MAX_LEN-1:0] puncture_vector_tdata, input puncture_vector_tvalid, output puncture_vector_tready,
  input [WIDTH-1:0] i_tdata, input i_tlast, input i_tvalid, output i_tready,
  output [WIDTH-1:0] o_tdata, output o_tlast, output o_tvalid, input o_tready
);

  assign vector_len_tready      = 1'b1;
  assign puncture_vector_tready = 1'b1;

  reg [$clog2(MAX_LEN):0] puncture_index, vector_len;
  reg [MAX_LEN-1:0] puncture_vector;
  always @(posedge clk) begin
    if (reset | clear) begin
      vector_len         <= DEFAULT_VECTOR_LEN-1;
      puncture_index     <= DEFAULT_VECTOR_LEN-1;
      puncture_vector    <= DEFAULT_PUNCTURE_VECTOR;
    end else begin
      if (puncture_vector_tvalid | vector_len_tvalid) begin
        puncture_index   <= vector_len_tdata - 1;
      end else if (i_tready & i_tvalid) begin
        if (puncture_index == 0) begin
          puncture_index <= vector_len;
        end else begin
          puncture_index <= puncture_index - 1;
        end
      end
      if (puncture_vector_tvalid) begin
        puncture_vector = puncture_vector_tdata;
      end
      if (vector_len_tvalid) begin
        vector_len = vector_len_tdata - 1;
      end
    end
  end

  wire puncture = puncture_vector[puncture_index];
  // Puncture by ANDing i_tvalid
  axi_fifo_flop #(.WIDTH(WIDTH+1)) axi_fifo_flop_punctured (
    .clk(clk), .reset(reset), .clear(clear),
    .i_tdata({i_tlast,i_tdata}), .i_tvalid(i_tvalid & puncture), .i_tready(i_tready),
    .o_tdata({o_tlast,o_tdata}), .o_tvalid(o_tvalid), .o_tready(o_tready),
    .space(), .occupied());

endmodule