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.

timer_top.sv 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. //clock divider
  2. module timer(input inClk, inTaste, inEN, output reg outReadTemp, outTasteAktiv);
  3. int divide1 = 30000000;
  4. int divide2 = 60000;
  5. logic state = 0;
  6. logic [31:0] count1 = 32'b0;
  7. logic [31:0] count2 = 32'b0;
  8. initial begin
  9. outReadTemp = 0;
  10. outTasteAktiv = 0;
  11. end
  12. always @(posedge inClk or posedge inEN) begin
  13. if(inEN) begin
  14. count1 <= 0;
  15. count2 <= 0;
  16. outReadTemp <= 0;
  17. end
  18. else begin
  19. count1 <= count1 +1;
  20. if(count1>=((2**32)-1))
  21. count1 <= 32'b0;
  22. if(count1 % divide1 == 0)
  23. outReadTemp <= ~outReadTemp;
  24. if(inTaste) begin
  25. count2 <= count2 +1;
  26. if(count2 >= 6000000)
  27. outTasteAktiv = 1;
  28. end
  29. else begin
  30. outTasteAktiv <= 0;
  31. count2 <= 0;
  32. end
  33. end
  34. end
  35. endmodule // clk_divider
  36. module parallelport(input inClk, inTimerMeas, inEndOfConv, [7:0] inData, output reg outDataValid, [7:0] outData);
  37. logic [7:0] storage = 8'b0;
  38. initial begin
  39. outDataValid <= 0;
  40. outData <= 8'b0;
  41. end
  42. always @(posedge inClk) begin
  43. if(inEndOfConv)
  44. storage <= inData;
  45. if(inTimerMeas == 1 && outDataValid == 0) begin
  46. outData = storage;
  47. outDataValid <= 1;
  48. end
  49. else if(inTimerMeas == 0)
  50. outDataValid <= 0;
  51. end
  52. endmodule