NET "AL<1>" LOC = "P30";
NET "AL<0>" LOC = "P32";
NET "AH<1>" LOC = "P37";
NET "AH<0>" LOC = "P39";
NET "UIO<5>" LOC = "P43";
NET "UIO<6>" LOC = "P49";
NET "UIO<7>" LOC = "P50";
NET "UIO<8>" LOC = "P52";
NET "UIO<9>" LOC = "P53";
接下来的窗口要求添加任何现有的源文件。点击Add Source按钮添加源代码提供的所有Verilog文件(文件列表见上文的Verilog编码一节)和CPLD.ucf文件。一旦添加后,程序会询问:File.v is which source type The suffix is ambiguous as to type (File.v是什么文件类型,后缀类型不明确)。选择Verilog Design File并点击OK (参见图5)。所有输入文件归类完毕后,点击Next继续。
在接下来的窗口(Boundary-Scan Mode Selection)中选择Automatically connect to cable and identify Boundary Scan chain,并点击Finish。
如果器件连接正确,iMPACT将弹出一个窗口,显示“There was one device detected in the boundary-scan chain. iMPACT will now direct you to associate a programming or BSDL file with this device....”。点击OK。
注意,也可以用两个函数完成同样的工作:program(int address, int x)和read(int address)。但是,在本应用中选择每个地址分配一个函数,这样允许应用提取不同的地址作为功能寄存器。每个程序的汇编程序代码和读函数都相当简单。代码只要求以正确的地址载入数据指针,然后用一个movx指令激活存储器总线。
Native_program0:
clr a ; request first parameter
lcall NatLib_LoadPrimitive ; load parameter into r3:r0
mov dptr, #0C00000h ; point to memory mapped peripheral
mov a, r0 ; move low byte of source into accumulator
movx @dptr, a ; write to memory mapped peripheral
clr a ; indicate no error condition
ret ;
...
Native_read0:
mov dptr, #0C00000h ; point to memory mapped peripheral
movx a, @dptr ; read from memory mapped peripheral
mov r0, a ; move into low byte of result
clr a ; indicate no error condition
mov r1, a ; unsigned extend to 32-bits
mov r2, a ; unsigned extend to 32-bits
mov r3, a ; unsigned extend to 32-bits
ret ;