www.pudn.com > hmac-zy.rar > modectrlunit.v, change:2006-12-27,size:882b


///////////////////////////////////////////////////////
//    module describe
// name: 		modectrlunit
// function:	record the ctrl word,the addr is 0;ctrlword[0] is the padflg.
// writer:		zy
// data:		2006/03/14
// version:		1.0
// feature:		
////////////////////////////////////////////////////////

module modectrlunit(clk,reset,en,wr,addr,datain,ctrlword,maskword);

input clk;
input reset;
input en;
input wr;
input [3:0] addr;
input [4:0] datain;

output [4:0] ctrlword;
output [2:0] maskword;

reg [4:0] ctrlword;//ctrl[0] is pad flag, ctrl[1] is soft reset,ctrl[2] is modsel, ctrl[3] is newhmac, ctrl[4] is ivrst
reg [2:0] maskword;

always @(posedge clk)
begin
	if (!reset)
		begin
			ctrlword<=0;
			maskword<=0;
		end
	else if ((addr==0)&&(en)&&(!wr))
		ctrlword<=datain;
	else if ((addr==15)&&(en)&&(!wr))
		maskword<=datain[2:0];
	else 
		ctrlword[1]<=0;
end

endmodule