Laboratory 2 using the PowerPC simulator

This page is essentially the same as the 68K page that gave the final instructions on getting the virtual device running. However, there are many specific details that are different. You might like to try your own version of WIDFI and see if you can get the virtual device to work on the PowerPC before reading about the details.


Final instructions for Laboratory 2 on the PowerPC simulator

Now that you have seen that the virtual COFFEEPOT actually works, you now need to develop the code to control it yourself.

You should experience no difficulty in linking the files, but is you do, follow the link for solving certain linker errors.


Controlling the COFFEEPOT device

You are going to make the coffeepot device perform the activities discussed earlier.

	Place_COFFEEPOT_on_DATA_BUS
	INIT_COFFEEPOT

	while (temperature < BOILING) 
		Apply_Heat 
	end_while 

	Signal_Water_Boiled 

	while (time < TOO_LONG) 
		Apply_Low_Heat 
	end_while 

	Signal_Coffee_Ready

You will need to make use of the data sheets on the COFFEEPOT device. I am only going to provide some general examples on accessing the device registers. The control of the loops is your responsiblity. You'll have to use the examples in HVZ to guide you, together with the information provided about for and while loops.


Limitations of the COFFEEPOT device

The virtual device operation is handled by introducing some complex operations during an interrupt service routine. This interrupt service routine was complicated to develop to work with a real processor on an evaluation board. It was doubly difficult on the SDS PowerPC demo simulator which only supported one of the different types of interrupts available on a processor.

The reason that you did not need to specify which PowerPC processor to simulate is that they all have the same interrupt handling methods. The PowerPC RISC approach to interrupts is both easier and more difficult to handle than interrupts on the 68K CISC processors,

Because of the problems with the simulator, I again limited myself to generating virtual devices that operate with a limited number of instructions. These were the typical operations you would perform -- moving values to and from the device.

The operations are, unfortunately, even more limited on the PowerPC device than they were on the 68K. Again there were more problems with the limitations on the PowerPC starter kit than with the 68K kit. The major limitation is the use of the PowerPC registers. The virtual device will only work if the

Watch my web page for possible new devices after we have explored the limitations associated with the new PowerPC Version 7.X demo kit release.

Note that you MUST use register R4 for the data value and R3 for the address value and no others. The SDS PowerPC demo simulation was much more crippled than the 68K simulation and I was unable to create the type of interrupts I needed to get a greater flexibility of the available registers. You only need two instructions any way.


Controlling the COFFEEPOT device

You must first install the COFFEEPOT device on the PowerPC buses using the InitCoffeePot() subroutine. This places the device so that its BASEADDRESS is at memory location 0x20000. If you read the COFFEEPOT data sheets you will see that, for example, that the C_CONTROL register is described as having an offset of 0x20. This offset is relative to the base address of the device. Thus the COFFEEPOT C_CONTROL register will respond when the processor places the value 0x20020 (0x20000 + register offset 0c20) on its address bus. The other registers will respond in a similar way.

If a second COFFEEPOT is installed on the PowerPC buses (possible with the COFFEEPOT device from the "Full Companion") with a baseaddress of 0x40000, then that COFFEEPOT device would have a C_CONTROL register that would respond to address 0x40020.

After you have installed the COFFEEPOT device, and sent a RESET signal to the device's control register (C_CONTROL), you will find that you can

You will find that, unlike the 68K COFFEEPOT device, the PowerPC device is alot more sophisticated. Mistreat it and, just like a real device it will start "smoking" and other unpleasant "simulated" events will occur.

The following code shows how to activate the water valves and read the water temperature, all necessary tasks in controlling a typical device.

# Directly include the code from a PowerPC version of "cof020.i"
# as the demo version of the DIAB DATA assembler does not support
# the .include directive
COFFEEPOT_BASEADDRESS 	.equ 0x20000

	ADDIS R3, 0, COFFEEPOT_BASEADDRESS@ha	# Set the address pointer
	ADDI R3, R3, COFFEEPOT_BASEADDRESS@l

	ADDI R4, 0, START_WATER			# Set the value
	STW R4, C_WATER(R3)			# Activate the device

	LWZ C_TEMPERATURE(R3), R4		# Read the temperature

You'll have to modify a copy of cof020.i to the PowerPC syntax and add it directly in your PowerPC source file. The starter-kit DIAB assembler does not support the "include" directive. The translation is the sort of task you could be expected to have to perform if your company switched processors. This file contains all the register offsets and constants needed to control the device.

For the rest of Laboratory 2, you are on your own. PLEASANT PERKING



Last modified: July 22, 1996 10:01 PM by M. Smith.
Copyright -- M. R. Smith