Picoblaze Proyect
Picoblaze Proyect
Homework 4
Rana TİLKİ
040180741
CALL / RETURN Stack: The CALL/RETURN hardware stack can store up to 31 instruction addresses. It
provides nested CALL sequences up to 31 levels deep. The CALL instruction executes a program counter
manipulation. With this instruction next instruction address is saved to the stack. With return instruction
the most recent address pops from the stack and resumes execution. Stack is also used in interrupt
operation so when interrupst are enable one of these levels should be allocated. If stack is full, oldest
value is overwrited.
Interrupts: Interrupt causes the microprocessor to stop its work and execute a different code instead it is
called ISR (interrupt service routine). So, this way interrupts can solve response problems without
creating new problems themselves. The picoblaze processor provides a single interrupt signal. For
recognition of the interrupt input signal it must be applied at least 2 clock cycle. After the recognition it
stops executing sequence of instructions that was executing and saves address of the next instruction to
be executed on the stack. the Picoblaze processor calls 3FF instruction by the force of interrupt. The CALL
3FF instruction subroutine calls the last memory location of program. 3FF location is an instruction
location that jumps to ISR. Then executes it. After the execution of ISR returns from ISR with a RETIRNI
command. Pops address from stack and continues normal execution of next instruction.
#ifDef proc::xPblze6
#set instmem::pageCount, 1
#endIf
COMP s0, 255 ;if s0 < 255 C will be set and equals 1
end: JUMP end ;if C != 1, it means s0 = 255, end the main code
isr: load s2, 1 ;It is stated that there is an interrupt so, increment interrupt counter equals 1
CALL critical_timing
RETI DISABLE ;Executes a return at the end of an interrupt and disables further interrupts
ADD s2, 1 ;It is stated that there is an interrupt so, increment interrupt counter by 1
COMP s2, 10 ;Continue with critical_timing loop until there are 10 interrupts
#ORG ADDR, 4095 ;Presets the memory address of the following instruction to 0
After the interrupts instructions continue from where they left off.
In Vivado top module is modified. The interrupt_0 signal is connected to the top port like below:
entity top is
interrupt_0 : in STD_LOGIC;
);
end top;
And also interrupt => interrupt_0 is connected in picoblaze: kcpsm6 port map.
begin
end process;
process
begin
end process;
end Behavioral;
In simulation inteerupt is given after 2000ns and with 30ns intervals which is bigger than 2 clock cycle.
Then simulation is run.
When Interrupt (interrupt_0) is given after 2000 ns, 10 interrupt enable signals (interrupt_enable) are
observed as in above figure. s2 also counts the interrupts from 0 to 0A. Through the interrupt routine s0
is stays at 18 which is the value when interrupt is begin.
And below figure shows that after the interrupt routine ends pc returns 003 again.
For 32 Nested Interrupts;
In Fidex code nothing has changed except COMP s2, 32 to count 32 interrupts.
As it can be seen from below, when the interrupt is given s0 = 0E. 31 interrupts is observed and for 32nd
interrupt stack overflow error is given and execution stops. The reason of this error is program counter
stack can store up to 31 instruction addresses.
process
begin
end process;
When Interrupt (interrupt_0) is given after 4000 ns, 31 interrupt enable signals (interrupt_enable) are
observed as in above figure. 32nd interrupt cannot be observed because of the stack overflow. s2 also
counts the interrupts from 0 to 0e. Through the interrupt routine s0 is stays at 31 which is the value
when interrupt is begin. This can be ovserved from above and below figures.
Above figure shows when interrupt routine begins, pc is at 003.
And below figure shows that after the interrupt routine ends it is observed that pc returns 000 not 003. It
is because of the stack overflow. Therefore, after the interrupt routine ends s0 value will be 0 again
because of returning the address 000.