sp3ctrm5tr

8 to 3 Line Encoder using Task

Mar 18th, 2013
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. 8 to 3 Line Encoder using Task
  3. */
  4. module ENC8TO3TASK (
  5.     input [7:0] in,
  6.     output [2:0] out);
  7.  
  8. always@(*)
  9.     taskenc8to3(in, out);
  10.  
  11.  
  12. task taskenc8to3;
  13.  
  14.     input [7:0] IN;
  15.     output reg [2:0] OUT;
  16.  
  17.     if(IN == 8'b0000_0001) OUT = 0;
  18.     else if(IN == 8'b0000_0010) OUT = 1;
  19.     else if(IN == 8'b0000_0100) OUT = 2;
  20.     else if(IN == 8'b0000_1000) OUT = 3;
  21.     else if(IN == 8'b0001_0000) OUT = 4;
  22.     else if(IN == 8'b0010_0000) OUT = 5;
  23.     else if(IN == 8'b0100_0000) OUT = 6;
  24.     else if(IN == 8'b1000_0000) OUT = 7;
  25.  
  26. endtask
  27.  
  28. endmodule
Advertisement
Add Comment
Please, Sign In to add comment