it252.groups.et.byu.netit252.groups.et.byu.net/17wi/labs/good write-up.doc · web viewlab 6: add...

11
(Name Deleted) IT 252 Section #1 Lab 6: Add Instructions to the VHDL CPU Objective: At the end of this lab, you should have either added to your VHDL CPU instructions from last lab, keeping the old instructions and just adding to it, or made a new VHDL file, copying the style and syntax from the file from last lab, and then change the instructions to match the set of instructions for this lab. In the end you should have 7 instructions; subtract, xor, or, and, add immediate, jump positive, jump zero. You should also be able to test and show the end result of both the true and false cases for both jumps. Procedures: Open up Quartus II in the lab. Enter either the information for Quartus to recognize the license for the IT department. At the project page you can either create a new project and name it scomp2 or scompmorefunctions, just so the project can differ from your last project, or just copy all your lab 5 files into a new folder named lab 6 and then open an existing project in Quartus and open scomp, just make sure you know which project is which and not overwrite something you didn’t want to. When project set up is complete, read over the directions of this lab fully. It will be very similar to the last project, just with more functions to add. From this point on, if you are making a new project, you will have to download the .mif and .vhdl sample files and re-edit them, otherwise you will work from your old project. From here, make a diagram or a flow chart of how you want your .mif file to work and when and where to call the functions and what values you are going to pass that function. Once you

Upload: others

Post on 23-Sep-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: it252.groups.et.byu.netit252.groups.et.byu.net/17wi/labs/good write-up.doc · Web viewLab 6: Add Instructions to the VHDL CPU Objective: At the end of this lab, you should have either

(Name Deleted)IT 252Section #1

Lab 6: Add Instructions to the VHDL CPU

Objective:

At the end of this lab, you should have either added to your VHDL CPU instructions from last lab, keeping the old instructions and just adding to it, or made a new VHDL file, copying the style and syntax from the file from last lab, and then change the instructions to match the set of instructions for this lab. In the end you should have 7 instructions; subtract, xor, or, and, add immediate, jump positive, jump zero. You should also be able to test and show the end result of both the true and false cases for both jumps.

Procedures:

Open up Quartus II in the lab. Enter either the information for Quartus to recognize the license for the IT department. At the project page you can either create a new project and name it scomp2 or scompmorefunctions, just so the project can differ from your last project, or just copy all your lab 5 files into a new folder named lab 6 and then open an existing project in Quartus and open scomp, just make sure you know which project is which and not overwrite something you didn’t want to.

When project set up is complete, read over the directions of this lab fully. It will be very similar to the last project, just with more functions to add. From this point on, if you are making a new project, you will have to download the .mif and .vhdl sample files and re-edit them, otherwise you will work from your old project.

From here, make a diagram or a flow chart of how you want your .mif file to work and when and where to call the functions and what values you are going to pass that function. Once you have created this chart, you will have an easier time putting together your functions in the .vhdl and the instructions in the .mif file.

At this point, move to your .vhdl file and add the additional functions that are going to be used. For the arithmetic functions, I recommend copying the add function and pasting it five times, then editing it like the example on the instruction page on the website. Add immediate will be the most detailed instruction, so I recommend looking at the tutorial on VHDL for helpful hints and tips on how to right the instructions. If you understand what add immediate is supposed to do, but don’t fully understand how you are going to implement it, then call over the TA/TA’s and he/she/they will help you.

Once the arithmetic instructions are done, you have the jump positive and jump zero functions left to do. I would copy the jump function and modify it from there. I would recommend doing the negative test first of either jump, both in your instruction in the .mif file and in the function definition in your .vhdl, that way when you are testing, you can just go to

Page 2: it252.groups.et.byu.netit252.groups.et.byu.net/17wi/labs/good write-up.doc · Web viewLab 6: Add Instructions to the VHDL CPU Objective: At the end of this lab, you should have either

the next instruction line in your code instead of having to jump someplace then jump back, although that way works just as well. Either way make sure you know where the next instruction is coming from and from what line the instruction in being read.

Once you have all the new instructions written in the .vhdl file, make sure you have defined your new functions up at the top in the state define section and also at the bottom in that state section as well. The bottom section you will model after the add instruction already there on all seven of the new functions. Once completed, assign the appropriate pins, which are the clock, all the registers and memory outs, the program counter, reset, and the state register (delete any duplicates that show up), compile, and handle any of the errors that show up. The main errors will most likely be that you forgot to define a function up at the top, so recheck your definitions, and recompile. If a problem still persists, seek the help of a TA.

Once your .vhdl compiles with no errors, it is time to have fun in your .mif file. This is where you can get creative in your order of instructions and values given, the key is to remember what each instruction is doing and to make sure you have used each case, including the true and false cases for the jumps.

Once the .mif is looking how you would like it to look, save it and open the .mif file in Quartus. Once there, recompile just for good measure and then run a simulation. Scroll through your simulation waveform and check to see that every function is being used and it is doing what you thought it should do. If a function in not doing the appropriate instruction or if the wrong values are being used, you need to go back to your .mif and make sure your instructions have the right pointers to the right instruction lines.

If no miscalculations are apparent, then go to your .vhdl file and look at your instruction definitions. If everything makes logical sense and you can’t figure out what is wrong, ask help from a TA. Once your miscalculations are fixed either by you going back and finding it or the TA helping you, recompile and run the simulation again. Keep checking and repeating this process until everything functions as it should and then pass of with your TA. At this point, take screenshots of each of your functions in the waveform and then explain them and their values, for a total of 9 screenshots there among any others you feel would benefit you.

Screenshots on next page…

Page 3: it252.groups.et.byu.netit252.groups.et.byu.net/17wi/labs/good write-up.doc · Web viewLab 6: Add Instructions to the VHDL CPU Objective: At the end of this lab, you should have either

Add Immediate:

And Instruction:

Page 4: it252.groups.et.byu.netit252.groups.et.byu.net/17wi/labs/good write-up.doc · Web viewLab 6: Add Instructions to the VHDL CPU Objective: At the end of this lab, you should have either

Jump Positive True:

Jump Positive False:

Page 5: it252.groups.et.byu.netit252.groups.et.byu.net/17wi/labs/good write-up.doc · Web viewLab 6: Add Instructions to the VHDL CPU Objective: At the end of this lab, you should have either

Jump Zero True:

Jump Zero False:

Page 6: it252.groups.et.byu.netit252.groups.et.byu.net/17wi/labs/good write-up.doc · Web viewLab 6: Add Instructions to the VHDL CPU Objective: At the end of this lab, you should have either

Or Instruction:

Subtract Function:

Page 7: it252.groups.et.byu.netit252.groups.et.byu.net/17wi/labs/good write-up.doc · Web viewLab 6: Add Instructions to the VHDL CPU Objective: At the end of this lab, you should have either

Xor Instruction:

Lab Compilation for Gates Used:

Page 8: it252.groups.et.byu.netit252.groups.et.byu.net/17wi/labs/good write-up.doc · Web viewLab 6: Add Instructions to the VHDL CPU Objective: At the end of this lab, you should have either

Ending Infinite Loop Jump:

References:

http://it252.groups.et.byu.net/11wi/labs/instructions.phphttp://it252.groups.et.byu.net/11wi/labs.phphttp://it252.groups.et.byu.net/11wi/labs/lab6/http://it252.groups.et.byu.net/11wi/labs/lab5/A_Simple_Computer_Design.pdfhttp://www.eng.auburn.edu/department/ee/mgc/vhdl.htmlLab 5 Files – Names deleted

Results:

I think we performed about averagely. We got the concepts and code fairly quickly into the lab, but we got stuck on some weird error that kept us stuck for over an hour, so we had to come back the next lab period. On that next lab period, the replacement TA happened to have the same problem in their program and showed us the problem, which was literally one line “off”, not incorrect, just semantically wrong, so we fixed it and were passed off within five minutes. I then stayed to help the TA because I just thought I should. It ended up that besides us, only one group from that section passed off and only one other got close, so maybe our group got the concepts better than this second group, but in either case that is why I said we were average.

Page 9: it252.groups.et.byu.netit252.groups.et.byu.net/17wi/labs/good write-up.doc · Web viewLab 6: Add Instructions to the VHDL CPU Objective: At the end of this lab, you should have either

Conclusion:

This lab matters because if gives us another opportunity to understand VHDL and more importantly how instructions in x86 (Y86) are basically constructed and used and how you can quicken compile and runtime depending on the order that your code in.

I think the main principle that can be applied here to your career is debugging. In this lab especially, there are a lot of multiple variable and functions, so they can be confused very easily. Even if the program might work, it could be getting the wrong values, thus giving you the wrong information. You have to be able to asses and debug these types of problems as they arise in real life so you can correct them before a real error is made and money and resources are lost.

Even though there weren’t any direct questions in the lab, there is something I did notice about the lab. This lab not only teaches us more about instruction sets, but it also makes us be aware of all cases, not the just optimal cases. Not all the time in real life will we get the optimal results and we have to be able to see that and adjust the values. It is not only the program that could be wrong, but it might be the values you are giving it. The program could have absolutely no errors with it, but the values given to you were unquestioned and so everybody thinks these values are correct. Always double check the data given to make sure it is correct and if there is any doubt, address the person(s) that calculated the data and “resolve the differences.”