Skip to content

Commit

Permalink
mcs51: max opcode cycles is 4
Browse files Browse the repository at this point in the history
  • Loading branch information
happppp committed Jan 19, 2025
1 parent cf29189 commit 60caa30
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/devices/cpu/mcs51/mcs51.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class mcs51_cpu_device : public cpu_device
virtual uint64_t execute_clocks_to_cycles(uint64_t clocks) const noexcept override { return (clocks + 12 - 1) / 12; }
virtual uint64_t execute_cycles_to_clocks(uint64_t cycles) const noexcept override { return (cycles * 12); }
virtual uint32_t execute_min_cycles() const noexcept override { return 1; }
virtual uint32_t execute_max_cycles() const noexcept override { return 2+2; }
virtual uint32_t execute_max_cycles() const noexcept override { return 4+2; } // max opcode cycles + irq
virtual void execute_run() override;
virtual void execute_set_input(int inputnum, int state) override;

Expand Down

4 comments on commit 60caa30

@happppp
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quantum uses min_cycles, but what is max_cycles for?
A quick grep tells me nothing uses it.

@cuavas
Copy link
Member

@cuavas cuavas commented on 60caa30 Jan 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it’s unused at the moment. IIRC at one point it had to do with anticipating how much a device could overshoot the number of cycles it was given. It doesn’t really work for that when read/write handlers can burn additional cycles.

@Robbbert
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There used to be an assert if max_cycles was exceeded. Apart from catching programming errors, what was the point?

@cuavas
Copy link
Member

@cuavas cuavas commented on 60caa30 Jan 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Giving an indication of how much a device could overshoot its timeslice by – e.g. if max cycles is 4 and the device is told to execute for 7 cycles, it could execute for up to 7 + 4 - 1 = 10 cycles. But it doesn’t work properly because read/write handlers can burn additional cycles.

Please sign in to comment.