Home

GRSIM User`s Manual

image

Contents

1. 20 GRSIM User s Manual iv Cobham Gaisler AB Simulator Modules uses 543 en 21 3 1 The basic structure de kie ana ar dan ELA CEU nea gle d ni hante 21 3 2 Read and Write operations 22 3 2 1 The parameters explained 22 3 2 2 Ordinary accesses 22 3 2 3 Diagnostic accesses 22 3 3 Predefined Modules sa nn bec e Ce te oe aud NE nl ace ute 22 2 ESA LEON2 LEQN2 CPUL 155224 2 pisa sa die Raps cam i Red oi sees 23 3 3 2 ESA MCTRL LEON2 memory controller 23 4 0 IGAISLER APBUABT GRLIB APBUABRT coincida deb 23 3 3 4 GAISLER ETHMAC GRETH 10 100 Ethernet MAC module 24 3 341 Commands u ers ra da E erede ERG ETE ne 24 3 9 4 2 Packet Server sudiste Ren RAV de a as 25 3 8 5 GAISLER GPTIMER GRLIB APB General Purpose Timer 25 3 3 6 GAISLER_GRGPIO General Purpose I O Port 26 3 5 6 1 Commands edu die een ERR UR ee 26 3 5 6 2 T O driver mera DOS us eade do dart eee daniel kae rA d ae 27 3 3 7 GAISLER_IRQMP Multiprocessor Interrupt controller with AMP support 29 3 3 8 GAISLER_L2C LEON2 Compatibility 29 3 3 9 GAISLER L2101RQ LEON Interrupt controller ana ad
2. il 1 2 Obtaining GRSIM race nes Pe n aed E ha da wean red d s 1 IS Installation sans keene a er a de oct na adn DS a 1 1 4 License installation 0 1 1 5 Problem reports ernro ass ri mre ne Gos que sde ae nn cx pg 1 1 6 Limitations to the evaluation version 1 2 Opera sre ERAS senior AAA bd M RE 3 2 1 Operational modes essas e Rr ERG ELE RE DO RR Medea ee P ORE eee 3 2 2 Command line options use daa epar rn mine dob aire 3 2 2 1 Switches specific to certain modules 3 222 JVENDOR GAISLEE 252 23 22 721549559 riadas iria 4 2 2 2 1 GAISLER_APBUART GRLIB APB UART 4 2 2 2 2 GAISLER ETHMAC GRLIB GRETH 10 100 Ethernet MAC 4 2 2 2 3 GAISLER GPTIMER GRLIB APB General Purpose Timer 4 2 2 2 4 GAISLER GRGPIO General Purpose I O Port 4 2 2 2 5 GAISLER_IRQMP Multiprocessor Interrupt controller options 5 2 2 2 0 GAISLER L2C LEON2 Compatibility UART 5 2 2 2 7 GAISLER LEON3 4 LEON3 4 CPU 5 2 2 2 8 GAISLER SDCTRL GRLIB SDRAM Controller 6 2 2 2 9 GAISLER SPW GRLIB GRSPW SpaceWire controller 6 2 2 2 10 GAISLER_SPW2 GRLIB GRSPW2 SpaceWire controller 6 2 2 2 11 GAISLER SRCTRL GRLIB SRAM PROM Cont
3. 44 Appendix A THASP aussi eae rex T EXER skewers re 45 A 1 Installing HASP Device Driver 45 A 1 1 Ona Linux platform 0 45 A 1 1 1 Enabling Access to USB Keys 45 A 1 1 2 Loading the Daemon 45 Appendix B Sample simulator configuration AT Cobham Gaisler AB V GRSIM User s Manual Appendix C Simple Example Amba Device 53 CL Memetri PM 53 C2 Membtrlie icon 2 deber adds tie dadas Be He el 53 Appendix D grcommon h exe Exe ii 57 GRSIM User s Manual vi Cobham Gaisler AB Cobham Gaisler AB 1 GRSIM User s Manual 1 Introduction GRSIM is a generic SPARC simulator capable of emulating LEON based systems GRSIM includes the following functions e Read write access to all LEON registers and memory e Built in disassembler and trace buffer management e Downloading and execution of LEON applications e Breakpoint and watchpoint management e Remote connection to GNU debugger gdb 1 1 Supported platforms and system requirements GRSIM is currently provided for linux 2 2 glibc 2 3 1 2 Obtaining GRSIM The primary site for GRSIM is http www gaisler com where the latest version of GRSIM can be ordered and evaluation versions downloaded 1 3 Installation GRSIM can be installed anywhere on the host computer for co
4. coverage cpunum print address len print coverage data to console starting at address coverage cpunum clear reset coverage data Cobham Gaisler AB 15 GRSIM User s Manual The coverage data for each 32 bit word of memory consists of a 5 bit field with bitO Isb indicating that the word has been executed bit1 indicating that the word has been written and bit2 that the word has been read Bit3 and bit4 indicates the presence of a branch instruction if bit3 is set then the branch was taken while bit4 is set if the branch was not taken As an example a coverage data of 0x6 would indicate that the word has been read and written while 0x1 would indicate that the word has been executed When the coverage data is printed to the console or save to a file it is presented for one block of 32 words 128 bytes per line grsim gt coverage O print start 40000000 11110000000000000000111111110000 40000080 00000000000000000000000000000000 40000100 00000000000000000000000000000000 40000180 00000000000000000000000000000000 When the code coverage is saved to file only blocks with at least one coverage field set are written to the file Block that have all the coverage fields set to zero are not saved in order to decrease the file size Note that all memory prom and ram are subject for code coverage Coverage also supports virtual addresses When coverage is enabled disassembly will include an extra column after the address indicatin
5. returns the bus index SimTime T Grsim GetTime void sim The the current time in the simulator sim Cobham Gaisler AB 43 GRSIM User s Manual void Grsim IRQ struct ahb dev rec dev int level Set the interrupt pending bit for interrupt level Valid values are 0 15 void Grsim_Stop LibIf_T lib Stop the simulation now The event that is executing will be finished but the next event in the event queue will not be executed int Grsim SetConfigParams Liblf T lib char conf Add configuration parameters This function is to be used if the library is started with the nosimconf switch 1 e grsim is started without a configurations module int32 Grsim GetStatistics void sim Grsim GetStatisticsT stat Get statistics for bus and cpu Grsim GetStatisticsT is defined in simif h 4 2 Multi threading The library version of GRSIM is designed to be thread safe and reentrant thus providing the opportunity to run several instances of the library in a multi threaded application 4 2 1 Limitations to multi threading support Since the HASP libraries used in GRSIM for licensing are not thread safe the user must make sure that multiple calls to Grsim Liblnit are made in a non concurrent way Otherwise the application might fail to get a license 4 3 UART handling By default the library is using the same UART handling as the stand alone simulator This means that the UARTS can be connected to the console or any Unix devi
6. 2 2 2 8 GAISLER SDCTRL GRLIB SDRAM Controller sdram size Sets the amount of simulated SDRAM Mbytes Default is 16 Mbytes sdbanks num Number of sdram banks Default is 1 2 2 2 9 GAISLER SPW GRLIB GRSPW SpaceWire controller idx i Set unique index for specific GRSPW core Needs to be set in simulation configu ration file grspwlX connect ip address Same as the grspw1X connect command See Section 3 3 15 GAISLER SPW GRSPW SpaceWire controller page 36 grspwlX server port Same as the grspwi1X server command See Section 3 3 15 GAISLER SPW GRSPW SpaceWire controller page 36 grspwi normap Disable hardware RMAP handler grspwi rmap Enable hardware RMAP handler grspwi rmapcrc Only enable hardware RMAP CRC calculations No hardware RMAP handler grspwiX dbg flag Turn on debug information For a list of flags use the grspw1X_dbg help command see Section 3 3 15 GAISLER SPW GRSPW SpaceWire controller page 36 2 2 2 10 GAISLER_SPW2 GRLIB GRSPW2 SpaceWire controller idx i Set unique index for specific GRSPW2 core Needs to be set in simulation configu ration file grspwX connect ip address Same as the grspwX connect command See Section 3 3 16 GAISLER_SPW2 GRSPW2 SpaceWire controller page 38 Cobham Gaisler AB 7 GRSIM User s Manual grspwX server port Same as the grspwX server command See Section 3 3 16 GAISLER SPW2 GRSPW2 SpaceWire controller pa
7. NULL AddDevice NULL AddParams NULL params drvparams init ConfInit Cobham Gaisler AB 51 exit ConfExit cmd ConfCmd ctrl ConfCtrl Fi SimConf T SimConf amp simcfg GRSIM User s Manual GRSIM User s Manual 52 Cobham Gaisler AB Cobham Gaisler AB 53 GRSIM User s Manual Appendix C Simple Example Amba Device Here are presented a simple example amba device This device a very simple memory controller is also supplied as source code with the grsim distribution C 1 MemCtrl h ifndef _MEMCTRL_H define _MEMCTRL_H include grcommon h define RAMSIZE 0x4000000 typedef struct unsigned char ramb unsigned int size AccRes_T accres MemCtrl T define DATA dev MemCtrl T dev gt data endif MEMCTRL H C 2 MemCtrl c include lt stdlib h gt include lt stdio h gt include types h include simif h include MemCtrl h static int32 memctrl_init struct ahb_dev_rec me printf Initialising the memory controller n DATA me calloc 1 sizeof MemCtrl T DATA me gt ramb calloc 1 RAMSIZE DATA me gt size RAMSIZE return O static int32 memctrl_exit struct ahb_dev_rec me printf Exiting the memory controller n Free the malloc ed memory free MemCtrl_T me gt data gt ramb free me gt data return O GRSIM User s Manual 54 Cobham Gaisler AB int32 memctrl read struct ahb de
8. prom default at 0x00000000 0x00400000 The memory controller s registers will appear at 0xc0000000 onward mem ctrl i simcfg AddDevice simcfg sim busid VENDOR ESA ESA MCTRL 1 4 SLAVE 0x00000000 0x10000000 1 SLAVE 0x20000000 0x10000000 1 SLAVE 0x40000000 0x30000000 1 APB 0xc0000000 0x00000100 0 simcfg AddParams i simcfg params sram 16384 sdram 16 3 3 3 GAISLER APBUART GRLIB APBUART The GRLIB APB UART vendorid VENDOR GAISLER deviceid GAISLER_APBUART simulates one uart The configuration module example below shows how to instantiate the module uart who s registers are accessible from address 0xc0000100 onward is created GRSIM User s Manual 24 Cobham Gaisler AB uart i simcfg AddDevice simcfg sim busid VENDOR_GAISLER GAISLER_APBUART 3 1 APB 0xc0000100 0x00000100 0 simcfg AddParams i simcfg params fast_uart uart dev ptypc 3 3 4 GAISLER_ETHMAC GRETH 10 100 Ethernet MAC module The Ethermac module vendorid VENDOR_GAISLER deviceid GAISLER_ETHMAC sim ulates the GRLIB GRETH 10 100 Ethernet MAC The simulation model delivers and receives packets through a TCP socket An example packet server is delivered with GRSIM which uses the tun tap interface in Linux to attach to a real Ethernet network The configuration module example below shows how to instantiate the module ethermac i simcfg AddDevice simcfg sim busid VENDOR_G
9. AddDevice simcfg sim busid VENDOR GAISLER GAISLER SDCTRL 1 2 SLAVE 0x40000000 bari 0x20000000 bari 1 AHBIO Oxfff00400 ahb io entry 0x00000200 ahb io entry 0 simcfg AddParams i simcfg params sdram 16 GRSIM User s Manual 36 Cobham Gaisler AB 3 3 15 GAISLER_SPW GRSPW SpaceWire controller The SpaceWire module vendorid VENDOR_GAISLER deviceid GAISLER_SPW simulates the GRLIB GRSPW SpaceWire controller The simulation model delivers and receives packets through a TCP socket and can either act as a server or client which means you can easily connect two GRSIM simulators through SpaceWire The configuration module example below shows how to instantiate the module i simcfg AddDevice simcfg sim busid VENDOR GAISLER GAISLER SPW 14 1 APB 0x80000a00 0x00000100 0 simcfg AddParams i simcfg params idx 0 3 3 15 1 Commands Commands for this module grspwiX_status Print out he status of the buffer descriptors and the registers grspwiX connect ip address port Iry to connect to the packet server at address ip address port port If ip address is omitted localhost is used If port is omitted T CP port 2225 is used grspwlX server port Start server at address port if port is omitted 2225 is used grspwiX dbg lt flags gt clean list help Toggle debug output options Do grspw1X_dbg help for a list of possible options grspw1X dbg clean will deactivate all d
10. GAISLER_DDR2SP 0x02E define GAISLER GRTM 0x030 define GAISLER_GRTC 0x031 define GAISLER_GRPW 0x032 define GAISLER_GRCTM 0x033 define GAISLER_GRHCAN 0x034 define GAISLER_GRFIFO 0x035 define GAISLER_GRADCDAC 0x036 define GAISLER GRPULSE 0x037 define GAISLER_GRTIMER 0x038 define GAISLER_AHB2PP 0x039 define GAISLER_GRVERSION 0x03A define GAISLER_LEON4 0x048 define GAISLER L2CACHE 0x04B define GAISLER_FTAHBRAM 0x050 define GAISLER_FTSRCTRL 0x051 define GAISLER_AHBSTAT 0x052 define GAISLER_LEONSFT 0x053 define GAISLER_FTMCTRL OxOBF define GAISLER_KBD 0x060 define GAISLER_VGA 0x061 define GAISLER_LOGAN 0x062 define GAISLER_B1553BC 0x070 define GAISLER_B1553RT 0x071 define GAISLER_B1553BRM 0x072 define GAISLER_LEON2 Oxffb define GAISLER_L2IRQ Oxffc internal device leon2 interrupt controller define GAISLER L2TIME Oxffd internal device leon2 timer define GAISLER L2C Oxffe internal device leon2compat define GAISLER PLUGPLAY Oxfff internal device plug amp play configarea ESA cores define ESA LEON2 0x002 define ESA LEON2APB 0x003 define ESA L2IRQ 0x005 GRSIM User s Manual 62 define define define define define define define define define define define define define define ESA_L2TIMER 0x006 ESA_L2UART 0x007 ESA_L2CFG 0x008 ESA L210 0x009 ESA MCTRL OxOOF ESA_PCIARB 0x010 ESA HURRICANE Ox011 ESA SPW RMAP 0x012 ESA AHBUART 0
11. GRDRV CPU TRANSADDR GRDRV CPU GETNPC GRDRV BUS GET FREQ GRDRV RESTART CPU GRDRV CPU GET SREGS GRDRV CPU REPORT CACHE GRDRV_PREINIT GRDRV_SYSREG GRDRV_PREINIT2 GRDRV_PRELOAD else Vendor codes define define define define define VENDOR GAISLER 0x01 VENDOR PENDER 0x02 VENDOR ESA 0x04 VENDOR OPENCORES 0x08 VENDOR GLEICHMANN Ox10 Gaisler cores define define define define define define define define define define define define define define define define define GAISLER LEON2DSU 0x002 GAISLER_LEON3 0x003 GAISLER_LEON3DSU 0x004 GAISLER_ETHAHB 0x005 GAISLER_APBMST 0x006 GAISLER_AHBUART 0x007 GAISLER SRCTRL 0x008 GAISLER_SDCTRL 0x009 GAISLER SSRCTRL 0x00A GAISLER_APBUART 0x00C GAISLER_IRQMP 0x00D GAISLER AHBRAM OxOOE GAISLER GPTIMER 0x011 GAISLER PCITRG 0x012 GAISLER PCISBRG 0x013 GAISLER PCIFBRG 0x014 GAISLER PCITRACE 0x015 60 29 30 31 32 33 34 35 36 3T 38 39 40 41 42 43 44 45 46 47 48 49 50 Cobham Gaisler AB Cobham Gaisler AB 61 GRSIM User s Manual define GAISLER_PCIDMA 0x016 define GAISLER_AHBTRACE 0x017 define GAISLER ETHDSU 0x018 define GAISLER_CANAHB 0x019 define GAISLER_GRGPIO OxO1A define GAISLER AHBJTAG OxO1C define GAISLER_ETHMAC 0x01D define GAISLER_SPW 0x01F define GAISLER_SPACEWIRE 0x01f define GAISLER AHB2AHB 0x020 define GAISLER_DDRMP 0x023 define GAISLER_NUHOSP3 0x02b define
12. Gaisler AB 5 GRSIM User s Manual driver so dll file symbol Loads an I O driver from the given so dll file where the given symbol must be a pointer to a struct grgpio_iodriver output zeroes data Sets quirk that a line that drives output will always read 0 for that line in the data register restricted output mask Sets quirk that only the lines for which the corresponding bit in the given mask is set can drive output The other lines behaves as if direction is always set to in even when the corresponding bit in the in the direction register is set to 1 2 2 2 5 GAISLER_IRQMP Multiprocessor Interrupt controller options broadcast Enables the broadcast functionality amp cnt Implement the AMP functionality of the IRQMP controller for cnt instances ext nr Implement the extended irq controller functionality with extended interrupt nr cpubus busid If the interrupt controller is located on a separate bus specify the bus busid where the CPUs are located 2 2 2 6 GAISLER_L2C LEON2 Compatibility UART uart device By default the UART is connected to stdin stdout In Linux this switch can be used to connect the uart to another device E g uart dev ptypc will connect the UART to the pseudo device ptypc To communicate with ptypc the user should connect to dev ttypc fast uart Run the uart at infinite speed rather than the default slow baud rate 2 2 2 7 GAISLER_LEON3 4 LEON3 4 CPU smpid num The cpu
13. ahb dev rec struct grdriver short vendor short version short device char desc 32 int ctrl int struct ahb_dev_rec int cmd char struct ahb dev rec P typedef struct acc res struct ahb_dev_rec dev int mexc AccRes_T typedef int IrqFn_T struct ahb dev rec dev int cmd int arg typedef struct struct ahb dev rec dev IrgFn T fn IrgRouteEntry T typedef struct amba unit identification data Cobham Gaisler AB 65 GRSIM User s Manual short vendor short version short device char desc 32 functions int read struct ahb_dev_rec me struct ahb dev rec master unsigned int unsigned int data unsigned int length unsigned int wsize int write struct ahb_dev_rec me struct ahb dev rec master unsigned int unsigned int data unsigned int length unsigned int wsize int read_done AccRes T result int write_done AccRes_T result int ctrl int ctl struct ahb dev rec me void args int cmd char cmd struct ahb dev rec me AmbaUnit T struct ahb dev rec 1 struct ahb mem rec mem 4 struct ahb mem rec apb struct grdriver drv struct amba unit simdrv void data unsigned int devid unsigned char irg unsigned char vendor unsigned short device unsigned short version unsigned char type unsigned char index access with timing accumulated unsigned char acc access unsigned int acc WS unsigned int b
14. by issuing the following commands echo 1 gt proc sys net ipv4 ip forward echo 1 gt proc sys net ipv4 conf tap0 proxy arp route add host 192 168 0 80 dev tapO Where 192 168 0 80 is the ip address of the interface of the operating system running in the simulator or num if ip num was given greth config tries to issue the commands at startup In case they can t be executed issue them by hand When running the server you can enter 1 3 to specify the debugging level For 3 each received transmitted packet will be dumped on the screen The packet format used by the GRETH module is shown below 31 0 LENGTH LENGTH specifies length of packet including the header Header 31 16 15 8 7 5 4 0 0x4 RES IPID 1 TY PE 0 RES 31 16 RES reserved for future use 15 8 IPID IP core ID must equal 1 for Ethernet 7 5 TYPE packet type O for data packets 4 0 RES reserved for future use Payload Ethernet frame 3 3 5 GAISLER_GPTIMER GRLIB APB General Purpose Timer The GRLIB APB General purpose Timer vendorid VENDOR_GAISLER deviceid GAISLER_GPTIMER simulates a multipurpose interrupt timer One instance can simulate multiple timers which can eather issue the same interrupt or seperate interrupts The configuration module example below shows how to instantiate the module A general purpose Timer with 2 timers default using the same interrupt is created The irq number is that of the amba co
15. compat module Gaisler Research AHB APB Bridge Gaisler Research Leon2 Timer and Watchdog module Gaisler Research Leon2 IRQ Controller Gaisler Research APB UART Gaisler Research grsim gt load samples stanford prom total size 28048 bytes in lt i sec read 37 symbols entry point 0x00000000 grsim gt run MkProm LEON boot loader v1 2 Copyright Gaisler Research all right reserved system clock 50 0 MHz baud rate 19171 baud prom 512 K 2 2 ws r w sram 2048 K 1 bank s 0 0 ws r w edac disabled decompressing text decompressing data starting stanford Starting Perm Towers Queens Intmm Mm Puzzle Quick Bubble Tree FFT 50 50 33 67 33 184 33 33 317 50 Nonfloating point composite is 137 Floating point composite is 168 Program exited normally GRSIM User s Manual 14 Cobham Gaisler AB 2 6 Inserting breakpoints and watchpoints GRSIM supports execution breakpoints and write data watchpoints In stand alone mode hard ware breakpoints are always used and no instrumentation of memory is made When using the gdb interface the gdb break command normally uses software breakpoints by overwriting the breakpoint address with a ta 1 instruction Hardware breakpoints can be inserted by using the gdb hbreak command Data write watch points are inserted using the watch command A watchpoint can only cover one word address block watchpoints are not available 2 7 Displaying registers The current
16. execution cpu lt enable disable active num all gt Without parameters the cpu command shows cpu status The cpu active com mand sets active cpu ie the cpu to control from command line The cpu en able disable command enables disables one or all cpus dcache show data cache debug change or show debug level delete delete breakpoint s disassemble disassemble memory echo echo string in monitor window ep lt addr gt set the entry point for the active cpu exit see quit float display FPU registers gdb connect to gdb debugger go addr start execution without initialization hbreak print breakpoints or add hardware breakpoint if available help show available commands or usage for specific command xhelp show debugging and status commands for specific cores icache show instruction cache info lt sys libs drivers cpulbus gt show information about the system load load a file mem see x examine memory vmem like x examine memory but with virtual address register show set integer registers reset reset active GRSIM run reset and start execution at last load address GRSIM User s Manual 10 Cobham Gaisler AB set lt cpu lt num gt bus lt num gt gt set which cpu bus to control from command line shell execute a shell command stack lt addr gt set the stack pointer for the active cpu step single step one or n times symbols show symbols or load symbols from file profile
17. grgpio_core_iodriver h as struct grgpio_core_iodriver struct grgpio core core Opaque pointer for the grgpio core void ip data Pointer for use by the I O driver Gets called by the grgpio core whenever a direction is changed or if an output value for a pin in the out direction is changed Bit x of dir indicates that the grgpio core drives output on line x when 1 and that it does not when it is O Function must be initialized by 1 0 driver void output change struct grgpio core iodriver driver uint32 dir uint32 output GRSIM User s Manual 28 Cobham Gaisler AB Must be called by I O driver whenever the input to the core changes May be called by I O driver even if input data has not changed since last call x Note that is up to the I O driver to call or arrange for a call of this function to change input value even for lines for which the grgpio core is driving an output value Function gets initialized by grgpio core void set input struct grgpio core core uint32 input Can optionally be set by I O driver If set should print I O driver status void print status struct grgpio core iodriver driver b The struct iodriverif contains functions that an I O driver can use to interface with GRSIM It is defined in iodriver h as struct iodriverif Pointer to simulation instance to use as an argument in the functions belo
18. interval show and enables profiling with interval accuracy perf Display execution statistics statistic Display access statistics for cpu and bus quit exit grsim version show version watch print or add watchpoints wmem write word to memory x examine memory Typing a Ct O will interrupt a running program Short forms of the commands are allowed e g C co or con are all interpreted as cont Tab completion is available for commands text symbols and filenames 2 4 Simulator configuration Before starting the simulator a configuration module has to be created A configuration module defines which devices are present in the simulated system and where they appear in the address space See Appendix B Sample simulator configuration page 47 for a complete sample simu lator configuration 2 4 1 Constructing a simulator configuration To construct a simulator configuration referred to as simconf from now on a SimConf T structure has to be exported typedef struct simconf 1 data provided by grsim void sim operations provided by grsim int CreateBus void sim int AddLib struct vendor lib lib int AddDriver AmbaUnit T driver int AddDevice void simulator int busid unsigned int vendor unsigned int devid int irq int numbars 25 Cobham Gaisler AB 11 GRSIM User s Manual int AddParams int idx char params char str data char params operatio
19. is supplied e Commands should be a list of available commands used for command completion e NumCommands should be the number of entries in Commands It is crucial that this number matches the number of entries in Commands If NumCommands is set to 0 zero no command completion will be done A simple example of a command module is supplied with the professional version of GRSIM 2 13 GDB interface This section describes how to use gdb with GRSIM 2 13 1 Attaching to gdb GRSIM can act as a remote target for gdb allowing symbolic debugging of target applications To initiate gdb communications start the monitor with the gdb switch or use the GRSIM gdb command grsim gt gdb gdb interface using port 2222 Then start gdb in a different window and connect to GRSIM using the extended remote proto col gdb target extended remote pluto 2222 Remote debugging using pluto 2222 0x40000800 in start gdb Cobham Gaisler AB 19 GRSIM User s Manual While attached normal GRSIM commands can be executed using the gdb monitor command Output from the GRSIM commands such as the register information is then displayed in the gdb console gdb monitor reg INS DATA OUTS GLOBALS 00000004 00000000 00000008 00000000 400155FC 40001DD4 00000001 40022000 40015694 40001DD8 00000004 00000073 00000030 00000010 00000005 00000000 4001562C 00000800 40015624 4000A8F0 00000007 00000080 40015694 00000770 401FD7C8 00000000 401FD760 00000001 4000
20. log informing you if the installation has been successful or not It reports its version the version of the API used for USB and the version of the API inside the kernel driver for parallel port keys If the kernel driver happens to be unavailable when aksusbd is launched parallel port keys cannot be accessed but USB keys are still accessible The system log reflects this status If proc bus usb is not mounted when launching aksusbd USB keys cannot be accessed Preferably the daemon should be started at system boot up time with some script located in etc rc d init d or etc init d depending on Linux distribution Command Line Switches for aksusbd Linux v Print version number as decimal format xx xx 1 value Select type of diagnostic messages Possible values are 0 only errors 1 normal default 2 verbose 3 ultra verbose The messages are logged in syslog with priority kern info and kern debug Refer to etc syslog conf to see where the messages will be put usually it is the file var log messages GRSIM User s Manual 46 Cobham Gaisler AB u lt value gt Specifies the permission bits for the socket special file Default is 666 access for everyone h Print command line help Cobham Gaisler AB A7 GRSIM User s Manual Appendix B Sample simulator configuration Here is a sample simulator configuration defining a standard Leon 2 setup include lt stdio h gt include simconf h include grcommo
21. register window can be displayed using the register command grsim gt register INS DATA OUTS GLOBALS 00000027 40013000 00000027 00000000 40650E97 40001024 4000A470 00000001 9999999A 40001028 401FDFOO 00000001 0000029D 40013344 00000000 401FD687 00000770 00000000 40650E97 40004800 401FDF30 00000000 9999999A 00000770 401FDEBS 00000000 401FDE50 00000001 40001208 00000000 40004E08 00000000 NO O1 amp NO Hr O psr 004010C5 wim 00000080 tbr 40000800 y 01800000 pc 40000800 291402000 ta 0x0 npc 40000804 01000000 nop Other register windows can be displayed using reg n when n denotes the window number Use the float command to show the FPU registers if present 2 8 Code coverage The normal GRSIM doesn t include code coverage There is a special GRSIM binary marked with a coverage suffix This binary implements the coverage commands similar to those present in TSIM The GRSIM version with suffix coverage runs slower due to the overhead imposed Coverage is implemented for LEON3 and LEON4 processor cores and is done on a per cpu basis When enabled code coverage keeps a record for each 32 bit word in the emulated memory and monitors whether the location has been read written or executed The coverage function is controlled by the coverage command coverage cpunum enable enable coverage coverage cpunum disable disable coverage coverage cpunum save filename write coverage data to file file name optional
22. s id that will appear in the cpu index field of asr17 nfp Disables the FPU to emulate system without FP hardware Any FP instruction will generate an FP disabled trap dcsize size Defines the set size kbytes of the LEON dcache Allowed values are 1 64 im binary steps dlock Enable data cache line locking Default is disabled dlsize size Sets the line size of the data cache in bytes Allowed values are 8 16 or 32 dsets sets Defines the number of sets in the data cache Allowed values are 1 4 drepl repl Sets the replacement algorithm for the data cache Allowed values are rnd for random replacement lru for the least recently used replacement algorithm and Irr for least recently replaced replacement algorithm GRSIM User s Manual 6 Cobham Gaisler AB icsize size Defines the set size kbytes of the icache Allowed values are 1 64 in binary steps isets sets Defines the number of sets in the instruction cache Allowed values are 1 4 ilock Enable instruction cache line locking ilsize size Sets the line size of the instruction cache in bytes Allowed values are 8 16 or 32 irepl repl Sets the replacement algorithm for the instruction cache Allowed values are rnd for random replacement lru for the least recently used replacement algorithm and Irr for least recently replaced replacement algorithm ca cache area generic Leon4 only The value of the cached region vhdl generic Default Ox10ff
23. status Print out the status of registers and I O provider gpioX input value Set default input value do be used when there is no connected I O driver gpioX dbg flags clean list help Toggle debug output options Do gpioX_dbg help to list possible options gpio X dbg clean to deactivate all debug output and gpioX dbg list to list the current settings Cobham Gaisler AB 27 GRSIM User s Manual gpioX verbose 011 Toggle or set verbose output of module 3 3 6 2 I O driver interface The user should supply a dynamic library that exposes a symbol of type struct grgpio_ iodriver The struct grgpio iodriver is the overall interface between a GRGPIO I O and GRSIM It is defined in grgpio_iodriver h as struct grgpio iodriver See grgpio core iodriver h struct grgpio core iodriver core driver Called by GRSIM once at setup Should return O on success and non zero otherwise int setup struct grgpio_iodriver driver Called by GRSIM on reset void reset struct grgpio_iodriver driver Called by GRSIM for tearing down the 1 0 driver void exit struct grgpio_iodriver driver 1 0 driver interface for interfacing with grsim struct iodriverif iodif Index among grgpio cores of the core int idx Name of grgpio const char name E The struct grgpio_core_iodriver is the interface between a GRGPIO I O driver and the GRGPIO core logic It is defined in
24. 000100 0 3 3 13 1 Commands Commands for this module grpci_help Shows information about GRPCI module commands grpci_status Show the status of the GRPCI core grpci dbg lt flags gt clean list help Toggle debug output options Do grpci_dbg help for a list of possible options grpci dbg clean will deactivate all debug output and grpci_dbg list will list the current settings grpci_ip lt input provider gt lt args gt Load a GRPCI input provider The args parameter is passed to grpci_inp_setup of the input provider 3 3 13 2 GRPCI User supplied dynamic library The user supplied dynamic library should expose a public symbol grpciinputsystem of type struct grpci subsystem GRSIM User s Manual 34 Cobham Gaisler AB The struct grpci subsystem is defined as struct grpci subsystem void grpci inp setup int id struct grpci input 1 char argv int argc void grpci inp restart int id struct grpci input 1 void event struct grpci input 1 void cfunc uint32 arg uint64 offset void stop event arg struct grpci input 1 void cfunc int arg At initialization the callback grpci inp setup will be called once supplied with a pointer to structure struct grpci input The grpci inp restart callback should be set to 0 The user supplied dynamic library should claim the grpci input structure by using the IN PUT CLAIM macro see the example below The struct grpci_input consist
25. 1084 L window underflow 0x400010dc L _fpdis 0x400011a4 T _flush_windows 0x400011a4 T start 0x40001218 L fstat 0x40001220 L isatty 0x40001228 L getpid 0x40001230 L kill 0x40001238 L exit 0x40001244 L lseek The profile command can be used to show usage of program functions Enabling profile is done by profile interval where interval is the interval time in clock cycles for which a probe should reoccur On each profiling interval event the callstack is used to update a execution count for each symbol present Recursive functions may therefore cause expected though correct results grsim gt profile 100 Profiling enabled interval 100 grsim gt run Starting Perm Towers Queens Intmm Mm grsim gt profile function samples ratio tower 691022 27 93 Permute 269377 10 88 _hardreset_real 256988 10 38 _start 256986 10 38 main 256265 10 35 Try 185961 7 51 Intmm 73309 2 96 Innerproduct 66984 2 70 Towers 53463 2 16 Perm 48513 1 96 Mm 47115 1 90 Move 45831 1 85 rInnerproduct 38796 1 56 Queens 33579 1 35 Doit 33551 1 35 2 10 Displaying memory contents Any memory location can be displayed using the x command If a third argument is provided that is interpreted as the number of bytes to display Text symbols can be used instead of a numeric address If the mmu is switched on the vmem command can be used to translate Cobham Gaisler AB 17 GRSIM User s Manual the address first The bus on which to issue the access has to be s
26. 1E3C 40022000 400155FC 00000000 NO O1 amp WNF O psr 000010E4 wim 00000004 tbr 40000050 y 00000000 pc 40001eic d4232004 st o2 ho4 0x4 npc 40001e20 10800004 ba 0x40001e30 gdb 2 13 2 Debugging of applications To load and start an application use the gdb load and run command gdb lo Loading section text size Oxcb90 Ima 0x40000000 Loading section data size 0x770 Ima 0x4000cb90 Start address 0x40000000 load size 54016 Transfer rate 61732 bits sec 278 bytes write gdb bre main Breakpoint 1 at 0x400039c4 file stanford c line 1033 gdb run The program being debugged has been started already Start it from the beginning y or n y Starting program home john samples stanford Breakpoint 1 main at stanford c 1033 1033 fixed 0 0 gdb To interrupt simulation Ctrl can be typed in both GDB and GRSIM windows The program can be restarted using the GDB run command but a load has first to be executed to reload the program image on the target Software trap 1 ta 1 is used by gdb to insert breakpoints and should not be used by the application 2 13 3 Detaching If gdb is detached using the detach command the monitor returns to the command prompt and the program can be debugged using the standard GRSIM commands The monitor can also be re attached to gdb by issuing the gdb command to the monitor and the target command to gdb GRSIM translates SPARC traps into Unix signals which are prope
27. AISLER GAISLER_ETHMAC 12 1 APB 0x80000800 0x00000100 0 3 3 4 1 Commands Commands for this module grethX status Print out he status of the buffer descriptors and the registers grethX connect ip address Try to connect to the packet server at address ip address if ip address is omitted localhost is used TCP port 2224 is used The packet server must have been started in another shell or on another linux box grethX dbg lt flags gt clean list help Toggle debug output options Do grethX_dbg help for a list of possible options greth X dbg clean will deactivate all debug output and grethX dbg list will list the current settings grethX dump file Dump packets to Ethereal readable file When a file is not specified the current dumpfile will be closed grethX ping ip address Simulate a ping transmission Packets will be generated by GRSIM If ip address is not specified the default is 192 168 0 80 Cobham Gaisler AB 25 GRSIM User s Manual 3 3 4 2 Packet server A example packet server is delivered with GRSIM greth config To start the packet server greth config you have to be root It uses 192 168 0 81 as the tapO interface s address by default To specify a different interface ip number use the ipif lt addr gt switch The ipaddress of the operating system running in GRSIM is default assumed to be 192 168 0 80 but can be changed by the ip lt addr gt switch The packet server tries to configure the ip stack
28. B 0x80000068 0x00000008 0 Cobham Gaisler AB params e g ram 2048 leon2compat leon2compat Cobham Gaisler AB 49 GRSIM User s Manual i simcfg AddDevice simcfg sim busid VENDOR GAISLER GAISLER L2C internal device leon2compat 3 1 APB 0x800000a0 0x00000040 0 simcfg AddParams i simcfg params apb master i simcfg AddDevice simcfg sim busid VENDOR GAISLER GAISLER APBMST 3 1 SLAVE 0 0 0 simcfg AddParams i simcfg params leon2 timer i simcfg AddDevice simcfg sim busid VENDOR GAISLER GAISLER_L2TIME 3 1 APB 0x80000040 0x00000028 0 simcfg AddParams i simcfg params Interrrupt Controller i simcfg AddDevice simcfg sim busid VENDOR GAISLER GAISLER L2IRQ 3 1 APB 0x80000090 GRSIM User s Manual 50 Cobham Gaisler AB 0x00000010 0 simcfg AddParams i simcfg params Int Ctrl UART i simcfg AddDevice simcfg sim busid VENDOR GAISLER GAISLER_APBUART 3 1 APB 0x80000070 0x00000020 0 simcfg AddParams i simcfg params fast uart return result static int ConfExit void int result 0 return result static int ConfCmd char cmd void arg int result 0 return result F static int ConfCtrl int ctl void arg int result 0 return result F static SimConf T simcfg sim NULL AddLib NULL AddDriver NULL CreateBus
29. EGS_GDB GRDRV_CPU_FLUSH GRDRV_CPU_FLUSH_WIN GRDRV_CPU_GET_STATUS GRDRV_CPU_GDB_SYNC_REGS GRDRV_CPU_CACHE_SNOOP GRDRV_AMBA_READ_DONE GRDRV_AMBA_WRITE_DONE GRDRV_CPU_READ_SCRATCH GRDRV_CPU_WRITE_SCRATCH GRDRV_CPU_DISAS 63 26 27 28 29 30 31 32 33 34 35 36 37 GRDRV MCTRL GET USEABLE STACK 38 GRDRV CPU GET SMPID GRDRV CPU PRINT STATUS GRDRV CPU TRANSADDR GRDRV CPU GETNPC GRDRV BUS GET FREQ GRDRV RESTART CPU GRDRV CPU GET SREGS GRDRV CPU REPORT CACHE GRDRV_PREINIT GRDRV_SYSREG GRDRV_PREINIT2 GRDRV_PRELOAD DEBUG ifndef __ASSEMBLER__ AMBA define define define define define Used define configuration ID VENID x GO gt gt 24 DEVID x GO gt gt 12 CFGVER x x gt gt 10 VERID x Ge gt gt 5 TRQNUM x x gt gt 0 39 40 41 42 43 44 45 46 47 48 49 50 amp OxOff amp OxOfff amp 0x03 amp OxO1f amp Ox1f GRSIM User s Manual as master for diagnostic accesses on the AMBA bus DIAG NULL struct ahb cfg rec x int devid int custom cfg 3 int bar 4 struct ahb cfg area GRSIM User s Manual 64 Cobham Gaisler AB struct ahb cfg rec master 64 struct ahb cfg rec slave 64 struct apb_cfg_rec int devid int bar struct apb_cfg_area 1 struct apb cfg rec slave 64 struct ahb_mem_rec unsigned int start unsigned int end unsigned int type struct
30. GRSIM User s Manual for version 1 1 54 16 October 2015 This manual is for GRSIM version 1 1 54 16 October 2015 which is a simulator developed at Cobham Gaisler AB Copyright 2015 Cobham Gaisler AB Permission is granted to make and distribute verbatim copies of this manual pro vided the copyright notice and this permission notice are preserved on all copies Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying provided also that the entire resulting derived work is distributed under the terms of a permission notice identical to this one Per mission is granted to copy and distribute translations of this manual into another language under the above conditions for modified versions Cobham Gaisler AB i GRSIM User s Manual Short Contents 1 Introduction uua ues woe C E and ii Oe e RE e Re CR e 1 2 Operations ass cae dada cee he eee RAR deen teas EE BAV dad B a Sim lat r Modules 2 22 4e ok RR dE pra Se RES 21 A Tibay sd oe ee bei E ORE RECON UR eee CEN E ee ee oU ee a d 41 E e ar rd 45 B Sample simulator configuration ss pas ace do de dai AA 47 O Simple Example Amba Device as diu qe nn OR E u a dp een 53 D PEO MAMADA done PRB 57 GRSIM User s Manual 1i Cobham Gaisler AB Cobham Gaisler AB ili GRSIM User s Manual Table of Contents 1 Introducido sadenenda Paw e ER sds CERA ACER 1 1 1 Supported platforms and system requirements
31. RACE 0x015 GAISLER_PCIDMA 0x016 GAISLER AHBTRACE 0x017 GAISLER_ETHDSU 0x018 GAISLER_CANAHB 0x019 GAISLER_GRGPIO OxO1A GAISLER_AHBJTAG 0x01C GAISLER_ETHMAC 0x01D GAISLER_SPW 0x01F GAISLER_SPACEWIRE 0x01f GAISLER_AHB2AHB 0x020 GAISLER_DDRMP 0x023 GAISLER_NUHOSP3 0x02B GAISLER_DDR2SP 0x02E GAISLER_GRTM 0x030 GRSIM User s Manual GAISLER_GRTC GAISLER_GRPW GAISLER_GRCTM GAISLER_GRHCAN GAISLER_GRFIFO GAISLER_GRADCDA GAISLER_GRPULSE GAISLER_GRTIMER GAISLER_AHB2PP GAISLER_GRVERSI GAISLER_LEON4 GAISLER_L2CACHE 0x031 0x032 0x033 0x034 0x035 C 0x036 0x037 0x038 0x039 ON 0x03A 0x048 0x04B GAISLER_FTAHBRAM 0x050 GAISLER_FTSRCTR GAISLER_AHBSTAT GAISLER_LEON3FT GAISLER_FTMCTRL GAISLER_KBD GAISLER_VGA GAISLER_LOGAN GAISLER_B1553BC GAISLER_B1553RT L 0x051 0x052 0x053 0x05F 0x060 0x061 0x062 0x070 0x071 GAISLER_B1553BRM 0x072 GAISLER_LEON2 GAISLER L2IRQ GAISLER_L2TIME GAISLER_L2C Oxffb Oxffc Oxffd Oxffe GAISLER PLUGPLAY Oxfff ESA cores enum ESA_LEON2 ESA LEON2APB ESA L2IRQ ESA L2TIMER ESA L2UART ESA L2CFG ESA L210 ESA MCTRL ESA_PCIARB ESA_HURRICANE ESA_SPW_RMAP ESA_AHBUART 0x002 0x003 0x005 0x006 0x007 0x008 0x009 OxOOF 0x010 0x011 0x012 0x013 58 internal de
32. aisler AB 31 GRSIM User s Manual arg i simcfg AddDevice simcfg sim busid VENDOR GAISLER GAISLER L2IRQ 3 1 APB 0x80000090 0x00000010 0 simcfg AddParams i simcfg params 3 3 10 GAISLER_L2TIME LEON2 Timer The Leon2 Timer module vendorid VENDOR GAISLER deviceid GAISLER_L2TIME sim ulates a Leon2 timer The configuration module example below shows how to instantiate the module timer i simcfg AddDevice simcfg sim busid VENDOR GAISLER GAISLER_L2TIME 3 1 APB 0x80000040 0x00000028 0 simcfg AddParams i simcfg params 3 3 11 GAISLER_LEON3 LEON3 CPU The LEON3 cpu module vendorid VENDOR GAISLER deviceid GAISLER_LEON3 simu lates a LEON3 processor The configuration module example below shows how to instantiate the module A multiprocessor system with 2 cpus is created 1eon3 i simcfg AddDevice simcfg sim busid VENDOR GAISLER GAISLER_LEON3 0 0 simcfg AddParams i simcfg params smpid 0 i simcfg AddDevice simcfg sim busid VENDOR GAISLER GAISLER_LEON3 0 0 simcfg AddParams i simcfg params smpid 1 GRSIM User s Manual 32 Cobham Gaisler AB 3 3 11 1 Commands Commands for this module cctrl show Shows decoded cache control register 3 3 12 GAISLER_LEON4 LEONA CPU The LEONA cpu module vendorid VENDOR GAISLER deviceid GAISLER_LEONA4 simu lates a LEONA processor The configuration module example below shows h
33. al 42 Cobham Gaisler AB void Grsim Read Liblf T lib uint32 addr uint32 data void Grsim Write LibIf T lib uint32 addr uint32 data Performs a read write from addr returning the value in data Only for diagnostic use void Grsim GdbIf LibIf T lib unsigned char inchar O void outchar unsigned char c Controls the simulator using the gdb extended remote protocol The inchar parameter is a pointer to a function that when called returns next character from the gdb link The outchar parameter is a pointer to a function that sends one character to the gdb link int32 Grsim AddEvent void sim void EventHandler uint32 arg SimTime_T offset Add an event to the event queue EventHandler will be called offset simulator ticks from now arg is passed as an argument to EventHandler int Grsim StopEvent void sim void EventHandler O Removes all events with the given EventHandler from the event queue Returns the number of events removed int Grsim StopEventArg void sim void EventHandler void arg Removes all events with the given EventHandler and arg from the event queue Returns the number of events removed int Grsim EventExists void sim void EventHandler 0 void arg Returns 1 if an event with the given EventHandler and arg exists in the event queue or 0 otherwise int32 Grsim CreateBus void sim Create A bus in the simulator sim
34. c DATA me gt accres dev master DATA me gt accres mexc 0 Grsim_AmbaWriteDone me amp DATA me gt accres SimTime_T length return O static int32 memctrl ctrl int ctl struct ahb dev rec me void arg switch ctl case GRDRV_INIT memctrl_init me break case GRDRV OPTIONS printf MemCtrl s n char arg break case GRDRV EXIT memctrl_exit me break default break return 0 AmbaUnit_T MyMemCtrl vendor 17 version 1 device 13 desc Simple EXAMPLE Mem Controller read memctrl_read write memctrl_write read_done NULL write_done NULL cmd NULL GRSIM User s Manual 56 Cobham Gaisler AB ctrl memctrl ctrl Cobham Gaisler AB 57 GRSIM User s Manual Appendix D grcommon h ifndef _GRCOMMON_H define _GRCOMMON_H ifdef DEBUG enums make debugging easier enum x VENDOR GAISLER 0x01 VENDOR PENDER 0x02 VENDOR ESA 0x04 VENDOR OPENCORES 0x08 VENDOR GLEICHMANN 0x10 Fi Gaisler cores enum GAISLER_LEON2DSU 0x002 GAISLER_LEON3 0x003 GAISLER_LEON3DSU 0x004 GAISLER_ETHAHB 0x005 GAISLER_APBMST 0x006 GAISLER_AHBUART OxOOT GAISLER_SRCTRL 0x008 GAISLER_SDCTRL 0x009 GAISLER_SSRCTRL Ox004 GAISLER_APBUART 0x00C GAISLER_TRQMP 0x00D GAISLER_AHBRAM OxOOE GAISLER_GPTIMER 0x011 GAISLER_PCITRG 0x012 GAISLER_PCISBRG 0x013 GAISLER_PCIFBRG 0x014 GAISLER_PCIT
35. ce pseudo ttys pipes fifos 4 4 Linking an application with the GRSIM library Six sample application are provided appl c exemplifies the basic usage of the library version of GRSIM app2 c shows how to use the library in a multi threaded environment app3 c exemplifies the use of the GDB interface app4 c a multithreaded example where one thread is stopped from the main thread using the Grsim_Stop command app5 c shows how to use the GRSIM library without a configuration module app6 c demonstrates the usage of the internal gdb server They are built by typing make in the example directory GRSIM User s Manual 44 Cobham Gaisler AB 4 5 GRSIM library without a simconf module When using the library version of GRSIM it is possible to not use a simulator configuration module but configuring the simulator by calling the function interface directly However there are some restrictions in how this may be done which is described below 1 Call Grsim LibCreate 2 Call Grsim PreConfigure 3 Create all buses and attach your modules using Grsim CreateBus Grsim AddLib Gr sim AddDriver Grsim AddDevice and Grsim AddParams Provide your own array of strings char as the second argument to Grsim AddParams 4 Call int Grsim_SetConfigParams LibIf_T lib char conf Here conf is supposed to be the array of strings you used as the second parameter to Grsim_AddParams 5 Call Grsim_Liblnit wi
36. cfg params broadcast amp 4 ext 10 cpubus 0 3 3 8 GAISLER_L2C LEON2 Compatibility The LEON2 Compatibility module vendorid VENDOR GAISLER deviceid GAISLER_L2C simulates all LEON registers from 0x800000000 onward except of the interrupt controller which should be implemented using the LEON Interrupt controller module GAISLER_L2IRQ the timer module which should be implemented using the LEON2 Timer controller module GAISLER L2TIME and the uart which should be implemented using the apb uart module GAISLER_APBUART The configuration module example below shows how to instantiate the module GRSIM User s Manual 30 Cobham Gaisler AB leon2 compat i simcfg AddDevice simcfg sim busid VENDOR_GAISLER GAISLER_L2C 3 1 APB 0x80000010 0x00000030 0 1eon2 compat i simcfg AddDevice simcfg sim busid VENDOR_GAISLER GAISLER_L2C 3 1 APB 0x80000068 0x00000008 0 1eon2 compat i simcfg AddDevice simcfg sim busid VENDOR_GAISLER GAISLER_L2C 3 1 APB 0x800000a0 0x00000040 0 simcfg AddParams i simcfg params 3 3 9 GAISLER L2IRQ LEON2 Interrupt controller The LEON Interrupt controller vendorid VENDOR GAISLER deviceid GAISLER_L2IRQ simulates a LEON2 single processor interrupt controller As for the default LEON register layout it should be allocated at address 0x80000090 The configuration module example below shows how to instantiate the module Cobham G
37. d by the I O driver with a function that deals with changes of the output from the core print status function pointer is typically initialized with a function that prints status information on the I O driver and the ip data pointer is typically set to point to some user defined data structure that is used by the I O driver Between the call to the setup function and the exit function of a struct grgpio iodriver the idx and the name can be read and core driver set input and all the functions in iodif can be called Note that when an GRGPIO I O driver is loaded the readout of the data register is not automatically updated due to writes to the output or direction registers It is up to the GRGPIO I O driver to arrange for a call of core driver set input by calling it directly or by adding an event that will eventually call it to have the input as viewed from the GRGPIO core change at the appropriate time For an example GRGPIO I O driver see the example in the distributed grgpio_iodriver_example c file 3 3 7 GAISLER_IRQMP Multiprocessor Interrupt controller with AMP support The IRQMP Interrupt controller vendorid VENDOR GAISLER deviceid GAISLER_IRQMP simulates a multiprocessor processor interrupt controller The configuration module example below shows how to instantiate the module irq i simcfg AddDevice simcfg sim BUS1 VENDOR_GAISLER GAISLER_IRQMP 10 1s APB Oxf0004000 0x00004000 0 simcfg AddParams i sim
38. d commands read for write commands wsize 0 8 bit access 1 16 bit access 2 32 bit access 3 64 bit access 64 bit is only used to model STD instructions to the GRPCI AHB slave ws Number of PCI clocks it shall to complete the transaction abort Set to 1 to generate target abort 0 otherwise The return value of acc determines if the transaction terminates successfully 1 or with master abort 0 The callback target_acc is installed by the GRPCI module The PCI user dynamic library can call this function to initiate an access to the GRPCI target cmd Command to execute see the PCI command table for details I O cycles not support by the GRPCI target addr PCI address data Data buffer returned data for read commands supply data for write commands wsize 0 8 bit access 1 16 bit access 2 32 bit access mexc 0 if access is succesful 1 in case of target abort If the address matched MEMBARO MEMBAR1 or CONFIG target acc will return 1 otherwise 0 3 3 14 GAISLER SDCTRL GRLIB SDRAM Controller The GRLIB SDRAM Controller vendorid VENDOR GAISLER deviceid GAISLER SDCTRL simulates a sdram region for a given address range The con figuration module example below shows how to instantiate the module One bar with range 0x40000000 0x60000000 is defined in which 16 mb of sdram are allocated 0 0x1000000 The AHBIO entry allocates the bar entry for the AMBA ahb configuration records for this instance sdram mem ctrl i simcfg
39. e simulator to be integrated in a larger simu lation frame work The various GRSIM commands and options are accessible through a simple function interface The library version of GRSIM is fully reentrant and thread safe 4 1 Function interface The following functions are provided to access GRSIM features void Grsim_LibCreate void Create an instance of the library This must be done first A pointer to the new library is returned void Grsim LibExit LibIf T lib Exit the library in a clean way void Grsim LibInit LibIf T lib char str Initialize the Library ie allocate space for data structures and initialize them This call is NOT thread safe and should be done in a controlled way int Grsim Cmd LibIf T lib char cmd Execute a GRSIM command Any valid GRSIM command line command may be given The following return values are defined SIGINT Simulation stopped due to interrupt SIGHUP Simulation stopped normally SIGTRAP Simulation stopped due to breakpoint hit SIGSEGV Simulation stopped due to processor in error mode SIGTERM Simulation stopped due to program termination int Grsim IncTime LibIf T lib uint64 leap Increment simulator time with leap ticks void Grsim GetRegs Liblf T lib unsigned int regs void Grsim SetRegs Liblf T lib unsigned int regs Get Set SPARC registers regs is a pointer to an array of integers see simif h for how the various registers are indexed GRSIM User s Manu
40. ebug output and grspw1X dbg list will list the current settings 3 3 15 2 Packet server Each SpaceWire core can be configured independently as a packet server or client using either grspw X server or grspwX connect TCP sockets are used for establishing the connections When acting as a server the core can only accept a single connection For more flexibility such as custom routing an external packet server can be implemented using the protocol specified below Data packet format Cobham Gaisler AB 37 GRSIM User s Manual 31 0 0x0 LENGTH 31 0 LENGTH specifies length of packet including the header Header 31 16 15 8 7 5 4 1 0 0x4 RES IPID 0 TYPE 0 RES EEP 31 16 RES reserved for future use 15 8 IPID IP core ID must equal 0 for Space Wire 75 TYPE packet type O for data packets RES reserved for future use must be set to 0 EEP Error End of Packet Set when the packet is truncated and terminated by an EEP Payload 0x8 SpaceWire packet Time code packet format 31 0 loo LENGTH 1310 LENGTH specifies length of packet including the header Header 31 16 15 8 5 4 0 oa RES trm o TYPE 1 RES 31 16 RES reserved for future use must be set to 0 IPID IP core ID must equal 0 for SpaceWire TYPE packet type 1 for time code packets 140 RES reserved for future use must be set to O Payload 31 8 7 6 5 0 31 8 RES reserved for future use must be set
41. et using the set bus ida command grsim gt x 0x40000000 40000000 a0100000 29100004 81c52000 01000000 Vs messes 40000010 91d02000 01000000 01000000 01000000 E WAAL A den bis 40000020 91d02000 01000000 01000000 01000000 as 40000030 91d02000 01000000 01000000 01000000 dpa ay d Bee grsim gt x 0x40000000 32 40000000 a0100000 29100004 81c52000 01000000 Jo messes 40000010 291402000 01000000 01000000 01000000 i Cad CARA RES grsim gt x main 40001AC8 9Ide3bf88 7fffffb1 9007bfe8 d407bfe8 40001AD8 92102003 912aa001 9002000a 912a2003 beh Reg are des 40001AE8 9002000a 40000913 2912a2001 281c7e008 Fico 40001AF8 91e80008 13000049 92126003 1510006b sacella uere 2 11 Disassembly of memory Any memory location can be disassembled using the disassemble command As with the examine command text symbols can be used as an address Also a region can be disassembled grsim gt disassemble 0x40000000 5 40000000 20100000 clr 10 40000004 29100004 sethi hi 0x40001000 14 40000008 81c52000 jmp 14 4000000c 01000000 nop 40000010 291402000 ta 0x0 grsim gt disassemble main 3 40001ac8 1110000e sethi hhi 0x40003800 00 40001acc 90122010 or 00 0x10 00 40001ad0 8213c000 or 407 hel grsim gt disassemble 0x40000000 0x4000000c 40000000 a0100000 clr 10 40000004 29100004 sethi hi 0x40001000 14 40000008 81c52000 jmp 14 4000000c 01000000 nop 2 12 Loadable command module It is pos
42. g the coverage data This makes it easier to analyse which instructions has not been executed grsim gt dis 0 00000000 0x88100000 1 clr g4 00000004 0x0900003a 1 sethi hi 0xe800 g4 00000008 0x81c12098 1 jmp g4 0x98 0000000c 0x01000000 1 nop 00000010 0xa1480000 0 mov psr 10 00000014 0xa7500000 O mov wim 13 00000018 0x10803ala O ba 0x0000e880 0000001c Oxac102001 O mov 1 416 Example scripts for annotating C code using saved coverage information from GRSIM can be found in the coverage sub directory 2 9 Symbolic debug information and profiling GRSIM will automatically extract text symbol information from elf files It is also possible to read symbols from an alternative elf file which is very useful when debugging self extracting applications such as those created by mkprom The symbols can be used wherever an address is expected grsim gt load samples stanford prom total size 28048 bytes in lt 1 sec read 37 symbols entry point 0x00000000 grsim gt break main breakpoint 1 at 0x000067f8 main grsim gt symbols samples stanford read 195 symbols entry point 0x40000000 grsim gt break main breakpoint 2 at Ox40001ac8 main grsim gt The symbols command can also be used to display all currently loaded symbols grsim gt symbols samples hello GRSIM User s Manual 16 Cobham Gaisler AB read 71 symbols grsim gt symbols 0x40000000 L trap table 0x40000000 L start 0x4000102c L window overflow 0x4000
43. ge 38 grspwX dbg flag Turn on debug information For a list of flags use the grspwX_dbg help command see Section 3 3 16 GAISLER SPW2 GRSPW2 SpaceWire controller page 38 2 2 2 1 GAISLER SRCTRL GRLIB SRAM PROM Controller sram size Sets the amount of simulated RAM kbyte Default is 2048 0 disables the sram prom size Sets the amount of simulated PROM kbyte Default is 4096 promstart address Start address of prom Default is bar 1 of the amba configuration Note that the amba bars have to cover the address sramstart address Start address of sram Default is bar 2 of the amba configuration or bar 2 if prom size is 0 Note that the amba bars have to cover the address sramws ws Sets the number of SRAM waitstates to ws Default is 1 promws size Sets the number of PROM waitstates to ws Default is 1 2 2 2 12 GAISLER_PCIFBRG GRLIB GRPCI PCI master target interface pci abits abits Defines size of BARO PCI address space 2 abits Upper half accesses PAGEO register Lower half is translated to AHB accesses pci dmaabits dmaabits Defines size of BAR1 PCI address space 2 dmaabits pci nothost If pci nothost is specified the device is modeled as if not in a PCI host slot pci blen bits Number of bits in burst length register of PCIDMA core grpciip lt sold11 gt Defines user defined PCI input provider See Section 3 3 13 2 GRPCI User supplied dynamic library page 33 grpciiparg lt str
44. gt Define argument to be given to the input providers grpci_inp_setup callback on startup grpciiparg can be given multiple times 2 2 3 VENDOR_ESA Switches for modules in package VENDOR_ESA GRSIM User s Manual 8 Cobham Gaisler AB 2 2 3 1 ESA LEON2 Leon2 CPU sci size Enable instruction scratchpad RAM of size kb Valid sizes are 1 64kb in binary steps scd size Enable data scratchpad RAM of size kb Valid sizes are 1 64kb in binary steps sci base address Set the base address of the instruction scratchpad RAM to address Defaults to 0x8e000000 scd base address Set the base address of the data scratchpad RAM to address Defaults to 0x8f000000 nfp Disables the FPU to emulate system without FP hardware Any FP instruction will generate an FP disabled trap dcsize size Defines the set size kbytes of the LEON dcache Allowed values are 1 64 in binary steps dlock Enable data cache line locking Default is disabled dlsize size Sets the line size of the data cache in bytes Allowed values are 8 16 or 32 dsets sets Defines the number of sets in the data cache Allowed values are 1 4 drepl repl Sets the replacement algorithm for the data cache Allowed values are rnd for random replacement lru for the least recently used replacement algorithm and Irr for least recently replaced replacement algorithm icsize size Defines the set size kbytes of the icache Allowed values are 1 64 in bina
45. hat the next APB device added with AddDevice should associate with The parameter apbid is the return value of the call to AddDevice when allocating the APB bridge The default APB bridge is the first one added SetBusPnp Currently not used For a more complete example see the simulator configuration module that is supplied with the GRSIM release Also see Appendix B Sample simulator configuration page 47 for detailed code listing 2 5 Running applications To run a program first use the load command to download the application and then run to start it john venus grsim exe GRSIM LEON MP Simulator v1 1 39 professional version Copyright C 2004 2009 Aeroflex Gaisler all rights reserved For latest updates go to http www gaisler com Comments or bug reports to support gaisler com Creating a simulator instance Loading Config Module simconf so Loaded simconf so added library Test Vendor added driver Simple EXAMPLE Mem Controller Initialising icache 1 4 kbytes 16 bytes line 4 kbytes total Cobham Gaisler AB 13 GRSIM User s Manual dcache 1 4 kbytes 16 bytes line 4 kbytes total allocated 4096 K RAM memory in 1 bank s allocated 2048 K ROM memory Initialising the Interrupt controller Initializing UART serial port on stdin stdout Component Vendor Leon2 SPARC V8 Processor ESA Leon 2 Memory Controller ESA Leon2 compat module Gaisler Research Leon2 compat module Gaisler Research Leon2
46. ib Sram Prom Mem Controller ver 0 10000000 70000000 APB UART ver 0 80000200 Leon3 Mp IRQ Controller ver 0 80000300 General purpose timer unit ver 0 80000400 AHB APB Bridge ver 0 81000000 The memory is configured to 4096kb RAM and 256kb ROM Cobham Gaisler AB 3 GRSIM User s Manual 2 Operation This chapter describes how to use GRSIM 2 1 Operational modes GRSIM can operate in two modes stand alone and attached to gdb In stand alone mode LEON applications can be loaded and debugged using a command line interface A number of commands are available to examine data insert breakpoints and advance execution etc When attached to gdb GRSIM acts as a remote gdb target and applications are loaded and debugged through gdb or a gdb front end such as DDD or Emacs GUD mode 2 2 Command line options GRSIM is started as follows on a command line grsim options The following command line options are supported by GRSIM c file Reads commands from file instead of stdin gdb Listen for gdb connection directly at start up port gdbport Set the port number for gdb communications Default is 2222 v Turn on verbose mode debug 1 vv Turn on extra verbose mode debug 2 simconf file Use file as simulator configuration module instead of the default simconf so simconfcfg opts Pass opts as parameters to the simulator configuration module E g simconfefg single argument or simconfcfg three arg
47. imulator exits Here is a good place to free memory that has been allocated by the device GRDRV RESTART is called during simulator reset GRDRV OPTIONS is actually not required but it is strongly advisable to at least implement an empty handler for this command to easily beeing able to send configuration parameters to the device cmd This function is called whenever GRSIM doesn t recognize a command as a internal command E g if run is issued cmd will not be called because run is an internal grsim command But if my_nice_cmd is issued cmd will be called 3 2 Read and Write operations There are a couple of implementations constraints when implementing the read and write oper ations which will be described below 3 2 1 The parameters explained me a pointer to this device s instantiation structure This can be thought of as this in C master a pointer to the callee s device structure address the address to which the access is made The simulator guaranties that this address always is within the region that the device was attached in the simulator configura tion See Appendix B Sample simulator configuration page 47 data a pointer to the data which is read from written to length the length of the transaction in wsize units wsize the wordsize in the transaction wsize word size bytes 0 1 1 2 2 4 3 8 3 2 2 Ordinary accesses Apart from filling in reading out the requested data the slave must al
48. is used when configuring a device with multiple interfaces to different buses SETVERSION Set the version field of all following entries The default version is 0 SETCUSTOM lt idx gt lt val gt Set the custom0 2 membar entry GRSIM User s Manual 12 Cobham Gaisler AB AddParams adds configuration parameters to the device with id idx The value of idx for a specific device is the return value from the call to AddDevice thus AddDevice must be called prior to AddParams The params argument is the argument that the user supplied in simconf params The AddParams call will simply copy the argument of its call there params is a pointer to a pointer to the first string in an array of strings i e char foo These parameters are passed only to the specified device and allows for different configurations of multiple instances of the same device E g the second of two UART instances might be passed uart dev ptypc to avoid both uarts from using stdin stdout init are called from the simulator at startup Arguments can be passed to this function by the simconfcfg command line option exit are called from the simulator when the simulator exits It is not mandatory to provide this from the simconf module cmd are not used but provided for future extensions of the simconf module ctrl are not used but provided for future extensions of the simconf module SetMBApbMaster for a bus with multiple APB bridges specify the APB bridge t
49. ll input characters locally when the terminal is connected to stdin stdout uartfifo Selects the size of the Receiver and Transmitter FIFOs Valid values are 1 2 4 8 16 32 Default is 1 Cannot be used together with fast_uart sbits Selects the number of bits in the scaler register Valid values are 12 32 2 2 2 2 GAISLER ETHMAC GRLIB GRETH 10 100 Ethernet MAC idx i Set unique index for specific GRETH core Needs to be set in simulation configura tion file phyrstadr i Set reset value of PHY address in MDIO Control Status register mdio register This also sets the bus that will repond to MDIO operations Default 0 2 2 2 3 GAISLER_GPTIMER GRLIB APB General Purpose Timer pirq num Irq number to use for timer interrupt By default the amba configuration s irq is used sepirq Use separate irq s for the n timers sbits Number of bits for the scalar Default is 16 nbits Number of bits for the counter Default is 32 ntimers Number of timers 1 7 Default is 2 2 2 2 4 GAISLER_GRGPIO General Purpose I O Port idx nr The index among gpio cores v Turn on verbose output nbits Sets the GRGPIO nbits generic Default is 16 imask mask Sets the GRGPIO imask generic Default is 0 irggen Sets the GRGPIO irggen generic Note that this generic is available from version 1 of the core and decides whether interrupt map registers are implemented or not Default is 0 which is also how version 0 behaves Cobham
50. n h define VENDOR_TEST 17 extern AmbaUnit_T MyMemCtr1 static char drvparams 22 static SimConf_T simcfg static const struct amba_unit testdrivers 22 NULL static const struct vendor_lib test_lib i name Test Vendor vendor VENDOR TEST version 1 drivers NULL simdrivers AmbaUnit T testdrivers F static int ConfInit void 1 int i j int busid int result 0 Add a new library simcfg AddLib void amp test_lib Add a driver to the newly added library simcfg AddDriver amp MyMemCtr1 Create a bus busid simcfg CreateBus simcfg sim Add some devices on the bus leon2 CPU i simcfg AddDevice simcfg sim busid VENDOR ESA ESA_LEON2 0 0 GRSIM User s Manual 48 simcfg AddParams i simcfg params cpu params mem ctrl i simcfg AddDevice simcfg sim simcfg AddParams i simcfg params SRAM Ctrl leon2 compat busid VENDOR_ESA ESA_MCTRL 1 4 SLAVE 0x00000000 0x10000000 La SLAVE 0x20000000 0x10000000 15 SLAVE 0x40000000 0x30000000 La APB 0x80000000 0x00000010 0 i simcfg AddDevice simcfg sim leon2 compat busid VENDOR_GAISLER GAISLER_L2C internal device 3 1 APB 0x80000010 0x00000030 0 i simcfg AddDevice simcfg sim leon2 compat busid VENDOR_GAISLER GAISLER_L2C internal device 3 1 AP
51. nfiguration 8 GRSIM User s Manual 26 Cobham Gaisler AB timer i simcfg AddDevice simcfg sim busid VENDOR_GAISLER GAISLER_GPTIMER 8 irqnr 1 APB 0xc0000300 bari 0x00000100 bari 0 simcfg AddParams i simcfg params 3 3 6 GAISLER_GRGPIO General Purpose I O Port The GRGPIO general purpose I O port vendorid VENDOR_GAISLER deviceid GAISLER_GRGPIO simulates all registers of the GRLIB GRGPIO core except for the bypass register Note that the available registers depends on the version of the core capabilities register from version 2 and the generics interrupt map registers availability depends on irggen that are being used to instantiate it See Section 2 2 2 4 GAISLER GRGPIO General Purpose 1 0 Port page 4 for instantiation options A user defined I O driver module is connected to the GRGPIO module to simulate the I O environment of the core The configuration module example below shows how to instantiate the module i simcfg AddDevice simcfg sim busid VENDOR_GAISLER GAISLER_GRGPIO 0 1 APB 0x80000900 0x00000100 0 simcfg AddParams i simcfg params idx O nbits 32 imask Oxffff 3 3 6 1 Commands Commands for this module where the X in gpioX should be replaced by the index of the core to work with gpioX driver lt so dll file symbol Loads an I O driver from the given so dll file where the given symbol must be a pointer to a struct grgpio_iodriver gpioX
52. ns int init char str int exit void int cmd char cmd void arg int ctrl int ctl void arg int SetMBApbMaster void simulator int busid int apbid int SetBusPnp void simulator int busid unsigned int addr SimConf_T where sim AddLib AddDriver CreateBus AddDevice is a pointer to the current simulator instance is used to add a library to the built in ones in grsim This allows reuse of device driver ID adds a driver to one of the existing libraries creates a bus in the system The return value from this function is the busid of the newly created bus A bus must of course be created before any device is added to the system adds a device to a bus in the simulated system The first 6 parameters to AddDe vice are fixed numbars designate the number of entries to follow Each entry is headed by a tag followed by variable arguments depending on the tag The possible tags are APB lt start gt lt size gt lt iscache gt Add a APB slave memory bar to the last added APB master MASTER Add a AHB master memory bar to the bus SLAVE lt start gt lt size gt lt iscache gt Add a AHB slave memory bar to the bus AHBIO lt start gt lt size gt lt iscache gt Add a AHB slave io bar to the bus In addition there are tags that are used when configuring a multibus system SWITCHBUS lt busid gt Switch membar allocation target to bus with id lt busid gt This
53. nvenience the installation di rectory should be added to the search path The commercial versions use a HASP4 license key 1 4 License installation GRSIM is licensed using a HASP USB hardware key Before use a device driver for the key must be installed The latest drivers can be found at http www aladdin com or http www gaisler com See Appendix A HASP page 45 for installation instructions of device drivers 1 5 Problem reports Please send problem reports and or comments to support gaisler com 1 6 Limitations to the evaluation version The evaluation version of GRSIM has a fixed configuration that cannot be changed i e no configuration command line paramters can be passed to the simulated units and no custom configuration module can be loaded Also simulation time is limited to 2732 cycles The configuration can be shown with the info sys command SPARC is a registred trademark of SPARC International GRSIM User s Manual 2 Cobham Gaisler AB grmon grsim 00 gt 00 01 gt info sys 00 01 003 01 01 003 02 01 008 03 01 00c 04 01 00d 05 01 011 06 01 006 Gaisler Research ahb master O Gaisler Research ahb master 1 Gaisler Research mem 00000000 mem 40000000 Gaisler Research irq 2 apb 80000100 Gaisler Research apb 80000200 Gaisler Research irq 8 apb 80000300 Gaisler Research mem 80000000 Leon3 SPARC V8 Processor ver 0 Leon3 SPARC V8 Processor ver 0 Grl
54. ore 30 3 5 10 GAISLER I2TIME LEON2 Timer ur ass C o ERR Ro e kas 31 3 3 11 qUAISDER LEONS LEONS CPU u sea rn 31 SA Commands ie nine dates meos EEG EE da Rode dn do 32 34127 JGAIDSEER LEONA LEONA CPU currada pra edes eda eco manioc 32 2 9 12 1 Commands 20d dede racer due 32 3 3 13 GAISLER_PCIFBRG GRLIB GRPCI master target interface 32 Soloed Commands a 24 cae bete oq a den de AR a Ra na ord 33 3 3 13 2 GRPCI User supplied dynamic library 33 3 3 13 3 PCI bus model API 34 3 3 14 GAISLER SDCTRL GRLIB SDRAM Controller 4 4 42 35 3 3 15 GAISLER SPW GRSPW SpaceWire controller 36 3 3 15 1 Commands siens ta pate ea a 36 3 9 15 2 Packet server 2 2 du oed dcr edad ae ee a AULA Eo ened des 36 3 3 16 GAISLER SPW2 GRSPW2 SpaceWire controller 38 3 3 16 L Commands uide a a ele RR ped Ro ae pese 38 3 3 17 GAISLER SRCTRL GRLIB SRAM PROM Controller 39 4 Libwary Tm 41 4 1 Function interface t be Peor ed ann ala ana 41 4 2 Multr threading dre rere Reti ee 43 4 2 1 Limitations to multi threading support 43 4 3 UART Wand nie mais tnd nn ana eere Lob eed epe ds 43 4 4 Linking an application with the GRSIM library 43 4 5 GRSIM library without a simconf module
55. ow to instantiate the module A multiprocessor system with 2 cpus is created leon4 i simcfg AddDevice simcfg sim busid VENDOR_GAISLER GAISLER_LEON4 0 0 simcfg AddParams i simcfg params smpid 0 i simcfg AddDevice simcfg sim busid VENDOR GAISLER GAISLER_LEON4 0 0 simcfg AddParams i simcfg params smpid 1 3 3 12 1 Commands Commands for this module cctrl show Shows decoded cache control register cctrl lt cpunum gt lt val gt Write lt val gt into cache control register of cpu lt cpunum gt possibly flushing caches 3 3 13 GAISLER PCIFBRG GRLIB GRPCI master target interface The GRPCI module vendorid VENDOR_GAISLER deviceid GAISLER PCIFBRG simu lates the GRLIB GRPCI PCI controller The user models all devices on the PCI bus through a user supplied dynamic library The configuration module example below shows how to instantiate the module Cobham Gaisler AB 33 GRSIM User s Manual i simcfg AddDevice simcfg sim busid VENDOR GAISLER GAISLER PCIFBRG 9 3 SLAVE 0xa0000000 0x20000000 0 AHBIO Oxfff20000 0x00020000 0 APB 0x80000a00 0x00000100 0 The GAISLER_PCIDMA module is an optional DMA engine addon to the GAISLER_PCIFBRG module It can only be used in combination with GAISLER PCIFBRG The example below shows how to intantiate it i simcfg AddDevice simcfg sim busid VENDOR GAISLER GAISLER_PCIDMA 0 1 APB 0x80000b00 0x00
56. riptors and the registers Cobham Gaisler AB 39 GRSIM User s Manual grspwX connect ip address port Iry to connect to the packet server at address ip address port port If ip address is omitted localhost is used If port is omitted T CP port 2225 is used grspwX server port Start server at address port if port is omitted 2225 is used grspwX dbg lt flags gt clean list help Toggle debug output options Do grspwX dbg help for a list of possible options grspwX_dbg clean will deactivate all debug output and grspwX_dbg list will list the current settings 3 3 17 GAISLER SRCTRL GRLIB SRAM PROM Controller The GRLIB SRAM PROM Controller vendorid VENDOR GAISLER deviceid GAISLER_SRCTRL simulates a prom or sram for a given address range Ether one region prom sram region or 2 regions one prom and one sram can be specified The configuration module example below shows how to instantiate the module One bar with range 0 0x10000000 is defined in which 2 mb of ram are allocated 0 0x200000 The below example doesn t allocate sram sram 0 sram prom mem ctrl i simcfg AddDevice simcfg sim busid VENDOR GAISLER GAISLER_SRCTRL 1 1 SLAVE 0x00000000 bar 1 0x10000000 bar 1 1 no sram 2mb prom simcfg AddParams i simcfg params sram 0 prom 2048 GRSIM User s Manual 40 Cobham Gaisler AB Cobham Gaisler AB 41 GRSIM User s Manual 4 Library GRSIM are also available as a library allowing th
57. rly communicated to gdb If the application encounters a fatal trap execution will be stopped exactly before the failing GRSIM User s Manual 20 Cobham Gaisler AB instruction The target memory and register values can then be examined in gdb to determine the error cause 2 13 4 Specific GDB optimization GRSIM detects gdb access to register window frames in memory which are not yet flushed and only reside in the processor register file When such a memory location is read GRSIM will read the correct value from the register file instead of the memory This allows gdb to form a function traceback without any intrusive modification of memory This feature is disabled during debugging of code where traps are disabled since no valid stack frame exist at that point GRSIM detects the insertion of gdb breakpoints in form of the ta 1 instruction When a breakpoint is inserted the corresponding instruction cache tag is examined and if the memory location was cached the tag is cleared to keep memory and cache synchronized 2 13 5 Limitations of gdb interface Do not use the gdb command where in parts of an application where traps are disabled e g trap handlers Since the stack pointer is not valid at this point gdb might go into an infinite loop trying to unwind false stack frames Cobham Gaisler AB 21 GRSIM User s Manual 3 Simulator Modules This describes how to write you own simulation model of an AHB slave or APB slave to u
58. roller 7 2 2 2 12 GAISLER_PCIFBRG GRLIB GRPCI PCI master target interface 7 2 23 VENDOR ESA sis Ai QNA S RN Ab qd au eee 7 22 01 ESA LEON Leon GPU sida RR ds 8 2 2 3 2 ESA MCTRL Leon2 Memory Controller 8 2 3 Interactive Commands 9 2 4 Simulator Configuration ses us rs eggs eee ee nr 10 2 4 1 Constructing a simulator configuration 10 25 Running applications ues ere rex ql ane due ne Ga a OR D Ried le Ree ote 12 2 6 Inserting breakpoints and watchpoints 13 2 1 Displaying resisters u cu veda nee ate axe trek Mad yea En oe 14 2 8 Code coverage siepe a b en De delicet he UH EA RUE E 14 2 9 Symbolic debug information and profiling 15 2 10 Displaying memory contents 16 2 11 Disassembly of memory ebbe teas da adero baa E doe o nare 17 2 12 Loadable command module 17 2 13 GDB interface ie sms ee ee ee ec 18 2 13 0 Attaching to pdb urn we ar a U da a ak ea 18 2 13 2 Debugging of applications 0ur ee eed ba aa na teste 19 2 13 9 Detachingu iesus zero een RA nad an een 19 2 13 4 Specific GDB optimization 20 2 13 5 Limitations of gdb interface
59. ry steps isets sets Defines the number of sets in the instruction cache Allowed values are 1 4 ilock Enable instruction cache line locking ilsize size Sets the line size of the instruction cache in bytes Allowed values are 8 16 or 32 irepl repl Sets the replacement algorithm for the instruction cache Allowed values are rnd for random replacement lru for the least recently used replacement algorithm and Irr for least recently replaced replacement algorithm 2 2 3 2 ESA MCTRL Leon2 Memory Controller onlyrom Only allocate ROM area memory sram size Sets the amount of simulated RAM kbyte Default is 4096 rom size Sets the amount of simulated ROM kbyte Default is 2048 Cobham Gaisler AB 9 GRSIM User s Manual rom8 romi6 By default the prom area at reset time is considered to be 32 bit Specifying rom8 or rom16 will initialize the memory width field in the memory configuration register to 8 or 16 bits T he only visible difference is in the instruction timing 2 3 Interactive Commands GRSIM dynamically loads libreadline so if available on your host system and uses readline to enter or edit monitor commands If libreadline so is not found fgets is used instead no history poor editing capabilities and no tab completion Below is a description of those commands available when used in stand alone mode batch execute a batch file of grsim commands break print or add breakpoint cont continue
60. s of callbacks that model the PCI bus see the section PCI bus model API A typical user supplied dynamic library would look like this int pci_acc struct grpci_input ctrl int cmd unsigned int addr unsigned int wsize unsigned int data unsigned int abort unsigned int ws BUS access implementation static void grpci inp setup int id struct grpci input l char argv int argc for i 0 i lt argc i do argument processing 1 gt acc pci acc do module setup printf grpci_inp_setup Claiming s n 1 gt _b name INPUT CLAIM 1 Y static struct grpci subsystem grpci pci 1 grpci inp setup 0 0 struct grpci subsystem grpciinputsystem amp grpci pci 3 3 13 3 PCI bus model API The structure struct grpci input models the PCI bus It is defined as struct grpci input struct input inp _b int acc struct grpci input ctrl int cmd unsigned int addr unsigned int data unsigned int abort unsigned int ws int target acc struct grpci input ctrl int cmd unsigned int addr unsigned int data unsigned int mexc 3 The acc callback should be set by the PCI user module at startup It is called by the GRPCT module whenever it reads writes as a PCI bus master Cobham Gaisler AB 35 GRSIM User s Manual cmd Command to execute see the PCI command table for details I O cycles not support by the GRPCI target addr PCI address data Data buffer fill for rea
61. se in grsim 3 1 The basic structure The simulator interface for attaching a device in the simulator is as follows typedef struct amba unit identification data short vendor short version short device char desc 32 functions int read struct ahb dev rec me struct ahb dev rec master unsigned int address unsigned int data unsigned int length unsigned int wsize int write struct ahb dev rec me struct ahb dev rec master unsigned int address unsigned int data unsigned int length unsigned int wsize int read done AccRes T result int write done AccRes T result int ctrl int ctl struct ahb dev rec me void args int cmd char cmd struct ahb dev rec me AmbaUnit T This is the structure that should be exported by each device module vendor The vendor ID of the device version The version of the device device The device ID of the device read The function that is called when a read access is made to the device write The function that is called when a write access is made to the device read done write done Not used by AHB slaves or APB slaves ctrl This is the generic control function It is via this function that grsim communicates with the device The minimum set of commands that a device has to implement are GRSIM User s Manual 22 Cobham Gaisler AB GRDRV_INIT is called during simulator initialisation GRDRV EXIT is called when the s
62. sible for the user to add commands to grsim by creating a loadable command module The module should export a pointer to a UserCmd_T called UserCommands e g UserCmd_T UserCommands amp CommandExtension UserCmd_T is defined as GRSIM User s Manual 18 Cobham Gaisler AB typedef struct Liblf T lib Functions exported by grmon int MemoryRead LibIf_T lib unsigned int addr unsigned char data unsigned int length int MemoryWrite LibIf T lib unsigned int addr unsigned char data unsigned int length void GetRegisters Liblf T lib unsigned int registers void SetRegisters Liblf T lib unsigned int registers void dprint char string Functions provided by user int Init O int Exit Q int CommandParser int argc char argv char Commands int NumCommands UserCmd_T The first five entries is function pointers that are provided by grsim when loading the module The other entries has to be implemented by the user This is how e Init and Exit are called when entering and leaving a grsim target e CommandParser are called from grsim before any internal parsing is done This means that you can override internal grsim commands On success CommandParser should return 0 and on error the return value should be gt 200 On error grsim will print out the error number for diagnostics argv 0 is the command itself and argc is the number of tokens including the command that
63. so finish the transaction by a call to Grsim_AmbaReadDone or Grsim_AmbaWriteDone if it was a write 3 2 3 Diagnostic accesses The simulator uses the read and write operations for diagnostic accesses which should not interfere with the simulation This is done by setting the master to DIAG see Appendix D grcommon h page 57 When the slave detects that the master is set to DIAG it should not call Grsim_AmbaReadDone or Grsim_AmbaWriteDone if it was a write 3 3 Predefined modules This chapter describes the predefined modules available with GRSIM Cobham Gaisler AB 23 GRSIM User s Manual 3 3 1 ESA LEON2 LEON2 CPU The LEON cpu module vendorid VENDOR ESA deviceid ESA LEON2 simulates a LEON2 processor The configuration module example below shows how to instantiate the module 1eon2 i simcfg AddDevice simcfg sim busid VENDOR ESA ESA LEON2 0 0 simcfg AddParams i simcfg params cpu params 3 3 2 ESA MCTRL LEON2 memory controller The LEON2 memory controller module vendorid VENDOR ESA deviceid ESA_MCTRL simulates rom sram and sdram The configuration module example below shows how to instantiate the module Four bars with range 0x00000000 0x10000000 0x20000000 0x30000000 0x40000000 0x70000000 and 0xc0000000 0xc0000100 are allocated Inside 0x40000000 0x70000000 there will be 16 mb of sram at 0x4000000 0x4100000 and 16 mb of sdram ar 0x6000000 0x6100000 Inside 0x00000000 0x10000000 there will be Amb of
64. th the option nosimconf Please see the provided app5 c for an example Cobham Gaisler AB 45 GRSIM User s Manual Appendix A HASP This appendix describes how to install the HASP drivers A 1 Installing HASP Device Driver A 1 1 On a Linux platform The HASP software for Linux includes the following e Kernel mode drivers for various kernel versions e Utilities to query the driver version and to display parallel ports e HASP library It is contained in the redhat 1 05 1 1386 tar gz suse 1 5 1 1386 tar gz or the haspdriver tar gz archive in the Linux directory on the GRMON CD The latest drivers are also available from the Aladdin website http www aladdin com For detailed information on the components refer to the readme files in the archive Note All described action should be executed as root A 1 1 1 Enabling Access to USB Keys In order for the daemon to access USB keys the so called usbdevfs must be mounted on proc bus usb On newer distributions it is mounted automatically e g SuSe 7 0 To mount usbdevfs manually use the following command mount t usbdevfs none proc bus usb Enabling Access to Parallel Keys To enable access to parallel port keys the kernel driver aksparlnx must be installed before starting aksusbd A 1 1 2 Loading the Daemon Load the daemon by starting it lt path gt aksusbd The daemon will fork and put itself into the background The status message is generated in the system
65. to O 7 6 CT time control flags 5 0 CN value of time counter Link state packet format GRSIM User s Manual 38 Cobham Gaisler AB 31 0 00 LENGTH LENGTH specifies length of packet including the header Header 31 15 8 7 54 3 2 0 0x4 RES IPID 0 TYPE 2 RES LS 31 16 RES reserved for future use must be set to 0 15 8 IPID IP core ID must equal 0 for Space Wire 75 TYPE packet type 2 for link state packets 4 3 RES reserved for future use must be set to O 2 0 LS Link State 0 Error reset 1 Error wait 2 Ready 3 Started 4 Connecting 5 Run 3 3 16 GAISLER_SPW2 GRSPW2 SpaceWire controller The SpaceWire module vendorid VENDOR_GAISLER deviceid GAISLER_SPW2 simulates the GRLIB GRSPW2 SpaceWire controller The simulation model delivers and receives packets through a TCP socket and can either act as a server or client which means you can easily connect two GRSIM simulators through SpaceWire The packet format is described in Section 3 3 15 2 GRSPW Packet server page 36 The configuration module example below shows how to instantiate the module i simcfg AddDevice simcfg sim busid VENDOR_GAISLER GAISLER_SPW2 14 15 APB 0x80000a00 0x00000100 0 simcfg AddParams i simcfg params idx 0 3 3 16 1 Commands Commands for this module replace X with the cores index specified with idz grspwX status Print out he status of the buffer desc
66. uments passed nosimconf Tell the simulator not to load a configuration module This switch is only available in the library version of GRSIM sci size Enable sizekb instruction scratch pad memory scd size Enable sizekb data scratch pad memory ucmd file Load a user command module See examples UserCmd in the distribution for an example f input files Executable files to be loaded into memory The input file is loaded into the target memory according to the entry point for each segment Recognized formats are elf32 and S record 2 2 1 Switches specific to certain modules Here follows switches that are specific to certain simulator models If more than one instance of a model is used it might be a good idea to pass the options via the configuration module see Appendix B Sample simulator configuration page 47 to allow different parameters to the two instances GRSIM User s Manual 4 Cobham Gaisler AB 2 2 2 VENDOR GAISLER Switches for modules in package VENDOR GAISLER 2 2 2 1 GAISLER APBUART GRLIB APB UART uart device By default the UART is connected to stdin stdout In Linux this switch can be used to connect the uart to another device E g uart dev ptypc will connect the UART to the pseudo device ptypc To communicate with ptypc the user should connect to dev ttypc fast uart Run the uart at infinite speed rather than the default slow baud rate uartlocalecho This will echo a
67. us unsigned int custom cfg 3 Entries only used in simulator void sim unsigned int busid struct bus_dev_rec struct ahb dev rec dev 128 int ndevs int ioarea 4 int cfgarea int nbus GRSIM User s Manual 66 Cobham Gaisler AB struct vendor_lib 4 char name 64 int vendor int version struct grdriver drivers struct amba unit simdrivers typedef struct addr data unsigned int addr unsigned int data AddrData T enum regnames 1 GO G1 G2 G3 G4 G5 G6 G7 00 01 02 03 04 05 SP 07 LO Li L2 L3 L4 L5 L6 L7 IO I1 I2 13 14 15 FP 17 FO F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 Y PSR WIM TBR PC NPC FPSR CPSR Fi extern void GetRegisters void lib unsigned int regs struct mbus_rec int found unsigned int cfgarea float ffact i endif __ASSEMBLER__ endif GRCOMMON H
68. v rec me struct ahb dev rec master uint32 address uint32 data uint32 length uint32 wsize int i uint32 mem uint32 MemCtrl T me gt data gt ramb uint32 addr address amp DATA me gt size 1 for i 0 i lt length i datali uint32 amp mem addr gt gt 2 il I if NULL master 1 struct abh dev rec DATA me gt accres dev master DATA me gt accres mexc 0 Grsim_AmbaReadDone me amp DATA me gt accres SimTime T length return O int32 memctrl write struct ahb dev rec me struct ahb dev rec master uint32 address uint32 data uint32 length uint32 wsize int i char mem MemCtrl T me gt data gt ramb uint32 addr address amp DATA me gt size 1 uint32 addr2 for i 0 i lt length i switch wsize case O addr2 addr i ifdef HOST LITTLE ENDIAN addr2 0x3 endif mem addr2 unsigned char data i break case 1 addr2 addr i 2 ifdef HOST_LITTLE_ENDIAN addr2 0x2 endif unsigned short amp mem addr2 unsigned short datalil break case 2 Cobham Gaisler AB 55 GRSIM User s Manual unsigned int amp memladdr i 4 unsigned int datalil break case 3 unsigned int amp mem addr i 8 unsigned int data 2 i unsigned int amp memladdr 4 i 8 unsigned int data 2 i 1 F if NULL master struct abh dev re
69. vice internal device internal device internal device Cobham Gaisler AB leon2 irq leon2 timer leon2compat plug amp play configarea Cobham Gaisler AB ESA_SPWA 0x014 ESA BOSCHCAN 0x015 ESA L2IRQ2 0x016 ESA L2STAT 0x017 ESA L2WPROT 0x018 H enum 1 GLEICHMANN CUSTOM 0x001 GLEICHMANN GEOLCDO1 0x002 GLEICHMANN DAC 0x003 F enum GRDRV IRQ SETLEVEL 0 GRDRV IRQ SETRUNNING 1 GRDRV IRQ GETRUNNING 2 enum GRDRV_NOP GRDRV_APBINIT GRDRV_OPTIONS GRDRV_INIT GRDRV_EXIT GRDRV_REPORT GRDRV_RESTART GRDRV_APBCONFREAD GRDRV_IRQCTRL_ATTACH GRDRV_IRQROUTE_ATTACH GRDRV_GDB_MODE GRDRV_CPU_SETPC GRDRV_CPU_GETPC GRDRV_CPU_ATTACH GRDRV_CPU_DISP_REGS GRDRV_CPU_ADD_WP GRDRV_CPU_DEL_WP GRDRV_CPU_SHOW_WP GRDRV_CPU_ADD_BP GRDRV_CPU_DEL_BP GRDRV_CPU_DEL_BP_GDB GRDRV_CPU_SHOW_BP GRDRV_CPU_STEP GRDRV_CPU_CONT GRDRV_CPU_GET_REGS GRDRV_CPU_SET_REGS GRDRV_CPU_GET_REGS_GDB GRDRV_CPU_SET_REGS_GDB GRDRV_CPU_FLUSH 59 oo J O O1 amp amp ND ro NNNNNNNNNER EA RRRR PR PB 0 J O O1 ND H OO J O O1 NO H GRSIM User s Manual GRSIM User s Manual GRDRV CPU FLUSH WIN GRDRV CPU GET STATUS GRDRV CPU GDB SYNC REGS GRDRV CPU CACHE SNOOP GRDRV AMBA READ DONE GRDRV AMBA WRITE DONE GRDRV CPU READ SCRATCH GRDRV CPU WRITE SCRATCH GRDRV CPU DISAS GRDRV MCTRL GET USEABLE STACK GRDRV CPU GET SMPID GRDRV CPU PRINT STATUS
70. w void sim Adds an event to the event queue Returns 0 on success non zero on failure int add_event void sim void handler void void arg SimTime T offset Stops all event that matches the given handler Returns the number of stopped events int stop event void sim void handler void Stops all event that matches both the given handler and arg Returns the number of stopped events int stop event arg void sim void handler void void arg Returns non zero in an event exists in the event queue that matches both the given handler and arg int event exists void sim void handler void void arg Returns the current simulation time SimTime T get_time void sim Stops the simulation after current event is finished but before the next event void stop simulation void sim Cobham Gaisler AB 29 GRSIM User s Manual Prints both to stdout and if logging to logfile Works like printf apart from the sim arugment int simprintf void sim char format Typically an 1 0 driver sets up a struct grgpio_iodriver initializing the setup reset and exit functions that are called by GRSIM when the module is loaded at reset and when the module is unloaded For the struct grgpio_iodriver core driver field the output change function pointer must be initialize
71. x013 ESA SPWA 0x014 ESA BOSCHCAN 0x015 ESA L2IRQ2 0x016 ESA L2STAT 0x017 ESA L2WPROT 0x018 GLEICHMANN cores define define define irg lt define define define GLEICHMANN_CUSTOM 0x001 GLEICHMANN_GEOLCDO1 0x002 GLEICHMANN_DAC 0x003 gt cpu cmds GRDRV_IRQ_SETLEVEL 0 GRDRV IRQ SETRUNNING 1 GRDRV IRQ GETRUNNING 2 driver commands define define define define define define define define define define define define define define define define define define define define define define define define define define GRDRV_NOP GRDRV_APBINIT GRDRV_OPTIONS GRDRV_INIT GRDRV_EXIT GRDRV_REPORT GRDRV_RESTART GRDRV_APBCONFREAD GRDRV_IRQCTRL_ATTACH GRDRV_IRQROUTE_ATTACH GRDRV_GDB_MODE GRDRV_CPU_SETPC GRDRV_CPU_GETPC GRDRV_CPU_ATTACH GRDRV_CPU_DISP_REGS GRDRV CPU ADD WP GRDRV CPU DEL WP GRDRV CPU SHOW WP GRDRV CPU ADD BP GRDRV CPU DEL BP GRDRV CPU DEL BP GDB GRDRV CPU SHOW BP GRDRV CPU STEP GRDRV CPU CONT GRDRV CPU GET REGS GRDRV CPU SET REGS Oo OO NO O1 amp amp ND Hr o Pe RO NONNNNNRPRPRPRP RP RP RP HR OPWNRPOOAN DOR YN Cobham Gaisler AB Cobham Gaisler AB define define define define define define define define define define define define define define define define define define define define define define define define define endif GRDRV_CPU_GET_REGS_GDB GRDRV_CPU_SET_R

Download Pdf Manuals

image

Related Search

Related Contents

RT 2122 A - ikra GmbH  Page 1 Page 2 火災はもちろん』 ァクシテーント 住まいを取りまく“火災  Posiflex CD-2860U-B bar code reader  9.1MB      Garmin Forerunner 450CX User's Manual  OsiriX User Manual  HP StorageWorks Enterprise File Services WAN Accelerator User's Manual  

Copyright © All rights reserved.
Failed to retrieve file