state_reg_cg.v 568 Bytes
Newer Older
lwc-tester committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
module state_reg_cg (/*AUTOARG*/
   // Outputs
   so,
   // Inputs
   si, skinnys, clk, rst, enc, se
   ) ;
   parameter initial_value = 0;
   parameter width = 32;   
   
   output reg [width-1:0] so;

   input [width-1:0]      si, skinnys;
   input 	     clk, rst, enc, se;

   wire 	     clki, enci;
   wire [width-1:0]  sr;

   assign enci = (clk == 0) ? enc : enci;   
   assign clki = enci & clk;
   assign sr = rst ? initial_value : si;   
   
   always @ (posedge clki) begin
      if (se) so <= sr;
      else so <= skinnys;
   end
   
endmodule // state_reg