Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

NIOS II Custom Instruction blocks printf

Hi

I am trying to add custom Instruction block to my SOPC Builder Design but i find the printf gets blocked whenever i add custom instruction to my design .I even powered off and powered on by board but still i see that the Printf doesnt print on the console

Custom Instruction is just a combinatorial adder

I am able to see in the registers the addition happening well but the result i am unable to print it on to screen

Please help me out

regards

M Kalyansrinivas

3 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I´m not shure but the first think which comes into my mind was maybe there is something wrong with your Avalon interface in your custom block. So it would help if you can post your HDL Code and the c-File so that we can see how you want to use it.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I´m afraid you forgot to implement the Avalon interface and it´s combinational logig. At least the entity looks somehing like that

    module xyz(CLK, RST, READDATA, WRITEDATA, READ, WRITE, ADRESS);
    input CLK;
    input RST;
    input  READDATA;
    input READ;
    output  WRITEDATA;
    input WRITE;
    input  ADRESS;
    
    At SOPC Builder you conect these signals as Avalon slave to the signals. I think they have the same name or sounds simular.

    You also need some logig to put data on the Avalon inteface if you want to read it from your c-code.

    
    always@ (posedge CLK)
    beginif(WRITE == 1'b1)
    begincase(ADRESS)
    begin
    ...
    end
    end
    else
    begin
    if(READ == 1'b1)
    begincase(ADRESS)
    beginresult_adress: READDATA <= result;
    end
    end
    end
    end
    
    In your c-Code you can then write:

    
    result = IORD_32DIRECT(XYZ_BASE,result_adress);
    
    I´m not sure if that´s all. I´m afraid there is something missing but I think the basics get clear. And I hope it is that what you like to do ;).
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi mki

    Thank you for the reply but i cannot connect the combinatorial logic of dataa and datab to avalon slave as i am trying to make it as a custom instruction

    Custom Instruction will directly connect with the alu instead of being as slave for avalon bridge So i think in custom instruction i should not connect to avalon slave rather i should do it as a nios_custom_instruction_slave

    Thank you

    M Kalyansrinivas