




已阅读5页,还剩8页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
嵌入式系统开发翻译报告文档名称 A Verilog 8051 soft core for FPGA applications 翻译页码 pdf页数从38到58,英文文档页数从27到47 姓 名 何天从 学 号 3110757101 班 级 网络11-1班 院 系 信息科学与工程学院 4.1.2. Simulation and Testing The controller FSM diagram shows that the CPU_STATES and EXE_STATES are sequencing as designed. The function of the controller module is to synchronize the control signals to / from other components of the 8051. Therefore the controller was tested after integrating all the modules. A test program, Test_r1, was loaded in the ROM, a Synchronizing Clock of 12Mhz was started and the inter-module signals, during Controller CPU_STATEs & EXE_STATEs were monitored. CS_0 state is entered when reset is asserted. The controller resets the SFR in RAM, namely ports (p0 to p1) to FFh and the SP to 07h, by sequencing thru the EXE_STATES ES_0 thru ES_5. Figure 4.1-11 shows CS_2 the instructions fetch and decode cycles. The controller reads the ROM contents at the address pointed by the PC, interfaces with the ALU to perform a PCUADD (Program Counter Unsigned ADD) and increments its local pc-register; sends the instruction read from ROM to decoder; the decoder returns a 9-bit decoded op-code; the controller fetches the next location from ROM, and if bit-7 of decoder op-code is set, sends a source operand of value 1 to perform a PCUADD by the ALU, and updates its local pcregister; then fetches ROM contents as pointed by pc-register, and if bit-8 of the decoder op-code is set sends a source operand value 1 else 0 to the ALU for PCUADD. The controller having collected the data updates the PC and operands for the instruction execution cycle. To account for the register latching delays the controller loads its registers with data from ROM or RAM modules at the third EXE_STATE with respect to the corresponding read control signal. Figure 4.1-12 shows details of the instruction execution cycle for the 8051 instructions RLC A (rotate A-register left through carry) and the next instruction MOV P0, A (move contents of A register to output port p0). For execution of RLC in this example, at ES_0 the controller enables the ALU by sending control variable alu_opcode (B corresponding to RLC) and the A-register contents as source operand to perform the rotate operation. During ES-1 the controller loads the data lines to RAM with the result from the ALU and enables RAM write to write the new value to the SFR A-Register. The carry-bit from ALU is also stored in its internal register. During ES_2 it sends the data to update the PSW, also an SFR on RAM. The controller sequences thru the next states ES_3 to ES_6 until it reaches ES_7 when the execution is completed by resetting all variables to ALU, and jumping to CS_1 and ES_0 to fetch next instruction. In this example the next instruction is MOV P0, A. The waveforms of Figure 4.1-12 show that in the fetch cycle the decoder output corresponds to the MOV instruction. During the execution cycle of this instruction there is no ALU operation. During ES_0, the contents of A-register are written to the port address, also an SFR in RAM. The rotated data value is seen on port0-out on the simulation waveform. 4.1.3. Verification The results of the simulation waveforms verify that the controller module is operational. 4.2. ROM The ROM is the dedicated 4KB of program memory space on the 8051 microcontroller. It contains the binary code with the instructions to be executed. The ROM module takes as input the 12 bits of the program counter PC, and gives as output the 8- bit data of instruction op-code and operands.4.2.1. Detailed Design Altera recommends the use of a Parameterized ROM mega-function to implement all ROM functions. This mega-function allows for a synchronous read only memory with clock for strobing in the address. The Quartus II Mega-function Plug-in Manager tool was used to configure the LPM_ROM mega-function named “v8051_rom_mem” for the following parameters to implement the 8051 ROM: Memory size 4096 words. Word width 8-bits Address width 12- bits Initialize file A hexadecimal (Intel Format) file of the program code to be stored in the ROM memory. Test programs/applications were written in 8051 assembly language. The assembled test runs were verified on the 8051 simulator. The program code in Intel hex format was stored in the module directory, was then specified as data file for loading the ROM at power-up/ reset. The memory address is enabled at the positive clock edge, requires a hold- time of 3 clock pulses for the memory content to become available on the data lines. The ROM module therefore requires two clock inputs, a fast clock to read the ROM and a slower one to synchronize the rom_data with the controller timings. The ROM_module instantiates the ROM mega-function v8051_rom_mem to read the instructions at valid rom_addr from controller and to latch it to the out data register in the rom_rd signal interval. 4.2.2. Simulation & Testing To test the program code in ROM, this module was simulated with the following input conditions, and the data lines were observed: Clock set at 12MHz. Read asserted at 6 MHz frequency. Address lines incremented by 1 starting from 00H. The simulation was carried for a period of 5 sec. Result: Refer to listing of the text file Test1_r1 below. The data lines (ref Figure 4.2-2) read the values of the first column below which is program code. Figure 4.2-1: ROM Contents of Test Program Test1_r1.txt - 8051 Instructions Figure 4.2-2: Simulation Waveform for ROM Module (Verilog Model) 4.2.3. Verification The same simulation conditions were applied to the ROM module of Dalton model. The two waveforms are similar. Figure 4.2-3: Simulation Waveform for ROM Module (Dalton Model) 4.3. RAM The 8051 has an internal Data Memory (internal RAM) of 256 bytes. The internal RAM is divided into 2 blocks: the first 128 byte block is the general purpose RAM, and a second part starting from address 80H, is the Special Function Register (SFR) area 15. The RAM module defines an array of 128 bytes in the address range 00h-7Fh and 21 Special Function Registers (SFR) within the address space 80H-FFh. 4.3.1. Detailed Design The detailed design of internal RAM (Data memory) of the 8051 IP soft core is shown in Figure 4.3-1: Flow Diagram for RAM. The RAM module generates a 128 byte array of write (parallel load) and read (output enable) memory (registers). Locations 20H to 2FH are bit addressable. It also has 21 bytes allocated to function as Special Function Registers (SFRs) of the 8051 microcontroller. Eleven of these SFRs are bit-addressable 15. Verilog does not support two-dimensional array in which any cell can be addressed. A word in Verilog memory can be addressed directly. A cell (bit) in a word is addressed by first loading the word onto a buffer and then addressing the bit of the word 17, 18. The Verilog code for bit read from bit addressable internal memory (20h- 2Fh) was accomplished as follows: The v8051_ram module performs the following tasks: Clears the memory when reset signal reset is asserted. Performs a synchronous read or write from / to the addressed memory location. If bit data is requested, reads or writes to the addressed bit number of the addressed memory location. Figure 4.3-1: Flow Diagram for RAM Module Figure 4.3-1: Flow Diagram for RAM Module Figure 4.3-2: Flow Diagram for RAM - Bit Manipulation Figure 4.3-3: Flow Diagram for RAM - Byte Read /Write图4.3-1:流量图的内存模块4.3.2. Simulation and Testing The input signals to the RAM module were defined in the vector waveform file. Clock frequency was set to 12 MHZ (standard 8051 clock specification) The RAM module was tested for the following simulated functions/ conditions: Reset. a)Test: While clock was continuously applied reset was asserted. Memory locations were then read to confirm response of the module. b)Observation: Refer to the waveforms in Figure 4.3-4. While reset is asserted out_data is seen to be held at last read memory value, indicating read and write operations were inhibited. For subsequent read pulses, out_data changed to contents of addressed RAM or SFR, at the positive edge of clock. Figure 4.3-4: Reset Asserted Result: During reset memory is initialized and all other operations are inhibited. The contents of RAM and Registers are reset to 00H Byte Read /write For byte read /write tests, reset was asserted for approx 10 cycles, is_bit_address and in_bit_data (the bit addressing signals) were forced lo (disabled), and address, in_data, read and write signals were varied to monitor the RAM module functions. a) Test: RAM Address incremented from 00H to 0DH, each address is held for 4 clock cycles. In-data lines count from A2H, incrementing by 01h and hold the data for 2 clock cycles. For each address write and then read was asserted. SFRs Addresses E0H (A-register), F0H (B-register), 80H (Port 0) and 81H (SP) sequentially asserted on address lines, and each address was held for 4 clock cycles. Write and then read signals pulsed for each addressed location. b) Observations: The waveforms in Figure 4.3-5, Figure 4.3-6 and Figure 4.3-8, show out-data holds the contents of addressed memory location and switches to corresponding in-data at the consecutive read pulse synchronously with positive edge of clock pulse. No switching on out_bit_data line iii) The timing simulation waveforms indicate the same functionality. Maximum achievable frequency during simulation is over 145MHz, refer to Figure 4.3-7. Bit Manipulation For bit read /write tests, a short reset was asserted, then input signals simulated as follows: a) Test RAM bit manipulation Address incremented from 20H to 2FH, each address is held for 2 clock cycles. in-data lines count from A2H, incrementing by 11h and hold the data for 4 clock cycles. is_bit_addr asserted in parallel with write and then with read signals. in_data line switched for serial data C3H, 67H. Figure 4.3-9: Bit Manipulation on RAM Locations 20H to 2FH SFR bit manipulation Address 90H (Port 1), D0H (PSW), E0H (A-register), and F0H (B-register), asserted on address lines, and each address was held for 4 clock cycles. in-data lines switched to E6H, 2AH, F7H, and F7H each held for 4 clocks, write asserted. Then, rd and is_bit_addr asserted to read the above registers. Figure 4.3-10: Bit Read from SFRs A-Register, B-Register, Port1, & PSW b) Observation Referring to Figure 4.3-9 and Figure 4.3-10 a)Waveforms show out-data holds contents of addressed memory location and switches to corresponding in-data at the consecutive read, only if is_bit_addr is not asserted. b)Switching on out_bit_data line occurs when is_bit_addr and read is true. c)Data as written to the addressed bit of the respective location during write was correctly read back. 4.3.3. Verification The simulation waveforms indicate that the module performs the functions of the internal memory (128 locations + registers) of the standard 8051. Correct addressing as well as bit and byte read / write, as per design, was observed. 4.4 External RAM The External RAM is just like the RAM module but has 16 address lines and can have a size of up to 64KB. This memory is external to the 8051 module. The controller can access the external memory for read or write of 8-bit data in response to a MOVX instruction from ROM. 4.5 Decoder The function of this module is to convert the op-code of the 8051 instruction, as read by the controller from program memory, to a pointer for the controller to implement the corresponding execution cycle for that instruction. The decoder also generates corresponding signals if the instruction requires additional operands. 4.5.1 Detailed Design The 8-bit op-code input from the controller is converted by checking against a look-up table defined in the opcodelookup.txt file and stored in the project directory. The output of the decoder is a 9-bit signal composed of 7-bit op-code pointer, bit 8 set if instruction requires 2nd operand, and bit 9 set if instruction requires a 3rd operand. 4.5.2 Simulation & Testing Functional simulation was carried out on the Decoder module by varying the input op-code signal at 10 ns for a period of 260ns. 2 types of addressing each for arithmetic and logical instructions were tested. Table 4.5-1 shows input conditions and expected results. Figure 4.5-1 shows the simulation waveforms correspond to the expected results. Table 4.5-1: Decoder Test - Instructions & Expected Results Figure 4.5-1: Simulation of 8051 Instruction Decoding (Verilog Model) Timing simulation for the same input conditions was carried out. Maximum input to output delay was approx. 18ns. Refer to Figure 4.5-2. Figure 4.5-2: WorstCase Delay in Timing Simulation of Decoder Functions 4.5.3 Verification The same tests were applied to the decoder module of the Dalton model. Quartus II “Compare waveform file” command was used to compare the simulation waveforms obtained from the Dalton module with that of the Verilog module. View of both sets of waveforms is shown in Figure 4.5-3. The waveforms from the simulation of both the modules are overlapped, indicating an exact match. Figure 4.5-3: Comparison Report of Simulation of 8051 Instruction Decoding (Dalton Model with Verilog model) 4.1.2 仿真和测试该控制器的FSM图显示,CPU_STATES和EXE_STATES被测序的设计。该控制器模块的功能是将控制信号同步向/从8051的其它组件。因此,控制器被整合所有模块后进行测试。一个测试程序, Test_r1 ,加载在ROM中, 12MHz时同步时钟启动和模块间的信号,在控制器CPU_STATEs EXE_STATEs进行了监测。当复位有效CS_0进入状态。控制器复位SFR在RAM中,即端口( P0到P1)到FFh和SP到07h ,通过测序直通的EXE_STATES ES_0直通ES_5 。图4.1-11所示CS_2的指示读取和解码周期。该控制器在指出由PC ,接口与ALU来执行PCUADD (程序计数器无符号地址)的地址读取ROM内容,并增加其本地PC注册;发送从ROM中读取指令译码器,解码器会返回一个9位解码运算的代码;控制器读取从ROM中的下一个位置,如果位7的解码运算代码设置,发送的值1的源操作数由ALU执行PCUADD ,并更新其本地PC寄存器; ;然后取ROM的内容所指向的PC寄存器,如果位8的解码运算代码设置发送一个源操作数的值1 ,否则为0到ALU的PCUADD 。已收集的数据的控制器更新PC和操作数指令执行周期。考虑到寄存器锁存延迟的控制器加载其寄存器与从ROM或RAM模块的数据在第三EXE_STATE相对于相应的“读”控制信号。图4.1-11:指令获取和解码过程中CS_2图4.1-12:执行周期CS_3的指令RLC 图4.1-12所示为指令执行周期为8051指令RLC A的细节(旋转A寄存器带进左)与下一条指令MOV P0 , A(移动的寄存器内容到输出端口P0 ) 。在这个例子中执行RLC的,在ES_0控制器使ALU通过发送控制变量alu_opcode ( “B”对应的RLC )和A寄存器的内容作为源操作数进行旋转操作。在ES - 1控制器加载数据线与RAM从ALU的结果,使 RAM写入“写入新的值到SFR A寄存器。来自ALU的进位也被存储在其内部寄存器中。在ES_2它发送的数据来更新PSW ,还对内存的SFR 。通的下一个状态的控制器序列ES_3到ES_6直到达到ES_7当执行由所有变量重置为ALU ,并跳转到CS_1和ES_0去取下一条指令完成。在这个例子中的下一个指令是MOV P0, A的波形图4.1-12表明,在取指周期解码器输出对应于MOV指令。在这个指令执行周期没有ALU操作。在ES_0时,A寄存器中的内容写入端口地址,同时在RAM的SFR 。旋转的数据值被认为是对的仿真波形PORT0出。4.1.3 验证仿真波形结果验证控制器模块是可操作的。4.2 只读存储器该ROM是程序存储器空间的8051微控制器的专用4KB 。它包含与将要执行的指令的二进制代码。 ROM模块作为输入的12位程序计数器PC ,并给出作为输出的8 - 指令操作码和操作数的位的数据。4.2.1 。详细设计Altera建议使用“参数化的ROM超级功能”来实现所有的ROM功能 。这个大型功能允许与时钟同步只读存储器选通的地址。在Quartus II 兆功能插件管理器“工具用于配置下列参数的LPM_ROM超级功能名为” v8051_rom_mem “实施8051罗”:内存大小4096字。字宽8位地址宽度12 - 位初始化文件 - 一个十六进制(Intel格式)存储在ROM中存储的程序代码文件。测试程序/应用程序写在8051汇编语言。组装测试运行已于8051模拟器验证。在Intel十六进制格式的程序代码被存储在模块目录中,然后被指定为加载的ROM在上电/复位数据文件。所述存储器地址在时钟上升沿被启用,需要3个时钟脉冲的保持时间为存储器的内容变为可用的数据线。因此在ROM模块需要两个时钟输入,一个快速时钟来读取ROM和较慢的1至与控制器的定时同步rom_data 。该ROM_module实例化的ROM大型功能v8051_rom_mem阅读说明书从控制器有效ROM_ADDR并将其锁定在rom_rd信号间隔出的数据寄存器。4.2.2 仿真与测试为了测试在ROM中的程序代码,该模块进行了模拟具有下列输入条件下,与数据线进行观察:时钟设置为12MHz 。阅读断言在6兆赫的频率。加1,从00H开始地址线。仿真进行为期5微秒。结果:参照文本文件“Test1_r1”下面的列表。数据线(参考图4.2-2)读取第一列下面是程序代码的值。75 /MOV_12 F0 12 74 / MOV_4 3A 7D 04 /MOV_7 33 /RLC F5 /MOV_8 80 C5 /XCH_2 F0 13 /RRC F5 /MOV_8 90 C5 /XCH_2 F0 DD /DJNZ_1 F4 80 /SJMP EB 00 /NOP 00 /NOP 图4.2-1:测试程序Test1_r1.txt的ROM内容 - 8051说明图4.2-2:模拟波形ROM的模块(Verilog的型号)4.2.3验证相同的仿真条件被应用到的ROM模块道尔顿模型。两个波形是相似的。图4.2-3 :模拟波形ROM的模块(道尔顿模型)4.3 内存8051有256字节的内部数据存储器(内部RAM ) 。内部RAM被分为2个部分:第一个128字节的块是通用RAM ,以及第二部分从地址80H开始,是在特殊功能寄存器(SFR)区域 15 。内存模块中定义的地址范围00h - 128字节的数组7FH和21个特殊功能寄存器(SFR )的地址空间80H - FFH内。4.3.1 详细设计8051的IP软核的内部数据存储器(RAM )的详细设计如图4.3-1 :流图的RAM 。该内存模块产生写一个128字节的数组(并行加载)和read(输出使能)内存(寄存器) 。地点20h到2Fh是位寻址。它还具有分配功能的8051微控制器作为特殊功能寄存器( SFR)的21个字节。这些SFR的十一个可位寻址 。Verilog的不支持的二维阵列,其中的任何细胞可以得到解决。用Verilog内存的一个字,可直接寻址。在一个字中的细胞(比特)是由第一加载字到一个缓冲器中,然后寻址单词17的位18解决。在Verilog代码位从位寻址内存( 20H -读2FH )中完成如下:begin add = 4b0010, addr 6:3;/ address hi_nibble= 2h, lo_nibble =addr 6:3 memword = iramadd; / get contents of addressed memory out_bit_data = memword cbit; / read bit value end 该v8051_ram模块执行以下任务:清除内存时,复位信号复位有效。执行同步读取或写入从/到寻址的存储器位置。如果位数据被请求时,读取或写入到寻址的存储器位置的寻址位数字。图4.3-2:流量图的内存 - 位操作图4.3-3:流量图的内存 - 字节读/写4.3.2 仿真和测试输入信号到RAM模块中的矢量波形文件中定义。时钟频率设置为12 MHz(标准8051时钟规范)内存模块进行了测试以下模拟功能/条件:复位测试:虽然时钟已连续施加复位是断言。存储器位置,然后读确认模块的响应。观察:参照图4.3-4的波形。当复位有效OUT_DATA都被看作是在最后一次读取的内存值举行,表明读取和写入操作被禁止。对于后续的读脉冲,OUT_DATA改为寻址RAM或SFR内容,在时钟的上升沿。图4.3-4:复位断言结
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 如何学建筑方案设计软件
- 楼房施工方案有哪些类型
- 咨询流程方案
- 美国建材营销方案设计
- 旧建筑修缮技术方案设计
- 网络营销合作方案书
- 广东钢结构住宅施工方案
- 预算管理实施咨询方案
- 家园2级建筑方案设计
- 咨询顾问能力评测方案
- 2025 ada糖尿病诊疗标准要点解读
- 中国人口研究专题报告-中国2025-2100年人口预测与政策建议
- 浙江首考2025年1月普通高等学校招生全国统考政治试题及答案
- 小学体育知识
- 企业安全生产标准化培训课件
- 心内科人文关怀护理
- 内部控制与风险管理(第3版)题库
- 医院培训课件:《预灌式抗凝剂皮下注射》
- 2025年中考语文备考之名著复习:《艾青诗选》题集组(答案)
- 2024年游泳初级指导员认证理论考试题库(浓缩500题)
- 新能源发电技术 电子课件 2.5 可控核聚变及其未来利用方式
评论
0/150
提交评论