10.1.
Make a list of eight simple instructions you think would be useful and possible to add Parwan.10.2. In Parwan assembly code, write a program to move a block of data that is stored in the memory. The data begins at location 4:00 and ends at 4:63, and is to be moved to page 5 starting at 5:64.
10.3. A block of data in the Parwan memory begins at location 1:00 and ends at 1:63. Write a program in Parwan assembly language to find the largest positive number in these locations.
10.4. Show the VHDL description of the Mark-1 machine whose ISPS description appeared in Figure 1.3 of Chapter 1.
10.5 Write a procedure for reading Parwan memory from an external file. Assume address and data in this file are in hexadecimal number representation and are arranged as shown here:
page : offset data
Name this procedure read_memory and use this subprogram declaration:
PROCEDURE read_memory (addr : IN qit_vector; data : OUT qit_vector;
found : OUT BOOLEAN; file_name : IN STRING);
The read_memory procedure searches an entire memory file for an address that matches its addr argument. If the address is found, it returns the qit equivalent of the data appearing on the same line of the file as the address. If the address is not found, the found parameter is returned as FALSE. File name is used as the parameter so that the file declaration can take place each time the procedure is called.
10.6 Write a procedure for writing Parwan memory to an external file such that the address is passed to this procedure as a qit_vector od size 12, and the data as a qit_vector of size 8. Each time the procedure is called, one line containing address and data should be appended to the end of the file. This information is return to the file in hexadecimal using the format shown here:
page : offset data
Name this procedure write_memory and use this subprogram declaration:
PROCEDURE write_memory (addr : IN qit_vector; data : IN qit_vector;
VARIABLE memory_file : OUT TEXT);
The memory_file parameter in this procedure should be associated with a file object which is declared outside the procedure.
10.7 Rewrite the Parwan test bench such that the memory read and write are done from and to external files instead of to a declared array as they are shown in Figure 10.68. For this purpose, use the procedures developed in Problems 10.5 and 10.6. When a read from the memory is to be done, a call should be made to the read_memory procedure and the data read by the procedure should be placed on the databus. When a memory write is to be done, a call to write_memory should append the address and data to the end of a memory write file. Use this test bench to verify correctness of the changes that you will be making to Parwan in the problems that follow.
10.8 Modify the behavioral description of the Parwan controller such that the jsr instruction can use indirect addressing.
10.9. Suggest a set of instructions for more complete interrupt handling than what is presently available in Parwan.
10.10. Parwan can be modified to use only three bits for distinguishing between various non-address instructions. We can, therefore, reserve bit 3 of the instruction register as an opcode bit for extending Parwan instructions. In addition, two more non-address instructions can be added to the Parwan instructions. Modify the behavioral description of Parwan such that non-address instructions use 11100xxx opcode. For xxx use 000, 001, 010, 011, 100, and 101 for nop, cla, cma, cmc, asl, and asr, respectively.
10.11. Use the method suggested in Problem 10.10 to add an instruction for immediate loading of the accumulator. This instruction can use one of the extra opcodes that become available by modifying opcodes of non-address instructions. For ldi (load accumulator immediate), you may use the 11101000 opcode. The second byte of an ldi contains the byte that is to be loaded into the memory. Modify the behavioral description of Parwan for the execution of this instruction.
10.12. Add a stack pointer to the register and bussing structure of Parwan for the implementation of a software stack. Restrict the stack to the last page of the memory. Use the method of opcode expansion suggested in Problem 10.10 to make room for a new instruction, and use 11101001 for an lds instruction that loads the stack pointer with the data in the next instruction byte. Show all bus connections, registers, and necessary control signals.
10.13. Use the method suggested in Problem 10.10, and the stack pointer of Problem 10.12 to add two new non-address instructions, push and pop. Use 11100110 for push and 11100111 for pop. Modify the behavioral description of Parwan for the execution of these instruction.
10.14. Use the stack implementation in Problem 10.12 to modify the jsr instruction such that it pushes the return address on the top of the stack. Add a new rts instruction that causes a return from the subroutine. For this instruction, use the method of opcode expansion suggested in Problem 10.10, and use 11101010 for its opcode. Modify the behavioral description of Parwan for the execution of these instruction.
10.15. Modify the dataflow description of Parwan for implementing jsr as specified in Problem 10.8.
10.16. Show the dataflow implementation of the opcode extension scheme suggested in Problem 10.10. Show all required bus connections and modify the controller of Parwan.
10.17. Modify the dataflow description of Parwan for the implementation of the ldi instruction as specified in Problem 10.11. Show all required bus connections and modify the Parwan controller.
10.18. Modify the Parwan dataflow description for the implementation of lds, push and pop instructions (see Problem 10.12 and Problem 10.13). Show all required bus connections, write a description for the stack pointer (sp), and insert this unit in the data path description of Parwan. Also, modify the Parwan controller so that it properly executes these instructions.
10.19. Modify the Parwan dataflow description to implement a version of jsr that uses the stack in problems 10.12 (also see Problem 10.14). Show all required bus connections and modify the Parwan controller to properly execute this instructions.
10.20. Use the stack in Problem 10.12 to implement a better interrupt handling for Parwan. The new system should have an int input which becomes ‘1’ when interrupt is requested. The CPU identifies an interrupting device by reading the address of its interrupt service routine from location 0:00 of the memory. To service an interrupt, the CPU jumps to predefined memory locations for each of the interrupt sources. Assume an external priority logic determines the device with highest priority and generates its service routine address. Your solution to this problem should also include implementation of a return_from_interrupt instruction.