Home

MDS User Manual - Moravia Microsystems

image

Contents

1. Q Availability Shift 0 into the lsb Shift 1 into the lsb Shift previous lsb back into the new lsb Shift C into the lsb SO 0x01 S0 S0 S0 S0 3 S0 S0 S0 S0 S0 ll 0b00000001 0b00000010 0b00000101 0b00001011 0b0001011C C is either O or 1 1 if result is zero otherwise 0 the msb most significant bit of the original content of the sX register PicoBlaze 6 PicoBlaze 3 PicoBlaze II PicoBlaze PicoBlaze CPLD yes yes yes yes yes 6 2 INSTRUCTIONS 63 SRO SR1 SRX SRA Instructions SRO SR1 SRX and SRA all shift contents of the specified register by one bit to the right The new msb most significant bit depends on the instruction and the lsb least significant bit is shifted out to the C flag Syntax SRO sX Shift 0 into the msb SR1 sX Shift 1 into the msb SRX sX Shift previous msb back into the new msb SRA sX Shift C into the msb Examples LOAD SO 40x80 SO 0b10000000 SRO S0 SO 0b01000000 SR1 S0 SO 0b10100000 SRX S0 SO 0b11010000 SRA S0 SO 0bC1101000 C is either O or 1 Flags Z 1 if result is zero otherwise 0 C the lsb least significant bit of the original content of the sX register Availability PicoBlaze 6 PicoBlaze 3 PicoBlaze II PicoBlaze PicoBlaze CPLD yes yes yes yes yes 64 CHAPTER 6 ASSEMBLER RR RL These instructions rotate the specified register by one bit to the left or righ
2. Generate If you have your input and output file selected This button will trigger generation of VHDL template 36 CHAPTER 4 USER INTERFACE 37 Chapter 5 Simulator 5 1 Main simulator panel This panel is the main part of the simulator user interface Simulator mimics functionality of PicoBlaze instruction set and provide detailed view in its registers overview of input and output ports etc and displays warning when the simulated program behaves strangely i e does something which under normal circumstances results an error Following picture shows main window of the simulator You can find here internal registers scratch pad ram input and output ports stack program counter elapsed time and cycles current clock and internal flags carry and zero All those features can be edited during processor simulation If some value changes state it will turn yellow You can drag out whole simulation panel and place outside of the main window for example another display on your computer Simulation Info Registers Scratchpad RAM Input Ports RD Output Ports WR Stack exee PC 0x60A f Pu 152 00 01 02 03 04 05 06 07 00 01 02 03 04 05 06 07 00 01 02 03 04 05 06 07 JtustiPos cs 52 000 00 00000000 170 AA 10101010 99 99 oo oo o0 o0 o0 o0 oo 00 oo o0 o0 00 oo 00 oo o0 00 48 39 36 FF FF 7F 00 00 lock 10 0 4 026 1A 00011010 ooo 00 00000000 os gg 0g 90 00 GO 0G GO O0 os G0 bo G6 0 GG 00 O9 GO os
3. fill VHDI and Verilog templates in the same was as the assembler would do it This tool can even read and extract memory initializations from VHDL and Verilog files but only if they were created from templates provided with this IDE or very similar ones and save this data to file format of your preference MEM for instance or use them to initialize another template which you provide Input file is the file from which memory initialization data will be read Input Options Type selects input file type HEX MEM etc Input Options Bytes per record is for MEM files only Select 3 for PicoBlaze 6 Pi coBlaze 3 and PicoBlaze II or select 2 for PicoBlaze CPLD and PicoBlaze Input Options OPCode size is for VHDL and Verilog only and selects opcode width Se lect 18 for PicoBlaze 6 PicoBlaze 3 and PicoBlaze II or select 16 for PicoBlaze CPLD and PicoBlaze Output file is here this tool will store the result of this operation Output options Type selects output file type HEX MEM etc Input Options Bytes per record same as with input options Input Options OPCode size same as with input options Input Options Name is for VHDL and Verilog only and is used for module name name Input Options Overall size is for HEX and sets the overall number of records lines with hexadecimal number in the resulting file Input Options Template file is for VHDL and Verilog only and spec
4. 0 Unable to resolve this expression The given expression cannot be resolved please check if the expression is syntactically correct Syntax not understood There is a syntax error in your source code in this case the error is completely ununder standable for the assembler Character constant has to have 8 bits Character constants are supposed to be only one letter long Unterminated string or character constant Strings and character constants start with respectively and has to end with the same character i e respectively gt In this case you have apparently left a string or character constant unterminated by the appropriate character 6 9 ASSEMBLER MESSAGES 121 Unrecognized escape sequence X Escape sequence X was not understood by the assembler please check the table of escape sequences for reference section 6 1 4 No file name specified You probably forgot to specify name of file for the INCLUDE directive Unable to open the specified file X The specified file X cannot be opened probably does not exists or your operating system refuses to grad you access to it Please check whether the file exists and check your permissions Unrecognized token X Lexical analyzer was unable to recognize this token X Normally this does not happen but if your code contains some binary values with no printable representation or something like that this may happen Maximum number of mes
5. Button Generate Generate the code 2 Loop Generator x c Q9 r Desired delay Options e Time e UpperCase Clock cycles X Coments Time 120 i m ms v Instruction DJNZ ly Clock 10 MHz Cycles 1200000 Registers C Use default register names 1 S1 3 S3 Js s5 2 S2 4 4 6 S6 Code Type Macro e Blank LOAD S2 2144 LOAD 3 5 DELAY DJNZ S1 DELAY DJNZ S2 DELAY DJNZ S3 DELAY Copy to clipboard Generate code j Figure 4 7 Delay loop generator 4 5 TOOLS 29 4 5 3 Disassembler Disassembler is a tool that translates machine language into assembly language The inverse operation to that of an assembler Section File File you want to disassemble Section Target Processor architecture Family Processor family of the selected architecture Indentation Whether you want to indent the generated code with tabs or spaces Tab size Tab size measured in number of spaces Radix Radix for numeric literals in the resulting code binary octal decimal or hexadecimal Line break CRLF Windows LF Linux or CR Mac Case Use uppercase or lowercase characters Generate symbols Which types of values should be defined as symbols in resulting code de File Disassembler my file mem Target Architecture PicoBlaze v r Options Indentation Tabs X TabSize 4 Radix Linebreak Case Bin
6. License Display detailed information about the terms of license for this product Action shortcuts These are the key shortcuts for the main windows code editor shortcuts will be shown later in this manual Shortcut Description Shortcut Description Ctrl N New file ctrl 0 Open file Ctrl S Save file Ctrl W Close file Ctrl Shift Ss Save As Ctrl L Save All F11 Compile F6 Start simulator F7 Simulator Run Fs Simulator Animate F9 Simulator Step F10 Simulator Reset Table 4 1 Key shortcuts for the Main Window 22 CHAPTER 4 USER INTERFACE 4 2 Code Editor Code editor is optimized for writing source code for your applications it behaves as is generally expected from a code editor The editor has two different modes of operations 1 Editing mode for editing your files this mode is for reading and writing editing 2 Simulation mode for displaying progress of the program simulation in this mode the displayed code is for reading only 4 2 1 Main features Syntax highlight Syntax highlight is supported only for the PicoBlaze assembly language Syntax highlighting is automatically activated for files with extension asm and psm otherwise syntax highlight stays inactive Left panel For easier navigation the editor s left panel shows line numbers in your code bookmarks and breakpoints Editor status bar Editor status bar displays information about current column and line number Context m
7. A and B can be either register address or immediate value in case of immediate value it has to be prefixed with So immediate constants are specified with prefix A value without is considered to be a register address Syntax Description Example A B equal to SO 81 A B not equal to SO 0xA5 A gt B greater than H OX5A 2 gt SO A lt B lower than HA lt my reg A gt B greater or equal A gt B A lt B lower or equal S4 lt B A B bitwise AND A amp SO A amp B bitwise NAND SO amp SO Table 6 10 Condition syntax used for all code generation directives Availability PicoBlaze 6 PicoBlaze 3 PicoBlaze II PicoBlaze PicoBlaze CPLD yes yes no no no 6 5 CODE GENERATION DIRECTIVES 101 IF ELSEIF ELSE ENDIF To implement run time conditions you can use IF ELSEIF ELSE and ENDIF directives for better readability of you code Assembler translates these directives as predefined macros con taining COMPARE TEST and JUMP instructions You can use registers and immediate constants in conditions Syntax IF lt condition gt lt code gt ELSEIF lt condition gt lt code gt ELSE lt code gt ENDIF Example IF sO 10 Register to immediate value LOAD sO 10h ELSEIF B gt 81 Register to register SRO s0 ELSE 0x5 gt 0x6 Immediate value to immediate value INPUT s0 RX_data ENDIF In this example the f
8. Commencing read cycle at port address lt location gt plio_read_end Finishing the read cycle plio_write location lt detail gt Commencing write cycle at port address lt location gt with value lt detail gt plio_outputk 0 location detail Commencing OUTPUTK type write cycle at port address location with value detail plio write end Finishing the write cycle 7 4 SIMULATOR 141 7 4 5 Notes Safety The simulator never crashes no matter what the input might be Error states are always responded with appropriate error message or are just silently ignored Usability This simulator interface is not meant for the user to hand write commands and directly read results it is intended to be used in scripts Complexity This tool is generally relatively modest in terms of memory usage and runs very fast in run mode command sim run The only thing which might heavily slow it down is the textual input and output if you plan to use this tool in your scripts please try to use the run mode as much as possible to preserve some speed advantage 142 CHAPTER 7 COMMAND LINE TOOLS 143 List of Tables 4 1 Key shortcuts for the Main Window sees 19 AD bor shoes ono koe A Seats See v eed EH 20 il Escape seguents ccoo once koe y EE 9 BOW X Yo X o3 9m x RR ROS 42 6 2 Predefined symbols for registers cas ecos 22e 44 6 9 Operators priorities oc e e saaba bee ad E OE ob RU
9. Dll aio ra aaar ee YR a aaa 4 403060 wed 84 NAMEREG o casa eats an ae eG ae REA AA A OXON db do eoo ee eae AUN A 84 DATE ovario a OS 85 CODE sn a ka A RRO EES ee Ow eo SR t xoi om bE SR Se A 4 30 85 PORT ocioso eee dS EO RE ae le ROS PG 4e ee Oe 86 PORTES send kk ea GAG a Bed oe we X TSS3d4duas 86 PE suu du Ns a att a eee aves e o d we ee a id 86 AUTORE G e pe ra ne A ARREARS Ea he wo x 458 87 AITOR ok bie A Meee ee E EE ee 87 INTESPR lt a a we OX OX Re eee ae amp hb PERS Sw 88 A a Sk Gn amp Aa Ba te eee ee DR AAS SOAS SG AMA AL a 88 MERGESPR s a p wu b eee ha RRS EEE 09 9X wx ee OE x YS 89 UU ng ee a oe Ba OE ES x wo a A ees 89 DEFINE 3252 Gh oe PHA a S 3 P3309 ee o qu 90 ORG ADDRESS 2l22x2du eon A A ect done Re v PST adda es 90 A we RO ew at ta oe ee ag dw a ae ee 91 UNDERENE UNDEF gg alae e giia EXC YE ae aE RA eS 91 DB 22222 25889 POS aE ee Eee nee ead Sob m m XL Ro wid 92 LIMEE Zio bbe ene ha ERE Pee wae A Gs 92 CONTENTS LIST NOLIST ses a bb GAS eee RA ee e eee bd a ee 93 AR S ehh he ee A a a ee oe A a et 94 MESSAGE owe OR HO A A ea ROS m aE ES 94 ERROR dx eb ew ee hee ee ds ee TIT 94 WARNING oiu oaea Sie ee ee ele ROR uec m b RE es a 94 REPEAT lt a 20 i844 26 60 Bae Oe Oe ai dese dedi aix dz de di ae oe 95 AWHILE ico a eb wem aa EP Ae a a ded 96 EXILJMP DEFAULT JUMP ok eb ee adeeb da E 96 s uu MEME TT 97 6 5 Code generation directives 2e 98 IF ELSEIF ELSE ENDIF 225m a a a ee ee 9
10. OFFOOh oXx Y X Y When operators with different priority levels appear in the expression operations are eval uated according to priorities When operators of the same priority appear in the expression operations are evaluated from left to right Parenthesis may be used to force a different order of evaluation for example 2 2 2 is evaluated as 6 because multiplication has higher priority than addition but 2 2 2 results in 8 because addition is enclosed by parenthesis and therefore it is evaluated prior to the multiplication The table below shows priorities for all supported operators priority 1 is the highest prior ity priority 9 is the lowest priority Arithmetic operators have higher priority than relational operators and relational operators have higher priority than logical operators Priority Operator Description Example 1 unary plus sign 12 1 unary minus sign 5 2 id bitwise NOT Oa55ah 2 logical NOT 0a55ah 3 unsigned multiplication 11 12 3 unsigned division 11 12 3 unsigned modulo 13 11 4 unsigned addition 3 5 4 unsigned subtraction 20 4 5 binary shift left 21 4 5 gt gt binary shift right 32 gt gt 2 6 lt less than 11 12 6 lt less or equal than 11 lt 11 6 gt greater than 12 gt 11 6 gt greater or equal than 12 gt 11 7 equal to 11 11 7 l not equal to A B T lt gt no
11. OPTIONS Options g debug file lt full file name gt REQUIRED Specify MDS native debug file d device device REQUIRED Specify exact device for simulation For PicoBlaze kepsm1 kcpsm1cpld kcpsm2 kcpsm3 and kcpsm6 c code file lt full file name gt REQUIRED Specify file with machine code for simulation t code file type lt file type gt REQUIRED Specify type of the machine code file supported are hex Intel 8 HEX or Intel 16 HEX srec Motorola S Record bin Raw binary file mem Xilinx MEM file for PicoBlaze only vhd VHDL file for PicoBlaze only v Verilog file for PicoBlaze only rawhex Raw HEX dump for PicoBlaze only 7 4 SIMULATOR 135 p proc def file lt processor definition file gt Specify architecture for user defined processor this option makes sense only if device Adaptable h help Print a brief help message V version Print version information and exit 8 silent Be less verbose Examples mds proc sim d kcpsm6 g Examplei dbg c Examplei ihex t hex 7 4 3 Commands Commands might have several subcommands and might take arguments arguments might be optional if an argument is a number it might be hexadecimal decimal octal or binary radix is specified with either prefix or suffix notation in the same way as in the assembler examples Oxff 255 0377 0b11111111 or ffh 255d 377q 11111111b When simulator responses to a command with a
12. and store the result in sX AND sX sY Perform AND on sX register and immediate value kk put result in sX Examples AND SO 0x55 SO SO 0x55 AND S1 SO S1 S81 amp SO Flags Z Lifresult is zero 0 otherwise c 0 Availability PicoBlaze 6 PicoBlaze3 PicoBlaze II PicoBlaze PicoBlaze CPLD yes yes yes yes yes 56 CHAPTER 6 ASSEMBLER 6 2 3 Arithmetic ADD ADDCY The ADD instruction performs an 8 bit addition of two values Syntax ADD sX kk ADD sX sY ADDCY sX kk ADDCY sX sY Examples LOAD LOAD ADD ADD ADDCY ADDCY Flags Availability SO S1 SO SO S0 SO 1 2 S1 5 S1 5 Add immediate value kk to sX register Add content of sY register to sX register Add immediate value kk to sX register Add content of sY register to sX register without carry without carry with carry with carry 50 1 50 2 SO SO S1 90 80 5 S0 SO 81 Carry S0 SO 5 Carry Z 1 if result is zero 0 otherwise C 1 if results in an overflow 0 otherwise PicoBlaze 6 PicoBlaze 3 PicoBlaze II PicoBlaze PicoBlaze CPLD yes yes yes yes yes 2 ADDCY on PicoBlaze 6 behaves differently zero flag is set to 1 if result is zero and zero flag was set prior to the ADDCY instruction otherwise it set to 0 6 2 INSTRUCTIONS 57 SUB SUBCY The SUB instruction performs an 8 bit subtraction of two values withou
13. location detail Unable to decode instruction opcode detail read from address location cpu invalid irq location Attempt to invoke interrupt service from location while it is not possible cpu invalid ret location Attempt to return from subroutine at location while there is no subroutine to return from cpu invalid reti 0 location Attempt to return from interrupt service at location while there is no interrupt service subroutine to return from cpu pc overflow value Program counter overflow new value of PC is value cpu pc underflow value Program counter underflow new value of PC is value cpu pc changed value Program counter changed new value of PC is value cpu call location detail Calling subroutine at address detail from address location cpu return location Returning from subroutine return request occurred at address location cpu irq location Calling interrupt service subroutine from address lt location gt cpu return from isr location Returning from interrupt service subroutine return request occurred at address location Memory group attribute indicates memory space where the event occurred 140 CHAPTER 7 COMMAND LINE TOOLS register Register file data Scratch pad ram stack Call stack code Program memory Events are gt gt gt gt
14. olx Port address GRAY Converts output port value to gray code oo Hex 0 Dec o Use coder Noe Figure 4 12 8 segment editor BCD Output port value will be presented as BCD Re member that bigger number than 99 cannot be dis played 4 5 8 7 segment simulator Simulator of 7 segment display with common anode the display is connected to an output port Port bits can be assigned to any display segment Multiple instances of this simulator can be opened at once You can set BCD decoder to simulate certain commonly used FPGA logic BCDlowNibb Low order nibble is decoded and displayed BCDhighNibb High order nibble is decoded and displayed 4 5 9 Numeric base converter This tool might be useful when you want to quickly convert some number to another radix E Converter NJ ey HEX BIN DEC F5 11110101 245 aa 10001010 138 11101011 235 Figure 4 14 Converter Hex 23 Address 00 Figure 4 13 7 segment sim ulator 4 5 TOOLS 33 4 5 10 VHDL Wizard x HDL wiza Input file Output file Existing components MPU_SYS entity UA KCPSM I2C interface LCD interface SPI slave I2C interface SPI slave LCD interface LCD interface Buttons KCPSM6 v Create component Delete component Generate Figure 4 15 VHDL Wizard Purpose of this tool This tool is can be u
15. rules Special macros include directives IF ELSEIF ELSE FOR and WHILE Term pairing rules refers to pairing of IF ENDIF FOR ENDFOR and WHILE ENDWHILE Only one fail jump may be specified in the code When using the FAILJMP directive or similar directive it may be used only once in the compilation unit Multiple usage of such directive would result either in mutual overrides or in collisions for that reason it is not allowed String X not defined You are attempting to use a string X which has not been defined in the table strings using the STRING directive Probably this is just a typo please check if you are using the correct syntax for the OUTPUTK or LOAD amp RETURN instruction Assembler feature X is supported only on X and higher Certain special assembler features like autogenerated run time conditions etc are sup ported only on certain processors because they dependent on specific instructions Attempting to override string X A string defined using the STRING directive would be overridden by symbol This action is not allowed 6 9 ASSEMBLER MESSAGES 125 Attempting to override symbol X A symbol defined using the EQU SET etc directive would be overridden by string STRING directive This action is not allowed Redefinition of macro X original definition is at Y This indicates that the macro X originally defined at location Y will be overridden by this definition expansions of this macro from this line o
16. set memory etc animate Animate program Program animation will run in a separate thread while this tool continues to listen and answer to commands It is safe to use all other commands while the simulator is running e g set memory etc halt Halt program animation or run y reset Reset simulated processor irq Invoke an interrupt request exit lt code gt Exit this command line interface with exit code lt code gt if the lt code gt is not specified default exit code with value of 0 will be used help lt command gt Print a brief help message about the commands if optional lt command gt is specified this command prints a message concerning specifically the given lt command gt Example Input Output get cycles 0 done sim step done get cycles 1 done sim step OxA done get cycles 11 done 7 4 4 Events When something changes in the simulator for instance content of some register simulator prints a message like gt gt gt register mem_inf_wr_val_written 0 Event message al ways starts with gt gt gt sequence so it can be easily identified and handled by a parser All numbers present in an even message are represented in decimal radix 138 CHAPTER 7 COMMAND LINE TOOLS Event message syntax gt gt gt lt attribute gt lt event id gt lt value gt lt location gt lt detail gt Tokens enclosed by squar
17. zero prefix 076 011 027 for binary radix use the Ob prefix 0b11001100 0b10101010 0b11111111 for ASCII value put the character in single quotes a A 3 Suffix notation is also supported 80h hex 128d dec 200q oct 10000000b bin for ASCII characters you can also use C language escape sequences 0 NUL n LF X CR Nt TAB Addressing mode specification is mandatory For immediate addressing use the 7 prefix LOAD SO 0xAB for indirect addressing use the prefix STORE SO S1 and for direct addressing do not use any prefix LOAD SO Si 3 this loads SO with S4 This assembler is case insensitive load SO S1 is the same as LOAD sO s1 or Load SO s1 This assembler supports user defined macro instructions and expressions LOAD SO 2 3 8 etc please refer to the Tutorial Project and the Quick User Guide for brief introduction or to later pages in this manual for detailed description 14 CHAPTER 3 GETTING STARTED 3 4 Compatibility mode with Xilinx assembler Don t want to learn a new assembler There is a solution to that since version 1 2 MDS supports compatibility mode with the Xilinx assembler for PicoBlaze you can enable this mode in the project configuration dialog Main Menu gt Project gt Configure gt Options With compatibility mode enabled you can simply use the syntax you a
18. The compiler identifies certain strings enclosed by characters marks and substi tutes these character strings with corresponding values The MDS assembler replaces instances of timestamp name INIT_X INITP_X INIT64 X INIT128_x INIT256 X 1 8 0 INIT X 8 0 _INITP_X 17 9 INIT X 17 9 INITP X and begin template Templates have to contain these marks for the compiler to work correctly 6 8 2 MEM File MEM file contains machine code generated by the assembler There are 17 columns 4 bytes wide the first column starts with and represents address other columns contain instruction opcodes Unused locations are filled with zeros Example 00000 000011F7 00001299 0000132E 00004577 00007789 000015A4 00040 000004DF 000047F4 00000000 00000000 00000000 00000000 00080 00000000 00000000 00000000 00000000 00000000 00000000 00CO 00000000 00000000 00000000 00000000 00000000 00000000 00100 00000000 00000000 00000000 00000000 00000000 00000000 Q3F80 000011F7 00001299 0000132E 00000000 00000000 00000000 3FCO 000011F7 00001299 0000132E 00000000 00000000 00000000 110 CHAPTER 6 ASSEMBLER 6 8 3 Raw Hex Dump file Raw Hex Dump is very simple file starts with hexadecimal representation of opcode of the first instruction in your program at address 0x0 then it is followed by opcode at address 0x1 0x2 and so on Unused l
19. VARIABLE VARIABLE VARIABLE VARIABLE LOAD First symb 0b10011100 Second symb 47 Third symb 0x39 Fourth symb A 4 18 B Fifth symb Ox09 2 S0 First_symb Binary Decimal Hexadecimal An expression Another expression Loads SO with 0b10011100 86 CHAPTER 6 ASSEMBLER REG Symbols defined with the REG directive are considered to be register addresses only and cannot be used for anything else except for that REG is just another EQU Syntax lt symbol gt REG lt address gt Examples A_reg REG si B_reg REG s2 C_reg REG s3 D_reg REG 0x4 E_reg REG 0x5 LOAD A reg D reg SO 85 LOAD B reg 40x55 82 0x55 NAMEREG This directive is nothing more the REG directive with another syntax Syntax NAMEREG symbol address Examples NAMEREG a s1 NAMEREG b s2 NAMEREG x s3 NAMEREG y 4 NAMEREG z OxA LOAD a b 51 S2 LOAD x 0x55 S3 0x55 6 4 DIRECTIVES 87 Symbols defined with the DATA directive are considered to be scratch pad ram addresses only and cannot be used for anything else except for that DATA is just another EQU Syntax lt symbol gt DATA lt expression gt Examples my_location PORT 0x12 STORE SO my location Symbols defined with the CODE directive are considered to be program memory addresses only and cannot be used for anything else except for that CODE is just another EQU Syntax lt symbol gt CODE lt expres
20. as possible But in certain cases compilation has to aborted instantaneously 6 9 ASSEMBLER MESSAGES 119 Device not supported X The given processor X is not supported this usually happens due to some typo Device specification code is already loaded The processor architecture has to be specified only once multiple specifications for one source code would not make sense they could collide with each other Limit value X is not valid Invalid memory size limit for the LIMIT directive only 1 0 and positive integers are valid Directive LOCAL cannot appear outside of macro definition Directive LOCAL can be only used inside macro definition outside macro definition it has no meaning and therefore cannot be used Directive EXITM cannot appear outside macro definition Directive EXITM can be only used inside macro definition outside macro definition it has no meaning and therefore cannot be used Maximum macro expansion depth X reached Macros can be expanded in other macros and they can be expanded in other macros and so on To avoid infinite loops or other kinds of undesirable behavior related to macro expansion occurring in another macro expansion the assembler limits maximum depth of macro expansion You can change your compiler settings and allow higher expansion depth By default maximum macro expansion depth is set to 1024 Maximum file inclusion depth X reached A source file may include another sour
21. containing 3 numbers VMMP where V stands for major version number MM stands for minor version number and P stands for patch number For example if your MDS version was for instance 1 2 3 value of this constant would be 0x1023 or if your MDS version was 3 2 1 the value would be 0x3021 DATE This is a string containing the current date formatted as Jan 19 2015 it contains 11 characters and if the day of the month is less than 10 it is padded with a space on the left Its the same as in the ISO C language TIME This is a string containing the current time formatted as 13 18 06 it contains 8 characters Its the same as in the ISO C language FILE A string containing the name of the current input file including its full path _ LINE This string contains line number in the current input file Please see the STRING directive 6 4 for details on what the strings are and what they can be used for 6 1 GENERAL 47 6 1 6 Expressions Mathematical expressions are evaluated at compilation time and replaced with constants cor responding to their resulting values Expression calculation is performed on 32 bit unsigned integers the resulting values then are trimmed from left to 16 bits at most with exception for the DB directive where values might be trimmed to 18 bits Expression comprises of arithmetical operators numeric literals and symbols Examples of such expressions include e 2 1 e 2 4 ABC eA amp B e X
22. data FETCH S1 my data 1 FETCH S2 my data 2 FETCH S3 my data 3 FETCH S8 my data2 ORGSPR Specify address of origin for scratch pad RAM initialization directive INITSPR Syntax ORGSPR address Examples ORGSPR 0x10 my_data INITSPR Hello PicoBlaze lt address assigned to my_data is 0x10 FETCH S0 my_data FETCH S1 my data 1 FETCH S2 my data 2 6 4 DIRECTIVES 91 MERGESPR Merge scratch pad RAM initialization with program memory initialization at the specified ad dress Syntax MERGESPR lt address gt Examples MERGESPR 0x280 my_data INITSPR Hello PicoBlaze FETCH S0 my data FETCH S1 my data 1 FETCH S2 my data 2 STRING Defines a named character string sequence of characters which can later be used with LOAD amp RETURN and OUTPUTK instructions and with DB directive Syntax lt name gt STRING lt string gt STRING lt name gt lt string gt Examples my_string STRING Hello PicoBlaze LOAD amp RETURN SO my string OUTPUTK my_string 2 DB my_string 92 CHAPTER 6 ASSEMBLER DEFINE Define and expression which is evaluated every time separately when used in the code These expressions can handle unlimited number of parameters parameters are defined in curly brackets and are numbered from 0 to infinity in decimal radix using expressions with parameters resembles calling a function in C language please see the example below Syntax lt symbol g
23. detail gt Call stack group These events are related solely to content of the processor call stack they does not contain detailed information about interrupt services and subroutine calls gt gt gt gt gt gt Stack overflow 0 location lt detail gt Call stack overflow occurred when PC was location new virtual stack pointer value is detail Stack underflow location detail Call stack underflow occurred when PC was location new virtual stack pointer value is detail 7 4 SIMULATOR 139 gt gt gt stack_sp_changed lt detail gt Content of the call stack has been changed now the stack contains lt detail gt return addresses Interrupt group These are interrupt service routine ISR handling related events gt gt gt gt gt gt gt gt gt int_irq_denied Interrupt request denied int_entering_interrupt Entering ISR Interrupt Service Routine int_leaving_interrupt Leaving ISR Interrupt Service Routine Instruction set group These events are related to instruction opcode decoding and instruction execution in general gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt cpu_undefined_opcode lt location gt Reading instruction opcode from uninitialized memory location at address lt location gt cpu_invalid_opcode
24. e modo 45 GA Pseudo sucio soo aone aoe eS ews Oe ace he ven ee oS o aad 2 47 6o it die a 1 II ea ere oe ep we Paar Ue 47 56 Hosular usicucbloH q 225 999 ER AA 47 O6 Special macios oea s s oo dodoa ad sa ok OR eus 47 6 8 Conditional compilation amp the WHILE 47 8 Recular directivos noue qox o o Ren ee ee eee du Re Rs 47 6 10 Condition syntax used for all code generation directives 98
25. eane e ee e ko Re x X censes 0 909 3 E Ro RR b b b bos 130 Ta OE a ke Dh we ech e ee ee ee de oe ac ee a 132 Tob Desp ke ee es a a a ee ee 132 VAD Weyoestiiis Lu x oa ee Oe a eee aa aa ee 132 n T ER ndun oc ge ea OE Ra edad HOt Ge bee dha ae ee 133 Ve DE cd om Sea REUS S RU e ROMUR Ue GR SAREE AU CURE 135 1 OB a a a 139 Chapter 1 Preface This manual is introduces the Moravia Microsystems Multitarget Development System MDS and provides detailed description and instructions for usage of the features and functions of this integrated development environment This document assumes that the user is either already familiar with the PicoBlaze processors or is someone who actively learns about them like a student CHAPTER 1 PREFACE Chapter 2 About MDS Multitarget Development System MDS for PicoBlaze is a graphical integrated development environment IDE for Xilinx s PicoBlaze soft core processors and their compatible clones MDS is intended to be used mainly by developers and by education institutions for students and hobbyists there is also noncommercial version available under a different license MDS provides all the necessary functionality to develop software part of a PicoBlaze appli cation including source code editor assembler disassembler and simulator Besides that there is also a number of tools and functions to make your work easier the sole purpose of MDS is to save your time and enable developme
26. gt Tutorial Project Demonstration project should introduce a new user into the basics of usage of this IDE this generally covers the most common functions like assembling the code running simulator and so on The tutorial project is for reading only File Edit Interface Project Simulation Tools Simulation tools Help SS BBB S b amp 0G PL Debebrenioonts MDSExample Breskpoints 0 y osa Bemeelpsm Ed Exmpe2psm 3 Exmpespsm 7 Exampe amp psm Exempespsm Examplesipsm C m p 14 Es Source i Bample1 FE Example psm Bxamge2 pum m 50 Example pem amp gt Example3 psm Example pem 03 2 gt ExampleS psm 04 3 Example6 psm os H Indude 06 amp Compiled 07 Ll Other ES Example 1 mem z Example Lrawhex 09 3 Example Lihex 10 el Example an I 12 z 13 L3 14 a 15 16 17 18 19 20 21 Semtin Info E Registers Scratchpad RAM Input Ports RD Output Ports WR stak PC 0x000 J i cydes 0 J 00 01 02 03 04 05 06 07 90 01 02 03 04 05 06 07 eo o1 02 63 04 os os o7 hlPoe ae p 000 09 00000000 609 09 90000000 as 68 00 00 00 BO BO BE BB oo ss oo oo oo oo oo oo oof es 78 o1 00 oo 6D eo co co a seo oo sesecece ces se sesesace se oo oo eo co oo co oo ool os gg Gi SE Bs 88 Bs 80 os os B 88 88 68 SE EE ES ER 213 609 00 60000000 i gt eee 60 o0000000 Bs 88 86 80 86 B8 86 86 BB 10 00 ce co oo oo oo 00 oof 10 FF
27. gt kk or sX gt sY C lif lst lt 2nd sX lt kk or sX lt sY 0 if 1st gt 2nd sX gt kk or sX gt sY Availability PicoBlaze 6 PicoBlaze 3 PicoBlaze II PicoBlaze PicoBlaze CPLD yes yes no no no 6 2 INSTRUCTIONS 61 COMPARECY CMPCY The COMPARECY instruction is COMPARE with carry CMPCY is only shortcut for COMPARECY these two mnemonics can be used interchangeably Syntax COMPARECY sX kk Compare immediate value kk to content of register sX COMPARECY sX sY Compare content of register sY to content of register sX CMPCY SX kk Same as COMPARECY sX kk CMPCY sX sY Same as COMPARECY sX sY Examples COMPARECY SO 1 Set Z flag if SO JUMP Z somewhere Jump to label somewhere if Z flag is set Flags Z 1 if result is zero and zero flag was set prior to the COMPARECY instruction 0 otherwise C 1 if results in an overflow i e the result is negative 0 otherwise Availability PicoBlaze 6 PicoBlaze 3 PicoBlaze II PicoBlaze PicoBlaze CPLD yes no no no no 62 CHAPTER 6 ASSEMBLER 6 2 5 Shift and Rotate SLO SL1 SLX SLA Instructions SLO SL1 SLX and SLA all shift contents of the specified register by one bit to the left The new lsb least significant bit depends on the instruction and the msb most significant bit is shifted out to the C flag Syntax SLO SLi SLX SLA sX sX sX sX Examples LOAD SLO SLi SLX SLA Flags N
28. machine code is bigger than your processor could handle in its current configuration Some of the source code files were apparently changed during compilation Please do not change source files during the compilation wait for the compilation finish first User defined memory limit for X memory exceeded You have exceeded boundary of some memory space X defined by the LIMIT directive Instruction X requires operand Y to be of type s Z This means for example that you are trying to use a symbol defined as port address in place of register address Y stands for operand number starting from 1 Macro not defined X The macro you are attempting to use X has not yet been defined possibly you are trying to expand a macro before its definition Too many arguments given expecting at most X arguments Directives require certain number of arguments when you provide a different number of arguments the directive makes no sense to the assembler Attempting to use unavailable space in X memory at address Y Suppose you have 8 registers and you try for example to write to register at address 10 then the assembler will give you this error The same of course apply also to program memory or any other memory space The last error was critical compilation aborted Normally the assembler tries to carry on compiling for as long as possible despite errors it is implemented that way to provide you with as many error message at the time
29. of lines with following format Name Type Value Usage Attribute lt Location gt Name Symbol name Type Symbol type e PORT PORT ID indicator e DATA Scratch pad memory address e LABEL Address in program memory e REGISTER Address of an internal register e EXPRESION An expression e NUMBER Symbol is a general number Value Value assigned to the symbol Usage USED or NOT USED Attribute e IMPLICIT Symbol is defined implicitly for your processor e LOCAL Local symbol in macro e REDEFINABLE Symbol is re definable i e is not constant e CONSTANT Symbol cannot be redefined i e is constant Location Location of symbol definition formatted as lt file name gt lt line number gt lt column gt lt line number gt lt column gt 112 CHAPTER 6 ASSEMBLER 6 8 7 Macro table Macro table is a human readable text file containing table of macros defined in your source code using the MACRO directive File format The table of macros consists of a number of lines with following format lt Name gt Parameters Usage Location Name Name of macro Parameters Macro parameters Usage Information about how many times the macro was used Location Location of the macro definition formatted as lt file name gt lt line number gt lt column gt lt line number gt lt column gt 6 8 8 Intel 8 HEX Intel 8 HEX is a popular object fil
30. prior to its defini tion Symbol X has been already defined with type Y The given symbol has been already defined with type Y you are trying to define two or more symbols with the same name but with different types This is not allowed in this assembler such practice often tends to lower software quality Cannot remove predefined symbol X Predefine symbols like MDS VERSION __ DATE TIME_ FILE and LINE _ cannot be redefined or deleted Cannot change value of predefined symbol X Predefine symbols like MDS VERSION __ DATE TIME FILE and __LINE___ cannot be redefined or deleted Undefined value You are attempting to use some value whose numerical representation is unknown to the assembler Real numbers are not supported in this assembler Real numbers 1 8 22 65 etc are not supported by this assembler Undefined symbol X Symbol X has been undefined i e deleted from the symbol table using the UNDEFINE directive and therefore can be no longer used This value is not valid inside of expression Expressions in this assembler can be calculated only from integer values other values like strings etc are not allowed Division by zero During evaluation of an expression the assembler encountered division by zero Division by zero results in value not representable by this assembler therefore is reported as er ror Examples of such case might be LOAD SO 10 0 or A EQU 2 A B where B
31. provide you with the fixed version as soon as possible 42 CHAPTER 6 ASSEMBLER 6 1 General 6 1 1 Main differences from the Xilinx assembler Default radix is decimal not hexadecimal You can use different radix for each numerical literal if you do not specify radix it is decimal by default For hexadecimal radix use the Ox prefix Oxla Oxbc 0x23 for octal radix use the 0 zero prefix 076 011 027 for binary radix use the Ob prefix 0b11001100 0b10101010 0b11111111 for ASCII value put the character in single quotes a A 3 Suffix notation is also supported 80h hex 128d dec 200q oct 10000000b bin for ASCII characters you can also use C language escape sequences 0 NUL w LF Xr CR Nt TAB Addressing mode specification is mandatory For immediate addressing use the 7 prefix LOAD SO 0xAB for indirect addressing use the Q prefix STORE SO 081 and for direct addressing do not use any prefix LOAD SO S1 3 this loads SO with S4 This assembler is case insensitive load SO S1 is the same as LOAD sO s1 or Load SO s1 This assembler supports user defined macro instructions and expressions LOAD SO 2 3 8 etc please refer to the Tutorial Project and the Quick User Guide for brief introduction or to later pages in this manual for detailed description 6 1 GENERAL 43 6
32. that this port is bus Checking this will enable MSB most significant bit and LSB least significant bit field which represents width of your bus Signal check box If checked generator will insert this port declared as signal in VHDL template Tab GENERIC Port tab lets you define generic attributes of defined component Port name Name of every generic attribute Names or identifiers may consist of letters numbers and underscore Value You can set the initial value Leaving this field empty means no initial value is needed Type Defines type of your generic attribute Logic means zero or one Logic vector is a bus defined with MSB and LSB numbers Integer can be number defined in range from 2147483648 to 2147483647 Positive is RANGE 1 TO integer HIGH Natural is in RANGE 0 TO integer HIGH Bus check box Telling generator that this port is bus Checking this will enable MSB most significant bit and LSB least significant bit field which represents width of your bus This check box in generic tab makes sense only for logic vector type of attribute Constant check box If checked generator will insert this attribute declared as constant in VHDL template Save and add button Component will be added to MPU SYS entity and saved for later usage Component name will appear in list Existing components and can be edited or added to current entity any time Add button This button will add component to the current entity only once
33. 0 30 00 5 000 00 00000000 000 60 00000006 E a a m Es tH m A a A ano oms ops 600 00 00000000 600 oo 00000000 3g nua HTT El sig EO E 600 00 00000000 000 00 00000000 40 e 66 66 rr all sp 27 cary Zero 48 j 80 68 S 48 0i 86 interrupt 50 00 00 00 oo 50 oo o0 Itenabl 58 88 66 06 S se FF Bi SUP i NN Read Write Read Write Read Write Compiler info Simulation Info Hide Figure 4 1 Layout of the main window 16 CHAPTER 4 USER INTERFACE 4 1 1 Left and right panel demo_1_simple_prog asm abcc asm 010_store_fetch asm Example Breakpoints Ex Example File Bi Sourek abcc asm demo 3 directives asm 13 abcc asm demo 4 buttons leds asm f demo 5 UART asm 14 spe cm E 4 20 abcc asm demo 1 simple p demo 1 simple p 8PIH Soen syieubpoog syujodjeasg Left panel Include 13 demo 1 simple p i Compiled demo 5 UART asm i ean 12 demo 5 UART asm 15 demo 5 UART asm 20 demo_5_UART asm aa demo 5 UART asm Left panel Right panel Left panel displays files in your project tree Also it allows to perform various actions via context menus right click like configure project close project open file close file remove file from this list or set some file as the project s main source file etc Right panel Right panel contains lists of breakpoints bookmarks and macros defined in your source co
34. 1 2 Statements Source code files for this assembler have to be text files in the following format label instruction operand operand comment label directive argument argument comment symbol directive argument argument comment directive symbol argument comment Tokens in square brackets are optional Compilation does not continue beyond line contain ing the END directive after that directive the code does not have to be syntactically correct Empty lines are valid as well as lines containing only comment or label Statements are sep arated by white space spaces or tabs Statements are case insensitive and their length is not limited overall line length is also not limited Allowed line delimiters are LF CR and sequence CRLF Expected encoding is UTF 8 but it is not necessarily required 6 1 3 Comments Comments in source code are ignored by the assembler they are supposed to serve only as notes to the developer MDS assembler uses two types of comments single line comment starting with semicolon character and ending with the end of line and multi line comments starting with sequence slash followed by asterisk and ending with sequence asterisk followed by slash like in the C language Example Single line comment Multi line comment LOAD Comment SO another comment Si more comment 44 CHAPT
35. 222 999 ss XI Gt x ROGO Y 9 ew OR ER GOR 43 2 Project configuration ru bee e o og ymo RR eae es 44 UP LonBERIALOH s aari eo LE EE a A i O A a 4 5 1 External Applications o 4 aa sacs o o 0004 ee eG yo RR RR 4 5 2 Delay loop generado 22 o ow RR ROROR AO OR e E ee eee 45 9 Disassemblet o a 22225222 x ke e RR ew S 4 5 4 Assembler translator rs AnS Data e GOHXER BE o ii a a ee x eee A ADG ao oue o a ae we vov ow we OE ER AS LED panel sum bbdE noie Rok 94x eee 9 9 9e 9 s 45 8 epinentsdldLOK 2 cvs o o UR AR 4 CONTENTS 4 5 9 Numeric base converter sh 30 Ax VHDL Wizara uuu ee a X REOR 31 5 Simulator 35 5 1 Main simalstor panel 222222 omm RA LES 35 5 2 Modes of simulation s sp ss p RR RR ee ee RR 36 bus ata 22e ae ee Se ee wae Ae ee eS 36 Da tni is 4 PP 37 DAA Memory POUR I lolo e ono seo R 39 Ro De ee FOR ee eee a 3T DILE Lak POUD epos aa COS LIE EIS See EA aaa Pe RH 38 DAS CPU giou soos nee dS oem e Er RR RO Ro o9 3o NUR Be 38 6 Assembler 39 G1 General 22229429 e Wo E RO ROR 3 Up eee ede bes 40 6 1 1 Main differences from the Xilinx assembler 40 6 1 2 Blalements lt lt v9 9e dd ooh o ROLE 41 QUE MEG o RM Be we ae ES 41 6 1 4 Numbers i229 o eed da ee RS E AO Gad E Robe 42 Dl SOM ys 2 Dodo Ge dk vedo 9 9 9 9 Se BOE ayy me SO eH IA ELS 43 6 1 8 Expressi ng gt ou cR RR Deor ROO d x OR Rh RS 45 01 7 Reserved keywords gt occ r9 ee wa STG AS 47 62 u
36. 9 WHILE ENDWHILE lt 2 si RR Ee o3 a RR OG a 100 FOR ENDFOR ou e406 a Ga aia E a EORR M RU UR dog 101 6 6 Conditional Assembly Directives lee 102 GOI Beep x26 eta wis aa mmm A 103 6 7 Macro processing directives i22 oon xoxo 9 omo ee EORR RR OR Rn 104 o cs ew aoe wy deere Tr T TTL 104 6 02 Directives s q ser eoe e doe RR RR Rex omes m onum 9 DR dad Rob Ro x 104 LUN MS ooo dono Bele AEN EEE AR UR UR Del die ir itte Oe ae 104 6 69 Exemples 222222294 od EAS ARR ko ea ER n9 E 105 Hs OUTIS uuu bus oos o Gok eee amp ae aA Ge Pw Se 107 6 8 1 Generated VHDL and Verilog files 107 DEZ MEM Pile a ss s a a a a RGR BARRE OE AE 107 055 Raw Hex Dump ile snc ba die za cada 108 GSA Raw binape DB oo ge aed ls rr he ee eee a aes 108 685 5 BUS TAD 4 a a ee Fh BORO at Oe eee E a a ee A 108 6 5 8 Symbol table t ues sv ud aa bami a Ra De 109 GAT Macro table co es succ RUE emo RR RR deeem hon aa 110 6838 asl B HEX 4222s eae PEE be Bae eee dO eR Ud 110 DAI ORC Ioa a a a a a a a a a o m 111 6 5 10 Code Listing sas c o9 9 xo x Oe EDD ea yy ee A 114 6 9 Assembler messages Ir 116 Command Line Tools 125 A 225 eso omm Boo RR o aA mum Ro S ROB ROS A A UR UR eS 125 GLE Description 201022206 9 ex ee ee Ro ER de de bees 125 Ta D sasscmbler oo TORRES ee ee a od Re 128 1 1 Description 42222 ee eee Se ORE ee y ee 128 T3 Assembler translator 22 ku Lecce aa a a A E REGE Rom wo Rod 130 Tel Description s qa
37. ER 6 ASSEMBLER 6 1 4 Numbers MDS assembler supports multiple radixes for numeric constants radix is specified using prefix or suffix notation Default radix is decimal like in the C language Hexadecimal ld S0 ld S0 Decimal ld S0 ld S0 Octal ld S0 ld S0 ld S0 Binary ld S0 ld S0 ASCII ld S0 ld S0 Escape sequences 0xAB HOABh 123 123d H 076 R 76q 760 0b1100 E 1100b HA t prefix notation 0x suffix notation h no prefix default radix decimal suffix notation d prefix suffix suffix prefix suffix notation notation notation notation notation 0 7 9 Siang 5 0 0b C b ASCII value of capital A ASCII value of the tab character escape sequence In place of ASCII value you can also use a single escape sequence escape sequences can also be used in strings abcNr Nn the C language Escape sequences in MDS assembler are exactly the same as in Sequence Description Value a alarm bell 0x07 b backspace 0x08 NY single quote 0x27 double quote 0x22 question mark Ox3F NN backslash 0x5C f form feed 0x0C Mn line feed 0x0A Nr carriage return OxOD t horizontal tab 0x09 v vertical tab 0x0B e escape 0x1B Table 6 1 Escape sequences In addition to the escape sequences sequences described in the
38. FF 28 01 01 GG G0 GG 60 MHz zj 000 00 00000000 000 00 00000000 10 00 00 00 00 00 00 00 00 10 00 00 OO OO OO OO OO 00 10 oo 00 00 00 00 00 00 00 Time 600 00 00000000 000 00 00000000 18 Ja 88 8 80 GO 00 15 80 00 06 pa 86 OG OO GO 15 i 00 00 OG GO GO GG S go ge 000 00 00000000 000 00 00000000 20 6 00 00 00 00 oo 20 oo oo 00 00 oo oo 00 oo 20 30 oo oo 00 oo oo o0 oo decus Mom nM c sed eo O6 09 G0 60 00 30 os 00 G0 60 os oo oo oo 30 so 00 00 01 G0 0 o6 oo 9 oms ops epo 05 Mee Beia Lu bo po ba 6d O0 3s 00 00 00 G6 00 OG 00 GG 35 63 G0 00 O9 GO GO GG 6d E MM NE ANIM PEN UE HMNEEDR 48 60 00 o0 00 ao oo oo oo 40 s0 17 FF 00 00 00 60 a0 Cam zero 48 00 88 80 66 80 00 80 00 4s 61 80 da 68 8O bo BO s Looamemupt so 00 00 oo oo oo 00 00 oo 50 00 00 00 00 00 60 00 60 itenable 58 80 po 88 88 88 00 00 00 55 FF Oi 00 00 69 60 60 60 Read Write Read Write Read Write Figure 5 1 Main simulator panel Registers You can find here values of internal processor registers The first column represents name second value in decimal third hexadecimal value and last binary value Scratch pad RAM This hexadecimal editor represents values stored in the scratch pad RAM Address of a particular field is addition of the line and column numbers Ports Output and input ports are represented by hexadecimal editors in their full address range Besides viewing and changing input and output values you
39. FF FF 00 00 00 oo ool Time 600 00 60000000 ooo oo 00000000 ce eo oo oo oo oo as oe co ia pa ga BS 88 88 86 Sasal 18 46 FF 43 86 3A 00 SC gal ar dc 60 00 00600009 lt i oeo eo 60000000 CS G8 88 88 8 86 88 88 88 2o oo 00 co eo eo eo eo oo 20 so 09 72 00 GF 00 67 00 Vr da 909 00 00000000 660 oo o0000009 De os oo so 90 oo as oe oe 2s ag gg gg ba ga Sa GO 0 25 72 86 61 00 60 DO 20 S 600 60 99980000 999 eo ooo00ooo DS 89 86 00 80 PO 80 86 B 36 aa oo co ce co oo oo oo 30 46 00 69 o0 ec o0 65 o0 gi 009 60 66090600 gt seo se oooooooo EO oo 00 oo oo eo 99 oo sol sa ag gg gg gg Bg G0 0G G0 3e 73 60 26 09 28 09 78 08 Gary zero 600 00 60000000 eee ee 00000000 ES 99 89 00 80 80 89 80 BB 49 os oo oo oo oo oo oo oo 40 38 00 36 00 29 00 sc 00 Interrupt 600 60 00000000 eee 60 00000000 O 02 99 90 oo oo oo oo cel 4s SS Bg B6 B6 B6 86 66 a s 40 80 GF 00 72 00 61 08 600 60 60000000 es oo oooooooo gt 99 98 89 Be 66 BA Be Ba Eoo oe so co soso oo OS s co co oo s so ze Los Read Write Figure 3 1 Tutorial project 12 CHAPTER 3 GETTING STARTED 3 2 Your first project NOTE We recommend that you to go through the Tutorial Project first There is not too much you have to do to start you first project in MDS to keep things simple e Click on Main Menu gt Project gt New Project e Choose a name for your project and directory in which you want to store files created i
40. LOAD sO sO Examples NOP NOP NOP Increments the given register value by one Syntax INC sX Equivalent ADD sX 1 Examples INC s0 6 3 PSEUDO INSTRUCTIONS 79 Decrements the given register value by one Syntax DEC sX Equivalent SUB sX 1 Examples DEC s0 Sets the given register to binary ones Equivalent OR sX 0xFF Examples SETR sO Clears the given register set it to 0 Syntax CLRR sX Equivalent AND sX 0 Examples CLRR sO 80 CHAPTER 6 ASSEMBLER Performs ones complement with the given register Syntax CPL sX Equivalent XOR sX 0xFF Examples CPL s0 Performs two s complement with the given register Syntax CPL2 sX Equivalent XOR sX 0xFF ADD sX 1 Examples CPL2 s0 Sets one bit in the given register Syntax SETB sX bit bit belongs to interval 0 7 Equivalent OR SX 1 lt lt bit Examples SETB 80 3 6 3 PSEUDO INSTRUCTIONS 81 Clears one bit in the given register Syntax CLRB sX bit bit belongs to interval 0 7 Equivalent AND sX 4 OxFF 1 lt lt bit Examples CLRB SO 7 Negates one bit in the given register Syntax NOTB sX bit bit belongs to interval 0 7 Equivalent XOR sX 7 1 lt lt bit Examples NOTB SO 7 Decrements the given register and jumps at the given label until the register contains zero Syntax DJNZ sX label Equivalent SUB sX 1 JUMP NZ label Example
41. MIT directive removes the limit set by that directive there is nothing bad about that but the assembler notifies you about it just to make sure you know what you are doing Symbol X declared as local but never used declaration ignored What is the point of having a local symbol inside a macro and do not use it This is not an error but its possible side effect from some error or mistake that is why the compiler warns you about it 122 CHAPTER 6 ASSEMBLER Comparing two immediate constants result is always X When using autogenerated run time conditions it does not make sense to write a condition which result is always known in advance that is why you get this warning message Please check if you are using correct addressing modes Sign overflow Result is negative number lower than the lowest negative Two s complement signed arithmetic overflow occurred during expression evaluation File name contains a null character This is a very unlikely error message it means that the provided file name contains an invalid character in this case it is the NULL character Result is negative number X this will be represented as X bit number Result is negative number in two s complement signed arithmetic that means that the number contains binary ones in high order bits after the value is trimmed to fit binary width required for the specific purpose it might result in a different value even a positive number Value out of range a
42. MP Ox300 Oxff Jump to address 3FF hexadecimal Flags Z no effect C no effect Availability PicoBlaze 6 PicoBlaze 3 PicoBlaze II PicoBlaze PicoBlaze CPLD yes yes yes yes yes 74 CHAPTER 6 ASSEMBLER CALL Call subroutine at the address specified by aaa operand or by sX sY Syntax CALL aaa Unconditional call CALL Z aaa Call only if the Zero flag is set CALL NZ aaa Call only if the Zero flag is NOT set CALL C aaa Call only if the Carry flag is set CALL NC aaa Call only if the Carry flag is NOT set JUMP sX sY Unconditional subroutine call at sX 3 0 sY 7 0 Examples subprog ADD S0 81 SO SO S1 SUB S1 5 2 81 S1 7 RETURN CALL my_subprog CALL 40 Call subroutine at address 40 decimal Flags Z no effect C no effect Availability PicoBlaze 6 PicoBlaze 3 PicoBlaze II PicoBlaze PicoBlaze CPLD yes yes yes yes yes 6 2 INSTRUCTIONS 75 RETURN RET Return from subroutine RET is only shortcut for RETURN these two mnemonics can be used interchangeably Syntax RETURN Unconditional return RETURN Z Return only if the Zero flag is set RETURN NZ Return only if the Zero flag is NOT set RETURN C Return only if the Carry flag is set RETURN NC Return only if the Carry flag is NOT set Examples subr ADD S0 81 SO SO S1 RETURN Z Return if SO contains zero value LOAD SO 1 Load S1 with value 1 RET Return
43. O 0x55 Load register S0 in inactive bank with 0x55 STAR S1 SO Copy S0 in active bank to S1 in inactive bank Flags Z no effect C no effect Availability PicoBlaze 6 PicoBlaze 3 PicoBlaze II PicoBlaze PicoBlaze CPLD yes no no no no 6 2 INSTRUCTIONS 53 6 2 2 Logical OR The OR instruction performs bit wise logical inclusive OR operation Syntax OR sX sY OR sX kk Examples OR SO 0x55 SO SO Ox55 OR S1 SO S1 S1 SO Flags Z 1 if result is zero 0 otherwise c 0 Availability PicoBlaze 6 PicoBlaze 3 PicoBlaze II PicoBlaze yes yes yes yes Perform OR on sX and sY registers and store the result in sX Perform OR on sX register and immediate value kk put result in sX PicoBlaze CPLD yes 54 CHAPTER 6 ASSEMBLER XOR The XOR instruction performs bitwise logical exclusive OR operation Syntax XOR sX kk Perform XOR on sX and sY registers and store the result in sX XOR sX sY Perform XOR on sX register and immediate value kk put result in sX Examples XOR SO 0x55 S0 SO 0x55 XOR S1 SO S1 S51 SO Flags Z 1 if result is zero 0 otherwise c 0 Availability PicoBlaze 6 PicoBlaze 3 PicoBlaze II PicoBlaze PicoBlaze CPLD yes yes yes yes yes 6 2 INSTRUCTIONS 55 AND The AND instruction performs bitwise logical AND operation Syntax AND sX kk Perform AND on sX and sY registers
44. PU group The CPU group contains warnings related control flow and interrupt handling Program counter overflow The program counter has exceeded its maximum value this is usually a serious error in the simulated program System fatal error This indicates an error in the simulator itself normally this never happens the simulator is tested by vast series of automated tests but if that happens please report this as a bug in the MDS Invalid opcode Indicates that the simulator encountered instruction opcode which is cannot decode and execute this is very unlikely to happen but if you use the DB directive to directly write opcodes in the program memory this might happen Invalid IRQ Invalid interrupt request For instance you are trying to interrupt an interrupt service routine Invalid return Attempt to return from subroutine while there is no subroutine to return from Invalid return from interrupt Attempt to return from ISR interrupt service routine while there is no ISR in progress 41 Chapter 6 Assembler In this chapter we will be concerned with the build in macro assembler With syntax of its statements directives and PicoBlaze instructions We assume that the reader is familiar with general concepts of the assembly language programming and with PicoBlaze architecture MDS macro assembler for PicoBlaze is a two stage fast macro assembler inspired by Intel assemblers and the C language It supports wide range of o
45. R MESSAGES 123 Invalid unicode character X Invalid value used for Unicode escape sequence please check the Unicode table for refer ence Too big number X Some numeric literal in your source code represents a value too high to be usable in the compiler s internal logic Invalid token X Compiler s lexical analyzer encountered a token which it cannot use Identifier cannot start with a digit X Assembler encountered a token which it cannot recognize in this case it might be a numeric literal or an identifier For example Dabc might be meant as hexadecimal number but correct syntax is with radix specifier i e Ox0abc or OabcH or it may be identifier like a label or so but in that case it cannot start with a digit Too many arguments given to macro X expecting at most Y argument s You have defined some macro with parameters X this macro is defined with certain number Y of parameters When you expand this macro with lower number of arguments than is the number of parameters the remaining parameters will be filled with blank values but when you provide higher number of arguments the compiler will not know what to do with them String already defined X You are attempting to override already defined character string X Character strings are defined with the STRING directive Blank value Blank value used in expression since blank values are not numbers they cannot be use for calculations Blank value
46. UR CR GR e 69 ENABLE DISABLE INTERRUPT ENA DIS 70 62 19 Program Control gt oc eoi desa ala auia bee a a ee 71 JUMP cn su a SA EE A SS 5S D ee vov Y us AUR B BR EG 71 CAGE cka n IR ae Be A A Eh a a A 72 RETURN RET 42 229323 ak nU RR Ee xw x xov X 9 RR RR SU 73 LOAD amp RETURN LDRET 3 846 S00 Baw Seabee ae ad eme ew word 74 6211 Version Control o oe s p a a acasa a eee m A a a a E 75 ibo cg A o a o n ea E G he de ee Ge a a a JS a 75 63 Pseudo Inetructhions ocea cas hee a a a aaa a aa he ee a a AEE a 76 NOP o ceee enana g sana a aue g a Se a i EE d x Pe we de 34604 76 ME coria e e acc E ae a es 76 DRO o pa mad aa AA daa AA 77 A a ee eda a EUR Ne ee RS eH 77 DLER os Gg eae PREIS ale a wal os Oe ed be Xe du dodo 77 Ua ese da i Bis is a a I eee QC cs a ee 78 CPIS aii ba BG Be ee wd ae ie ewe GS Bee ee VR EIE 78 Be ek heer satin ta al ws Sin em oh St aoe ey Adee ee dhe Gn a oa aa 78 Re amp Ge Hen 2 ee eee os ow oe MNT 79 PTS Secs as ks oe he he Ee we ag a AA a a ee a BE Bh 79 PRIN G sica e a ee ee TD o de ee ata ded 79 BINA D nek he aa e EDR Re EUR iek ow a dB Bow 80 bd DNOS uu aoro Reese a we ee a ae ke ar RR RR LIE XO X Xo RE Wu 81 INCLUDE 2 3 4 28 ak Ra ee ele ea a o4 X9 m 323 3 3034 81 END S uoo See eo ee a AA a Sedge EC E Pod ded ee ee oe 81 PAs ee ka ab Raw ewe EEE EE Ob GRCY ORAE TE eer w 82 CONSTANT oom mox oh AA ee eom oe DA we 82 Ree hw A je ane RTT 83 VARIABLE oii o oo dad Oe Oe ae Pe BE did ee 83
47. X Read default Read write only 8 Read part write only R Read reserved register Write access denied Xx Write read only X Write part read only Write reserved register ok X cancel Simulator Warnings gt Memory SIDE Simulator Warnings e cee Memory Stack ceu Les amp invalid opcode amp Simulator 3 Invalid jump I Invalid call e Invalid IRQ i Invalid return i Invalid interrupt return Invalid set of operands R Instruction unsupported Instruction ignored ae PC overflow ae PC underflow Simulator Warnings gt CPU 4 5 TOOLS 27 4 5 Tools 4 5 1 External Applications Purpose of this function is to ease usage of 3rd party JTAG loaders and similar software tools in the MDS With External Applications the user can specify a set commands or scripts to run when the corresponding external application is invoked from the MDS s main tool bar Textual output from the external application is shown in the bottom panel in tab External Applications v IDE IDE External Applications General lication 1 v Editor uut General Path JTAG loader La Fonts i a v Simulator Args in curfilepath hex Warnings v Show Application 2 Path a Args Show Application 3 Path o Args A _ Show v Y OK Q Cancel Figure 4 6 External Apps Config Dialog Any command can be invoked with a specific set of command line arguments in which the user can u
48. aded 28 5F 24 5F 22 12 22 6A 00 04 24 29 00 08 23 7C Sixteen character pairs representing the actual binary data 2A The checksum The second and third S1 records are comprised as follows The second and third S1 records each contain 0x13 19 character pairs and are ended with checksums of 13 and 52 respectively The fourth S1 record contains 07 character pairs and has a checksum of 92 The S5 record is comprised as follows S5 S record type 5 indicating it is a count record indicating the number of S1 records 03 Hexadecimal 03 decimal 3 indicating that three character pairs follow 00 04 Hexadecimal 0004 decimal 4 indicating that there are four data records previous to this record F8 The checksum 9 record is comprised as follows 89 S record type S9 indicating it is a termination record 03 Hexadecimal 03 decimal 3 indicating that three character pairs follow 00 00 The address field hexadecimal 0 decimal 0 indicating the starting execution ad dress FC The checksum 116 CHAPTER 6 ASSEMBLER 6 8 10 Code Listing Code listing serves as an additional information about the assembled code and the progress of the assembly process It contains information about all symbols defined in the code Where and how they have been defined what are their values and whether they are used in the code Also detailed information about all macros defined in the code and or expanded in the code Conditional compil
49. amem coo eo 90999999 sa 66 gg gg gg gg gg gg gg 38 gg gg gg g 00 00 86 86 35 03 06 86 66 09 08 8G 66 nonse eaanneae MN Sh SEMEN 40 00 00 00 00 00 00 00 oo 40 50 17 FF 00 00 00 00 00 sary ero 4s 88 66 66 08 88 06 66 S 4s 61 G6 08 BO GO OG BG 68 ___Interrupt so oo 00 00 oo 00 G0 00 oo 50 oo oo oo 00 oo 60 00 00 Int enable Read Write 58 00 06 60 06 60 O0 60 00 7 Read Write 58 FF 01 00 06 60 06 60 pa 7 Read Write Figure 4 3 Bottom panel 4 1 MAIN WINDOW 19 4 1 5 Exit amp Restoration Session Restoration When the main window is closed on user request the MDS automatically saves the current session and restores it when run again The session includes list of opened projects When you run MDS the projects and their files from the last session are automatically reopened as they were last time when you closed the MDS window Exit Dialog When closing the main window MDS automatically checks if all files which you have been working on have been saved on Save tiles the disk and if some of them have not it displays a dialog perene Exit Dialog asking you which files you want to save and which not But be aware that this function cannot possibly handle unlikely possibility of program crash we recommend that you save your files regularly to prevent accidental data loss Button Save Saves the selected file and if there is only one file left exits the IDE save save At discard pisc
50. arated list of decimal values read from the memory in range lt address gt lt end address gt size space Get size of the specified memory or I O please see set size command for addi tional details cycles Get total number of machine cycles executed on the simulated processor so far This value is automatically set to zero when the simulator is reseted using the sim reset command breakpoints List breakpoints set by user using the set breakpoint command locations List source locations i e files and line numbers where it is possible to set a break point Load or save a file with memory dump this commands recognizes the same file types at the code file type command line option and memory spaces are the same as with the set memory command This command has the following subcommands load space type file Load contents of the specified file lt file gt into the specified memory space type is type of file lt file gt is file name save space type lt file gt Save contents of the specified memory space into the specified file file 7 4 SIMULATOR 137 sim Simulate program step lt steps gt Step optionally execute lt steps gt steps run Run program Program animation will run in a separate thread while this tool continues to listen and answer to commands It is safe to use all other commands while the simulator is running e g
51. ardall cancel Button Save All Saves all files and exits the IDE Figure 4 4 Exit Dialog Button Discard Discards recent changes in the selected file if there is only one file left exits the IDE Button Discard All Discards recent changes in all files and exits the IDE Button Cancel Closes the dialog and returns to the IDE the main window will remain opened 4 1 6 Main menu actions File New File Create a new file in your current project File New Untracked File Create a new file outside your current project File Open File Open an existing file and add it to your current project File Open Recent Keeps track of recently opened files and allows to easily reopen them File Save File Save the current file in the current project File Save As Save the current file in the current project under a different name File Save All Save all opened files in all opened projects File Close File Close the current file File Exit Exit the MDS environment Edit Undo Undo the last editing action in the code editor Edit Redo Revert the last undo action 20 CHAPTER 4 USER INTERFACE Edit Cut Cut the selected text in the code editor and copy it into clipboard Edit Copy Copy the selected text into clipboard Edit Paste Paste the clipboard content into the code editor Edit Select All Select all text in the code editor Edit Deselect Deselect the selected text in the code editor Edit Fin
52. arnings please go to Main Menu gt Interface gt Configure gt Simulator warnings 5 4 1 Memory group The memory group relates to suspicious and invalid attempts to access program memory register file scratch pad memory and even ports of the simulated processor Write to nonexistent memory location Attempt to write at a memory location exceeding the size of that memory Read from nonexistent memory location Attempt to read from a memory location exceeding the size of that memory Write to unimplemented memory location Attempt to write at location in memory which has been disabled For instance you disable scratch pad memory by setting its size to 0 and then you attempt to write in there Read from unimplemented memory location Attempt to read from location in memory which has been disabled For instance you disable scratch pad memory by setting its size to 0 and then you attempt to read from there 40 CHAPTER 5 SIMULATOR 5 4 2 Stack group The stack group is related to processor call stack Stack overflow This happens when the program exceed the stack capacity It might happen when the call stack capacity is insufficient to handle so many subroutine calls as your program requires it may also easily happen when the program uses recursion or when there are nonsense calls the program Stack underflow This happens when there is a request to pop value from call stack but the stack is already empty 5 4 3 C
53. ary Lowercase X Generate symbols C Data Port X Code Reg Const J i cnet Figure 4 8 Disassembler 30 CHAPTER 4 USER INTERFACE 4 5 4 Assembler translator With this tool you can translate your previously written assembler code in different syntax that MDS uses You can select one of three choices for input file syntax Xilinx Mediatronix and OpenPiclde Input code has to be without errors Section Input File Here you can choose which file you want to translate into the MDS as sembler compatible code Section ASM type Input file syntax Symbol Letter case for symbols End of line CRLF Windows LF Linux or CR Mac Directive Letter case for assembler directives Indentation Whether you want to indent the translated code with tabs or spaces or to keep previous indentation Instruction Letter case for instruction mnemonics Tab size Tab size measured in number of spaces Short instructions Here you can allow short instructions like LD RETI etc Lowercase la Short instructions X Enabled Figure 4 9 ASM translator HE 3 ASM Translator Y QS Input file my file psm Change ASM type Xilinx lin Symbol End of line Lowercase Re LF X Directive Indentation Lowercase M Tabs Instruction Tab size EI 4 5 TOOLS 31 4 5 5 Data file converter This tool allows you to convert selected data file to another This also allows to
54. ation configuration instruction opcodes address space reservations inclusion of code from other files And all warnings errors and notes generated during the assembly by the assembler There are assembler directives which alters formatting of the code listing file A simple code listing 1 Comment 2 org 0 3 0000 01001 4 main load sO 1 0001 01102 5 load s1 2 0005 01203 6 load s2 3 0007 3E000 7 jump main 8 9 end Code listing contains entire source code which has been assembled but with each line prefixed with line number and some additional information which will be explained later Each line of the code listing which contains an original source code line may contain besides line number also some additional information regarding the compilation of the given line of code Such a additional information might look like this and is composed of these parts Format of code listing 00055 1 X EQU 0x55 2 INCLUDE file asm 0007 00100 1 3 1 label LOAD S1 SO E Expression value mE Address in program memory E Machine code E Level of file inclusion E Line number E Level of macro expansion B Original line 6 8 OUTPUT FILES 117 A more complex example of code listing 0001C 1 abc equ 14 2 Define symbol abc 2 org 0 Code at address O0 3 4 include macros asm Include macros asm 5 This is the beginning of file macros asm 6 Xyz macro arg 7 load si arg 8 nop 9 load arg si 10 endm 11 This is the en
55. aze 3 PicoBlaze II PicoBlaze PicoBlaze CPLD yes yes no no no 6 2 INSTRUCTIONS 59 TESTCY The TESTCY instruction performs bitwise logical AND operation and discards its result except for the status flags Syntax TESTCY sX sY TESTCY sX kk Examples TESTCY SO 0 Set Z flag if SO 0 JUMP Z somewhere Jump to label somewhere if Z flag is set Flags Z 1 if result is zero and zero flag was set prior to the instruction otherwise it set to 0 C Lifthe temporary result together with the previous state of the carry flag contains an odd number of 1 bits and 0 otherwise Availability PicoBlaze 6 PicoBlaze 3 PicoBlaze II PicoBlaze PicoBlaze CPLD yes no no no no 60 CHAPTER 6 ASSEMBLER COMPARE CMP The COMPARE instruction performs an 8 bit subtraction of two values Unlike the SUB instruction result of this operation is discarded and only status flags are affected CMP is only shortcut for COMPARE these two mnemonics can be used interchangeably Syntax COMPARE sX kk Compare immediate value kk to content of register sX COMPARE sX sY Compare content of register sY to content of register sX CMP SX kk Same as COMPARE sX kk CMP sX sY Same as COMPARE sX sY Examples COMPARE SO 1 Set Z flag if SO JUMP Z somewhere Jump to label somewhere if Z flag is set Flags Z 1 if both values are equal sX kk or sX sY 0 if 1st gt 2nd sX
56. ber gt Size of scratch pad RAM D stands for data LIMIT R lt number gt Number of registers R stands for registers LIMIT C lt number gt Size of program memory C stands for code Examples LIMIT R 8 Limit maximum register address to 7 LIMIT D 32 Limit maximum address in scratch pad ram to 31 LIMIT C 512 Limit maximum address in program memory to 511 6 4 DIRECTIVES 95 Normally you choose the target architecture when you are creating a project But you can also specify target architecture with DEVICE directive This will affect predefined symbols Syntax DEVICE lt device_name gt Examples DEVICE kcpsm6 DEVICE kcpsm3 DEVICE kcpsm2 DEVICE kcpsmi DEVICE kcpsmicpld Temporarily turns on and off output to the code listing Syntax LIST Turn code listing ON NOLIST Turn code listing OFF Examples NOLIST INCLUDE some file asm The included file will not appear in the code listing LIST 96 CHAPTER 6 ASSEMBLER Set title for code listing Syntax TITLE lt title text gt Examples TITLE My program for something etc Print compiler message the message will be printed by the compiler in the same was as errors and warnings are Such message however is not considered to be neither error nor warning Syntax MESSAGE some message Examples MESSAGE text text text This directive does the same things as the MESSAGE directive but in this case the printed message is
57. bol abc lt lt lt lt Assemble only if symbol abc has been defined lt Assemble if 13 has been assigned to symbol abc lt Assemble if 14 has been assigned to symbol abc lt Assemble if the value assigned to symbol abc is even lt Else lt Assemble if symbol xyz has NOT been defined Else lt Assemble if yxz modulo 2 is O lt 106 CHAPTER 6 ASSEMBLER 6 7 Macro processing directives Macro is a sequence of instructions which can be expanded anywhere in the code and for any number of times That may reduce necessity of repeating code fragments as well as source code size and make the solved task easier to comprehend and solve Unlike subprograms macros do not add extra run time overhead repeating usage of macros may significantly increase size of the resulting machine code Note that macros may contain any other code including other macro expansions and or definitions Macros can have no parameters or any number of parameters number of parameters is unlimited All parameters are optional parameters which has not been substituted with cor responding arguments are filled with blank values Blank values have special meaning cannot be used in arithmetical expressions or as operands but can be checked if they are blank or not using IFB and IFNB directives 6 7 1 Syntax lt name of macro gt MACRO lt parameter
58. build star testcy outputk jump comparecy Table 6 6 Regular instructions Directives Regular directives and special macros directives can be prefixed with without any effect on their meaning and function if elseif else endif while endwhile endw for endf endfor Table 6 7 Special macros if ifn ifdef ifndef elseifb endwhile elseifnb else elseif elseifn elseifdef endw elseifndef endif ifnb ifb while Table 6 8 Conditional compilation amp the WHILE failjmp device limit reg string default_jump namereg address org define undefine undef equ constant set variable port portin portout data code string db error warning list message messg nolist skip title expand noexpand local endmacro endm exitm repeat rept endrepeat endr autoreg autospr orgspr initspr mergespr macro end Table 6 9 Regular directives period character 50 CHAPTER 6 ASSEMBLER 6 2 Instructions Legend sX sY Direct address in register file e g SO 1 S2 sX sY Indirect address e g SO S1 S2 kk Immediate value e g 0x21 hex 26 dec st A ascii aaa Address in program memory pp 8 bit port address i e in the range from 0x00 to OxFF p 4 bit port address i e in the range from 0x0 to OxF ss Address in scratch pad RAM Addressing mode
59. can also see the status of PicoBlaze RD WR and WRK signals read and write strobes 38 CHAPTER 5 SIMULATOR Stack Stack window represents values stored in stack You can change the stack content by pushing and popping values and view its virtual stack pointer Info panel Panel on the right side of simulation panel gives you general information about simulated code You can find there the program counter number of executed cycles clock frequency elapsed time and status flags Carry and Zero plus normally hidden Interrupt Enable flag You can also invoke an interrupt by clicking on the Interrupt button Buttons showing status flags or other flags can also change them click on such button to invert the flag Green text in flag button indicates that the flag is set to 1 black text indicates that value of the flag is 0 5 2 Modes of simulation The simulator can operate three different modes Step Step by step simulation executes only one instruction when invoked no matter how many machine cycles it will take this does not apply for macro instruction in that case each instruction of the macro is executed separately Animation Similar to the step mode but in a loop instructions are executed one after another until stopped on user request or by a simulator waring message Run Run is generally the same as animation but much faster GUI is not updated so often and changes in the registers ports etc are not shown until th
60. ce file s using the INCLUDE directive and these files can in the same way include other source files and so on Although cycles in the inclusion tree infinite loop of inclusion are checked for by the assembler and theoretically cannot possibly happen the assembler limits maximum inclusion depth by default to 1024 for stability reasons You can change your compiler settings and allow higher inclusion depth Maximum number of WHILE directive iterations X reached When using the WHILE directive it is easy by mistake to make it an enormously long loop or even an infinite loop in order to prevent that from happening the assembler limits maximum number of the while loop iterations to 1024 Maximum number of REPEAT directive iterations X reached When using the REPEAT directive it is easy by mistake to make it an enormously long loop or even an infinite loop in order to prevent that from happening the assembler limits maximum number of the repeat loop iterations to 1024 Instruction word is only X bits wide value Y trimmed to Z You have exceeded instruction word length opcode value has been trimmed from left to X bits which reduces value Y to value Z Symbol already defined X The given symbol X has already been defined there cannot coexist two or more symbols with the same name in one compilation unit 120 CHAPTER 6 ASSEMBLER Symbol not defined X The given symbol has not been defined maybe you are trying to use it
61. considered as an error and causes the assembler to consider the entire compilation unsuccessful Syntax ERROR error message Examples ERROR my error message This directive does the same things as the MESSAGE directive but in this case the printed message is considered as a warning Syntax WARNING warning message Examples WARNING my warning message 6 4 DIRECTIVES 97 REPEAT Repeats the specified block of code for the specified number of times REPT is shortcut for REPT and ENDR is shortcut for ENDREPEAT Syntax REPEAT lt number of repeats gt lt code gt ENDREPEAT REPT lt number of repeats gt lt code gt ENDR Examples REPT 5 SRO sF ENDR Equivalent to SRO sF SRO sF SRO sF SRO sF SRO sF 98 CHAPTER 6 ASSEMBLER AWHILE Repeats the specified block of code until expression equals to zero ENDW is shortcut for ENDWHILE Syntax WHILE lt expression gt lt code gt ENDWHILE WHILE lt expression gt lt code gt ENDW Examples ld SO 0x44 addr set 0 while addr lt 5 out SO addr addr set addr 1 endwhile FAILJMP DEFAULT JUMP value to output starting address Repeat while addr is lower than 5 Redefine addr addr addr 1 End the while loop Fills program memory with jumps to the specified address Purpose of this directive is to provide a simple means of protection against random errors Syntax FAILJMP lt expressio
62. d Find strings in the code Edit Find Next Find the next occurrence of the search string Edit Find Previous Find the previous occurrence of the search string Edit Replace Replace string in the code Edit Go to Line Go to line specified by the line number Edit Comment Modify the selected portion of the code to become a comment Edit Uncomment Revert the Comment operation i e uncomment the selected portion of code Edit Jump to Next Bookmark Go to line with next bookmark Edit Jump to Next Breakpoint Go to line with previous bookmark Interface Configure Open user interface configuration dialog Project New Project Open wizard for creating new projects Project Open Project Open and existing MDS project Project Open Recent Keeps track of recently opened MDS projects and allows to easily reopen them Project Save Project Save all opened files in the current project Project Close Project Close the current project Project Compile Run compiler on your current file or the main file in your current project Project Save Project Config Save the project configuration compiler settings etc not the source files them selfs Project Configure Open project configuration dialog Simulation Start Simulation Start processor simulator with machine code generated from the current file or the main file Simulation Run Run the program loaded in the simulator Simulation Animate Animate the program loade
63. d in the simulator Simulation Step Execute one instruction cycle in the simulator Simulation Reset Reset simulator 4 1 MAIN WINDOW 21 Simulation Unhighlight Remove highlight for recently changed values in the simulator GUI components Simulation Breakpoint Set breakpoint for the current line in the current file Simulation Disable Breakpoints Disable simulator breakpoints generally Simulation Enable Breakpoints Re Enable simulator breakpoints generally Tools Disassembler Open disassembler dialog Tools Assembler translator Open Assembler Translator dialog Tools Data File Converter Open Data File Converted utility Tools Radix Converter Open Radix Converter utility Tools 8 Segment Editor Open single digit LED display editor Tools Loop Generator Open Loop Generator utility Simulation Tools LED Panel Open simple LED panel simulator Simulation Tools 7 Segment Display Open simple LED display simulator Simulation Tools Switch Panel Open simple switch panel simulator Help About Displays basic information about your MDS version Help User Manual Open user manual this document Help Open Tutorial Project Open the Tutorial Project each user should read the tutorial before using this IDE Help Welcome Dialog Reopen the welcome dialog you have already seen the welcome dialog when you first started the MDS Help About Qt Display basic information about the Nokia Qt framework Help
64. d of file macros asm 12 13 main Xyz sO Expand macro xyz here 0000 00100 14 1 load s1 s0 0002 00000 19 1 nop 0003 00010 16 1 load s0 si 0005 22000 17 jump main Jump back to main 18 end End of assembly 118 CHAPTER 6 ASSEMBLER 6 9 Assembler messages This chapter lists the messages generated by the MDS assembler The following sections include a brief description of the possible error and warning messages along with a description of the error or warning and any corrective actions you can take to avoid or eliminate the error or warning Errors terminate the assembly and generate a message that is displayed on the console Warnings generate a message that is displayed on the console but do not terminate the assembly All messages are recorded in the code listing file Unable to open file X The given file X cannot be opened probably does not exist or your operating system refuses to grad the access to it Check whether the file exists and check your permissions Unable to write to file X It is not possible to write into the given file X This is in most cases caused by wrong permissions set on the file or directory or nonexistent directory in the file path Unable to save file X The given file X cannot be saved This might indicate that there is something badly wrong like not enough space left on your storage device HDD etc The resulting machine code is too big to be stored in a file Size of the resulting
65. de From these lists you can easily navigate to the corresponding line in your source code just by clicking on an item List of macros might sometimes need to refresh which can be achieved by Right Click gt Refresh squiodyesig 9PH sonew speu pog Bookmarks 8 89 Breskpoints 8 3 y Macros EE Une Fie E Line re B Name aros une Fie P 56 Example1 psm El H37 Example 1 psm 2 backup 27 Example6 psm 7 Example2 psm E 50 Example 1 psm restore 34 Example6 psm 7788 Example2 psm E F3 Example2 psm w100 nop 57 Example6 psm 21 Example3 psm 7 Example2 psm dioad regO regi valo vali 71 Example6 psm 60 Example4 psm Hi H84 Example2 psm 8 t copyS target source 82 Example6 psm 27 Example6 psm 3 7 Example3 psm 3 mops number 91 Example6 psm i 30 Example6 psm 2 H 16 Example3 psm a wait register cydes 101 Example6 psm 34 Example6 psm a 64 Example4 psm a fill target value length 112 Example6 psm P36 Example6 psm 1 bn 68 Example4 psm copy target source number 133 Example6 psm 39 Example6 psm E 5 Example6 psm z a F 10 Example6 psm 3 o z Bookmarks Breakpoints Macros 4 1 MAIN WINDOW 17 The right panel also contains the Help Browser which can help you navigate and read in your user manual the Reg Watcher and the Call Watcher Reg Watcher This panel might help you to keep track of speci
66. dit Interface Project Simulation Tools G d w B 6 Help u02 Top panel Left panel 109 1 113 14 CPL LCD send com ICN init Example Breakpoints E Example irectives asm demo_4 buttons leds asm demo 5 UART asm demo 1 simple prog asm abcc asm E Ed Er Source r Il 5 demo 3 directives asm 099 SETB s1 5 i e a 3 demo 4 buttons leds asm 100 SETB si 4 pap a3 demo 5 UART asm 101 CLRB s1 5 ae abec asm z demo_1_simple_prog asm 102 abcc asm abcc asm SETR s8 2 010 store fetch asm 104 CLRR s8 8 Include 105 3 Compiled load 8 0b10101011 Other 107 CPL2 5 Right panel apik soi ew Simulation Info IES Registers Scratchpad RAM Bottom panel Output Ports WR Stack 0x00 PC exed 7 CO fush Pop fase 00 01 02 03 04 05 06 07 00 01 02 03 04 05 06 07 00 01 02 03 04 05 06 07 fusbl2o oe 152 um cH 00 as 00 00 00 60 00 00 oo oo oo oo o0 oa 00 o0 oo oo 48 39 36 FF FF 7F 00 00 Cs OC 926 1A 60011010 ooo 00 00000000 os 66 gg gd bs 80 00 06 os 66 80 00 00 OG BO GG OO os FF 28 O1 O1 OG O0 GO OG MHz 600 00 600000000 600 00 600000000 10 00 00 00 00 00 00 00 10 o 00 00 00 00 00 00 00 10 00 00 Time 000 00 00000000 000 00 00000000 18 88 60 88 80 66 60 O8 18 06 80 00 66 66 BO OO 00 18 81 80 om 15 us 000 oo 00000000 eee es ceccecee 28 00 00 00 20 00 oo o0 00 oo oo o0 oo 2
67. e brackets may not be present lt attribute gt and lt event id gt are strings lt value gt lt location gt and lt detail gt are always numbers Examples of event messages gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt General cycles 2 cpu_pc_changed 2 flags_c_changed 1 flags_z_changed 0 register mem inf wr val written 0 0 register mem inf wr val changed 0 O simulator events These events are not related to any specific part of the simulated processor gt gt gt cycles value gt gt gt Total number of lt value gt machine cycles has been executed so far breakpoint location Breakpoint reached at address specified by lt location gt Processor flags group All these events have lt detail gt which is either 0 or 1 and indicates the new value of the concerned flag gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt flags_z_changed lt detail gt Zero flag has been changed to lt detail gt flags_c_changed lt detail gt Carry flag has been changed to lt detail gt flags_pz_changed lt detail gt Pre zero flag has been changed to lt detail gt flags_pc_changed lt detail gt Pre carry flag has been changed to lt detail gt flags_ie_changed lt detail gt Interrupt enable flag has been changed to lt detail gt flags_int_changed lt detail gt Interrupt flag has been changed to lt
68. e file in big endian byte order File format The Motorola S Rec file consists of a number of lines with following format lt Type gt Count lt Address gt lt Data gt lt Checksum gt Type A char 2 field These characters describe the type of record S0 S1 S2 S3 S5 S7 S8 or S9 Count A char 2 field These characters when paired and interpreted as a hexadecimal value display the count of remaining character pairs in the record Address A char 4 6 or 8 field These characters grouped and interpreted as a hexadecimal value display the address at which the data field is to be loaded into memory The length of the field depends on the number of bytes necessary to hold the address A 2 byte address uses 4 characters a 3 byte address uses 6 characters and a 4 byte address uses 8 characters Data A char 0 64 field These characters when paired and interpreted as hexadecimal values represent the memory loadable data or descriptive information Checksum A char 2 field These characters when paired and interpreted as a hexadecimal value display the least significant byte of the ones complement of the sum of the byte values represented by the pairs of characters making up the count the address and the data fields Each record is terminated with a line feed If any additional or different record terminator s or delay characters are needed during transmission to the target system it is the responsibility of t
69. e format capable of containing up to 64kB of data Hex files have usually extension hex or ihx These files are text files consisting of a sequence of records each line line can contain at most one record Records starts with colon character at the beginning of the line and ends by end of the line Everything else besides records should be ignored Records consist of a sequence of 8 bit hexadecimal numbers e g a2 or 8c These numbers are divided into fields with different meaning see the example below For PicoBlaze opcodes are divided into either 3 bytes in case of 18 bit opcode unused high order bits are filled with zeros or 2 bytes in case of 16 bit opcode these bytes are placed in the file in big endian byte order FF sE e o 8 g a 2o 4Checksum is two s complement of 8 bit sum of entire record except for the start code and the checksum itself 6 8 OUTPUT FILES 113 6 8 9 S Rec format S records are a form of simple ASCII encoding for binary data An S record file consists of a sequence of specially formatted ASCII character strings An S record will be less than or equal to 78 bytes in length The order of S records within a file is of no significance and no particular order may be assumed For PicoBlaze opcodes are divided into either 3 bytes in case of 18 bit opcode unused high order bits are filled with zeros or 2 bytes in case of 16 bit opcode these bytes are placed in th
70. e run is halted 5 3 Simulation cursor Simulation cursor shows what instruction will be executed in next step Two previously executed instructions are highlighted but with lower and fading intensity you can use that to easier track previous steps Following figure shows actual cursor on line 8 one step before is on line 5 and two steps before is on 4 01 02 03 04 05 06 07 08 DM o sa 09 S2 DELAY 10 S3 DELAY 11 12 Figure 5 2 Simulation cursor 5 4 SIMULATOR MESSAGES 39 When simulator encounters macro expansion for better orientation cursor will appear on two or more locations On macro expansion and in macro definition showing what is being executed and where it came from When you have macro expanded in another macro you will see three cursors and so on For better understanding the following figure shows simulation cursor behavior with macros 04 05 06 07 my macro MACRO 08 XOR s1 FFh 09 10 XOR s3 FFh 11 ENDM 12 13 LOAD S1 247 14 LOAD 2 153 15 LOAD S3 46 16 17 DELAY 18 19 DJNZ S1 DELAY 20 DJNZ S2 DELAY 21 DJNZ S3 DELAY 22 23 Figure 5 3 Simulation cursor with macros 5 4 Simulator messages The simulator can display several warnings to handle some common mistakes in software de velopment like program counter overflow stack overflow and some others it is meant to make your debugging process less painful To adjust settings related simulator w
71. e starting execution address and is interpreted as a 4 byte address There is no data field S8 The type of record field is S8 0x5338 The address field contains the starting execution address and is interpreted as a 3 byte address There is no data field S9 The type of record field is S9 0x5339 The address field contains the starting execution address and is interpreted as a 2 byte address There is no data field Example S00600004844521B 1130000285F245F2212226A000424290008237C2A 11300100002000800082629001853812341001813 9113002041E900084E422343001823420008244952 S107003000144ED492 S5030004F8 S9030000FC This file consists of one S0 record four S1 records one 5 record and an S9 record The SO record is comprised as follows e S0 S record type 50 indicating it is a header record 6 8 OUTPUT FILES 115 06 Hexadecimal 06 decimal 6 indicating that six character pairs or ASCII bytes follow 00 00 Four character 2 byte address field zeros in this example 48 44 52 ASCII H D and R HDR 1B The checksum The first S1 record is comprised as follows S1 S record type S1 indicating it is a data record to be loaded at a 2 byte address 13 Hexadecimal 13 decimal 19 indicating that nineteen character pairs representing a 2 byte address 16 bytes of binary data and a 1 byte checksum follow 00 00 Four character 2 byte address field hexadecimal address 0x0000 where the data which follows is to be lo
72. enu Context menu pops up when you right click in the editor or when you press the Menu key available on some keyboards it provides means to perform some basic operations like Cut Copy Paste etc 4 2 2 Key shortcuts Shortcut Description Shortcut Description Ctrl X Cut Ctrl C Copy Ctrl V Paste Ctrl Z Undo Ctrl Shift Z Redo Ctrl D Comment Ctrl Shift D Uncomment Ctrl B Set bookmark Ctrl Shift B Set breakpoint Ctrl A Select all Ctrl Shift A Deselect Ctrl G Go to line Ctrl F Find F3 Find next Shift F3 Find previous Ctrl R Replace Ctrl Up Scroll one line up Ctrl Down Scroll one line down Ctrl Left Move cursor one word left Ctrl Right Move cursor one word right Ctrl U Convert to uppercase Ctrl Shift U Convert to lowercase Ctrl Alt U Capitalize Ctrl K Delete line Ctrl T Swap characters Ctrl H Select word under cursor Ctrl Shift Left Select one word to the left ctrl Shift Right Select one word to the right Ctrl Shift Up Move line up Ctrl Shift Down Move line down Alt PageUp Go to previous bookmark Alt PageDown Go to next bookmark F5 Reload file Table 4 2 Editor shortcuts 4 3 PROJECT MANAGEMENT 23 4 2 3 Breakpoints and bookmarks For efficient debugging our simulator supports breakpoints Breakpoint is a mark associated with certain location in os LOAD 1 247 04 LOAD 52 8153 the program code when reac
73. essed by the assembler 84 CHAPTER 6 ASSEMBLER EQU EQU stands for EQUals it defines a symbol and assigns it a numerical value Such symbol is considered constant and therefore cannot be redefined Constant symbols defined with directive EQU can be used as register addresses port addresses and many others Syntax lt symbol gt EQU lt expression gt Examples First symb EQU 0b10011100 Second symb EQU 47 Third symb EQU 0x39 Fourth symb EQU A 4 18 B Fifth symb EQU 0x09 lt lt 2 LOAD SO First_symb CONSTANT Binary Decimal Hexadecimal An expression Another expression Loads SO register with 0b10011100 This directive is nothing more or less than the EQU directive with another syntax Syntax CONSTANT symbol expression 6 4 DIRECTIVES 85 SET The SET directive does the same thing as the EQU directive the only difference is that symbols defined with SET are re definable while symbols defined with EQU are constant Syntax lt symbol gt SET lt expression gt Examples my symbol SET 0x10 my symbol 0x10 LOAD SO stmy symbol Loads SO register with immediate value 0x10 my symbol SET 0x20 re defining my symbol to new value 0x20 LOAD 50 my symbol Loads SO register with immediate value 0x20 VARIABLE This directive is nothing more or less than the SET directive with another syntax Syntax VARIABLE symbol expression Examples VARIABLE
74. fic locations in registers scratch pad RAM and ports You can add arbitrary locations in memory which you consider to be the most important for your current work Call Watcher From here you can see all subprogram and interrupt calls in your program For each entry there you can see whether it is a call or an interrupt return address and address from which the call was invoked And you can force each of them to premature return Reg Watcher Call Watcher Edit Remove Add A Return sdf REG A Oxl 0x0 pr CALL 0x102 From 0x101 alx pd RAM 0x11 0x0 L di i INTERRUPT OxOFF 3 OTAN InPORT 0x12 0x0 ie 18 I From 0x011 d al CALL 0x011 al From OxOOF E CALL Ox00E b b i From Ox00C CALL 0x00B From 0x009 CALL 0x005 From 0x003 CALL 0x002 From 0x001 Reg Watcher Call watcher 18 CHAPTER 4 USER INTERFACE 4 1 2 Central panel Central panel contains the main text editor with syntax highlight for writing a source code In the editor you can also easily add breakpoints and bookmarks just by clicking on desired line number by left or right mouse button each invokes different action 4 1 3 Top panel Top panel contains main menu and the toolbar both can be used to invoke various actions which are described alter in this documentation File Edit Interface Project Simulation Tools Simulation tools Help Ba a amp amp gt bb 070 BBS H 8B Hk e Figure 4 2 Top panel 4 1 4 Bottom panel Bot
75. gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt lt attribute gt mem_inf_wr_val_changed lt location gt Content of the lt attribute gt memory has been changed at address lt location gt attribute mem inf wr val written location Value written to attribute memory at address location attribute mem inf rd val read location Value read from attribute memory at address location attribute mem err rd nonexistent location Attempt to read from nonexistent memory ie memory with zero size memory Space attribute address location attribute mem err wr nonexistent location Attempt to write to nonexistent memory i e memory with zero size memory space attribute address location attribute mem wrn rd undefined location Attempt to read from uninitialized location in attribute memory at address location attribute mem rd addr overflow location detail Address overflow occurred during read former address location new address detail attribute mem wr addr overflow location detail Address overflow occurred during write former address location new address detail I O group Input and output related events gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt plio_read lt location gt
76. h than what can be stored at the given location the value is automatically silently trimmed from the right for example when the given value is 0x123 while it is supposed to be 8 bit number the value stored will be 0x23 136 CHAPTER 7 COMMAND LINE TOOLS get file size lt space gt lt size gt Resize the lt space gt memory or I O to new size of lt size gt Use with care For example set size code 128 reduces size of the program memory to 128 breakpoint lt file line gt lt value gt Set breakpoint at lt file line gt lt value gt is optional and may be set either to 0 or 1 1 is default 1 means set and 0 means unset Please use command get locations to see at which locations breakpoints can actually be set Breakpoints are effective only in run mode or animation mode config lt key gt lt value gt Alter processor or simulator configuration lt key gt might be e hwbuild for which the lt value gt is an 8 bit number e interrupt vector for which the value is an address to program memory Get some information from the simulator this command has the following subcommands pc Get current value of the program counter flag flag Get processor flag please see the set flag command for details concerning which flags can be retrieved memory space address lt end address gt Read memory or I O When lt end address gt is specified this command will output a space sep
77. he symbol is not defined ELSE Compiles the following block only if none of the previous conditions was met ELSEIF lt expression gt Compiles the following block only if none of the previous conditions was met and if the expression value is not zero ELSEIFN lt expression gt Compiles the following block only if none of the previous conditions was met and if the expression value is zero ELSEIFB lt macro parameter gt Compiles the following block only if none of the previous conditions was met and if the macro parameter is blank ELSEIFNB lt macro parameter gt Compiles the following block only if none of the previous conditions was met and if the macro parameter is not blank ELSEIFDEF lt symbol gt Compiles the following block only if none of the previous conditions was met and if the symbol is defined ELSEIFNDEF lt symbol gt Compiles the following block only if none of the previous conditions was met and if the symbol is not defined ENDIF Closes the tree of conditions using this directive is mandatory 6 6 CONDITIONAL ASSEMBLY DIRECTIVES 105 6 6 1 Example abc equ 14 xyz equ 10 ifdef abc Hif abc 13 load SO 0b1101 ttelseif abc 14 load SO 0x21 ttelseifn abc 2 load SO abc else load SO 077 endif elseifndef xyz clrr S0 else ifn xyz mod 2 load SO 128 endif endif 2 gt E gt Assign number 14 to symbol abc Assign number 10 to sym
78. he transmitting program to provide them Record types SO The type of record is S0 0x5330 The address field is unused and will be filled with zeros 0x0000 The header information within the data field is divided into the following subfields e mname is char 20 and is the module name e ver is char 2 and is the version number 114 CHAPTER 6 ASSEMBLER e rev is char 2 and is the revision number e description is char 0 36 and is a text comment Each of the subfields is composed of ASCII bytes whose associated characters when paired represent one byte hexadecimal values in the case of the version and revision numbers or represent the hexadecimal values of the ASCII characters comprising the module name and description S1 The type of record field is S1 0x5331 The address field is interpreted as a 2 byte address The data field is composed of memory loadable data 2 The type of record field is S2 0x5332 The address field is interpreted as a 3 byte address The data field is composed of memory loadable data S3 The type of record field is S3 0x5333 The address field is interpreted as a 4 byte address The data field is composed of memory loadable data S5 The type of record field is S5 0x5335 The address field is interpreted as a 2 byte value and contains the count of S1 S2 and S3 records previously transmitted There is no data field S7 The type of record field is S7 0x5337 The address field contains th
79. hed it triggers a temporarily gs pies S3 346 halt in the running simulation You can use breakpoints a e to test and debug programs in a manner that the program 08 i DJNZ S1 DELAY b ined i delimited bv breakpoi Pl 09 DINZ S2 DELAY can be examined in stages delimited by breakpoints Please pw DJNZ 53 DELAY be also aware that using breakpoints slows down the sim ulator about by 30 in run mode if you want to reach Figure 4 5 Yellow bookmark Red the maximum simulation speed you may temporarily dis breakpoint Yellow Red gradient both able switch off breakpoints generally in Main Menu gt Simulation gt Disable Breakpoints Another feature is bookmarks when editing one location in your source code more often it may be useful to add a bookmark to it so you can quickly get back when you need Like breakpoints bookmarks are marks in your source code but they are meant solely for quick navigation they do not affect simulation or compilation in any way 4 3 Project management MDS can organize your files into groups called projects a project is also bound with its specific configuration which includes e Information about which exact processor do you use and in what exact configuration memory size etc e Compiler settings to be applied paths to search for included file which file formats you want to be generated by the assembler what VHDL template you want to use etc e Whether your project co
80. i gt lt parameter2 gt lt code gt ENDM 6 7 2 Directives MACRO Define a new macro ENDM End of macro definition EXITM Exit macro expansion EXPAND Disable macro expansions NOEXPAND Re enable macro expansions LOCAL Directive LOCAL declares a symbol as local for the macro in which it appears Syntax LOCAL symbols Example MACRO my macro LOCAL wait wait SUBCY SO 40x10 SUB SO 0x01 LOAD SO HOxFO JUMP C Wait ENDM 6 7 MACRO PROCESSING DIRECTIVES 107 6 7 3 Examples Macro without parameters abc macro load s2 s0 add s2 1 load s1 s2 endm abc Expand macro abc here abc And here abc And here This produces the same result as if you wrote this load s2 s0 add s2 1 5 load si s2 load s2 s0 E add s2 1 5 load si s2 load s2 s0 add s2 1 3 load si s2 Macro with parameters abc macro X y load x dy load X y endm abc s2 3 This produces this result load s2 3 5 load s2 3 Using blank parameters abc macro X y ifb y E load x SO else E load X y endif endm abc SO 81 Produces this result load SO S1 abc so Produces this result load SO SO If blank Else End of condition Parameter y is S1 here Parameter y is blank here 108 CHAPTER 6 ASSEMBLER Premature end of macro expansion abc macro load if y gt 2 exitm endif load endm abc Prod
81. ief msg Print only unique messages no strict Disable certain error and warning messages no warnings Do not print any warnings no errors Do not print any errors no remarks Do not print any remarks 7 1 ASSEMBLER 129 silent Do not print any warnings errors or any other messages stay completely silent include I lt directory gt Add directory where the compiler will search for include files device d lt device gt Specify exact target device options are For PicoBlaze kepsm1 kcpsmlcpld kcpsm2 kcpsm3 and kcpsm6 precompile P lt prc file gt Specify target file for generation of precompiled code vhdl lt vhd file gt Specify target file for generation of VHDL code vhdl tmpl lt vhd file gt Specify VHDL template file verilog lt v file gt Specify target file for generation of verilog code verilog tmpl lt v file gt Specify verilog template file mem lt mem file gt Specify target file for generation of MEM file raw hex dump lt hex file gt Specify target file for Raw Hex Dump sequence of 5 digit long hexadecimal numbers separated by CRLF sequence secondary lt hex file gt Specify target file for SPR initialization output format is Intel HEX define D lt namel value gt Define a symbol with the given name Value is optional the default value is 1 value has to be a decimal number if specified Symbol defined using this op
82. ifies the template file to initialize File Convertor Input file C Wy file psm i Change Input Options Type Hex X Output file C my_file asm Change Output Options Type SRec Figure 4 10 DATA file converter 32 CHAPTER 4 USER INTERFACE 4 5 6 8 segment editor With this tool you can easily determine what value you have to set on a port to display some digit on numerical LED display In the left part of the dialog window you can find numerical values cor responding to the displayed digit These values are represented for both common cathode and common anode and in three numerical bases hexadecimal decimal and binary Buttons on the left side from entry boxes copies value from the adjacent entry box into clip board In the right part of the window you can set which port bit is connected to which LED segment this sets permutation of the resulting values 4 5 7 LED panel simulator Simple LED panel simulator allows to easily observe output Te Segment Editor Cels us Common cathode LED VAL Hex ss Dec oar Bn o10110 1 F Common anode Hex oq Dec 164 Bn 10100100 c D voaonmonm gt Figure 4 11 8 segment edi tor port behavior with visual representation of eight LEDs You can set BCD and Gray decoder to simulate certain common FPGA logic 3 LED panel alz sly tere ees sl id ly lal xix
83. irst condition compares register S0 to immediate value of 10 decimal The second condition compares register at address given by B symbol to register S1 and the third condition compares two immediate values in this case the result of comparison is known in advance and the assembler with exploit that fact and print warning 102 CHAPTER 6 ASSEMBLER WHILE ENDWHILE To implement run time loops you can use the WHILE directive Assembler translates the WHILE directive to COMPARE TEST and JUMP instructions to implement the loop Directive ENDWHILE closes the loop body ENDW is only shortcut for ENDWHILE they can be used interchangeably Syntax WHILE lt condition gt lt code gt ENDWHILE Example load load while output inc endwhile SO 0xAA S1 0 S1 lt 5 S0 S1 S1 C gt 6 C value to output starting address while S1 lt 5 SO S1 S1l 6 5 CODE GENERATION DIRECTIVES 103 FOR ENDFOR The FOR directive provides another way to relatively easily implement run time program loops it is best demonstrated on examples see below Directive ENDFOR closes the loop body ENDF is only shortcut for ENDFOR they can be used interchangeably Syntax FOR lt iterator register gt lt number of iterations gt lt code gt ENDFOR FOR lt iterator register gt lt start gt end lt code gt ENDFOR FOR lt iterator register gt lt start gt end ste
84. lability PicoBlaze 6 PicoBlaze 3 PicoBlaze II PicoBlaze PicoBlaze CPLD yes yes no no no 70 CHAPTER 6 ASSEMBLER FETCH FT The FETCH instruction copies from the scratch pad ram memory SPR at the specified address into the specified register FT is only shortcut for FETCH these two mnemonics can be used interchangeably Syntax FETCH sX ss Copy from SPR at address ss to register sX FETCH sX sY Copy from SPR at address pointed by reg sY and copy it to reg sX Examples Fetch value from SPR at address pointed by reg S1 and store it in SO reg FETCH SO 081 Fetch value from SPR at address 0x22 and store it in SO reg FETCH S0 0x22 Flags Z no effect C no effect Availability PicoBlaze 6 PicoBlaze 3 PicoBlaze II PicoBlaze PicoBlaze CPLD yes yes no no no 6 2 INSTRUCTIONS 71 6 2 9 Interrupt group RETURNI RETIE RETID Return from Interrupt Service Routine ISR while enabling or disabling further interrupts RETIE stands for RETurn from Interrupt and Enable RETID stands for RETurn from Interrupt and Disable Syntax RETURNI ENABLE Return from ISR and enable interrupts RETURNI DISABLE Return from ISR and disable interrupts RETIE Same as RETURNI ENABLE RETID Same as RETURNI DISABLE Examples ORG Ox3DO Interrupt vector LOAD SO 0x55 Load register SO with immediate value 0x55 RETURNI DISABLE Return from ISR and disable further interrupt
85. ler supports only one special symbol this symbol is always automatically defined on every line containing an instruction or the DB directive it is symbol contains address in the program memory where this instruction is going to be placed by the assembler Example Since conatins the address of the JUMP instruction this jump results in infinite loop JUMP Skip the next instruction 1 would skip only the jump itself JUMP 2 LOAD S0 81 lt This instruction is goigh to be skipped LOAD 82 S3 46 CHAPTER 6 ASSEMBLER Predefined Symbols Registers These symbols are defined by default when you specify the target device using the DEVICE directive Symbols S10 S1F are defined for KCPSM2 only symbols S8 S1F are not defined for KCPSMI CPLD but defined for every other PicoBlaze All these symbols are defined as register addresses Symbol Value Symbol Value S0 0x00 10 0x10 S1 0x01 S11 0x11 S2 0x02 812 0x12 S3 0x03 13 0x13 S4 0x04 S14 0x14 S5 0x05 15 0x15 S6 0x06 16 0x16 S7 0x07 S17 0x17 S8 0x08 18 0x18 S9 0x09 19 0x19 SA 0x0A S1A 0x1A SB 0x0B S1B 0x1B sc 0x0C S1C 0x1C SD 0x0D S1D 0x1D SE OxOE S1E 0x1E SF Ox0F S1F 0x1F Table 6 2 Predefined symbols for registers Other predefined symbols __MDS VERSION __ This constant contains current version of your MDS installation It is a 16 bit BCD coded integer
86. llowed range is X Y trimmed to Z bits which makes it N Value exceeds the required range for the specific purpose Architecture not supported for the selected language The specified processor architecture is not supported by this compiler for the selected programming language this cannot normally happen Programming language not supported The specified programming language is not supported by this compiler this does not normally happen Failure X This message indicates some kind of low level failure something wrong with your operating system etc This does not normally happen Programming language not specified Since this compiler is implemented in a way that it can be extended with support for additional programming languages via compiler modules programming language has to be specified as a compilation option Target architecture not specified Since this compiler is implemented in a way that it can be extended with support for additional target processor architectures via compiler modules target architecture has to be specified as a compilation option Source code file not specified You are trying to compile something but you did not provide any input file name Empty string used as source code file name If you are running the compiler from a script this probably indicates an error in that script otherwise it should not normally happen File not found X Some of the specified source files does not exist 6 9 ASSEMBLE
87. mprises of a set of independent files or if it has one main file and other project files are only included in it using the INCLUDE directive 4 3 1 Untracked files Besides files bound with particular project you can also open modify save compile and simulate on files which are not part of your current MDS project These files files not bound with a project we call untracked files using untracked files has some limitations and under normal circumstances it should be avoided for instance when you run simulator on an untracked file note that in that case compiler has to be run first MDS does not know what processor it should use as target what is the size of its program memory whether to generate MEM file or not etc All these configuration options can be set for also untracked files but these settings are ultimately lost when you leave the MDS environment while if you used project they would be saved The purpose of project is to provide you better comfort while using this IDE although in some cases you just do not want to bother with creating a new project just for one file for a few minutes of work and that is where the untracked files comes handy 24 CHAPTER 4 USER INTERFACE 4 3 2 Project configuration In project configuration window you can edit project and compiler settings You can open project configuration window by right clicking on project name in the left panel and choosing Configuration see the pictures below Thi
88. n the IDE e On next tab you can adjust size of the scratch pad and program memory or change default interrupt vector e On Compiler tab you can choose files to generate by the assembler e Then click OK and you have your project e Click on Main Menu gt File gt New Project File e Edit your file as you wish and save it by clicking on Main Menu gt File gt Save File General Memory Compiler Templates noc General Memory Compiler Templates gt Memory Compiler Templates Paths amp Project name Size Options Main File My Name Scratchpad q 256 Project directory Program memory L Use Main Hle j 4096 home abyss Desktop git DE GUI translat Generate Interrupt Vector HW Build O Symbol Table O List File O Mem File Architecture Family Macro Table E Hex File _ RawHex File gt 3FF Debug File C Bin File Verilog File Picoblaze v Code Tree C SRec File VHDL file 10 port address count 256 Register count 2x16 Callstack size 31 X cance X conce X conce General Memory Compiler To use what you have just created e To assemble your file click on Main Menu gt Project gt Compile e To start simulation click on Main Menu gt Simulation gt Start Simulation e Compiled files suitable for loading into FPGA can be found in the directory which you choose to be your project directo
89. n gt DEFAULT_JMP lt expression gt Examples something_is_wrong do something FAILJMP something is wrong 6 4 DIRECTIVES 99 ENTITY Specifies VHDL entity name to use when filling VHDL template by default the entity name is the base name of your source code file without file extension case sensitive Entity name is case sensitive and has to be enclosed in double quotes Assembler does not check whether the entity name is a valid VHDL identifier Syntax ENTITY lt name gt Examples entity my_entity_abc 100 CHAPTER 6 ASSEMBLER 6 5 Code generation directives MDS assembler supports several special directives for automated generation of run time loops and conditions Note that condition and loop blocks may contain any other code including other loops and conditions Loops Instead of writing loops with loads compares and jumps you might find it to be more straightforward to use the assembler to generate them for you You can use three types of FOR loop and one type of WHILE loop Conditions Instead of writing conditional branching using compares and jumps you can let the assembler do at least some this work for you with IF ELSEIF ELSE and ENDIF directives This feature resembles C language but don t forget that you are still working with assembler these branching directives are merely a syntax sugar they are translated as compare and conditional jump nothing more Condition syntax
90. n will use the new definition while the preceding expansions will not be affected Macro parameter X eclipses global symbol Y defined at Z This message means that your macro uses a parameter with the same name as some of the already defined symbols There is nothing wrong with that but it is generally better to avoid it Macro parameter X eclipses global symbol Y This message means that your macro uses a parameter with the same name as some of the already defined symbols There is nothing wrong with that but it is generally better to avoid it Argument X not used Expression defined using the DEFINE directive contains parameter which is not used during the expression evaluation Exact device not specified using X by default If you do not use the DEVICE directive to specify the exact processor assembler will use something X by default Processor type X should be specified without double quotes The DEVICE takes processor name as it argument the processor name should not be enclosed by double quote characters Reuse of iterator register in nested for loop The two loops will affect each other via their iterator registers Comparing a register with itself result is always X Result your auto generated run time condition is always known in advance because it compares the given register with the same register Register is expected here but given type is X Only register addresses are recommended for the FOR loops iterat
91. ne Tools Assembler Disassembler and Assembler Translator may also be invoked from command line and therefore used in your scripts On Linux versions there is also man page for each one of them 7 1 Assembler 7 1 1 Description Macro assembler for PicoBlaze soft core processors this tool takes one or more source code files and produces compiled machine code file usable in JTAG loaders processors simulators and similar tools along with these files containing compiled machine code compiler also produces extensive debugging output MDS macro assembler is made to run fast and extensively tested for greater reliability it feature set includes various special macros and user defined macros support making it one of the world most advanced assemblers available on the market today for PicoBlaze processors By default the compiler does not generate any output files that might be useful when you simply want to check a file for errors but you do not want that when you actually need to compile something a use the resulting machine code When you need the machine code or any other file output you have to specify which file or files you want the compiler to generate by providing the corresponding options Usage mds compiler OPTIONS source file Options architecture a lt architecture gt REQUIRED Specify target architecture supported architectures are PicoBlaze KCPSM soft core processor language l programming lang
92. nt of more complex applications User is our main concern We believe you will feel relatively comfortable while working with this tool 2 1 Main features e Text editor optimized for writing source code e Project manager for creating and maintaining your projects e Very fast simulator for all available versions of Picoblaze e Macro assembler supporting wide range of output file formats including MEM HEX and VHDL e PicoBlaze disassembler capable of reading from HEX VHDL MEM and other file formats e Tool called Assembler Translator for compatibility with your current tools e Command line tools and a number of graphical utilities 10 CHAPTER 2 ABOUT MDS 2 2 Requirements This software is compiled for x86 processors in both 32b and 64b variants with SSE instruction set that means you need a processor equipped with SEE feature most processors manufactured after the year 2003 are For GNU Linux MDS also requires GLIBC version gt 2 17 Supported host operating systems are e Microsoft Windows 7 32b and 64b e Microsoft Windows XP 32b e Ubuntu 13 10 and higher 32b and 64b e CentOS 7 64b e openSUSE 13 1 and higher 32b and 64b e Fedora 20 and higher 32b and 64b 11 Chapter 3 Getting Started 3 1 Tutorial project The aim of the tutorial project is to provide an easy way to explore the IDE without reading long documents The tutorial project can be opened from the Main Menu gt Help
93. number this number is always decimal when there are more that one number in the response these numbers are separated by a single space There are no negative or real numbers all numbers have to be nonnegative integers in both input and output Each response is written on separate line set Set something in the simulator this command has the following subcommands pe address Set program counter to address For example set pc Ox3ff executes uncondi tional jump at address Ox3ff flag flag value Set processor flag flag has to be one of C Z IE I pC pZ C is Carry Z is Zero pC is pre Carry Carry before ISR pZ is pre Zero Zero before ISR I is interrupt and IE is interrupt enable value has to be either 0 or 1 memory space address value Change content of the space memory or I O at address space has to be one of portin portout register data code stack where code is program memory data is scratch pad ram and others should be obvious For example set memory register 0 0x22 sets register at address 0 i e SO to value 0x22 When dealing with memory banks address is always absolute i e not respecting boundary of bank size this can be demonstrated on an example suppose there are 2 banks bank size is 16 and memory size is 32 address 1 in the 1st bank is 1 while the address in the other bank is 16 1 17 When the provided value has higher bit widt
94. ocations are filled with zeros Example 011F7 01299 0132E 19101 00000 19201 00000 19301 00000 00000 00 6 8 4 Raw binary file Raw binary file contains machine code generated by the assembler in raw form It contains instruction opodes formatted either as a sequence of byte triplets in case of 18 bit instruction opcodes or sequence of byte pairs in case of 16 bit instructions opcodes byte order for these sequences is big endian Unused memory locations and higher bits of bytes which are not used in their entire width are filled with binary zeros start address for the entire file is 0 6 8 5 String table String table is a human readable text file containing table of strings defined in your source code using the STRING directive File format The table of strings consists of a number of lines with following format Name lt Location gt lt Value gt Name Name of the string Location Location of the string definition formatted as lt file name gt lt line number gt lt column gt lt line number gt lt column gt Value The assigned character string 6 8 OUTPUT FILES 111 6 8 6 Symbol table Symbol table is a human readable text file containing table of symbols defined in your source code using labels symbol definition directives EQU SET REG DATA CODE AUTOREG AUTOSPR and implicitly defined symbols for your processor File format The table of symbols consists of a number
95. olic names and which should remain to be represented as numbers available options are c Program memory d Data memory r Register file p Port address k Immediate constants This options takes any combination of these i e for example cdr stands for program memory data memory register file cfg lc lt character gt Use uppercase or lowercase characters 1 Lowercase u Uppercase cfg radix lt radix gt Radix available options are h Hexadecimal d Decimal b Binary o Octal help h Print help message version V Print disassembler version and exit 132 CHAPTER 7 COMMAND LINE TOOLS Notes e marks the end of options it becomes useful when you want to disassemble file which name could be mistaken for a command line option 7 3 Assembler translator 7 3 1 Description mds translator is tool for translating assembly language source code from one dialect to another in this case it translates into assembly language used by MDS Multitarget Development System from dialect used by other companies or projects Usage mds translator OPTIONS lt input file gt Options type t lt asm variant gt REQUIRED Specify variant of assembly language used in the input file possible options are 1 Xilinx KCPSMx 2 Mediatronix KCPSMx 3 openPICIDE KCPSMx output o lt file asm gt REQUIRED Specify output file cfg ind lt indentation gt Indent with keep Do not alter
96. ols are be deleted from the symbol table and compiler will not recognize them Syntax UNDEFINE symbol UNDEF symbol Examples symbol SET 15 LOAD S0 symbol UNDEF symbol LOAD s0 symbol This will cause compilation error 94 CHAPTER 6 ASSEMBLER DB This directive initializes the program memory directly it can be used for direct writing of instruction opcodes Memory is initialized in two different ways in case of string given as argument to the directive program memory will be initialized byte by byte in case of constants and expressions each constant or expression initializes one instruction word If instruction word is 18 bits wide the MSB of the byte triplet will be trimmed to 2 bits making entire triplet only 18 bits wide instead of 24 Syntax Expresion syntax DB lt expressioni gt lt expression2 gt String syntax DB lt string gt Combination of string s and expression s DB lt string gt lt expression1l gt Parameter can be unlimited number of string characters or expressions divided by comma Examples DB 0x060FC Constant DB my string String DB my string 2 1 3 Combination of string expression and constant LIMIT Imposes user defined limit on size of register file scratch pad ram or program memory In the example below if you use 8 registers or JUMP to address higher than 512 compiler reports such attempt as error Syntax LIMIT D lt num
97. on Main Menu gt Interface gt Configure In the general settings you can set things like display the splash screen at start up etc In the code editor settings you can set tab width fonts etc In simulator settings you can slightly adjust simulator behavior SIDE IDE General Options Editor d spe E IP Display splash screen B Fonts amp Simulator Display tips on start up D Mim Session restoration x Language Engish ok X cancel IDE General SDE Editor Fonts General C Editor cond Font Size mach Simulator achana Warnings Rekha Saab Sans Serif Sawasdee Standard Symbols L Swift Symbol TakaoPGothic The Quick Brown Fox Jumps Over A Lazy Dog o x Cancel Editor Fonts SDE Simulator Warnings eee Memory Stack CPU General esed I Stack overflow Simulator X Stack underflow Simulator Warnings Stack E IDE Editor General Options General Er Editor eo Fonts Ta Simulator Tab width 4 Y Wenige Insert spaces instead of tabs x Number of spaces a 12 Files Default encoding Default EOL li Cao canca Editor General IDE Simulator Warnings General Memory pStack ceu Editor Memory Stack CPU i roma I Read nonexistent Write nonexistent E Simulator R Read unimplemented Write unimplemented R Read access denied Xt Read undefined
98. ons is in write strobe please refer to PicoBlaze manual and addressing of the 1st operand OUTPUTK copies immediate value value being part of the instruction s opcode from the 1st operand to the specified port address OUTK is only shortcut for OUTPUTK these two mnemonics can be used interchangeably Syntax OUTPUTK kk p Copy immediate value kk to port at address p in range 0x0 0xF OUTK Hkk p Same as above OUTPUTK kk sY Copy immediate value kk to port at address given by sY register OUTK kk OsY Same as above Examples OUTK OxAA Ox2 Write OxAA to port at address 0x2 LD S1 0x1 S1 Oxi OUTK 0x55 091 Write 0x55 to port at address given by S1 reg 0x1 Flags Z no effect C no effect Availability PicoBlaze 6 PicoBlaze 3 PicoBlaze II PicoBlaze PicoBlaze CPLD yes no no no no 6 2 INSTRUCTIONS 69 6 2 8 Storage STORE ST The STORE instruction copies from the specified register into the scratch pad ram memory SPR at the specified address ST is only shortcut for STORE these two mnemonics can be used interchangeably Syntax STORE sX ss Copy from register sX to SPR at address ss STORE sX sY Copy from register sX to SPR at address pointed by reg sY Examples Store value of reg SO in SPR at address pointed by reg 81 STORE S0 S1 Store value of reg SO in SPR at address 0x22 STORE S80 0x22 Flags Z no effect C no effect Avai
99. operator before the start address Missing AT operator please refer to the directive syntax for details Comma expected between operands There is a syntax error in your code and the assembler guesses that it might be caused by missing comma between instruction operands Instruction not supported on the this device X Various processors have various instruction sets this error message indicates that you are trying to use some instruction X which is not supported by the processor you are compiling your code for No user defined limit for the program memory size fail jump cannot be used When using the FAILJMP directive or similar directive there has to be defined exact size of the program memory Otherwise the assembler cannot know up to which address it is supposed to fill the program memory with JUMPs Invalid size X Size cannot be zero or negative number Cannot merge DATA memory SPR with the CODE memory at address X When using the MERGESPR directive the merge address has to be valid Zero and negative numbers are not valid zero would collide with the reset address and negative number does not make sense at all Address is crossing CODE memory size boundary Y When using the MERGESPR directive the merge address has to be within boundaries of the progra memory space Directive EXITM cannot appear inside special macro Directive EXITM cannot appear inside special macro because it would break its pairing
100. oravia icrosystems MDS Multitarget Development System Moravia Microsystems s r o Brno CZ European Union 2014 2015 Copyright 2014 2015 Moravia Microsystems s r o All rights reserved The City of Brno Czech Republic European Union http www moravia microsystems com Contents Preface About MDS 2 l Man POLES sa ee ae a OE HS Ew o3 2m BW Bors 22 GOSQUERPEIMONES 2020202 a E a es A RORCADE ROS a Rom m d m Getting Started SL Tutorial DOI Leu n nono Xo a qo YU SU RUE OX S eRe eS o ves e 2 33 3 0k ex vo xo ex xx oy POP ee Rex dodo 3 3 Short introduction to MDS macro assembler 3 3 1 Main differences from the Xilinx assembler 3 4 Compatibility mode with Xilinx assembler cles User Interface 21 Man Window s a ae eid omo gom UR meee dada SUR X PES RR UR es 24 41 AL aud right panel 2520069 Ba a oe ee aw EDA GO a 1 2 Central panel e rossa a a ae ae ee Ee eee OS 1 3 Top panel o eaaa Ete mk a AR GR Alas Botton panel e noo ae A Oe Ree a P om uus ANS Exit ic Restoration e eee oa sr ro ek RO 3 3 40 GG a xs 41 0 Main menu actions se cocoa a A EEG oe R9 a a 42 Lode Editor s ss uoo oe so oe ooo ORO dw voe y 9 o ee SE es 4204 Mam Tees 00 xs 9 9 a ROS RUE ee PR a ww ns 42 2 EV RBOPOUER ok ones ca ean ke e exe y humum ELE ELE oe oh wow Roy oy 4 2 3 Breakpoints and bookmarks o S Project management 2l AA odo wok RR Ro XS XI Vu gacked Bes
101. original indentation spaces Indent with spaces tabs Indent with tabs cfg tabsz lt n gt Consider tab to be displayed at most n spaces wide here it is by default 8 cfg eof lt end of line character gt Specify line separator available options are clrf WINDOWS use sequence of carriage return and line feed characters If UNIX use a single line feed character 0x0a default cr APPLE use single carriage return 0x0d gt short inst lt true false gt Use instruction shortcuts e g in instead of input etc default false 7 3 ASSEMBLER TRANSLATOR 133 cfg lc sym lt character gt Use uppercase or lowercase characters for symbols 1 Lowercase u Uppercase cfg lc dir lt character gt Use uppercase or lowercase characters for directives 1 Lowercase u Uppercase cfg lc inst lt character gt Use uppercase or lowercase characters for instructions 1 Lowercase u Uppercase backup b Enable generation of backup files version V Print version and exit help h Print help message Notes 6 e marks the end of options it becomes useful when you want to disassemble file which name could be mistaken for a command line option Examples e mds translator type 1 output final_file asm my_file psm 134 CHAPTER 7 COMMAND LINE TOOLS 7 4 Simulator 7 4 1 Description The main purpose of this tool is to provide means to use
102. ors Generic number is expected here but given type is X Only generic numbers are recommended for specifying the FOR loops intervals No target file for SPR initialization specified When you wish the compiler to perform scratch pad memory initialization you either need to specify target file for the initialization or specify merge address in the program memory Jump address is not specified by a label When using the FAILJMP directive argument for this directive is recommended to be a label 126 CHAPTER 6 ASSEMBLER Instruction word is only X bits wide value Y trimmed to Z When using the DB directive to directly initialize the program memory values exceeding bit width of the instruction opcode on your processor are automatically trimmed from left to fit the opcode width Unable to locate file X in base path Y or include path s Z This indicates that one of your include files i e files included into your source code using the INCLUDE directive cannot be located in the directories which you specified to search for included files include directories File X is already opened you might have an inclusion loop in your code This usually happens when you include a file from another file which includes the first file or when a file includes itself I O error cannot read the source file properly Some of the source files is not readable this might be caused by permissions set on that file 127 Chapter 7 Command Li
103. our design then create your custom component named UART and define its ports and generic attributes The newly created component will appear here and you can add it to your entity later 34 CHAPTER 4 USER INTERFACE KCPSM combobox You can select KCPSM version which you are using in your design it changes the declaration and instantiation of PicoBlaze in the generated VHDL file By default it is KCPSM6 Create component button This button will open create component dialog where you can define your new component See the next section Create component dialog Delete component button This button removes one component from your MPU_SYS en tity Generate If you have your input and output file selected this button will trigger generation of the VHDL file Create component dialog You can define your custom component and add it to the generated entity or save it for later usage You can remove or edit existing components by right clicking on them in the field Existing components Figure 4 17 VHDL port parameters Component name Name of your custom component 4 5 TOOLS 35 Tab PORT Port tab lets you define component ports Port name Name of every port Names or identifiers may consist of letters numbers and underscore Value You can set the initial value Leaving this field empty means no initial value is needed Direction Direction in port tab can be IN OUT or INOUT Bus check box Telling generator
104. p lt code gt ENDFOR Examples SO starts from 0 and goes up to 9 SO is incremented after each iteration FOR sO 10 NOP ENDF SO goes from 10 to 15 6 iterations 10 11 12 13 14 15 FOR sO 10 15 NOP ENDF SO goes from 10 to 50 by steps of 10 5 iterations 10 20 30 40 50 FOR sO 10 50 10 NOP ENDF 104 CHAPTER 6 ASSEMBLER 6 6 Conditional Assembly Directives The aim of the conditional assembly to to assemble certain parts of the code if and only if certain arithmetically expressed condition is met This feature can prove useful particularly when the user want to make the code somehow configurable Note that condition blocks may contain any other code including other conditions This assembler provides these directives to cope with conditional assembly HIF lt expression gt Compiles the following block only if the expression value is not zero IFN lt expression gt Means If Not compiles the following block only if the expression value is zero IFB lt macro parameter gt Means If Blank compiles the following block only if the macro parameter is blank IFNB lt macro parameter gt Means IF Not Blank compiles the following block only if the macro parameter is not blank IFDEF lt symbol gt Means IF DEFined compiles the following block only if the symbol is defined IFNDEF lt symbol gt Means IF Not DEFined compiles the following block only if t
105. ptions Options Options Memo looptest asm New Memory Main File translator qph Files Compiler Er Compiler looptest asm i Options Add pe maad Templates Templates Include Paths Include Paths xt Use Main File Generate C Symbol Table C List File C Mem File C Macro Table X Hex File C RawHex File Debug File C Bin File C Verilog File C Code Tree C SRec File _ VHDL file Project Compiler templates Files Compiler Options ok X Cancel Choose which VHDL or Verilog template will be used by the assembler to generate the HDL code for your design by default MDS uses its own built in templates Compiler include paths Here you can add or edit path where the compiler will try to find files included in other source code files directive INCLUDE E Project Options Memory i Files Er Compiler Options p Include Paths VHDL Template Templates Options Use Default Verilog Template Use Default Compiler Templates ok X Cancel E Project Options Memory Files Compiler Options Templates Include Paths Compiler Include Paths Edit Delete ok X Cancel Compiler Include paths 26 CHAPTER 4 USER INTERFACE 4 4 UI Configuration In the interface configuration dialog you can edit appearance and behavior of the IDE To open the interface configuration dialog click
106. re already used to and possibly try the macro assembler later if you wish However there is a couple of things you should probably know about before you start using this feature 1 When you use the compatibility mode you have to name your source files with psm extension otherwise the compatibility mode might not work 2 MDS is not equipped with an assembler that can accept the Xilinx syntax the compati bility mode uses the Assembler Translator to translate your code from Xilinx syntax to MDS syntax there is generally no problem with that but you will get much less useful error messages compilation warnings etc 3 The MDS syntax offers considerably wider options for writing code this cannot be ex plained in one sentence but there are two main ideas of innovation behind MDS 1 very high simulation speed almost real time and 2 a reasonably advanced assembler well suitable for developing moderately complex applications When you choose not to use the MDS assembler you are putting away one the main advantages of this IDE 4 This manual does not take into account that the user chooses to use the Xilinx syntax this option is meant primarily for users who just what a quick start 2 Assembler Translator will be discussed later in this manual 15 Chapter 4 User Interface 4 1 Main Window For a better understanding of further comments and instructions lets define five major areas of the main window File E
107. ry Types of these files and therefore their purpose can be easily determined by their extensions rawhex is HEX file suitable for JTAG loaders mem is a decimal representation of the machine code suitable for a number of various tools vhd is VHDL code with your machine code generated from template which can be chosen by user lst is code listing 1These file extensions are only recommended the actual extensions can be set by user at any time 3 8 SHORT INTRODUCTION TO MDS MACRO ASSEMBLER 13 stbl is table of symbols mtbl is table of macros ihex is Intel 8 Hex srec is Motorola S Record bin is plain binary file dbg is a file used the simulator for simulation it has no other purpose v is Verilog code with your machine code generated from template which can be chosen by user ctr is so called code tree this file has normally no application for regular users it contains textual representation of raw output from the syntax analyzer 3 3 Short introduction to MDS macro assembler This assembler uses almost the same syntax as the Xilinx assembler for PicoBlaze but there are some differences 3 3 1 Main differences from the Xilinx assembler Default radix is decimal not hexadecimal You can use different radix for each numerical literal if you do not specify radix it is decimal by default For hexadecimal radix use the Ox prefix Oxla Oxbc 0x23 for octal radix use the 0
108. s Immediate Instead of reading operand value from memory the operand value is taken from the instruction opcode itself Direct Effective address of the operand is address as given in the instruction opcode Indirect Effective address of the operand is taken from contents of register which address is given in the instruction opcode 6 2 INSTRUCTIONS 51 6 2 1 Register Loading LOAD LD The LOAD instruction provides a method for specifying the contents of any register The new value can be a taken from an immediate constant or contents of any other register LD is only shortcut for LOAD these two mnemonics can be used interchangeably Syntax LOAD sX kk Load register sX with immediate value kk LD sX kk The same a above LOAD sX sY Load register sX with content of register sY LD sX sY The same a above Examples LD SO 0x55 Load register SO with 0x55 LD S1 SO Copy content of SO to S1 Flags Z no effect C no effect Availability PicoBlaze 6 PicoBlaze 3 PicoBlaze II PicoBlaze PicoBlaze CPLD yes yes yes yes yes 52 CHAPTER 6 ASSEMBLER STAR Instruction STAR performs the same operation as the LOAD instruction except for that the target register is in inactive register bank while source is in active bank Syntax STAR sX sY Load sX in inactive bank with content of sY in active bank STAR sX kk Load sX in inactive bank with immediate value kk Examples STAR S
109. s Flags Z no effect C no effect Availability PicoBlaze 6 PicoBlaze 3 PicoBlaze II PicoBlaze PicoBlaze CPLD yes yes yes yes yes 72 CHAPTER 6 ASSEMBLER ENABLE DISABLE INTERRUPT ENA DIS Enable or disable interrupts ENA is only shortcut for ENABLE INTERRUPT these two mnemonics can be used interchangeably DIS is only shortcut for DISABLE INTERRUPT these two mnemonics can be used interchangeably Syntax ENABLE INTERRUPT Enable interrupts DISABLE INTERRUPT Disable interrupts ENA Same as ENABLE INTERRUPT DIS Same as DISABLE INTERRUPT Examples DIS Timing critical code begins here disable interrupts CALL something Call subroutine something ENA Timing critical code ends here re enable interrupts Flags Z no effect C no effect Availability PicoBlaze 6 PicoBlaze 3 PicoBlaze II PicoBlaze PicoBlaze CPLD yes yes yes yes yes 6 2 INSTRUCTIONS 73 6 2 10 Program Control JUMP Instruction JUMP loads program counter with the address specified by aaa operand or by Q sX sY Syntax JUMP aaa Unconditional jump JUMP Z aaa Jump only if the Zero flag is set JUMP NZ aaa Jump only if the Zero flag is NOT set JUMP C aaa Jump only if the Carry flag is set JUMP NC aaa Jump only if the Carry flag is NOT set JUMP sX sY Unconditional jump at sX 3 0 sY 7 0 Examples my label S ew Code ys cu JUMP my label Jump to label my label JU
110. s loop DJNZ s0 loop 82 CHAPTER 6 ASSEMBLER Increments the given register and jumps at the given label until the register contains zero Syntax IJNZ sX label Equivalent ADD sX 1 JUMP NZ label Examples loop IJNZ s0 loop 6 4 DIRECTIVES 83 6 4 Directives Assembler directives are commands for the assembler executed at compilation time their pur pose is to instruct the assembler how to compile your code to define constants implement conditional compilation and evaluate various things at compilation time INCLUDE Compiler copies content of the specified file to line where this directive is used Included files can include other files Path of the included file might be specified as either absolute or relative in case of relative path the path is always relative to location of file in which the INCLUDE directive appears and optionally to any of the include path list specified as assembler option Syntax INCLUDE file_name Examples INCLUDE some_file asm NCLUDE sub dir another file asm NCLUDE C my dir my file asm NCLUDE C my_dir my_file asm NCLUDE home user project file asm I L I I END The END directive informs the assembler that it has reached the end of all source code Assembler then ignores any code following this directive so everything after this directive is threated as comment Syntax END Examples LOAD SO 81 END LOAD 50 81 82 53 This will not be proc
111. s are automatically generated by the assembler when some of macro parameters was not substituted with the corresponding argument This value is not valid inside an expression This indicates an attempt to use nonnumerical value like a string in an expression Since such value is not a number it cannot be use for calculation Invalid number of operands instruction X takes Y operand s Each instruction takes an exact number of operands for example LOAD always takes two operands it cannot be used with only one operand or with three four etc operands Invalid number of operands instruction X takes Y or Z operand s Each instruction takes an exact number of operands for example LOAD always takes two operands it cannot be used with only one operand or with three four etc operands Cannot declare a label before X directive For various reasons with certain directives it is not allowed to define a label at the same line Directive X requires a single argument This means that directive X cannot be used with different number of arguments than one Directive X takes no arguments This means that directive X cannot be used with different number of arguments than zero 124 CHAPTER 6 ASSEMBLER Directive X requires an identifier for the symbol or macro which it defines Symbol string and macro definition directives always require name of the symbol string or macro which they are suppose to define Directive X requires AT
112. s will open main configuration window with multiple tabs on the left side Project Options e Project name Name of your project e Architecture Processor architecture used in your project e Family Processor family of the selected architecture e Info panel Brief description of selected processor Project Memory e Size options Memory size e Interrupt vector Interrupt vector size of program memory 1 is maximum e HW build Your HW build constant Er Project p Memory Project Options E Project Options 10 port address count 256 Register count 2x16 Callstack size 31 x Cancel Project Options Memory Options Project name Size Options Files Files Er Compiler jh Compiler Scratchpad Options Options 256 Templates 5 Templates B 4 Include Paths ELE Rn Include Paths Program memory Picoblaze M kcpsm6 hd y 4096 Interrupt Vector HW Build 3ff 4 X Cancel Project Memory Project Files Here is where you can create add or remove files from your project and set set the main file see below Compiler Options e Main file If you have Use main file checked you can choose which file will always chosen for compilation and simulation instead of the file currently opened in the code editor e Generate Select which files should the assembler generate in your project s directory from the given source code Er Project Project Files EF Project Compiler O
113. sages reached suppressing compiler message Source code contains a huge number of errors further error messages are from now on sup pressed in order to prevent enormous size of code listing file and enormous and impractical assembler console output Macro expansion has been disabled macro X will not be expanded The given macro X cannot be expanded because macro expansion has been temporarily disabled by NOEXPAND directive You can use EXPAND directive to re enable the macro expansion Parameter X substituted for blank value Macro parameters are optional those parameters which has not been substituted with arguments are filled with blank values Parameters can be checked if they are blanks using the IFB and IFNB directives Symbol X already declared as local You are trying to declare a symbol as local macro symbol which itself is perfectly valid operation unless you do it multiple times for the same symbol Reusing already reserved space in X memory at address Y There is a collision in two different attempts to utilize certain location in memory space For instance with the ORG directive you can easily by mistake attempt to put two in struction at the same location in the program memory Or using the REG directive you can also by mistake use the same register for two completely different things which could result in mysterious behavior of your program Limit value 1 means unlimited Using 1 as size argument for the LI
114. se the following strings which are automatically substituted with their corresponding values when the command is executed curfilename Name of file currently opened in the code editor without directory without extension curfilepath Name of file currently opened in the code editor with directory without extension curfiledir Directory where the file currently opened in the code editor is located projectdir Directory where your current project is located 28 CHAPTER 4 USER INTERFACE 4 5 2 Delay loop generator In many cases it is useful to have a tool for creating delay loops it can just save you some time during development This tool can generate wait loops using up to six registers as iterators All you have to do is to enter the desired time of delay or the number of instruction cycles and clock frequency Section Input variable Choose between time or instruction cycles Section Desired waiting time Time or number of instruction cycles Section Frequency Clock frequency Section Register names Register names to be used in the generated code as iterators Section Generated code The resulting automatically generated code Instruction Instruction used in loops Type Form of delay loop whether you want it as macro or plain Upper Case and Comments Comments turn on off automatically added comments Upper case use upper case letters Button Copy to clipboard Copy the generated code into clipboard
115. sed for easier setting up of connections between your PicoBlaze imple mentation and the other parts of your VHDL design It can help you when you do not want spend too much time writing peripheral logic for PicoBlaze and your VHDL components This tool automatically takes port addresses from your symbol table file generated by assembler and generates corresponding port constants and input output multiplexers Final output of this tool is a VHDL entity containing your custom defined components port constants all necessary signals constants and declaration of KCPSM design Main window Input file VHDL wizard reads a symbol table file and extracts all symbols defined with PORT PORTIN and PORTOUT directives Select path to your symbol table stbl file gener ated after the compilation of you source code Please make sure that you have enabled generation of the symbol table file Project gt Configure gt Compiler gt Options gt Symbol table Output file The resulting VHDL file MPU SYS entity General overview of your VHDL entity Each box represents one VHDL component there are always three boxes by default KCPSM Component Input De multiplexer and Output Multiplexer You can click to every one of them for detailed information When you create or add some custom defined components they will be shown here Existing components This list contains all your previously defined components For example let s say you have a UART receiver in y
116. sion gt Examples somewhere CODE Ox3ff ORG somewhere CALL somewhere 88 CHAPTER 6 ASSEMBLER PORT Symbols defined with the PORT directive are considered to be port addresses only and cannot be used for anything else except for that PORT is just another EQU Syntax lt symbol gt PORT lt expression gt Examples my_port PORT 0x22 OUTPUT SO my port PORTIN Symbols defined with the PORTIN behaves the same as if they were defined with the PORT directive but with one exception PORTIN is intended for specifying input port addresses and some tools might rely on that Generally it is a good idea to avoid using PORT as much as possible and use PORTIN and PORTOUT instead Syntax symbol PORTIN expression Examples my port PORTIN 0x22 INPUT SO my port PORTOUT Symbols defined with the PORTOUT behaves the same as if they were defined with the PORT directive but with one exception PORTOUT is intended for specifying output port addresses and some tools might rely on that Generally it is a good idea to avoid using PORT as much as possible and use PORTIN and PORTOUT instead Syntax symbol PORTOUT expression Examples my port PORTOUT 0x22 OUTPUT SO my port 6 4 DIRECTIVES 89 AUTOREG It will automatically assign a register at some address starting from 0x00 which is incremented with every other AUTOREG directive by one or if provided the size argument Optionally you can change starting addre
117. ss counter by adding a parameter after AUTOREG directive Symbols defined with this directive have the same purpose and limitations as if they were defined with the REG directive You can check assigned registers in code listing file lst and symbol table file sym This directive may save you some time you can use it when you don t care which exact register will be used Syntax lt symbol gt AUTOREG lt size gt lt symbol gt AUTOREG AT lt address gt Examples reg 1 AUTOREG reg_1 0 reg_2 AUTOREG reg_2 1 reg 3 AUTOREG reg_3 2 reg_4 AUTOREG AT 10 Start counting from 10 so reg_4 10 reg_5 AUTOREG my_reg_5 11 LOAD reg 3 reg 4 52 SA LOAD reg 1 40x22 SO 0x22 AUTOSPR This directive provides exactly the same functionality as the AUTOREG directive but for addresses in scratch pad ram Symbols defined with this directive have the same purpose and limitations as if they were defined with the DATA directive Syntax symbol AUTOSPR size symbol AUTOSPR AT lt address gt Examples my data AUTOSPR STORE SO my data 90 CHAPTER 6 ASSEMBLER INITSPR Initializes scratch pad RAM SPR with the given value s content of such initialized memory is stored in the Secondary Assembler Output see the compiler configuration dialog or command line option secondary Syntax lt symbol gt INITSPR lt value gt Examples my_data INITSPR Hello PicoBlaze my_data2 INITSPR Ox2b FETCH SO my
118. sse air eee aa a RA oe 48 Oa Repiater Loading o coc es eee FR RRA 49 LOAD BD ocio cage ees eee add dede eS dn de od aes 49 DUAL MI cr 50 Gra Lal A P UIT 51 d cae M bee Cee hee ete we SUPP ated bb dws 51 A vey Gx oh OE Go Ee ee a as hs ts A A A 52 CU a te a ae eee Seok GVH lane at at ate la ta eae ae ah Ded 53 02 1 A 0 ex 9 9 xx E ek Gea RARE RES 54 ADD ADOS 221282 m B aa vu ES EUER SS REGES 54 DEB SED Y x 32235 duce 6s BP sD eb Wald uo 55 624 Te and Lope uocum Resume mmm EG X ow ee ES 56 TEE kde AA sex eus uemqessses 3 s 56 a e MC CP Tl 57 COMPARE UMP lt 24 408 68 64 taa eee Ra RR 9 3 3 EE dee 58 GOMPARECY CMPUY 2 062 4445 00 044 4 44464646 2 Rm RA og ole 59 62 5 Shift and Rotate 222294 Ros Wee ae ee eee Ss 60 Pi SEL A Lu bo PA dese be eee ee EE Eh de Ree qu 60 SED SRL SEX SRA cocos Re RO ho eee EO ROS amp a RR 9 Rog 61 EU BD uuo uomo Raum SE BS mS OS Pub Vou aaa Shah EH 62 6 2 6 Register Bank Selection ee ee 63 REGBANE RB so nda Se RE Sw As ERE DS 63 627 Input Output AI 64 INPUT DN 2 24404446000 6 x E KeE EEE Ee eed etd bd 64 COUT OUT Se oe Sieve Boh a ae Ee Ade ae eee we ee AN A 65 OUTPUTRK QUTK 2 2 5 62 hae bee ae Sd chk Ue ae ee ea A 66 QA TEES ide eA enya doloe eG avant tat Gl Be eh sos ah ue d 67 STORE ST cid omoes ee a ae ee Ok E y ob eom cR s 67 A ee oa A EE een ees m fut t RR Se hs e e die aA 68 CONTENTS 5 628 Dupi EOM A 69 RETURNE RETIE EETID ciu RUE DE 4 o o9 eR
119. t DEFINE lt expression gt Examples A EQU 10 A 10 decimal B SET 25 B 25 decimal C DEFINE A B 2 Value of C is unknown for now LOAD SO C Load SO with 10 25 2 70 B SET 11 B 11 decimal LOAD SO C Now load SO with 10 11 2 42 X DEFINE 0 1 Value of C is unknown for now LOAD SO X 4 5 Now load SO with 4 5 9 ORG ADDRESS The assembler maintains a location counter for program memory this location counter is incremented with each assembled instruction With ORG or ADDRESS directive this location counter can be changed to instruct the assembler to start writing the code following the ORG directive at the new location counter position Syntax ORG expression ADDRESS expression Examples ORG Ox3ff Suppose that Ox3ff is the address for ISR JUMP handle interrupt 6 4 DIRECTIVES SKIP Do not initialize the given number of program memory words and skip to the next nearest location Syntax SKIP lt expression gt Examples ORG LOAD LOAD LOAD LOAD SKIP LOAD LOAD 0 SO 0x22 SO 0x22 SO 0x22 SO 0x22 5 SO 0x22 SO 0x22 Put opcode Put opcode Put opcode Put opcode at at at at address address address address OxO Ox1 Ox2 Ox3 Skip next 5 program memory locations Put opcode at address 0x8 Put opcode at address 0x9 UNDEFINE UNDEF All symbols can be undefined undefined symb
120. t The bit shifted out of the register and then shifted back to the other side Syntax RR sX Rotate Right RL sX Rotate Left Examples LOAD SO 40x18 SO 0b00011000 RR S0 SO 0b00001100 RL S0 SO 0b00011000 RL S0 SO 0b00110000 Flags Z 1 if result is zero otherwise 0 C The bit shifted out of the register and then shifted back to the other side Availability PicoBlaze 6 PicoBlaze 3 PicoBlaze II PicoBlaze PicoBlaze CPLD yes yes yes yes yes 6 2 INSTRUCTIONS 65 6 2 6 Register Bank Selection REGBANK RB Set active register bank RB is only shortcut for REGBANK these two mnemonics can be used interchangeably Syntax REGBANK A Set active bank A REGBANK B Set active bank B RB A Same as REGBANK A RB B Same as REGBANK B Examples RB A LD SO 0xAA RB B LD SO 40x55 Flags Z no effect C no effect Availability PicoBlaze 6 PicoBlaze 3 PicoBlaze II PicoBlaze PicoBlaze CPLD yes no no no no 66 CHAPTER 6 ASSEMBLER 6 2 7 Input Output INPUT IN The INPUT instruction reads data from a port i e from your hardware design into the specified register IN is only shortcut for INPUT these two mnemonics can be used interchangeably Please notice the difference between direct port addressing and indirect addressing Syntax INPUT sX pp Copy from port at address pp to register at sX address IN SX pp Same as above INPUT sX sY Copy from por
121. t at address given by sY register to register sX IN sX sY Same as above Examples IN S0 0x22 Read port at address 0x22 and copy its value to SO reg LD S1 0x11 S1 0x11 Read port at address given by S1 reg 0x11 and copy its value to SO reg IN S0 081 Flags Z no effect C no effect Availability PicoBlaze 6 PicoBlaze 3 PicoBlaze II PicoBlaze PicoBlaze CPLD yes yes yes yes yes 6 2 INSTRUCTIONS 67 OUTPUT OUT The OUTPUT instruction transfers data to a port i e to your hardware design from the specified register OUT is only shortcut for OUTPUT these two mnemonics can be used interchangeably Please notice the difference between direct port addressing and indirect addressing Syntax OUTPUT sX pp Copy from register at sX address to port at address pp OUT SX pp Same as above OUTPUT sX sY Copy from register sX to port at address given by sY register OUT SX OsY Same as above Examples OUT S0 0x22 Write content of S0 reg to port at address 0x22 LD 1 40x11 S81 Ox11 Write content of SO reg to port at address given by S1 reg 0x11 OUT S0 081 Flags Z no effect C no effect Availability PicoBlaze 6 PicoBlaze 3 PicoBlaze II PicoBlaze PicoBlaze CPLD yes yes yes yes yes 68 CHAPTER 6 ASSEMBLER OUTPUTK OUTK The OUTPUTK instruction is basically the same as the OUTPUT instruction difference between these two instructi
122. t carry and SUBCY instruction does the same but with carry Syntax SUB sX kk SUB sX sY SUBCY sX kk SUBCY sX sY Examples LOAD SO 10 LOAD S1 2 SUB S0 S1 SUB SO 5 SUBCY 0 S1 SUBCY SO 5 Flags Availability Subtract immediate value kk from sX register Subtract content of sY register from sX register Subtract immediate value kk from sX register Subtract content of sY register from sX register SO SO SO without carry without carry with carry with carry 1 2 sO 81 SO 5 S0 81 Carry SO 5 Carry Z 1 if result is zero 0 otherwise C 1 if results in an overflow i e the result is negative 0 otherwise PicoBlaze 6 PicoBlaze 3 PicoBlaze II PicoBlaze PicoBlaze CPLD yes yes yes yes yes 3SUBCY on PicoBlaze 6 behaves differently zero flag is set to 1 if result is zero and zero flag was set prior to the SUBCY instruction otherwise it set to 0 58 CHAPTER 6 ASSEMBLER 6 2 4 Test and Compare TEST The TEST instruction performs bitwise logical AND operation and discards its result except for the status flags Syntax TEST sX sY TEST sX kk Examples TEST SO 0 Set Z flag if SO O JUMP Z somewhere Jump to label somewhere if Z flag is set Flags Z 1 if result is zero 0 otherwise C 1 if the temporary result contains an odd number of 1 bits 0 otherwise Availability PicoBlaze 6 PicoBl
123. t equal to A lt gt B 8 bitwise AND 48 amp 16 8 bitwise OR 370q 7 9 amp amp logical AND 48 amp amp 16 9 E logical OR 370q 7 9 i bitwise XOR 00fh 005h Table 6 3 Operators priorities 48 CHAPTER 6 ASSEMBLER Special operators Special operators can appear only at certain places and serve special purposes high Operator HIGH extracts the high order byte from 16 bit value For example LOAD SO high 0x2233 would load SO with immediate value of 0x22 low Operator LOW extracts the low order byte from 16 bit value For example LOAD SO 1low 0x2233 would load S0 with immediate value of 0x33 at Operator AT is used only in conjunction with AUTOREG and AUTOSPR directives to set address counter to the specified value Operator is used only with the FOR directive to specify the loop iteration interval 6 1 GENERAL 49 6 1 7 Reserved keywords Please remember that the assembler is case in sensitive Instruction mnemonics cpl2 cpl inc dec setr clrr setb clrb notb djnz ijnz nop Table 6 4 Pseudo instructions ldret ena dis retie retid cmp in out outk ld cmpcy st ft ret Table 6 5 Instruction shortcuts add addcy sub subcy compare load return and or xor test store fetch jump sro sri srx sra rr s10 call sli slx sla rl input output hw
124. table above MDS assembler also supports these escape sequences 6 1 GENERAL 45 NNN To write a character whose numerical value is given by NNN interpreted as an octal number e g NO 22 377 etc xHH To write a character whose numerical value is given by HH interpreted as an hexadecimal number e g xOF Nx2A xC7 etc uXX To write a unicode character specified by max 4 hexadecimal digits uX XXX To write a unicode character specified by max 8 hexadecimal digits 6 1 5 Symbols Symbols are user defined symbolic names for numbers and addresses used in the program Symbol names consist of upper and lower case letters digits and underscore character their length is not limited they are case insensitive and they have to be different from language keywords Symbol names cannot start with digit Be aware of that there cannot coexists two or more symbols which differs only by letter casing for instance abc and ABC are considered by this assembler to be the same symbol Symbols have to be defined before they are used Example first_symbol EQU 0b100111 Binary radix number second symbol SET 047 Octal radix number third symbol REG 39 Decimal radix register address fourth symbol DATA 0x27 Hexadecimal radix scratch pad ram address fifth symbol CODE 0x27 Hexadecimal radix program memory address my_label Program memory address defined using label Special Symbols MDS assemb
125. the original source code from any object code Usage mds disasm OPTIONS lt input file gt Options arch a architecture REQUIRED Specify target architecture supported architectures are PicoBlaze family f family REQUIRED Specify processor family supported families for the given architectures are For PicoBlaze kepsm1 kcpsm1cpld kcpsm2 kcpsm3 and kcpsm6 out o lt output file gt Specify output file where the resulting assembly language code will be stored type t lt input file format gt Type of the input file if none provided disassembler will try to guess the format from input file extension supported types are hex Intel 8 HEX or Intel 16 HEX srec Motorola S Record bin Raw binary file mem Xilinx MEM file for PicoBlaze only vhd VHDL file for PicoBlaze only 7 2 DISASSEMBLER 131 v Verilog file for PicoBlaze only cfg ind lt indentation gt Indent with spaces Indent with spaces default tabs Indent with tabs cfg tabsz lt n gt Consider tab to be displayed at most n spaces wide here it is by default 8 cfg eof lt end of line character gt Specify line separator available options are clrf WINDOWS use sequence of carriage return and line feed characters If UNIX use a single line feed character 0x0a default cr APPLE use single carriage return 0x0d gt cfg sym symbols Which kind of addresses should be translated to symb
126. the MDS s processor simulator in user written scripts in which the user needs to simulate a processor For instance you can write a script in Tcl Python Bash etc and use the mds proc sim to test your programs written for PicoBlaze You can do things like feed your program with some input and read its output connect several processors together and make them exchange data you can even view contents of registers and all other memories watch subroutine calls and interrupts set breakpoints and many other tasks This tool implements command line interface for the simulator engine It listens to simple commands like sim step or get pc Each command must be on separate line empty lines are ignored and everything after the character is threated as comment and ignored Response to each command is either done or Error lt message gt or Warning lt message gt Some commands print some values in that case these values are printed before the done string This command line interface is case sensitive Input consists of sequence of text lines separated by LF each line may contains several words separated by spaces or tabs Input is taken from standard input output is written to standard output and error and warning messages are written to standard error output if possible End of line character is LF Line Feed CR characters at the end of line are ignored as white space 7 4 2 Invocation mds proc sim
127. tion is of type number and is re definable This option is particularly useful in conjunction with the conditional compilation directives IFDEF amp IF ELSE etc Example mds compiler D SKIP_LOOPS D DEFAULT_TIMEOUT 10 Notes e marks the end of options it becomes useful when you want to compile file s which name s could be mistaken for a command line option e When multiple source files are specified they are compiled as one unit in the order in which they appear on the command line from left to right 130 CHAPTER 7 COMMAND LINE TOOLS Examples e mds compiler architecture PicoBlaze language asm hex abc hex abc asm Compile source code file abc asm file abc asm for architecture PicoBlaze arch PicoBlaze written in assembly language language asm and create file abc hex containing ma chine code generated generated by the compiler e mds compiler language asm architecture PicoBlaze hex abc hex abc asm Do the same at the above only in this case we have used another variant of usage of switches with argument e mds compiler 1 asm a PicoBlaze x abc hex abc asm Do the same at the above only in this case we have used short version of the switches 7 2 Disassembler 7 2 1 Description Disassembler is a tool intended to generate assembly language code from an object file In other words it has certain level of capability of reversing the assembly process and regaining
128. tom panel consists of simulator main panel and compiler messages In simulator main panel you can see status of internal registers scratch pad ram input and output ports call stack program counter elapsed time elapsed machine cycles processor clock and internal flags carry zero interrupt and interrupt enable Most of these values can be edited during processor simulation In compiler messages panel you can see textual output from the assembler like warnings and other messages Simulation Info Registers Scratchpad RAM Input Ports RD Output Ports WR Stack 0x00 PC exooA J E 00 01 02 03 04 05 06 07 00 01 02 03 04 05 06 07 80 0102 03 e4 es 06 07 Jeust Pop EH as2 loc 000 90 00000000 170 AA 10101010 99 99 og oo oo oo oo o0 oo 80 oo vs oo oo o0 o0 o0 oo 00 48 39 36 FF rr 7F 00 00 ED 026 1A 00011010 ooo oo 90000000 os ga Bg Ba 80 86 OG OO sa os 6H BO BO BG GG O8 BO 60 os FF 28 01 01 80 88 88 88 MHz jv 600 00 00000000 600 00 00000000 10 00 oo oo 00 oo oo oo oo 10 oo oo oo oo oo oo oo oof 10 o0 oo oo oo oo oo oo oo Time 600 00 00000000 600 oo 00000000 18 88 80 08 GO 00 00 80 OG s 00 G6 00 06 00 0 GO O0 s 01 0 OO O0 00 GO O0 Go am 15 pe 000 oo 00000000 ooo 69 00000000 20 00 oo oo 00 00 00 oo oo 20 oo oo 00 va as 00 oo oo 20 30 00 00 00 oo 00 oo 00 2s ooo oo oooooooo ooo 06 90000900 3 hs Go oo oo oe oo ot oo 30 o6 os oo os oo 60 oo Go 38 o co oo or oo oo oo os eU oms 0 ps MM
129. uage gt REQUIRED Specify programming language supported languages are asm Assembly language 128 CHAPTER 7 COMMAND LINE TOOLS hex x lt intel HEX file gt Specify output file with machine code generated as a result of compilation data will be stored in Intel 8 Hex format debug g lt MDS native debug file gt Specify output file with code for MCU simulator and other debugging tools srec lt Motorola S REC file gt Specify output file with machine code generated as a result of compilation data will be stored in Motorola S record format binary lt binary file gt Specify output file with machine code generated as a result of compilation data will be stored in raw binary format lst lt code listing gt Specify output file where code listing generated during compilation will be stored mtable m lt table of macros gt Specify file in which the compiler will put table of macros defined in your code stable s lt table of symbols gt Specify file in which the compiler will put table of symbols defined in your code strtable lt table of symbols gt Specify file in which the compiler will put table of strings defined in your code help h Print help message version V Print compiler version and exit check c Do not perform the actual compilation do only lexical and syntax analysis of the the provided source code and exit no backup Don t generate backup files br
130. uces load load abc Produces load x y x y x y s0 1 s0 1 s0 1 s0 3 s0 1 A few simple practical examples Copy content of registers at addresses source source 4 to registers at addresses target target 4 copy5 macro load load load load load endm Copy SO copy5 target target target target target target S4 to S5 SO source 0 source 1 source 2 source 3 source 4 source S5 S9 PONRe rO Wait for the given number number of instruction cycles and use the given register as iterator for the delay loop register cycles register cycles 1 4 wait macro for nop endfor endm Wait 100 instruction cycles here wait S0 100 6 8 OUTPUT FILES 109 6 8 Output files 6 8 1 Generated VHDL and Verilog files As you know the PicoBlaze microprocessor is primarily designed for use in a VHDL design MDS will generate all the necessary files that are needed for implementation in FPGA The compiler will read a VHDL template and insert the generated machine code for PicoBlaze processor to complete the definition of program ROM and write the result into a new VHDL file that is ready for synthesis and simulation Template can be modified to define alternative memory definitions However you are re sponsible for ensuring that the template is correct the compiler does not perform any validity checks on the VHDL template
131. unconditionally CALL subr Flags Z no effect C no effect Availability PicoBlaze 6 PicoBlaze 3 PicoBlaze II PicoBlaze PicoBlaze CPLD yes yes yes yes yes 76 CHAPTER 6 ASSEMBLER LOAD amp RETURN LDRET Load the specified register with the specified immediate value and return from subroutine LDRET is only shortcut for LOAD amp RETURN these two mnemonics can be used interchangeably Syntax LOAD amp RETURN sX kk LD amp RET sX kk LDRET sX kk Examples my_subroutine LDRET SO 0x55 CALL my_subroutine Flags Z no effect C no effect Availability PicoBlaze 6 PicoBlaze 3 PicoBlaze II PicoBlaze PicoBlaze CPLD yes no no no no 6 2 INSTRUCTIONS 77 6 2 11 Version Control HWBUILD Instruction HWBUILD load the specified register with hwbuild Syntax HWBUILD sX Examples HWBUILD SO Flags 1 if loaded value is zero 0 otherwise 1 a n Availability PicoBlaze 6 PicoBlaze 3 PicoBlaze II PicoBlaze PicoBlaze CPLD yes no no no no 78 CHAPTER 6 ASSEMBLER 6 3 Pseudo Instructions MDS assembler supports a number of pseudo instructions which can improve understandability of your source code Assembler will replace these instructions with one or more PicoBlaze instructions to achieve the purpose of that pseudo instruction No operation This instruction does not do anything it just consumes processor time Syntax NOP Equivalent
132. utput data formats and a number of advanced features like macro processing conditions loops etc it is meant to give you means to write code with run time efficiency typical for the assembly language while giving you some of the comfort of a more high level language like C For instance you may use if SO 1 to easy write conditions instead of compares and conditional jumps for S0 0 9 for loops if my constant gt 20 for conditional compilation abc macro x y z for defining your own macros and more MDS assembler is enhanced with these features in hope it will help you save your time and make your work a little bit easier MDS assembler also has a number of features for smooth and transparent debugging and it is regularly subjected to extensive automated testing to ensure its very functionality and to provide high reliability Also this assembler supports all PicoBlaze versions publicly available at the time of its release For these reasons we are convinced that this is the most advanced assembler for PicoBlaze currently available on the market Supported processors e PicoBlaze 6 e PicoBlaze 3 e PicoBlaze II PicoBlaze CPLD PicoBlaze Note about this documentation to write a document properly describing any program ming language including the assembly language is always a challenging task If you find a mistake or improperly covered area in this documentation please let us know we will fix that and

Download Pdf Manuals

image

Related Search

Related Contents

Philips 6000 series Smart LED TV 42PFL6877K  Download: Bedienungsanleitung-cz-75-P-07  MDVK071  取扱説明書  n° 246 voir ce numéro  ComBridge Studio Suite Version 2.3 Benutzerhandbuch  ATLAS User's Manual  登録フロー  Onsight Connect for Librestream Devices User Manual  

Copyright © All rights reserved.
Failed to retrieve file