motor_control_hold_monitor.vh 807 B

12345678910111213141516171819202122
  1. `timescale 1ns/1ps
  2. `ifndef MOTOR_CONTROL_HOLD_MONITOR_VH
  3. `define MOTOR_CONTROL_HOLD_MONITOR_VH
  4. module motor_control_hold_monitor(input wire clk,rst_n,valid,accept,
  5. input wire [2:0] op,input wire [15:0] mask,input wire [7:0] flags,input wire [31:0] value);
  6. held_payload_monitor #(.WIDTH(59)) check_hold(clk,rst_n,valid,accept,{op,mask,flags,value});
  7. endmodule
  8. module held_payload_monitor #(parameter integer WIDTH=32)(input wire clk,rst_n,valid,accept,
  9. input wire [WIDTH-1:0] data);
  10. reg pending=0;
  11. reg [WIDTH-1:0] held;
  12. always @(posedge clk)begin
  13. if(!rst_n)pending<=0;
  14. else begin
  15. if(pending && !accept && held!==data)
  16. $fatal(1,"held transaction context changed before acceptance");
  17. if(valid && !pending)begin held<=data;pending<=1;end
  18. if(accept)pending<=0;
  19. end
  20. end
  21. endmodule
  22. `endif