TheLegace

Untitled

Oct 17th, 2011
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module Lab4(
  2.                 input [17:0] SW,
  3.                 output reg [17:0] LEDR
  4. );
  5.  
  6.  
  7.     initial begin
  8.         LEDR = 18'b0;
  9.     end
  10.    
  11.     always @(SW[8:0])
  12.         begin
  13.             //on for addition
  14.             if(SW[8]) begin
  15.                 LEDR[3:0] = SW[3:0] + SW[7:4];
  16.                 if(SW[3] == SW[7] && LEDR[3] != SW[3])
  17.                         LEDR[17] = 1;
  18.                 else
  19.                         LEDR[17] = 0;
  20.             end
  21.             else begin
  22.                 LEDR[3:0] = SW[7:4] + (~SW[3:0]+ 4'b0001);
  23.                 if(SW[3] != SW[7] && LEDR[3] != SW[7])
  24.                         LEDR[17] = 1;
  25.                     else
  26.                         LEDR[17] = 0;
  27.             end
  28.         end
  29. endmodule
  30.  
Advertisement
Add Comment
Please, Sign In to add comment