Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 11th, 2012  |  syntax: VeriLog  |  size: 0.70 KB  |  hits: 31  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. `timescale 1ns / 1ps
  2.  
  3. module Pipeline(out0, out1, inA, inB);
  4.  
  5. integer i = 0;
  6.  
  7. function funcao;
  8. input a, b, c;
  9. begin  
  10.         if(a === 1'bX | b === 1'bX)
  11.         begin
  12.                 if(c === 0)
  13.                         funcao = 1;                            
  14.                 else
  15.                         funcao = 0;
  16.                        
  17.                 i = 1;
  18.         end
  19.         else if(a === b)
  20.         begin
  21.                 funcao = a;                            
  22.         end
  23.         else if(funcao === 1'bX)
  24.         begin
  25.                 funcao = 1;                            
  26.         end    
  27.        
  28.         $display($time, " - %b - A = %b B = %b OUT = %b - %d", c, a, b, funcao, i);
  29.         i = 0;
  30.        
  31. end
  32. endfunction
  33.  
  34. input inA, inB;
  35. output out0, out1;
  36.  
  37. reg out0, out1;
  38.        
  39. initial begin
  40.         out0 = 1;
  41.         out1 = 0;
  42. end
  43.  
  44. always @ (inA)
  45. begin
  46.         out0 = funcao(inA, !out1, 0);                  
  47. end
  48.  
  49. always @ (inB)
  50. begin
  51.         out1 = funcao(out0, !inB, 1);  
  52. end
  53.  
  54. endmodule