您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

encoder_sub_block_interleaving_rtl.sv 3.4 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. `timescale 1ns / 1ps
  2. //////////////////////////////////////////////////////////////////////////////////
  3. // Company: BITSILICA PRIVATE LIMITED
  4. // Design Name: ENCODER SUB-BLOCK INTERLEAVING
  5. // Module Name: encoder_sub_block_interleaving_rtl
  6. // Project Name: POLAR ENCODER-DECODER
  7. // Target Devices: Zynq UltraScale+ ZCU111 Evaluation Platform (xczu28dr-ffvg1517-2-e)
  8. // Tool Versions: VIVADO 2020.1
  9. // Description: RTL code for sub block interleaving, in order to interleave the sub blocks of encoded codeword.
  10. //
  11. //////////////////////////////////////////////////////////////////////////////////
  12. module encoder_sub_block_interleaving_rtl#(
  13. parameter N=512 // input and output sequence length
  14. // parameter to break down the input message into 32- sub blocks of euqal length, S=N/32
  15. ) (
  16. input wire clock_i,
  17. input wire reset_ni,
  18. input wire [N-1:0] msg_i, // input message for sub block interleaver
  19. output reg [N-1:0] msg_o // output message after sub block interleaving
  20. );
  21. localparam S=(N >> 3'd5); // parameter to break down the input message into 32- sub blocks of euqal length, S=N/32
  22. reg [4:0] sbi_pat [31:0] = '{5'd31, 5'd30, 5'd29, 5'd27,
  23. 5'd28, 5'd26,5'd25, 5'd24,
  24. 5'd23,5'd15,5'd22, 5'd14,
  25. 5'd21, 5'd13, 5'd20, 5'd12,
  26. 5'd19, 5'd11, 5'd18, 5'd10,
  27. 5'd17, 5'd9, 5'd16, 5'd8,
  28. 5'd7, 5'd6, 5'd5, 5'd3,
  29. 5'd4, 5'd2, 5'd1, 5'd0};
  30. logic [N-1:0] msg_1;
  31. logic sub_blocks [31:0] [S-1:0]; //register to store the sub divided blocks
  32. logic temp [31:0] [S-1:0]; //register to store the interleaved sub blocks
  33. integer i,j,k,p,q,r; //looping variables
  34. // instantiating a register(group of FF's) to hold the output and synchronize the module w.r.t clock and reset signals
  35. register #(
  36. .WIDTH(N), // overriding the width of register with the length of output to be registered
  37. .SR(2'b00), // overriding SR inputs of the register
  38. .RST_VAL({N{1'b0}}) // overriding the reset value with expected value in the output when reset is applied
  39. ) REG (
  40. .clk(clock_i), // connecting clock ports
  41. .rstb(reset_ni), // connecting reset ports
  42. .din(msg_1), // connecting input of register with the value that needs to be registered
  43. .dout(msg_o) // connecting the registered output with the output port of current module
  44. );
  45. always_comb begin
  46. //breaking down the message into 32 bit sub blocks of width N/32
  47. begin
  48. for(j = 0 ; j < 32 ; j=j+1) begin
  49. for (i = 0 ; i < S ; i = i+1) begin
  50. sub_blocks[j][i] = msg_i[(j*S)+i];
  51. end
  52. end
  53. end
  54. //interleaving the subblocks according to the interleaving pattern
  55. begin
  56. for(p = 0 ; p < 32 ; p = p+1) begin
  57. temp[p] = sub_blocks[sbi_pat[p]];
  58. end
  59. end
  60. //assigning interleaved bits to the output
  61. begin
  62. for(q = 0 ; q < 32 ; q = q+1) begin
  63. for (r = 0 ; r < S ; r = r+1) begin
  64. msg_1[(q*S)+r] = temp[q][r];
  65. end
  66. end
  67. end
  68. end
  69. endmodule