Advertisement
STANAANDREY

ac sapt7

Nov 8th, 2023
1,347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. module pktmux(
  3.     input [63:0] msg_len, pkt,
  4.     input pad_pkt, zero_pkt, mgln_pkt,
  5.     output reg[63:0] o
  6. );
  7.     always @(*)
  8.         if (pad_pkt == 1) o = (1 << 63);
  9.         else if (zero_pkt == 1) o = 0;
  10.         else if (msg_len == 1) o = msg_len;
  11.         else o = pkt;
  12. endmodule
  13.  
  14. module pktmux_tb;
  15.     reg [63:0] msg_len, pkt;
  16.     reg pad_pkt, zero_pkt, mgln_pkt;
  17.     wire[63:0] o;
  18.     pktmux inst1(.msg_len(msg_len), .pkt(pkt), .pad_pkt(pad_pkt), .zero_pkt(zero_pkt), .mgln_pkt(mgln_pkt), .o(o));
  19.     localparam CYCLE = 100;
  20.     initial begin
  21.         {pad_pkt, zero_pkt, mgln_pkt} = 0;
  22.         repeat(3) begin
  23.         #(1*CYCLE){ pad_pkt, zero_pkt, mgln_pkt } = 4;
  24.         #(1*CYCLE){ pad_pkt, zero_pkt, mgln_pkt } = 2;
  25.         #(1*CYCLE){ pad_pkt, zero_pkt, mgln_pkt } = 1;
  26.         #(1*CYCLE){ pad_pkt, zero_pkt, mgln_pkt } = 0;
  27.         end
  28.     end
  29.     task urand64(output reg[63:0] r);
  30.     begin
  31.         r[63:32]=$urandom;
  32.         r[31:0]=$urandom;
  33.     end
  34.     endtask
  35.     integer k;
  36.     initial begin
  37.         urand64(pkt);
  38.         urand64(msg_len);
  39.         for (k = 0; k < 13; k = k + 1) begin
  40.             #(1*CYCLE);
  41.             urand64(pkt);
  42.             urand64(msg_len);
  43.         end
  44.     end
  45. endmodule
  46.  
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement