ostis icon indicating copy to clipboard operation
ostis copied to clipboard

Define a device model

Open larsbrinkhoff opened this issue 9 years ago • 7 comments

struct mmu is increasingly being abused for modelling hardware components. First diagnostics was added, and now interrupt handling has been included. Also, some entities that obviously model hardware components doesn't have a struct mmu. Most likely, struct mmu would be better off only handling MMU properties only.

I propose it would be a good idea to add a struct device for modelling all devices. Here are some things to consider for such a model:

  • MMU interface
  • Bus interface
  • Interrupts
  • Diagnostics
  • Recording state
  • Signals
  • Connecting outputs and inputs to other devices
  • Multiple instantiation (e.g. ROM, ACIA)
  • Timer callbacks
  • Periodic calls
  • Reset
  • Handling user/configuration/script commands

larsbrinkhoff avatar Mar 16 '16 12:03 larsbrinkhoff

https://github.com/larsbrinkhoff/ostis/compare/master...device is a work in progress with a first step in this direction.

larsbrinkhoff avatar Mar 16 '16 14:03 larsbrinkhoff

The first description of the issue and the proposal seem to clash a bit. The first one says it doesn't have an mmu, only a device, the code however puts the device inside an mmu object. Shouldn't it be the other way around, with the mmu object inside the device?

stefanberndtsson avatar Mar 16 '16 17:03 stefanberndtsson

The answer to the question is: Yes!

It's a work in progress, more commits to follow. At this point, discussion about the idea is more useful than looking at unfinished code.

larsbrinkhoff avatar Mar 16 '16 18:03 larsbrinkhoff

Good. The idea is definitely the right one. It might even be that MMU is the wrong semantic term for the I/O-mapping of devices, but that's a GLUE-related discussion :)

stefanberndtsson avatar Mar 16 '16 18:03 stefanberndtsson

Since this was first written, the code is moving more and more towards using clocked state machines. The device model should reflect this.

  • Devices should be able to register for clock signals. Possibly different clock cycles, and more than one clock source.
  • There should be support for writing the state machines. I see a need for requesting events to happen some number of clock cycles in the future, or periodic events.
  • The devices send signals to each other. If one device is to react to a signal in the same clock cycle as it's raised, the output device needs to execute before the input device, or else there will be a delay.

larsbrinkhoff avatar Mar 22 '16 19:03 larsbrinkhoff

The "request events to happen at " sort of, might be synced to a master clock, regardless of local slower clock in the device. That would probably help when triggering signals to other devices.

stefanberndtsson avatar Mar 22 '16 19:03 stefanberndtsson

Different kind of signals:

  • Level
  • Edge
  • Pulse
  • Clock (periodic pulses)

Physical view:

  • High/low level
  • Rising/falling edge

Logical view:

  • Active/passive

Implementations:

  • Setting a variable
  • Calling a function

larsbrinkhoff avatar Mar 23 '16 09:03 larsbrinkhoff