4

I am a student and I have to create an PicoBlaze 8-bit Microcontroller based on this documentation XAPP213.

I have a problem when I have to run a jump or call instruction:

When I jump or call the next instruction I forced to be a NULL instruction and thus my Program Counter(witch gives me my new ADDRESS) remains the same meaning that he holds for 2 clocks the same address and for that reads two times the instruction on witch I jumped or I called.

What can I do to not let that happen?

Here is my Program Counter code if it helps:

library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.STD_LOGIC_UNSIGNED.all;
use IEEE.NUMERIC_STD.all;

entity DL_PROGRAM_COUNTER is
     port(
         SELECT_1 : in BIT;
         SELECT_0 : in BIT;
         CARRY_IN : in BIT;
         CLK : in BIT;
         RESET : in BIT;
         ADR : in BIT_VECTOR(7 downto 0);
         IESIRE_STACK : in BIT_VECTOR(7 downto 0);
         ADDRESS : out BIT_VECTOR(7 downto 0)
         );
end DL_PROGRAM_COUNTER;

--}} End of automatically maintained section

architecture DL_A_PROGRAM_COUNTER of DL_PROGRAM_COUNTER is
component DL_GENERIC_MUX is 
    generic (Numar_biti_selectie: NATURAL :=1; Numar_biti_cale_date: NATURAL:=1);

    port (date: in BIT_VECTOR(0 to (2**Numar_biti_selectie)*Numar_biti_cale_date - 1);  -- date <= a0 & a1
          sel: in BIT_VECTOR(Numar_biti_selectie-1 downto 0);
          Y: out BIT_VECTOR(Numar_biti_cale_date-1 downto 0)
          );
end component;

component DL_GENERIC_REGISTRU_PASTRARE is
    port(date: in BIT_VECTOR(7 downto 0);
         clk,ce,reset: in BIT;
         Q: out BIT_VECTOR(7 downto 0)
        );
end component;

signal intermediar,iesire_1,iesire_0,aresa_urmatoare: BIT_VECTOR(7 downto 0);
signal date1,date0: BIT_VECTOR(0 to 15);
signal sel1,sel0: BIT_VECTOR(0 downto 0);

begin

COPIERE1: process(intermediar,ADR)
begin
    for k in 0 to 7 loop
        date1(k) <= intermediar(7-k);
        date1(8+k) <= ADR(7-k);
    end loop;
end process;
sel1(0) <= SELECT_1; 

MUX1: DL_GENERIC_MUX generic map(1,8) port map(date1,sel1,iesire_1);

COPIERE0: process(iesire_1,IESIRE_STACK)
begin
    for k in 0 to 7 loop
        date0(k) <= iesire_1(7-k);
        date0(8+k) <= IESIRE_STACK(7-k);
    end loop;
end process;
sel0(0) <= SELECT_0;

MUX2: DL_GENERIC_MUX generic map(1,8) port map(date0,sel0,iesire_0);

ADDER:process(iesire_0,CARRY_IN)
variable rez: INTEGER;
begin
    rez := CONV_INTEGER(TO_STDLOGICVECTOR(iesire_0));
    if CARRY_IN = '1' then
        rez := rez + 1; 
    end if;
    aresa_urmatoare <= TO_BITVECTOR(STD_LOGIC_VECTOR(TO_UNSIGNED(rez, aresa_urmatoare'length)));
end process;

REGISTRU: DL_GENERIC_REGISTRU_PASTRARE port map(aresa_urmatoare,CLK,'1',RESET,intermediar);

ADDRESS <= intermediar;

end DL_A_PROGRAM_COUNTER;

Here is a block diagram of what it looks like: Program Counter Block Diagram

for jump:

select_1 <= '1';
select_0 <= '0';
carry_in <= '0';

for call:

select_1 <= '1';
select_0 <= '0';
carry_in <= '0';

for NULL instruction:

select_1 <= '0';
select_0 <= '0';
carry_in <= '0';
Paebbels
  • 15,573
  • 13
  • 70
  • 139
Tandura
  • 866
  • 2
  • 7
  • 19
  • Since you're a student, I recommend you ask your TA (maybe write an email?). Maybe they can help you, since you're probably not the only one with this question. – Peanut May 06 '15 at 07:53
  • 1
    I already asked and he told me that the only way he knows is using prediction and that is too hard to try to do it now. It really is not another way? – Tandura May 06 '15 at 07:57
  • I do not understand. For example if I what to JUMP to `"1F"` address he is going there and runs two times what is there. For example if I want to ADD to register 4 the constant 3 ("ADD 4,03") he is going to actually add 6 – Tandura May 06 '15 at 08:28
  • 1
    The picoblaze uses two clock cycles per instruction, so I wonder if the answer is to change the problem from "JUMP takes two cycles" to "most other instructions take only 1 cycle"; if the others all took 2 cycles (like they do in the picoblaze), perhaps what you've described here can be worked around more easily. – scary_jeff May 06 '15 at 11:16

0 Answers0