Projektdaten für das ESY1B Praktikum im Sommersemester 2022
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Fsm.sv 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. module Fsm
  2. (
  3. input wire clk,
  4. input wire tim_ready,
  5. input wire alarm,
  6. output logic adc_en,
  7. output logic tim_en,
  8. output logic fram_c_en,
  9. output logic led_c_en
  10. );
  11. real S0 = 0;
  12. real S1 = 1;
  13. real S2 = 2;
  14. real S3 = 3;
  15. real S4 = 4;
  16. real S5 = 5;
  17. real S6 = 6;
  18. logic[2:0] state;
  19. initial begin
  20. #0 state <= 0;
  21. #0 adc_en <= 0;
  22. #0 tim_en <= 0;
  23. #0 fram_c_en <= 0;
  24. #0 led_c_en <= 0;
  25. end
  26. always @(posedge clk) begin
  27. case(state)
  28. S0: begin
  29. adc_en <= 1'b1;
  30. tim_en <= 1'b1;
  31. state <= S1;
  32. end
  33. S1: begin
  34. adc_en <= 1'b0;
  35. tim_en <= 1'b0;
  36. if(tim_ready) begin
  37. fram_c_en <= 1'b1;
  38. led_c_en <= 1'b1;
  39. state <= S2;
  40. end
  41. else begin
  42. // do nothing
  43. end
  44. end
  45. S2: begin
  46. fram_c_en <= 0'b0;
  47. led_c_en <= 0'b0;
  48. if(alarm) begin
  49. // taster
  50. end
  51. else begin
  52. if(tim_ready) begin
  53. end
  54. state <= S0;
  55. end
  56. end
  57. default: ;
  58. endcase
  59. end
  60. endmodule