data/full_repos/permissive/445695969/src_rtl/protected/skinny_rnd_nc.v
1: b'%Error: data/full_repos/permissive/445695969/src_rtl/protected/skinny_rnd_nc.v:8: Cannot find include file: romulus_config_pkg.v\n`include"romulus_config_pkg.v" \n        ^~~~~~~~~~~~~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/445695969/src_rtl/protected,data/full_repos/permissive/445695969/romulus_config_pkg.v\n             data/full_repos/permissive/445695969/src_rtl/protected,data/full_repos/permissive/445695969/romulus_config_pkg.v.v\n             data/full_repos/permissive/445695969/src_rtl/protected,data/full_repos/permissive/445695969/romulus_config_pkg.v.sv\n             romulus_config_pkg.v\n             romulus_config_pkg.v.v\n             romulus_config_pkg.v.sv\n             obj_dir/romulus_config_pkg.v\n             obj_dir/romulus_config_pkg.v.v\n             obj_dir/romulus_config_pkg.v.sv\n%Error: Exiting due to 1 error(s)\n'
module skinny_rnd_nc (

   nextcnt, nextkey, nexttweak, nextstate,

   roundkey, roundtweak, roundstate, randomness, roundcnt, constant, ring_en,
   clk
   ) ;
`include"romulus_config_pkg.v"

   output [127:0] nextcnt;
   output [128*KEYSHARES-1:0] nextkey;
   output [127:0]             nexttweak;
   output [128*STATESHARES-1:0] nextstate;
   input [128*KEYSHARES-1:0]    roundkey;
   input [127:0]                roundtweak;
   input [128*STATESHARES-1:0]  roundstate;
   input [RNDW-1:0]             randomness;
   input [127:0]                roundcnt;
   input [5:0]                  constant;
   input [CLKS_PER_RND-1:0]     ring_en;
   input                        clk;

   genvar                       i, j;

   wire [127:0]                 rndcnt;
   wire [128*STATESHARES-1:0]   sb;
   wire [128*KEYSHARES-1:0]     rkey;
   wire [128*STATESHARES-1:0]   atk;
   wire [128*STATESHARES-1:0]   shr;
   wire [128*STATESHARES-1:0]   mxc;
   wire [128*KEYSHARES-1:0]     rndkey;
   wire [127:0]                 rndtweak;

   wire [5:0]                   rndconstant;

   generate
      for (j = 0; j < 16; j = j + 1) begin:sbox_loop
         if (MASKING==DOM1NC) begin:dom1nc
	    if (CLKS_PER_RND == 26) begin:single_edge
               skinny_sbox8_dom1_sni_non_complete sbox0 (.bo1(sb[8*j+ 7+128:8*j+128+0]),
							 .bo0(sb[8*j+ 7+  0:8*j+  0+0]),
							 .si1(roundstate[8*j+128+7:8*j+128+0]),
							 .si0(roundstate[8*j+  0+7:8*j+  0+0]),
							 .r(randomness[RNDW/16*j+7:RNDW/16*j]),
							 .cycle(ring_en[CLKS_PER_RND-3:0]),
							 .clk(clk));
	    end
	    else begin:double_edge
	       skinny_sbox8_dom1_sni_non_complete_de sbox0 (.bo1(sb[8*j+ 7+128:8*j+128+0]),
							    .bo0(sb[8*j+ 7+  0:8*j+  0+0]),
							    .si1(roundstate[8*j+128+7:8*j+128+0]),
							    .si0(roundstate[8*j+  0+7:8*j+  0+0]),
							    .r(randomness[RNDW/16*j+7:RNDW/16*j]),
							    .cycle_i(ring_en[CLKS_PER_RND-3:0]),
							    .clk(clk));
	    end
         end
      end
   endgenerate

   wire [128*STATESHARES-1:0] sb_pg;
   wire [128*KEYSHARES-1:0] rkey_pg;
   wire [128*KEYSHARES-1:0] rndkey_pg;
   wire [128*KEYSHARES-1:0] nextkey_pg;
   
   assign sb_pg[255:128] = ring_en[CLKS_PER_RND-1] ? sb[255:128] : 128'h0;
   assign sb_pg[127:  0] = ring_en[CLKS_PER_RND-2] ? sb[127:  0] : 128'h0;

   generate
      if (KEYSHARES > 1) begin:extra_keyshare
	 assign rkey_pg[255:128] = ring_en[CLKS_PER_RND-1] ? rkey[255:128] : 128'h0;
	 assign rndkey_pg[255:128] = ring_en[CLKS_PER_RND-1] ? rndkey[255:128] : 128'h0;
	 assign nextkey_pg[255:128] = ring_en[CLKS_PER_RND-1] ? nextkey[255:128] : 128'h0;
      end
   endgenerate
   assign rkey_pg[127:  0] = ring_en[CLKS_PER_RND-2] ? rkey[127:  0] : 128'h0;


   assign atk = rkey ^ sb_pg;

   generate
      for (i = 0; i < STATESHARES; i = i + 1) begin:shiftrowsloop

         assign shr[127+128*i:96+128*i] =  atk[127+128*i:96*i];
         assign shr[ 95+128*i:64+128*i] = {atk[ 71+128*i:64*i],atk[95+128*i:72+128*i]};
         assign shr[ 63+128*i:32+128*i] = {atk[ 47+128*i:32*i],atk[63+128*i:48+128*i]};
         assign shr[ 31+128*i: 0+128*i] = {atk[ 23+128*i: 0*i],atk[31+128*i:24+128*i]};


         assign mxc[ 95+128*i:64+128*i] = shr[127+128*i:96+128*i];
				 assign mxc[ 63+128*i:32+128*i] = shr[ 95+128*i:64+128*i] ^ shr[63+128*i:32+128*i];
				 assign mxc[ 31+128*i: 0+128*i] = shr[127+128*i:96+128*i] ^ shr[63+128*i:32+128*i];
				 assign mxc[127+128*i:96+128*i] = shr[ 31+128*i: 0+128*i] ^ mxc[31+128*i: 0+128*i];
      end
   endgenerate

   assign nextstate = mxc;

   assign rndkey = roundkey;
   assign rndtweak = roundtweak;
   assign rndcnt = roundcnt;

   assign rndconstant = constant;

   wire [255:0] nextstate_pg;

   assign nextstate_pg[255:128] = ring_en[CLKS_PER_RND-1] ? nextstate[255:128] : 128'h0;
   assign nextstate_pg[127:  0] = ring_en[CLKS_PER_RND-2] ? nextstate[127:  0] : 128'h0;

   assign nextkey_pg[127:  0] = ring_en[CLKS_PER_RND-2] ? nextkey[127:  0] : 128'h0;

   assign rndkey_pg[127:  0] = ring_en[CLKS_PER_RND-2] ? rndkey[127:  0] : 128'h0;

   generate
      for (i = 0; i < KEYSHARES; i = i + 1) begin:keyexpansion
         key_expansion tk3 (.ko(nextkey[127+128*i:128*i]),.ki(rndkey_pg[127+128*i:128*i]));
      end
   endgenerate

   tweak2_expansion tk2 (.ko(nexttweak),.ki(rndtweak));

   tweak1_expansion #(.fullcnt(fullcnt)) tk1 (.ko(nextcnt),.ki(rndcnt));
   assign rkey[127:0] = {rndkey[127:64],64'h0} ^
                        {rndtweak[127:64],64'h0} ^
                        {rndcnt[127:64],64'h0}^
		                    {4'h0,rndconstant[3:0],24'h0,6'h0,rndconstant[5:4],24'h0,8'h02,56'h0};
   generate
      for(i = 1; i < KEYSHARES; i = i + 1) begin:round_keys_loop
         assign rkey[127+128*i:0+128*i] = {rndkey[127+128*i:64+128*i],64'h0};
      end
   endgenerate


endmodule
module skinny_rnd_nc (

   nextcnt, nextkey, nexttweak, nextstate,

   roundkey, roundtweak, roundstate, randomness, roundcnt, constant, ring_en,
   clk
   ) ;

`include"romulus_config_pkg.v"

   output [127:0] nextcnt;
   output [128*KEYSHARES-1:0] nextkey;
   output [127:0]             nexttweak;
   output [128*STATESHARES-1:0] nextstate;
   input [128*KEYSHARES-1:0]    roundkey;
   input [127:0]                roundtweak;
   input [128*STATESHARES-1:0]  roundstate;
   input [RNDW-1:0]             randomness;
   input [127:0]                roundcnt;
   input [5:0]                  constant;
   input [CLKS_PER_RND-1:0]     ring_en;
   input                        clk;

   genvar                       i, j;

   wire [127:0]                 rndcnt;
   wire [128*STATESHARES-1:0]   sb;
   wire [128*KEYSHARES-1:0]     rkey;
   wire [128*STATESHARES-1:0]   atk;
   wire [128*STATESHARES-1:0]   shr;
   wire [128*STATESHARES-1:0]   mxc;
   wire [128*KEYSHARES-1:0]     rndkey;
   wire [127:0]                 rndtweak;

   wire [5:0]                   rndconstant;

   generate
      for (j = 0; j < 16; j = j + 1) begin:sbox_loop
         if (MASKING==DOM1NC) begin:dom1nc
	    if (CLKS_PER_RND == 26) begin:single_edge
               skinny_sbox8_dom1_sni_non_complete sbox0 (.bo1(sb[8*j+ 7+128:8*j+128+0]),
							 .bo0(sb[8*j+ 7+  0:8*j+  0+0]),
							 .si1(roundstate[8*j+128+7:8*j+128+0]),
							 .si0(roundstate[8*j+  0+7:8*j+  0+0]),
							 .r(randomness[RNDW/16*j+7:RNDW/16*j]),
							 .cycle(ring_en[CLKS_PER_RND-3:0]),
							 .clk(clk));
	    end
	    else begin:double_edge
	       skinny_sbox8_dom1_sni_non_complete_de sbox0 (.bo1(sb[8*j+ 7+128:8*j+128+0]),
							    .bo0(sb[8*j+ 7+  0:8*j+  0+0]),
							    .si1(roundstate[8*j+128+7:8*j+128+0]),
							    .si0(roundstate[8*j+  0+7:8*j+  0+0]),
							    .r(randomness[RNDW/16*j+7:RNDW/16*j]),
							    .cycle_i(ring_en[CLKS_PER_RND-3:0]),
							    .clk(clk));
	    end
         end
      end
   endgenerate

   wire [128*STATESHARES-1:0] sb_pg;
   wire [128*KEYSHARES-1:0] rkey_pg;
   wire [128*KEYSHARES-1:0] rndkey_pg;
   wire [128*KEYSHARES-1:0] nextkey_pg;
   
   assign sb_pg[255:128] = ring_en[CLKS_PER_RND-1] ? sb[255:128] : 128'h0;
   assign sb_pg[127:  0] = ring_en[CLKS_PER_RND-2] ? sb[127:  0] : 128'h0;

   generate
      if (KEYSHARES > 1) begin:extra_keyshare
	 assign rkey_pg[255:128] = ring_en[CLKS_PER_RND-1] ? rkey[255:128] : 128'h0;
	 assign rndkey_pg[255:128] = ring_en[CLKS_PER_RND-1] ? rndkey[255:128] : 128'h0;
	 assign nextkey_pg[255:128] = ring_en[CLKS_PER_RND-1] ? nextkey[255:128] : 128'h0;
      end
   endgenerate
   assign rkey_pg[127:  0] = ring_en[CLKS_PER_RND-2] ? rkey[127:  0] : 128'h0;


   assign atk = rkey ^ sb_pg;

   generate
      for (i = 0; i < STATESHARES; i = i + 1) begin:shiftrowsloop

         assign shr[127+128*i:96+128*i] =  atk[127+128*i:96*i];
         assign shr[ 95+128*i:64+128*i] = {atk[ 71+128*i:64*i],atk[95+128*i:72+128*i]};
         assign shr[ 63+128*i:32+128*i] = {atk[ 47+128*i:32*i],atk[63+128*i:48+128*i]};
         assign shr[ 31+128*i: 0+128*i] = {atk[ 23+128*i: 0*i],atk[31+128*i:24+128*i]};


         assign mxc[ 95+128*i:64+128*i] = shr[127+128*i:96+128*i];
				 assign mxc[ 63+128*i:32+128*i] = shr[ 95+128*i:64+128*i] ^ shr[63+128*i:32+128*i];
				 assign mxc[ 31+128*i: 0+128*i] = shr[127+128*i:96+128*i] ^ shr[63+128*i:32+128*i];
				 assign mxc[127+128*i:96+128*i] = shr[ 31+128*i: 0+128*i] ^ mxc[31+128*i: 0+128*i];
      end
   endgenerate

   assign nextstate = mxc;

   assign rndkey = roundkey;
   assign rndtweak = roundtweak;
   assign rndcnt = roundcnt;

   assign rndconstant = constant;

   wire [255:0] nextstate_pg;

   assign nextstate_pg[255:128] = ring_en[CLKS_PER_RND-1] ? nextstate[255:128] : 128'h0;
   assign nextstate_pg[127:  0] = ring_en[CLKS_PER_RND-2] ? nextstate[127:  0] : 128'h0;

   assign nextkey_pg[127:  0] = ring_en[CLKS_PER_RND-2] ? nextkey[127:  0] : 128'h0;

   assign rndkey_pg[127:  0] = ring_en[CLKS_PER_RND-2] ? rndkey[127:  0] : 128'h0;

   generate
      for (i = 0; i < KEYSHARES; i = i + 1) begin:keyexpansion
         key_expansion tk3 (.ko(nextkey[127+128*i:128*i]),.ki(rndkey_pg[127+128*i:128*i]));
      end
   endgenerate

   tweak2_expansion tk2 (.ko(nexttweak),.ki(rndtweak));

   tweak1_expansion #(.fullcnt(fullcnt)) tk1 (.ko(nextcnt),.ki(rndcnt));
   assign rkey[127:0] = {rndkey[127:64],64'h0} ^
                        {rndtweak[127:64],64'h0} ^
                        {rndcnt[127:64],64'h0}^
		                    {4'h0,rndconstant[3:0],24'h0,6'h0,rndconstant[5:4],24'h0,8'h02,56'h0};
   generate
      for(i = 1; i < KEYSHARES; i = i + 1) begin:round_keys_loop
         assign rkey[127+128*i:0+128*i] = {rndkey[127+128*i:64+128*i],64'h0};
      end
   endgenerate


endmodule