- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'd like to program NIOS II like plc language "Structured Text " and
in my future i want to create system based on fpga and NIOS II that allows me to write accessing memory and pheriperal like this For example , i want to access to my image input and memory : IF (I2.0==true) and (M5.5==true) { OUT10.5=true; } It's possible , writing macro and structure or onion , to obtain like i want ? Obvios i must to include header file (.h) Thanks for information WalterLink Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
/*
* "Hello plc" example. * This example works on cyclone dev board */ # include <stdio.h># include "system.h"# include "altera_avalon_pio_regs.h" # define BYTE alt_u8# define WORD alt_u16# define DWORD alt_u32 # define BIT0 0x01# define BIT1 0x02# define BIT2 0x04# define BIT3 0x08# define BIT4 0x10# define BIT5 0x20# define BIT6 0x40# define BIT7 0x80 # define BIT8 0x0100# define BIT9 0x0200# define BIT10 0x0400# define BIT11 0x0800# define BIT12 0x1000# define BIT13 0x2000# define BIT14 0x4000# define BIT15 0x8000 # define PIO_WR(BASE,DATA) IOWR_ALTERA_AVALON_PIO_DATA((BASE),(DATA))# define PIO_RD(BASE) (IORD_ALTERA_AVALON_PIO_DATA((BASE))) typedef union { struct { BYTE b0:1; // bit0 BYTE b1:1; // bit1 BYTE b2:1; // bit2 BYTE b3:1; // bit3 BYTE b4:1; // bit4 BYTE b5:1; // bit5 BYTE b6:1; // bit6 BYTE b7:1; // bit7 } bit; BYTE val; } IO; IO in0,in1,out0; void read_inputs(void); void write_outputs(void); int main() { int i; printf("Hello from Nios II!\n"); while(1) { read_inputs(); // read all inputs // do plc stuff out0.bit.b4=in0.bit.b0 ; out0.bit.b5=in0.bit.b1 ; out0.bit.b7=in0.bit.b0 & in0.bit.b1; write_outputs(); // write all outputs } return 0; } void read_inputs(void) { // negate that 1 means key pressed in0.val=~PIO_RD(BUTTON_PIO_BASE); } void write_outputs(void) { PIO_WR(LED_PIO_BASE,out0.val); }- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thanks for the interesting
http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/wink.gif ciao walter
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page