Date: Sat, 6 Apr 2019 01:47:47 -0500
From: "Yale N. Patt"
To: a.deshmukh@utexas.edu, mohammadbehnia@utexas.edu, chestercai@utexas.edu
Subject: Lab 4 problem
Message-ID: <20190406064747.GD28848@ece.utexas.edu>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.5.21 (2010-09-15)

My students, my answer to this student's question is longer than usual,
so if you are having no trouble understanding what is expected, feel free
to delete and move on.

A student writes, (a) because he has technical questions about Lab 4, and
(b) because he wants more time to do the lab, even though he really does
not have a great excuse.

> Dear Dr. Patt,
>
> Looking at the lab 4 document, I noticed the first question on the FAQs
> says that we only need to simulate the generation of the timer interrupt.
>
> "1. Are we changing the datapath/state diagram to detect or generate the
> interrupt or exception?
>
> As part of this lab, you are changing the datapath and state diagram to
> detect both the protection exception and the timer interrupt. However, you
> are only simulating the generation of the timer interrupt."

I guess we need to look carefully at what your task is on lab 4. You have the
results of lab 3, where you had to add control signals to process each of
the LC-3 instructions. What instruction you process at any point in time
depends on where you are in executing your program.

In this lab you need to add whatever it will take to process (i.e., handle)
the timer interrupt and the three exceptions (i.e., unaligned access, unused
opcode, and protection). That means adding more states, data path and
microsequencer structure to be able to detect and handle each of these four
different events when they show up.

In the case of exceptions, you do not need to add anything to your Simulator
to make them show up. They will show up as a result of problems in a program.
Your job: Detect them with your additional microarchitecture states if they
show up. The timer interrupt should also show up at its expected time interval.
However, the timer interrupt is part of the hardware. That is, the program
will not cause the timer interrupt to happen. We need something to cause the
timer interrupt to happen at 300 cycles so the lab 4 additions to your
microarchitecture can handle it. A piece of code that you will write to
simulate the timer interrupt will do.


> Does this mean we would need to include microarchitecture support for the
> generation of the timer interrupt or only for its detection?

Only for its detection and processing. We are adding the following
paragraph to the lab description. Perhaps you will find it useful:

Micro-architecture support needs to be added only for detecting interrupts,
not generating them. You can generate the interrupt as follows: Since you
are simulating an interrupt at cycle 300, you can have an if() statement in
the cycle() function that sets the interrupt vector (INTV) to the appropriate
value at cycle 300 using the CYCLE_COUNT variable. Recall that unlike
exceptions, you can check for interrupts and deal with them whenever it is
convenient for you to do so. That is, you do not have to deal with the
interrupt immediately, you may choose to deal with the interrupt whenever
it is convenient for you

> In other
> words, I implemented the timer interrupt in the form of a current register
> that's decremented each cycle. Would I need to include support for loading
> and decrementing this current register in the datapath or simply for
> checking if the current register is zero to trigger the interrupt?
>
> Also do we only need to detect the protection exception and timer interrupt
> in the microarchitecture, or should we detect the other exceptions as well?

As I said above, you need to augment the microarchitecture so it can detect
and process three exceptions.

> I also would like to ask you to extend the lab 4 deadline if possible. This
> past week has been very busy for me, and I haven't been able to get as much
> work done on this lab as I had planned.

Not really the greatest excuse in the world. But I do think lab 4 is the
most demanding lab, so I will give you two more days to do it. New due date,
Next Tuesday night at 11:59pm. I hope that extra time results in a lot of
high grades. It is going to cost you two days in the time available for lab 5.

> Thank you,
> >

You are welcome. Good luck finishing this lab by Tuesday night.

Yale Patt