реклама на сайте
подробности

 
 
3 страниц V  < 1 2 3 >  
Reply to this topicStart new topic
> некоторые вопросы по написанию софта для NIOS II
RHnd
сообщение Oct 6 2007, 06:48
Сообщение #16


Знающий
****

Группа: Свой
Сообщений: 518
Регистрация: 12-04-07
Из: Санкт-Петербург
Пользователь №: 26 997



Я сейчас посмотрел ваши даташиты со структурами - это pdf от 2003 года. В последних версиях литературы (7.1) в пункте software programing model стали писать уже о макросах, типа того, что я привел выше.

PS: Сейчас глянул наискосок версию 7.2 - самую последнюю. Такое ощущение, что они из документации вообще описание API убрали, типа смотрите в таких-то h-файлах. Или мне показалось?
Go to the top of the page
 
+Quote Post
Mozart
сообщение Oct 9 2007, 06:45
Сообщение #17


Частый гость
**

Группа: Свой
Сообщений: 154
Регистрация: 16-08-07
Из: Москва
Пользователь №: 29 829



таймер в ISS не работает, проверено... PIO работает... по крайне мере если изменять значения PIO потом при помощи printf выводить в консоль, то выводит то, что надо... а таймеру в документации еаписано ясно что нужно тактирование clk... прям в самом начале, если нужна какая-то задержка то можно воспользоваться "usleep()" в #include "unistd.h"...

p.s. вообще писать софтинку под ниос просто как оказалось... нужно терпение только... ну как обычно...


--------------------
все косяки, даже о которых не знает сам разработчик, - мои
Go to the top of the page
 
+Quote Post
Волощенко
сообщение Oct 9 2007, 09:03
Сообщение #18


Местный
***

Группа: Свой
Сообщений: 347
Регистрация: 16-02-06
Из: г.Николаев, Украина
Пользователь №: 14 377



Цитата(Mozart @ Oct 9 2007, 09:45) *
таймер в ISS не работает, проверено...
У меня пока тот же результат, но есть утверждения, что должен работать (вот два):

1. http://forum.niosforum.com/forum/index.php?showtopic=322
The iss supports simulation of the following peripherals:
. memory (ram/rom)
. avalon timer
. avalon jtag uart
. avalon uart

2. http://forum.niosforum.com/forum/index.php?showtopic=5418
"If any unsupported components are present in the system, the ISS displays a warning message at the start of the run or debug session. The ISS ignores writes to unsupported components during simulation. Reading from an unsupported component during simulation returns zero.
suported component list:

-All Nios II processor cores: Nios II/f, Nios II/s, Nios II/e
-Interval timer core
-JTAG UART core
-UART core
-On-chip memory (RAM/ROM)
-SDRAM controller core
-IDT71V416 SRAM (1 MB SRAM mounted on Nios development board)
-EPCS serial flash controller core, with limitations."

And here is aditonal limitations of ISS:

Simulations are functional only, and not cycle-accurate.
The ISS does not model Nios II instruction and data caches, and will not find bugs involving cache initialization, flushing, or bypassing.
The ISS does not support reading or writing tightly coupled memories connected to the Nios II processor.
The ISS does not support custom instructions.



3. А это взято из Nios II IDE Help

Instruction Set Simulator (ISS)
The Nios II instruction set simulator (ISS) allows you to execute and debug Nios II programs in simulation on a host PC. The ISS simulates software executing on a Nios II processor core connected to a limited set of peripherals. The simulation is at the functional level, and all operations complete in one cycle. It is not a cycle-accurate simulation, and therefore performance benchmarking on the ISS gives optimistic results. On a modern Windows PC, the ISS runs at about 300K instructions per second when simulating code on the fast example design provided in the Nios II Embedded Design Suite.
The ISS can produce an execution trace. The trace output appears in the Console view, and you can optionally redirect it to a file. It is common to output trace data to a file, because trace tends to produce a large amount of information.

ISS-supported SOPC Builder components:
- All Nios II processor cores: Nios II/f, Nios II/s, Nios II/e
- Interval timer core
- JTAG UART core
- UART core
- On-chip memory (RAM/ROM)
- SDRAM controller core
- IDT71V416 SRAM (1 MB SRAM mounted on Nios development board)
- EPCS serial flash controller core, with limitations.
If any unsupported components are present in the system, the ISS displays a warning message at the start of the run or debug session. The ISS ignores writes to unsupported components during simulation. Reading from an unsupported component during simulation returns zero.

SOPC Builder system requirements:
The Nios II ISS simulates a Nios II processor system described by an SOPC Builder system file (.ptf). The Nios II ISS makes the following assumptions about the SOPC Builder system:
- SOPC Builder successfully generated the .ptf file.
- All memories with initialized content are initialized from one .elf file.
- The system contains exactly one Nios II CPU. The ISS does not support multiprocessor systems.
- The system has one clock domain.
- The system has one address map. (This is true for all Nios II systems created by SOPC Builder.)

ISS limitations:
- Simulations are functional only, and not cycle-accurate.
- The ISS does not model Nios II instruction and data caches, and will not find bugs involving cache initialization, flushing, or bypassing.
- The ISS does not support reading or writing tightly coupled memories connected to the Nios II processor.
- The ISS does not support custom instructions.
- The ISS models the Nios II ienable register as a complete 32-bit register. In hardware (both on a target board and in HDL simulation), all bits associated with unused interrupt inputs are always zero.
- The EPCS Serial Flash Controller core only supports boot-from-flash behavior. If the SOPC Builder system contains an EPCS Serial Flash Controller core, the simulation does not model the full behavior of the EPCS device. The ISS only models the first 1 Kbytes of the controller's register map as a block of ROM. In the case that the processor resets to the EPCS controller address (the typical boot-from-flash scenario), the simulation relies on the fact that RAMs are pre-initialized. Therefore, the controller's boot-loader does not need to copy code from EPCS memory to RAM. Instead, the controller simply jumps directly to RAM.
Go to the top of the page
 
+Quote Post
Mozart
сообщение Oct 10 2007, 10:16
Сообщение #19


Частый гость
**

Группа: Свой
Сообщений: 154
Регистрация: 16-08-07
Из: Москва
Пользователь №: 29 829



техническая документация нас спасёт...
Цитата
The Timeout Period setting determines the initial value of the periodl
and periodh registers. When the Writeable period setting is enabled, a
processor can change the value of the period by writing periodl and
periodh. When Writeable period (see below) is off, the period is fixed
and cannot be updated at runtime.

сейчас проверю это утверждение...
у меня такой код получился
Код
volatile np_timer *timer = TIMER_BASE;

void InitTimer1(void)
{
    timer->np_timerperiodl = 0xffff;
    timer->np_timerperiodh = 0xffff;
    timer->np_timercontrol = np_timercontrol_start_mask + np_timercontrol_cont_mask;
}

void delay(void)
{
    while(timer->np_timerstatus & np_timerstatus_to_mask);
    timer->np_timerstatus = 0;
    
}
    
int main(void){
    while(1)
    {
        delay();
        printf(" ok ");
    }
    
    return  0;  
}

как я понимаю при изменении timer->np_timerperiodl и timer->np_timerperiodh вывод "ок" должен быть с различной скоростью... может быть в железе так и есть.. но при симуляции т.е. ISS ничего подобного.... в сопс билдере я изменил период с мС до С....

Сообщение отредактировал Mozart - Oct 10 2007, 10:40


--------------------
все косяки, даже о которых не знает сам разработчик, - мои
Go to the top of the page
 
+Quote Post
RHnd
сообщение Oct 10 2007, 14:44
Сообщение #20


Знающий
****

Группа: Свой
Сообщений: 518
Регистрация: 12-04-07
Из: Санкт-Петербург
Пользователь №: 26 997



Это вы так цитату вставили или действительно забыли Init перед while(1) запустить?
Go to the top of the page
 
+Quote Post
Mozart
сообщение Oct 11 2007, 09:12
Сообщение #21


Частый гость
**

Группа: Свой
Сообщений: 154
Регистрация: 16-08-07
Из: Москва
Пользователь №: 29 829



это я действительно забыл инит вставить... вставил всё равно не пашет... зато появился варнинг...
Цитата
Warning : SOPC Builder system component pio_led is not supported by the simulato
r. Simulation may be incorrect if your software attempts to access it
но это ничего страшного... мдаа... smile3046.gif


--------------------
все косяки, даже о которых не знает сам разработчик, - мои
Go to the top of the page
 
+Quote Post
Manfred
сообщение Oct 15 2007, 10:22
Сообщение #22


Участник
*

Группа: Участник
Сообщений: 54
Регистрация: 29-08-07
Из: Красногорск
Пользователь №: 30 128



Можно как-то получить программу на ассеблере? - во что компилятор преврящает С код

Как ускоряется процесс записи в переферийные регистры (использую IOWR()) - сейчас интервал составляет аж 40 тактов из-за вызовов функций, на самом быстром Ниосе - переферийное устройство Slave Avalon

Сообщение отредактировал Manfred - Oct 15 2007, 10:28
Go to the top of the page
 
+Quote Post
Mozart
сообщение Oct 15 2007, 13:12
Сообщение #23


Частый гость
**

Группа: Свой
Сообщений: 154
Регистрация: 16-08-07
Из: Москва
Пользователь №: 29 829



у меня вообще железки нету... я чувствую себя ущербным каким-то...
Цитата
Как ускоряется процесс записи в переферийные регистры (использую IOWR()) - сейчас интервал составляет аж 40 тактов из-за вызовов функций, на самом быстром Ниосе - переферийное устройство Slave Avalon
я уже на такие вещи натыкаюсь и не раз... железки нету чтобы проверить, но если это повально у всех... то НИОС мягко говоря не оч хорошо...

меня nios2 ide добивает потихоньку... то симуляция идёт нормально то тормозит со страшной силой... то debug as nios ISS запускается, то посылает на три буковы... чаще посылает...
исходничек
Код
int main(void){
    InitPioLed();
    InitTimer1();
    InitTimerM();
//    printf("timer->np_timerperiodl = %d \n", timer->np_timerperiodl);
//    printf("timer->np_timerperiodh = %d \n", timer->np_timerperiodh);
//    printf("timer->np_timercontrol = %d \n", timer->np_timercontrol);
    //usleep(10000);
    unsigned char DataInPort = 101;
    DataInPort = IORD_ALTERA_AVALON_TIMER_STATUS(TIMER_BASE);
    printf("%d \n",  DataInPort);
    //usleep(10000);
    IOWR_ALTERA_AVALON_TIMER_STATUS(TIMER_BASE, 0x3);
    printf("%d \n", IORD_ALTERA_AVALON_TIMER_STATUS(TIMER_BASE));
    //usleep(10000);
    while(1)
    {
        //delay();
//        printf(" timer->np_timersnapl = %d ", timer->np_timersnapl);
//        printf(" timer->np_timersnaph = %d ", timer->np_timersnaph);
//        printf(" timer->np_timerstatus = %d \n", timer->np_timerstatus);
       // while(timer->np_timerstatus & np_timerstatus_to_mask);
        //led_pio->np_piodata = DataInPort;
        //delay();
        DelayM();
        printf(" ok \n");
        
        DataInPort = IORD_ALTERA_AVALON_TIMER_STATUS(TIMER_BASE);
        printf("%d \n",  DataInPort);
        usleep(10000);
        printf("%d \n", IORD_ALTERA_AVALON_TIMER_STATUS(TIMER_BASE));
        usleep(10000);
    }
    
    return  0;  
}

Код
int main(void){
0x00000310 <main>:     addi  sp,sp,-12
0x00000314 <main+4>:   stw   ra,8(sp)
0x00000318 <main+8>:   stw   fp,4(sp)
0x0000031c <main+12>:  mov   fp,sp
    InitPioLed();
0x00000320 <main+16>:  call  0x2e4 <InitPioLed>
    InitTimer1();
0x00000324 <main+20>:  call  0x200 <InitTimer1>
    InitTimerM();
0x00000328 <main+24>:  call  0x238 <InitTimerM>
//    printf("timer->np_timerperiodl = %d \n", timer->np_timerperiodl);
//    printf("timer->np_timerperiodh = %d \n", timer->np_timerperiodh);
//    printf("timer->np_timercontrol = %d \n", timer->np_timercontrol);
    usleep(10000);
0x0000032c <main+28>:  movi  r4,10000
0x00000330 <main+32>:  call  0xd60 <usleep>
    unsigned char DataInPort = 101;
0x00000334 <main+36>:  movi  r2,101
0x00000338 <main+40>:  stb   r2,0(fp)
    DataInPort = IORD_ALTERA_AVALON_TIMER_STATUS(TIMER_BASE);
0x0000033c <main+44>:  movui r2,32800
0x00000340 <main+48>:  ldwio r2,0(r2)
0x00000344 <main+52>:  stb   r2,0(fp)
    printf("%d \n",  DataInPort);
0x00000348 <main+56>:  ldbu  r5,0(fp)
0x0000034c <main+60>:  movhi r4,0
0x00000350 <main+64>:  addi  r4,r4,10136
0x00000354 <main+68>:  call  0x3dc <printf>
    usleep(10000);
0x00000358 <main+72>:  movi  r4,10000
0x0000035c <main+76>:  call  0xd60 <usleep>
    IOWR_ALTERA_AVALON_TIMER_STATUS(TIMER_BASE, 0x3);
0x00000360 <main+80>:  movui r3,32800
0x00000364 <main+84>:  movi  r2,3
0x00000368 <main+88>:  stwio r2,0(r3)
    printf("%d \n", IORD_ALTERA_AVALON_TIMER_STATUS(TIMER_BASE));
0x0000036c <main+92>:  movui r2,32800
0x00000370 <main+96>:  ldwio r5,0(r2)
0x00000374 <main+100>: movhi r4,0
0x00000378 <main+104>: addi  r4,r4,10136
0x0000037c <main+108>: call  0x3dc <printf>
    usleep(10000);
0x00000380 <main+112>: movi  r4,10000
0x00000384 <main+116>: call  0xd60 <usleep>
    while(1)
    {
        //delay();
//        printf(" timer->np_timersnapl = %d ", timer->np_timersnapl);
//        printf(" timer->np_timersnaph = %d ", timer->np_timersnaph);
//        printf(" timer->np_timerstatus = %d \n", timer->np_timerstatus);
       // while(timer->np_timerstatus & np_timerstatus_to_mask);
        //led_pio->np_piodata = DataInPort;
        //delay();
        DelayM();
0x00000388 <main+120>: call  0x274 <DelayM>
        printf(" ok \n");
0x0000038c <main+124>: movhi r4,0
0x00000390 <main+128>: addi  r4,r4,10144
0x00000394 <main+132>: call  0x3dc <printf>
        
        DataInPort = IORD_ALTERA_AVALON_TIMER_STATUS(TIMER_BASE);
0x00000398 <main+136>: movui r2,32800
0x0000039c <main+140>: ldwio r2,0(r2)
0x000003a0 <main+144>: stb   r2,0(fp)
        printf("%d \n",  DataInPort);
0x000003a4 <main+148>: ldbu  r5,0(fp)
0x000003a8 <main+152>: movhi r4,0
0x000003ac <main+156>: addi  r4,r4,10136
0x000003b0 <main+160>: call  0x3dc <printf>
        usleep(10000);
0x000003b4 <main+164>: movi  r4,10000
0x000003b8 <main+168>: call  0xd60 <usleep>
        printf("%d \n", IORD_ALTERA_AVALON_TIMER_STATUS(TIMER_BASE));
0x000003bc <main+172>: movui r2,32800
0x000003c0 <main+176>: ldwio r5,0(r2)
0x000003c4 <main+180>: movhi r4,0
0x000003c8 <main+184>: addi  r4,r4,10136
0x000003cc <main+188>: call  0x3dc <printf>
        usleep(10000);
0x000003d0 <main+192>: movi  r4,10000
0x000003d4 <main+196>: call  0xd60 <usleep>
0x000003d8 <main+200>: br    0x388 <main+120>

вот дизасм...

Сообщение отредактировал Mozart - Oct 15 2007, 13:28


--------------------
все косяки, даже о которых не знает сам разработчик, - мои
Go to the top of the page
 
+Quote Post
Manfred
сообщение Oct 15 2007, 13:27
Сообщение #24


Участник
*

Группа: Участник
Сообщений: 54
Регистрация: 29-08-07
Из: Красногорск
Пользователь №: 30 128



Где дизасм можно найти?)

Я задержки между выставлениями данных смотрю в модел симе

Сообщение отредактировал Manfred - Oct 15 2007, 13:28
Go to the top of the page
 
+Quote Post
Mozart
сообщение Oct 15 2007, 13:33
Сообщение #25


Частый гость
**

Группа: Свой
Сообщений: 154
Регистрация: 16-08-07
Из: Москва
Пользователь №: 29 829



Цитата(Manfred @ Oct 15 2007, 17:27) *
Где дизасм можно найти?)

Я задержки между выставлениями данных смотрю в модел симе

открываешь nios2ide
потом жмёшь кнопочку debug, выбираешь nios II ISS, чисто теоретически у тебя всё проходит хорошо, тебя перекидывают на debug и справа там есть disasm.... если вдруг нету, то window->show view
это я так делал, может быть как-то по другому мона... хз...

Сообщение отредактировал Mozart - Oct 15 2007, 13:34


--------------------
все косяки, даже о которых не знает сам разработчик, - мои
Go to the top of the page
 
+Quote Post
Manfred
сообщение Oct 16 2007, 09:35
Сообщение #26


Участник
*

Группа: Участник
Сообщений: 54
Регистрация: 29-08-07
Из: Красногорск
Пользователь №: 30 128



Цитата(Mozart @ Oct 15 2007, 17:33) *
открываешь nios2ide
потом жмёшь кнопочку debug, выбираешь nios II ISS, чисто теоретически у тебя всё проходит хорошо, тебя перекидывают на debug и справа там есть disasm.... если вдруг нету, то window->show view
это я так делал, может быть как-то по другому мона... хз...


Спасибо - я давно в дебаг не заглядывал сразу моделирование запускал) - чтоб он быстрее работал надо оптимизацию ставить тогда данные из массива во внешнее устройство записываются за 3-5 тактов

Не видел ли где файл асемблеровского листинга? Тот листинг, что в дебаге у меня почему-то не полный, не до конца программы

Не скажет ли кто, что надо сделать, чтобы можно было симулировать программу с самостоятельно сделаным устройством на шину авалон в симуляторе ISS? в Модел Симе работа устройства симулируется правильно
Go to the top of the page
 
+Quote Post
Волощенко
сообщение Oct 30 2007, 09:43
Сообщение #27


Местный
***

Группа: Свой
Сообщений: 347
Регистрация: 16-02-06
Из: г.Николаев, Украина
Пользователь №: 14 377



Цитата(Mozart' @ Oct 9 2007, 09:45) *
таймер в ISS не работает, проверено...

Цитата(Волощенко @ Oct 9 2007, 13:03) *
У меня пока тот же результат, но есть утверждения, что должен работать (вот два):

Все-таки таймер симулируется в ISS. Ниже текст программы с выводом на Console состояния изменяющегося таймера.
Вот первые строки, что видны на Console:
Hello from Nios II!
00000000, 00000646, 00000dad, 00001582, 00001dc4, 00002644, 00002eb8, 000
03784, 0000401e, 0000487a, 00005168, 00005a02, 00006274, 00006b14, 000073
bc, 00007cb6, 000085c4, 00008eba, 00009806, 0000a0ca, 0000a9b2, 0000b2bc,

А это программа:
#include "sys/alt_stdio.h"
//-----------------------------
#include "alt_types.h"
#include "system.h"
//-----------------------------
#include "altera_avalon_timer_regs.h" //all for timer
//-----------------------------
int alt_timestamp_start(void)
{ void* base = TIMER_BASE;
{ IOWR_ALTERA_AVALON_TIMER_CONTROL (base,ALTERA_AVALON_TIMER_CONTROL_STOP_MSK);
IOWR_ALTERA_AVALON_TIMER_PERIODL (base,0xFFFF);
IOWR_ALTERA_AVALON_TIMER_PERIODH (base,0xFFFF);
IOWR_ALTERA_AVALON_TIMER_CONTROL (base,ALTERA_AVALON_TIMER_CONTROL_START_MSK);
} return 0;
}
alt_u32 alt_timestamp(void)
{ alt_u32 lower; alt_u32 upper;
void* base = TIMER_BASE;
{ IOWR_ALTERA_AVALON_TIMER_SNAPL (base, 0);
lower = IORD_ALTERA_AVALON_TIMER_SNAPL(base);
upper = IORD_ALTERA_AVALON_TIMER_SNAPH(base);
return (0xFFFFFFFF - ((upper << 16) | lower));
}
}
//-----------------------------
int main()
{alt_u32 a;
a=alt_timestamp_start();
alt_putstr("Hello from Nios II!\n");
printf("%08x, ", a);
while (1){a=alt_timestamp(); printf("%08x, ", a);};
return 0;
}
Go to the top of the page
 
+Quote Post
Mozart
сообщение Nov 7 2007, 14:39
Сообщение #28


Частый гость
**

Группа: Свой
Сообщений: 154
Регистрация: 16-08-07
Из: Москва
Пользователь №: 29 829



вот я сейчас читаю документацию на этот таймер и там написано
Цитата
The TO (timeout) bit is set to 1 when the internal counter reaches zero. Once
set by a timeout event, the TO bit stays set until explicitly cleared by a master
peripheral. Write zero to the status register to clear the TO bit.


вот мой код...
Код
#include    "C:\altera\71\quartus\sopc_builder\components\altera_avalon_pio\sdk\pio_struct.h"
#include    "C:\altera\71\quartus\sopc_builder\components\altera_avalon_timer\sdk\timer_struct.h"

void InitTimer0(void)
{
    na_timer0->np_timercontrol = np_timercontrol_stop_mask;
    na_timer0->np_timerperiodl = 0x0000;
    na_timer0->np_timerperiodh = 0x01F4;
    na_timer0->np_timercontrol = np_timercontrol_cont_mask|np_timercontrol_start_mask;
}

int main()
{  
//if (alt_avalon_sysid_test())
{
    
    InitTimer0();
    InitPio();
    unsigned char a = 0x01;
    while(1)
    {
        //CountTimer0();
        while (!(na_timer0->np_timerstatus & (1 << 0)));
        na_timer0->np_timerstatus = 0;
        na_pio->np_piodata = a++;
    }
}
}

если честно мне только не нравися прописывать такие длинные пути.... как от этого уйти?
эмулировал всё на доске... ещё не получается запускать Debug ISS он раз через раз запускается, нашёл где-то про индексирование, но после индексации тоже не всегда запускается.... надо где-нить что-нить прописывать?

Сообщение отредактировал Mozart - Nov 7 2007, 15:29


--------------------
все косяки, даже о которых не знает сам разработчик, - мои
Go to the top of the page
 
+Quote Post
Postoroniy_V
сообщение Nov 8 2007, 14:25
Сообщение #29


МедвеД Инженер I
****

Группа: Свой
Сообщений: 816
Регистрация: 21-10-04
Пользователь №: 951



впечатление такое, что никто и не читает
Nios II Software Developer’s Handbook
тут http://www.altera.com/literature/hb/nios2/n2sw_nii5v2.pdf


--------------------
Cogito ergo sum
Go to the top of the page
 
+Quote Post
AlexanderL
сообщение Nov 20 2007, 07:38
Сообщение #30





Группа: Участник
Сообщений: 10
Регистрация: 22-03-07
Пользователь №: 26 400



Здравствуйте! Подскажите пожалуйста как отладить обработчик прерывания в NIOS IDE?
Отладка программы ведется на реальном железе (т.е. hardware debug mode), при запуске программы без IDE (т.е. старт после сброса) программа корректно выполняет обработчик прерывания (загораются светодиодики). Если начинать отлаживать по шагам, при возникновении прерывания (прерывание выставляется по записи в регистр) дебагер не входит в обработчик, а просто продолжает выполнять программу далее (причем в этом случае некоторые значения регистров устройства вычитываются неправильно), и заветные светодиодики не загораются. Помогите плиз разобраться.
Go to the top of the page
 
+Quote Post

3 страниц V  < 1 2 3 >
Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 21st June 2025 - 11:17
Рейтинг@Mail.ru


Страница сгенерированна за 0.0151 секунд с 7
ELECTRONIX ©2004-2016