Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers

code c++

Altera_Forum
Honored Contributor II
1,634 Views

hello 

I have a code in c++(class: objet) 

can I implmente it in niosII ? 

regards
0 Kudos
22 Replies
Altera_Forum
Honored Contributor II
773 Views

hi, 

 

yes, you can use c++ coding with niosII.
0 Kudos
Altera_Forum
Honored Contributor II
773 Views

In visuel studio the code excute with command Prompt and file script.txt. 

iIn niosII i don't knows how excute it without command prompt ? 

and the processeur niosII read the file script .txt? 

can you help me
0 Kudos
Altera_Forum
Honored Contributor II
773 Views

You can use the JTAG conneciton as stdin/sdout, then for command prompt and printf. 

You can't use the .txt file, unless you implement a filesystem with Nios and a NV memory device and I think you don't want to make such an effort. 

I'd suggest to incorporate the script.txt file information into the code, assuming you don't need to modify it. This is ok if itt contains only configuration information to be read when the executable starts.
0 Kudos
Altera_Forum
Honored Contributor II
773 Views

 

--- Quote Start ---  

In niosII i don't knows how excute it without command prompt ? 

--- Quote End ---  

command prompt is similar to niosii console. You can use printf() or getc() functions for user interaction if STDIN/STDOUT is set to your JTAG UART of your niosII design. This is a default setting and normally you should not need to set it by yourself.  

So this should work the way you are used to. 

 

 

--- Quote Start ---  

and the processeur niosII read the file script .txt? 

--- Quote End ---  

Problem here, you must transfer the script.txt to your embedded system in order to access it from niosII. For example you can load it in your FLASH or RAM. 

If you want to read it from your PC-filesystem you have to set up a communication-protocol between the niosII based embedded system and your PC. For example via UART or even the JTAG UART (using my_jtag_atlantic.h). 

 

Regards
0 Kudos
Altera_Forum
Honored Contributor II
773 Views

hello, 

I would like to explain how use the JTAG UART (using my_jtag_atlantic.h) 

can I send me the file ?
0 Kudos
Altera_Forum
Honored Contributor II
773 Views

hi 

I did not understand how to use the command prompt it does not exist in the menu nios 

explain me the path or steps to use the command prompt
0 Kudos
Altera_Forum
Honored Contributor II
773 Views

The following applies to Nios IDE 9.0. Probably something changes if you are using a different version of the tools. 

 

- Integrate the jtag uart function in your sopc and build fpga project 

- open System Library properties and select jtag uart for stdout/stin/stderr 

- in Nios application you use printf and getc as an ordinary C program running on pc. 

- build the Nios IDE project 

- Select Run... and in Target Connection option select jtag uart as Nios II communication device 

- when application runs on Nios, the Console pane will work as the pc monitor, as if your application were executing on the pc. 

 

Cris
0 Kudos
Altera_Forum
Honored Contributor II
773 Views

 

--- Quote Start ---  

hello, 

I would like to explain how use the JTAG UART (using my_jtag_atlantic.h) 

can I send me the file ? 

--- Quote End ---  

 

 

Take a look at this thread. (second post) 

http://alteraforums.net/forum/showthread.php?t=6146 

You will find links to download the files you need for the communication between PC and NIOSII using the jtag_uart. Also you find some sort of example code.  

With this library you can transfer data (bytes) from PC to your embedded NIOSII system. 

 

Regards
0 Kudos
Altera_Forum
Honored Contributor II
773 Views

hello 

i download the folder "jtag_atlantic_terminal" and the auther 

the folder "jtag_atlantic_terminal" contains tow file my_jtag_atlantic.h and min 

the role of the algorithm to read the image load in memore of fpga ? 

 

i dont' know ,how I can incorporate in my code or just put them with my code ?and how I run my algorithm through command prompt? 

 

my board fpga is cyclone II and the code is in cyclone I EP1C20F400C7 

can I use the somme file to excute in cyclone II? 

regard
0 Kudos
Altera_Forum
Honored Contributor II
773 Views

 

--- Quote Start ---  

and min 

the role of the algorithm to read the image load in memore of fpga ? 

--- Quote End ---  

Sorry, I didn't understand this sentence. 

 

 

--- Quote Start ---  

and how I run my algorithm through command prompt? 

--- Quote End ---  

Cris, described in his last post how to do it. If you want to use the niosii console as command prompt you don't need my_jtag_atlantic.lib

 

You only need my_jtag_atlantic.lib if you want to transfer data from your pc to your embedded system via jtag_uart. For example if you want to transfer the content of your script.txt

 

On PC-side I would write code which set up the connection with your embedded system via my_jtag_atlantic.lib. After establishing the connection (see the example files for that), I would open script.txt with fopen and read the content using fread () or similar function. With my_jtag_atlantic.lib you can then transfer the content to your embedded system. 

 

On your embedded system-side you can now use read/write/printf for receiving/transmitting/transmitting data. 

Example (quick and dirty!): 

# include <stdio.h># include <stddef.h># include <unistd.h># include <fcntl.h># include <stdlib.h># include <system.h># include <string.h># include <io.h># include "jtag_comm.h"# include "sys/alt_dev.h"# include "priv/alt_file.h"# include "alt_types.h" # include "altera_avalon_jtag_uart.h" # define READ_BUFFER_SIZE 64# define WRITE_BUFFER_SIZE 64 # define TIMEOUT 1000# define SEND_TIMEOUT 1000 # define SUCCESS 0# define ERROR -1# define ERROR_TIMEOUT -2 // locals UChar8 read_buffer; Int32 read_cnt; Int32 JTAG_COMM_Init (void) { UInt32 ulCnt; Int32 lResult; Char8 sBuf; Char8 sFlush; Int32 dummy; Char8 *pch=NULL; memset(sFlush,0,2048); // forgive me for this hack but I couldn't figure out a more eligant way to do this alt_fd_list.fd_flags |= O_NONBLOCK; // flush any stale STDIN data while((dummy=getchar()) != -1); return SUCCESS; } Int32 JTAG_COMM_Send(Int32 lValue) { printf("%d\n",lValue); return SUCCESS; } Int32 JTAG_COMM_Rcv(Char8 *pMsg) { Char8 sBuf; Int32 lResult=0; memset(sBuf, 0, READ_BUFFER_SIZE); lResult = read(STDIN_FILENO, sBuf, READ_BUFFER_SIZE); if (lResult>0) { memcpy(pMsg,sBuf,lResult); } return lResult; }note: You can not do both. Use the jtag_uart for Command Prompt and for data transfers as described above using my_jtag_atlantic. If you want to do that you need 2 jtag_uarts. One for command prompt and one for transferring data. 

 

Regards
0 Kudos
Altera_Forum
Honored Contributor II
773 Views

hello 

I tried to follow these steps, but I failed to have the results 

is that you can send me a tutorial or give me more information for the steps (used for command prompt and load the script. txt file in the memory for the FPGA for the niosII can operate at the execution)
0 Kudos
Altera_Forum
Honored Contributor II
773 Views

Hi 

 

 

--- Quote Start ---  

... me more information for the steps (used for command prompt...)  

--- Quote End ---  

I would recommend that you start with that.  

 

Did you follow the steps Cris72 mentioned in his post? 

If so, have you used printf() to print something on the niosii console? Could you see something on the niosii console (^= pc monitor command prompt)?  

Did you try to use getc() and pressed a button on your keyboard? Could you determine the button by reading the value returned by getc()

 

Regards
0 Kudos
Altera_Forum
Honored Contributor II
773 Views

yes 

I tried to follow the steps of Cris72 

I have not understood when add printf () or getc () 

more certain steps I havn't done such 

-in Nios application you use printf and getc year as ordinary C programs running on PC.(How to do) 

- Select Run ... and Target Connection option in select jtag uart have Nios II communication device (I did not find "Target Connection option") 

 

Écouter 

Lire phonétiquement
0 Kudos
Altera_Forum
Honored Contributor II
773 Views

 

--- Quote Start ---  

-in Nios application you use printf and getc year as ordinary C programs running on PC.(How to do) 

--- Quote End ---  

Sorry, but I didn't understand the sentence. 

 

 

--- Quote Start ---  

- Select Run ... and Target Connection option in select jtag uart have Nios II communication device (I did not find "Target Connection option") 

--- Quote End ---  

Go to menu run->run configurations....->Select your NiosII Hardware Configuration->target connection

Now it depends on your NIOS IDE/EDS Version. 

 

Are you new to NIOSII development? If so I would recommend to do some beginner tutorials. There are a lot on the web which can explain the whole thing much better than I can ever do it. 

 

Regards
0 Kudos
Altera_Forum
Honored Contributor II
773 Views

 

--- Quote Start ---  

[Run Configurations....->Select your NiosII Hardware Configuration->Target Connection] 

 

I have not found it 

 

in my niosIDE , in the menu Run -> Run,or Run as or Run History 

 

 

--- Quote Start ---  

[/Are you new to NIOSII development?] 

I implemnted a code c on nios II and I used the board fpga 

the problem I can not find all the commands mentioned?
0 Kudos
Altera_Forum
Honored Contributor II
773 Views

Okay you're using the IDE. 

 

You find it under run-> run...
0 Kudos
Altera_Forum
Honored Contributor II
773 Views

i find it 

but  

when application runs on Nios, the Console pane isn'it work as the pc monitor 

 

I think you must load the script.txt first 

 

can you explain me more how to load the script .txt?
0 Kudos
Altera_Forum
Honored Contributor II
773 Views

 

--- Quote Start ---  

the Console pane isn'it work as the pc monitor 

--- Quote End ---  

So you don't see any output on the console???  

 

 

--- Quote Start ---  

I think you must load the script.txt first 

--- Quote End ---  

I don't know how your code looks like.... 

 

As first step for you, I suggested to set up a simple project in which you use the console as alternative to the pc monitor. I recommended that you first try to print something on the Console using printf() and then read something back (from your PC keyboard) using getc(). This should have been your first example project for user interaction and not your final replacement of your existing code. 

 

 

--- Quote Start ---  

can you explain me more how to load the script .txt?  

--- Quote End ---  

In one of my older post, I printed a small piece of code on how to receive some raw data bytes from the PC via the jtag_uart. If you want to transfer your script.txt you could orientate to this piece of code. but you have to set up your own protocol/code for that. You have to do some work for it, but I believe it should'nt be too much. 

 

Regards
0 Kudos
Altera_Forum
Honored Contributor II
773 Views

 

--- Quote Start ---  

 

when application runs on Nios, the Console pane isn'it work as the pc monitor 

 

--- Quote End ---  

 

This is very strange. 

Do you see anything at all in the console pane? 

If not, you probably missed some points from what I and pillemann suggested. 

Verify the jtag uart module is correctly connected and configured in sopc builder 

Verify the target connection properties in Nios IDE. 

Please also erase any flash memory (epcs or parallel) possibly connected to your fpga. I had a similar behaviour once and, if I remember correctly, it was due to an epcs which I had previously programmed with a different design. 

 

If nothing helps, rebuild the WHOLE system; I mean: regenerate sopc, compile Quartus project and rebuild Nios syslib and application. Best if you can create a new project from scratch. 

 

Cris
0 Kudos
Altera_Forum
Honored Contributor II
665 Views

hi 

 

--- Quote Start ---  

[/ suggested to set up a simple project in which you use the Console as alternative to the PC monitor] 

 

I try to excute many time a sample project with the prompt commad but nothing appears. 

 

 

--- Quote Start ---  

[/If you want to transfer your script.txt you could orientate to this piece of code.] 

 

it is diffiuculte to some work with mon code (simple project) 

ae you a tutorial more explain or can you intervenant the code?
0 Kudos
Reply