Advertisement
fellpz

08jun17

Jun 8th, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. *module teste(a,b,sel,out);
  2.  
  3. input a,b,sel;
  4. output out;
  5.  
  6. assing out = (sel & a) | (~ sel & b);
  7.  
  8. endmodule;
  9.  
  10. ====================[
  11.  
  12. VERILOG
  13.  
  14. *module teste (SW,LEDR);
  15.  
  16. input [2:0] SW;
  17. output [0:0] LEDR;
  18.  
  19. assing LEDR[0] = (SW[O] & SW[1]) | (~ SW[0] & SW[2]);
  20.  
  21. endmodule;
  22.  
  23.  
  24. ====================[
  25.  
  26. VERILOG 2
  27.  
  28.  
  29. *module teste (SW,LEDR);
  30.  
  31. input [2:0] SW;
  32. output [0:0] LEDR;
  33.  
  34. reg saida; // reg LEDR[0]
  35.  
  36. always @ (1)    //(O que tiver dentro do parenteses for verdadeiro faça [1] autoriza)
  37.  
  38. begin
  39. if (SW[0] == 0)
  40.     begin
  41.         saida = SW[2];
  42.     end
  43.     else if (SW[0] == 1)
  44.     begin
  45.         saida = SW[1];
  46.     end
  47. end
  48.  
  49. assign LEDR[0] = saida; //LEDR[0] = bit de saida
  50.  
  51. endmodule
  52.  
  53.  
  54. ====================[
  55.  
  56.  
  57. VERILOG 3
  58.  
  59.  
  60. module teste (SW,LEDR);
  61.  
  62. input [2:0] SW;
  63. output [0:0] LEDR;
  64. reg soma, co;
  65.  
  66. always @ (1)
  67. begin
  68. soma = SW[0]^SW[1]^SW[2];
  69. co = SW[0]&SW[1] | SW[0] & SW[2] | SW[1] & SW[2];
  70. end
  71.  
  72. assign LEDR = {co,soma};
  73.  
  74. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement