Advertisement
Guest User

lab3_3

a guest
Sep 30th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. `timescale 1ns / 1ps
  2.  
  3. module Lab4_3(
  4. input wire clk,
  5. input wire rst,
  6. input wire mosi,
  7. output wire miso,
  8. output wire [7:0] ld
  9.  
  10. );
  11. localparam INIT = 2'd0;
  12. localparam ON = 2'd1;
  13. localparam OFF = 2'd2;
  14.  
  15. reg [1:0] state;
  16. wire blink= mosi;
  17.  
  18. always @ ( posedge clk)
  19. begin
  20. if(rst)
  21. state <= INIT;
  22. else
  23. case ( state)
  24. INIT : if (blink)
  25. state <= ON;
  26. else state <= INIT ;
  27. ON : state <= OFF;
  28. OFF : if (blink)
  29. state <= ON;
  30. else state <= INIT ;
  31.  
  32. default: state <= INIT;
  33. endcase
  34. end
  35.  
  36. // kimenetek meghajtása
  37. assign miso = (state == ON);
  38. assign ld = {8{(state == ON)}};
  39.  
  40. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement