1 // sidcomp.h - Define the external interface of a SID component, that
2 // is, the SID component API expressed in -*- C++ -*-.
4 // Copyright (C) 1999, 2000 Red Hat.
5 // This file is part of SID and is licensed under the GPL.
6 // See the file COPYING.SID for conditions for redistribution.
18 // PART 0: Basic declarations
19 // Together, these numbers describe the API as defined in the
20 // abstract sid:: classes. Every time the API changes, a new number
21 // pair needs to be assigned. These numbers figure in the
22 // COMPONENT_LIBRARY_MAGIC mechanism in sidso.h, and prevents
23 // interopration attempts with obsolete component objects.
25 const unsigned API_MAJOR_VERSION = 2;
26 const unsigned API_MINOR_VERSION = 2;
30 // The abstract class sid::bus defines a function-call oriented
31 // model of a hardware data/address/control bus. It supports a
32 // 32-bit address space, and allows reads and writes with data of
33 // varying lengths. The sid::bus class is the slave that provides
34 // the data. A bus accessor is the bus master which requests the
35 // data. One component's bus accessor is connected to another's bus
36 // with the connect_accessor() method.
41 // status values from read/write calls.
44 ok = 0x00, // done, no problems
45 misaligned = 0x01, // address misaligned
46 unmapped = 0x02, // address not in mapped range
47 unpermitted = 0x04, // may not read or may not write at address
48 delayed = 0x10, // data not yet available - try again after yielding
52 // These member functions enumerate the Cartesian product of all
53 // possible access requests to a bus:
54 // {data-endianness} X {addr-width} X {data-width}
55 // little,big 4 1,2,4,8
57 // Write data at given address.
59 virtual status write(host_int_4 addr, big_int_1 data)
62 virtual status write(host_int_4 addr, little_int_1 data)
65 virtual status write(host_int_4 addr, big_int_2 data)
68 virtual status write(host_int_4 addr, little_int_2 data)
71 virtual status write(host_int_4 addr, big_int_4 data)
74 virtual status write(host_int_4 addr, little_int_4 data)
77 virtual status write(host_int_4 addr, big_int_8 data)
80 virtual status write(host_int_4 addr, little_int_8 data)
83 // Write data from given address.
85 read(host_int_4 addr, big_int_1& data)
89 read(host_int_4 addr, little_int_1& data)
93 read(host_int_4 addr, big_int_2& data)
97 read(host_int_4 addr, little_int_2& data)
101 read(host_int_4 addr, big_int_4& data)
105 read(host_int_4 addr, little_int_4& data)
109 read(host_int_4 addr, big_int_8& data)
113 read(host_int_4 addr, little_int_8& data)
118 virtual ~bus() throw() {}
124 // The abstract pin class is one of the methods by which components
125 // communicate. The sid::pin class represents the input side of a
126 // pin->pin connection. Incoming signals are represented by calls
127 // on the driven() method. Outgoing signals may be sent to other
128 // components' pins after they are given to a component using the
129 // connect_pin() method.
134 // A notification that the pin has been driven with some value.
135 virtual void driven(host_int_4 value) throw () = 0;
139 virtual ~pin() throw() {}
143 // PART 3: Components
145 // The abstract component class is the basic building block of a
146 // simulator. Components are connected together to create complete
147 // simulations. There are several types of connections: pins, buses
153 // Status indications for various calls.
156 ok = 0, // successful
157 not_found = -1, // lookup key invalid
158 bad_value = -2 // illegal parameter
161 // PART 3.1: instantiation
164 virtual ~component() throw() {}
167 // PART 3.2: attributes (SUPERVISORY)
169 // List the names of all your attributes.
170 virtual std::vector<std::string>
174 // List the names of your attributes in a given category.
175 virtual std::vector<std::string>
176 attribute_names(const std::string& category)
179 // Get the value of your named attribute.
180 // Return an empty string on failure.
182 attribute_value(const std::string& name)
185 // Set your named attribute to a given value.
186 // Returns component::ok only if sucessful.
188 set_attribute_value(const std::string& name, const std::string& value)
192 // PART 3.3: pins (SUPERVISORY)
194 // List all your pin names. Include all input pins (for use with
195 // find_pin) and output pins (for use with connect_pin etc.).
196 virtual std::vector<std::string>
200 // Find input pin with given name.
201 // Return a pointer to your pin or 0 if the pin is not found.
203 find_pin(const std::string& name)
206 // Add new connection between your named output pin to given input pin.
208 connect_pin(const std::string& name, pin* pin)
211 // Remove connection between your named output pin from given input pin.
213 disconnect_pin(const std::string& name, pin* pin)
216 // List all pins connected to your named output pin.
217 virtual std::vector<pin*>
218 connected_pins(const std::string& name)
222 // PART 3.4: buses & accessors (SUPERVISORY)
224 // List the names of your buses.
225 virtual std::vector<std::string>
229 // Find a bus of the given name.
230 // Return a pointer to your bus, or 0 if the bus is not found.
232 find_bus(const std::string& name)
235 // List the names of your bus accessors.
236 virtual std::vector<std::string>
240 // Connect your named accessor to a given bus.
242 connect_accessor(const std::string& name, bus* bus)
245 // Disconnect your named accessor from a given bus.
247 disconnect_accessor(const std::string& name, bus* bus)
250 // Return the bus connected to your named accessor.
252 connected_bus(const std::string& name)
256 // PART 3.5: component enumeration (SUPERVISORY)
258 // List the names of your component relationship lists.
259 virtual std::vector<std::string>
263 // Add given component to your named relationship list.
265 relate (const std::string& name, component* comp)
268 // Remove given component from your named relationship list.
270 unrelate (const std::string& name, component* comp)
273 // List components in your named relationship list. Return
274 // empty list if relationship is not found.
275 virtual std::vector<component*>
276 related_components (const std::string& name)