You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

56 lines
2.9 KiB

  1. `timescale 1ns / 1ps
  2. //////////////////////////////////////////////////////////////////////////////////
  3. // Company: BITSILICA PRIVATE LIMITED
  4. // Design Name: ENCODER CORE
  5. // Module Name: encoder_core_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 polar encoder core operation.
  10. //
  11. // encoder_core_rtl is written to encode an N-bit input message and produce an N-bit
  12. // encoded codeword as an output
  13. //
  14. //////////////////////////////////////////////////////////////////////////////////
  15. module encoder_core_rtl
  16. #(
  17. parameter N = 512, // length of input and output messages for encoder_core_rtl
  18. localparam DEPTH = $clog2(N) // to derive depth of binary tree to carry out the operation of polar encoder core
  19. )
  20. (
  21. input wire clock_i, // system clock
  22. input wire reset_ni, // active low, synchronous reset
  23. input wire [N-1:0] msg_i, // input message to be encoded
  24. output reg [N-1:0] msg_o // output encoded codeword
  25. );
  26. reg [N-1:0] msg_1; // internal register to hold the encoded codeword throughout the operation
  27. integer i,j,k; // looping variables
  28. // instantiating a register(group of FF's) to hold the output and synchronize the module w.r.t clock and reset signals
  29. register #(
  30. .WIDTH(N), // overriding the width of register with the length of output to be registered
  31. .SR(2'b00), // overriding SR inputs of the register
  32. .RST_VAL({N{1'b0}}) // overriding the reset value with expected value in the output when reset is applied
  33. ) REG (
  34. .clk(clock_i), // connecting clock ports
  35. .rstb(reset_ni), // connecting reset ports
  36. .din(msg_1), // connecting input of register with the value that needs to be registered
  37. .dout(msg_o) // connecting the registered output with the output port of current module
  38. );
  39. // combinational always block for performing encoder operation
  40. always_comb begin
  41. msg_1 = msg_i; // temporary register is fed with input message
  42. for (i = 0; i <= DEPTH; i = i+1) begin : depth // to loop through the depth of binary tree
  43. for (j = 0; j <= (N-(2 ** i)); j = j+(2 ** i)) begin : limit // to find the boundaries of bits in different depths
  44. for (k = j; k < (j+(2 ** (i-1))); k = k+1) begin : count // to find the number of xor operations required to encode the message
  45. msg_1[k] = msg_1[k] ^ msg_1[k + (2 ** (i-1))]; // xor between two particular bits to be stored in another bit, based on the index calculated
  46. end : count
  47. end : limit
  48. end : depth
  49. end
  50. endmodule