Advertisement
Guest User

Untitled

a guest
Nov 27th, 2018
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module test_ep4ce6 (
  2.     input wire clk,
  3.     input wire a,
  4.     input wire b,
  5.     output reg y = 1'bx
  6.   );
  7.  
  8.   reg [1023:0] x0;
  9.   reg [1023:0] x1;
  10.   reg [511:0] y0;
  11.   reg [127:0] y1;
  12.   reg [31:0] y2;
  13.   reg [7:0] y3;
  14.   reg [1:0] y4;
  15.   integer i;
  16.  
  17.   always @* begin
  18.     for (i = 0; i < 512; i = i + 1) begin
  19.       y0[i] = (x0[i * 2] == x1[i * 2]) && (x0[i * 2 + 1] == x1[i * 2 + 1]);
  20.     end
  21.     for (i = 0; i < 128; i = i + 1) begin
  22.       y1[i] = (y0[i * 4] && y0[i * 4 + 1] && y0[i * 4 + 2] && y0[i * 4 + 3]);
  23.     end
  24.     for (i = 0; i < 32; i = i + 1) begin
  25.       y2[i] = (y1[i * 4] && y1[i * 4 + 1] && y1[i * 4 + 2] && y1[i * 4 + 3]);
  26.     end
  27.     for (i = 0; i < 8; i = i + 1) begin
  28.       y3[i] = (y2[i * 4] && y2[i * 4 + 1] && y2[i * 4 + 2] && y2[i * 4 + 3]);
  29.     end
  30.     for (i = 0; i < 2; i = i + 1) begin
  31.       y4[i] = (y3[i * 4] && y3[i * 4 + 1] && y3[i * 4 + 2] && y3[i * 4 + 3]);
  32.     end
  33.   end
  34.  
  35.   always @(posedge clk) begin
  36.     x0 <= {x0[1022:0], a};
  37.     x1 <= {x1[1022:0], b};
  38.      //y <= x0 == x1; // А так оказывается чуть быстрее.
  39.     y <= y4[0] || y4[1];
  40.   end
  41. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement