www.pudn.com > Haffman-encoding.rar > haffman.v, change:2012-11-05,size:507b


module haffmanencoding (clk,tran1,tran2);
    
    input clk;
    output [2:0] tran1,tran2;
    
    reg [2:0] add1,add2;
    wire [3:0] add11,add12;
    reg [1:0] in1,in2;
    wire [3:0] haf1;
    reg [3:0] haf2;

always @(posedge clk)
begin
    
   add2=add1;
   haf2=haf1; 
   in1=$random%2;
   in2=$random%2;
   
   add1=in1+in2;
   
end
   haff h(add1,haf1);
   assign add11={1'b0,add1};
   assign add12={1'b0,add2};
   numoftrans n(add11,add12,tran1);
   numoftrans n1(haf1,haf2,tran2);
    
endmodule