WO2011109970A1 - Data stack memory circuit and microcontroller - Google Patents

Data stack memory circuit and microcontroller Download PDF

Info

Publication number
WO2011109970A1
WO2011109970A1 PCT/CN2010/074117 CN2010074117W WO2011109970A1 WO 2011109970 A1 WO2011109970 A1 WO 2011109970A1 CN 2010074117 W CN2010074117 W CN 2010074117W WO 2011109970 A1 WO2011109970 A1 WO 2011109970A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
stack
memory
bus
control
Prior art date
Application number
PCT/CN2010/074117
Other languages
French (fr)
Chinese (zh)
Inventor
史卫东
潘松
岳卫杰
Original Assignee
上海海尔集成电路有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 上海海尔集成电路有限公司 filed Critical 上海海尔集成电路有限公司
Publication of WO2011109970A1 publication Critical patent/WO2011109970A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0875Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches with dedicated cache, e.g. instruction or stack

Definitions

  • the present invention relates to the field of computer technologies, and in particular, to a data stack storage circuit and a microcontroller. Background technique
  • the stack push and pop operations are a data processing method that is widely used in microcontrollers.
  • the stack mainly includes the program stack and the data stack, wherein the program stack should be saved and restored to the current program address in almost all of the microcontrollers, when the main program jumps or interrupts. Since early low-end microcontrollers had to process relatively little data and the application architecture was relatively simple, the data stack was rarely involved.
  • FIG. 4 is a schematic diagram of a stack structure of a prior art low-end microcontroller.
  • the data stack of the hardware structure is rarely used, and the on-chip general-purpose data memory is mostly used as the hardware foundation, and the data stack is simulated by software. Operation. Specifically, a memory of an address space of the general-purpose data memory is used as a data stack; a general-purpose data memory or a register is used as a stack pointer, and the address of the current top of the stack is stored, and all the push and pop operations are performed through ordinary A memory transfer or arithmetic instruction is completed.
  • FIG. 5 is a schematic diagram of a stack structure in a prior art high-end microcontroller.
  • the data stack of the hardware structure is used as a separate data stack memory. Specifically, by setting a data stack read or write control bit included in the read or write control register, the read or write buffer register is temporarily operated on the data to be pushed onto the stack or the data read out of the stack; by a specific hardware register As a stack pointer, store the address of the current top of the stack for push or pop operations.
  • stacking and popping operations are inefficient because of the need to indirectly manipulate the data stack through read or write control registers and read or write buffer registers. Summary of the invention
  • the present invention provides a data stack storage circuit and a microcontroller for solving the problem of the existing microcontroller by indirectly indirectly operating the data stack through a read or write control register and a read or write buffer register. Defects that are not efficient with pop-up operations.
  • the present invention provides a data stack storage circuit including a data stack memory and a data stack control circuit; the data stack memory and the data stack control circuit are connected;
  • the data stack memory is coupled to the data bus
  • the data stack control circuit is connected to the control bus; And the data stack control circuit is configured to press the data of the data bus that has been ready to be pushed onto the top of the stack of the data stack memory according to the push operation signal in the control bus, or for controlling according to the control A pop operation signal in the bus ejects data ready for the stack from the top of the data stack memory to the data bus.
  • the present invention provides a microcontroller, including a controller, further comprising a data stack storage circuit; the controller is connected to a control bus, and the controller is configured to generate a first by analyzing an operation code of the push instruction Controlling the signal set and transmitting to the control bus; or for analyzing the opcode of the pop instruction to generate a second set of control signals and transmitting to the control bus;
  • the data stack storage circuit includes a data stack memory and a data stack control circuit; the data stack memory and the data stack control circuit are connected; the data stack memory is connected to the data bus; the data stack control circuit is connected to the control bus;
  • the data stack control circuit is configured to press the data of the data bus that has been ready to be pushed onto the top of the stack of the data stack memory according to the push operation signal in the first control signal set, or for The pop operation signal in the second control signal set pops the data ready for the stack from the top of the data stack memory to the data bus.
  • the data stack storage circuit and the microcontroller of the present invention by the data stack control circuit included in the data stack storage circuit, press the data ready for stacking in the data bus into the data stack memory according to the push operation signal in the control bus.
  • the top of the stack, or according to the pop operation signal in the controlled bus the technical solution that pops the data of the ready stack from the top of the stack of the data stack memory to the data bus, solves the need in the existing microcontroller
  • the indirect operation of the data stack by reading or writing the control register and the read or write buffer register, so that the stacking and popping operations are not efficient, and the stacking and popping operations are respectively implemented through respective correlations. Means For the purpose of completion, the complicated chip architecture of the read or write control register and the read or write buffer register is omitted, and the execution efficiency of stacking and popping the data stack is improved.
  • FIG. 1 is a schematic structural diagram of a data stack storage circuit of the present invention
  • Embodiment 1 of a microcontroller according to the present invention is a schematic structural diagram of Embodiment 1 of a microcontroller according to the present invention
  • Embodiment 2 of a microcontroller according to the present invention is a schematic structural diagram of Embodiment 2 of a microcontroller according to the present invention.
  • FIG. 4 is a schematic diagram of a stack structure of a prior art low-end microcontroller
  • FIG. 5 is a schematic diagram of a stack structure of a prior art high-end microcontroller. detailed description
  • FIG. 1 is a schematic structural diagram of a data stack storage circuit of the present invention.
  • the data stack storage circuit of this embodiment includes a data stack memory 101 and a data stack control circuit 102.
  • the data stack memory 101 is connected to a data stack control circuit 102, wherein the data stack memory 101 is connected to the data bus.
  • the data stack control circuit 102 is coupled to the control bus, and the data stack control circuit 102 includes a push control circuit module 1021 and a pop control circuit module 1022.
  • the data stack memory 101 is dedicated to store data, instead of storing the program address; and the data stack memory and the program protection stack and the general data register file are independent of each other, and the operation of the data stack memory 101 needs to pass the push instruction ( Can be identified as a PUSH instruction in the programming language) and a pop instruction (identified as a POP instruction in the programming language)
  • the data stack memory 101 is operated without the normal read and write operations of the controller.
  • the push control circuit module 1021 in the data stack control circuit 102 pushes the data ready for stacking in the data bus into the stack of the data stack memory 101 according to the push operation signal in the control bus.
  • the data ready to be pushed can be the data obtained by addressing 10 ports, the data to be protected in the interrupt operation, or the data obtained by addressing the data memory; during the pop operation, the data stack control
  • the pop control circuit module 1022 in the circuit 102 pops the data ready for the stack from the top of the stack of the data stack memory 101 into the data bus based on the pop operation signal in the control bus.
  • the data stack memory 101 can be a separate memory, or a partial memory space of a separate memory, or a combination of at least two independent memories, or at least one independent memory and at least one independent A combination of partial storage spaces of memory, or a combination of partial storage spaces in at least two separate memories.
  • the data stack storage circuit of this embodiment further includes a hardware stack pointer 103 connected to the control bus and the data stack memory 101, and the hardware stack pointer 103 is in the push control circuit module 1021 according to the control bus.
  • the push operation signal pushes the data ready for stacking in the data bus into the top of the stack of the data stack memory 101, it may add 1 by itself according to the hardware stack pointer in the control bus; or in the pop control
  • the circuit module 1022 pops the data of the ready stack from the top of the stack of the data stack memory 101 to the data bus according to the pop operation signal in the control bus
  • the circuit stack pointer can be decremented by 1 according to the hardware stack pointer in the control bus. Minus 1.
  • the data stack storage circuit of this embodiment further includes an overflow flag register 104, which is connected to the hardware stack pointer 103, and the overflow flag register 104 packet
  • the overflow flag bit 1041 and the underflow flag bit 1042 are included; during the push operation, the current hardware stack pointer 103 is compared with the upper limit value by a comparison circuit to monitor the state of the hardware stack pointer 103 when the hardware stack pointer When the 103 is incremented from the highest address and jumps back to the lowest address, the overflow flag 1041 is automatically set to 1, and the upper limit is the highest address of the data stack memory 101; during the pop operation, the current hardware is compared by the comparison circuit.
  • the stack pointer 103 is compared with the lower limit value to monitor the state of the hardware stack pointer 103.
  • the underflow flag bit 1042 is automatically set to 1, and the lower limit value is automatically set. Is the lowest address of the data stack memory 101.
  • the data stack storage circuit of the embodiment by the data stack control circuit, presses the data ready for stacking in the data bus into the top of the stack of the data stack memory according to the push operation signal in the control bus, or according to the controlled bus
  • the pop-up operation signal the technical solution for popping the data of the ready-to-stack data from the top of the stack of the data stack memory to the data bus, solves the problem that the existing microcontroller needs to pass the read or write control register and read or write.
  • the buffer register indirectly operates on the data stack, so that the stacking and popping operations are not efficient, and the push and pop operations are completed by the corresponding corresponding instructions, which saves the need. Read or write control registers and read or write buffer registers in a complex chip architecture form, and improve the efficiency of the stack and pop operations of the data stack.
  • the microcontroller of this embodiment includes a controller 201 and a data stack storage circuit 202, wherein the controller 201 is connected to a control bus, and the controller 201 includes a program memory, an instruction register, and an instruction decoder.
  • the control logic circuit; the data stack storage circuit 202 includes a data stack memory 101 and a data stack control circuit 102, the data stack memory 101 and the data stack control circuit 102 are connected, and the data stack memory 101 is connected to the data bus, the data stack control circuit 102 is coupled to the control bus, and the data stack control circuit 102 includes a push control circuit module 1021 and a pop control circuit Module 1022.
  • the data stack memory 101 is dedicated to store data, instead of storing the program address; and the data stack memory and the program protection stack and the general data register file are independent of each other, and the operation of the data stack memory 101 needs to pass the push instruction (
  • the program language can be identified as a PUSH instruction and the pop instruction (which can be identified as a POP instruction in the programming language), and the data stack memory 101 cannot be operated with normal read and write operations of the controller 201.
  • the data stack storage circuit 202 further includes a hardware stack pointer 103 and the overflow flag register 104, wherein the hardware stack pointer 103 is connected to the control bus and the data stack memory 101, and the overflow flag register 104 is connected to the hardware stack pointer 103 and overflows.
  • the flag register 104 includes an overflow flag bit 1041 and an underflow flag bit 1042;
  • the instruction register of the controller 201 reads the push instruction (which can be identified as a PUSH instruction in the programming language) from the program memory, and then includes the push instruction included in the instruction register by the instruction decoder.
  • the opcode is decoded to generate a first set of control signals, and is sent by the control logic to the associated module circuit via the control bus for control purposes.
  • the first set of control signals includes at least a push operation signal and a hardware stack pointer plus 1 signal; the push control circuit module 1021 in the data stack control circuit 102 pushes the data ready for stacking in the data bus into the top of the stack of the data stack memory 101 according to the push operation signal, wherein the stack is ready to be pushed
  • the data may be data obtained by addressing 10 ports, data to be protected in the interrupt operation, or data obtained by addressing the data memory; and, the hardware stack pointer 103 is pushed in the stack control circuit module 1021 according to the push operation signal
  • the hardware stack pointer plus 1 signal in the control bus adds 1 to itself and points to the new top of the stack.
  • the current hardware stack pointer 103 and the upper limit are compared by the comparison circuit. Compare to monitor the hardware stack pointer 103 State, when the hardware stack pointer 103 is incremented from the highest address and jumps back to the lowest address, the overflow flag bit 1041 is automatically set to 1, and the upper limit value is the highest address of the data stack memory 101.
  • the instruction register of the controller 201 reads the pop instruction from the program memory (which can be identified as a POP instruction in the programming language), and then includes the pop-up instruction in the instruction register by the instruction decoder.
  • the opcode is decoded to generate a second set of control signals, and is sent by the control logic to the associated module circuit via the control bus for control purposes.
  • the second set of control signals includes at least a pop operation signal and a hardware stack pointer minus 1 signal; the pop control circuit module 1022 in the data stack control circuit 102 pops the data of the ready stack from the top of the stack of the data stack memory 101 into the data bus according to the pop operation signal, and can be controlled by the second
  • the control signal control related circuit module in the signal set receives the data popped up to the data bus; and, the hardware stack pointer 103, at the pop control circuit module 1022, prepares the data of the ready stack from the data stack memory 101 according to the pop operation signal. After the top of the stack pops up to the data bus, it can be based on the hard in the control bus.
  • the stack pointer minus 1 signal is decremented by 1 and points to the new top of the stack.
  • the current hardware stack pointer 103 is compared to the lower limit by the comparison circuit to monitor the hardware stack.
  • the state of the pointer 103 when the hardware stack pointer 103 is decremented by one from the lowest address and jumps back to the highest address, the underflow flag 1042 is automatically set to 1, and the lower limit is the lowest address of the data stack memory 101.
  • the data stack memory 101 can be a separate memory, or a partial memory space of a separate memory, or a combination of at least two independent memories, or at least one independent memory and at least one independent A combination of partial storage spaces of memory, or a combination of partial storage spaces in at least two separate memories.
  • the microcontroller of this embodiment is controlled by a data stack included in the data stack storage circuit
  • the circuit presses the data ready for stacking in the data bus into the top of the stack of the data stack memory according to the push operation signal in the control bus, or according to the pop operation signal in the controlled bus, the ready stack is prepared.
  • the technical solution of data being ejected from the top of the data stack memory to the data bus solves the problem that the existing microcontroller needs to operate the data stack indirectly through the read or write control register and the read or write buffer register.
  • the disadvantages of inefficient stacking and popping operations are realized by the stacking and popping operations through the corresponding corresponding instructions, eliminating the need for read or write control registers and read or write buffer registers.
  • the chip architecture form, and improve the efficiency of the stack and pop operations of the data stack.
  • FIG. 3 is a schematic structural diagram of Embodiment 2 of a microcontroller according to the present invention.
  • the microcontroller of this embodiment further includes an address selector 203 and a data memory 204 based on the above embodiment, wherein the address selector 203 is connected to the controller 201, the address bus, and the control.
  • a data memory 204 is coupled to the control bus, the data bus, and the address bus;
  • the data of the address data memory 204 is mainly described, and the data is pushed into the stack operation of the data stack memory 101; and the data popped up in the data stack memory 101 is stored in the data memory 204. Pop-up operation process; specifically,
  • the instruction register of the controller 201 reads the push instruction (which can be identified as a PUSH instruction in the programming language) from the program memory, and then includes the push instruction included in the instruction register by the instruction decoder.
  • the opcode is decoded to generate a first set of control signals, and is sent by the control logic to the associated module circuit via the control bus for control purposes.
  • the first set of control signals includes a push operation signal, a hardware stack pointer plus one.
  • the operation signal decodes the first operand sent by the controller 201 to generate a first data memory address and sends it to the address bus; the data memory 204 is ready to press according to the read data memory signal and the first data memory address.
  • the data of the stack is written on the data bus; and the push control circuit module 1021 in the data stack control circuit 102 pushes the data ready for stacking in the data bus into the top of the stack of the data stack memory 101 according to the push operation signal.
  • the data that has been prepared to be pushed is the data obtained by addressing 10 ports; the hardware stack pointer 103 pushes the data of the data bus that is ready to be pushed onto the data stack according to the push operation signal in the push control circuit module 1021.
  • the comparison circuit After the top of the memory 101 is stacked, it can be incremented by 1 according to the hardware stack pointer in the control bus, and points to the new top of the stack; for each increment of the hardware stack pointer 103, the comparison circuit will The current hardware stack pointer 103 is compared to the upper limit value to monitor the state of the hardware stack pointer 103 when the hardware stack pointer 103 is the most An address by adding 1 to the lowest address jump back, automatic overflow flag bit 1041 is set, the upper limit value and the highest address of the data stack memory 101.
  • the instruction register of the controller 201 reads the pop instruction from the program memory (which can be identified as a POP instruction in the programming language), and then includes the pop-up instruction in the instruction register by the instruction decoder.
  • the opcode is decoded to generate a second set of control signals, and is sent by the control logic circuit to the associated module circuit through the control bus for control purposes.
  • the second set of control signals includes a pop operation signal, and the hardware stack pointer is decremented by one.
  • the stack control circuit module 1022 pops the data of the ready stack from the top of the stack of the data stack memory 101 into the data bus according to the pop operation signal; the address selector 203 decodes the operation signal according to the second address, and controls the controller
  • the second operand sent by 201 is decoded to generate a second data memory
  • the address is sent to the address bus; the data memory 204 reads the data of the popped stack from the data bus according to the write data memory signal and the second data memory address; the hardware stack pointer 103 is popped according to the popup control circuit module 1022.
  • the operation signal pops the data of the ready stack from the top of the stack of the data stack memory 101 to the data bus, it can be decremented by 1 according to the hardware stack pointer minus 1 signal, and points to the new stack top; for each of the hardware stack pointers 103
  • the action of subtracting 1 times compares the current hardware stack pointer 103 with the lower limit value by the comparison circuit to monitor the state of the hardware stack pointer 103.
  • the underflow flag bit 1042 is automatically set to 1, and the lower limit value is the lowest address of the data stack memory 101.
  • the data stack control circuit included in the data stack storage circuit presses the data ready for stacking in the data bus into the top of the stack of the data stack memory according to the push operation signal in the control bus. Or according to the pop operation signal in the controlled bus, the technical solution that pops the data of the ready stack from the top of the stack of the data stack memory to the data bus solves the problem that the existing microcontroller needs to pass the read or write.
  • the control register and the read or write buffer register indirectly operate on the data stack, so that the push and pop operations are not efficient, and the push and pop operations are completed by the respective corresponding instructions.
  • the purpose is to eliminate the complicated chip architecture of reading or writing control registers and reading or writing buffer registers, and improve the efficiency of performing stacking and popping operations on the data stack.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Executing Machine-Instructions (AREA)

Abstract

A data stack memory circuit and a microcontroller are provided, the data stack memory circuit comprises a data stack memory and a data stack control circuit; the data stack memory is connected with the data stack control circuit; the data stack memory is connected to a data bus; the data stack control circuit is connected to a control bus; and the data stack control circuit is used to, according to a push operation signal in the control bus, push the data prepared to be pushed in the data bus into the top of the data stack memory, or is used to, according to a pop operation signal in the control bus, pop the data prepared to be popped from the top of the data stack memory to the data bus. This invention realizes the object of implementing the push and pop operations through instructions, and improves the executive efficiency of the push and pop operations for data stack.

Description

数据堆栈存储电路及微控制器  Data stack storage circuit and microcontroller
技术领域 Technical field
本发明涉及计算机技术领域,尤其涉及一种数据堆栈存储电路及微控制器。 背景技术  The present invention relates to the field of computer technologies, and in particular, to a data stack storage circuit and a microcontroller. Background technique
堆栈的进栈与出栈操作作为一种数据处理方式, 在微控制器中被广泛 釆用。 堆栈主要包括程序堆栈和数据堆栈, 其中, 程序堆栈几乎应所有的 微控制器中,主要程序跳转或中断处理时,对当前程序地址的保存及恢复。 由于早期较为低端的微控制器需要处理的数据处理量相对较少, 而应用程 序结构又相对简单, 因此很少涉及到数据堆栈。 但随着微控制器的广泛应 用, 以及应用系统复杂度的提升, 使得数据处理量和应用程序结构的复杂 度增加, 特别是高级语言开发环境的使用, 要经常保存和恢复大量的函数 变量; 在这种情况下, 由于数据堆栈能够方便地实现大量数据的保护和恢 复, 因此, 越来越多的微控制器开始应用数据堆栈, 同时对数据堆栈操作 方式也在不断改进, 以提升保存和恢复大量的函数变量进行效率。  The stack push and pop operations are a data processing method that is widely used in microcontrollers. The stack mainly includes the program stack and the data stack, wherein the program stack should be saved and restored to the current program address in almost all of the microcontrollers, when the main program jumps or interrupts. Since early low-end microcontrollers had to process relatively little data and the application architecture was relatively simple, the data stack was rarely involved. However, with the wide application of microcontrollers and the complexity of application systems, the complexity of data processing and application structure increases, especially the use of high-level language development environments, and a large number of function variables are often saved and restored; In this case, since the data stack can easily protect and recover a large amount of data, more and more microcontrollers start to apply the data stack, and the data stack operation mode is also improved to improve the preservation and Restore a large number of function variables for efficiency.
图 4为现有技术的中低端微控制器的堆栈结构示意图。 如图 4所示, 在现 有技术中, 对于中低端微控制器, 很少釆用硬件结构的数据堆栈, 而多以片 内通用数据存储器作为硬件基础, 并通过软件的方式模拟数据堆栈的操作。 具体地, 将通用数据存储器的一段地址空间的存储器作为数据堆栈; 用某个 通用数据存储器或寄存器作为堆栈指针, 存储当前栈顶的地址, 并且所有的 进栈与出栈操作都是通过普通的存储器转移或运算指令来完成。 在这些中低 端微控制器中, 由于数据堆栈需占用通用数据存储器的部分数据空间, 很难 保证该数据堆栈中被保护的数据与该通用数据存储器其他数据的相对独立 性。 具体地, 在执行相关程序而调用该通用数据存储器的其他数据时, 艮有 可能会误操作数据堆栈中的内容,从而造成数据堆栈中所保护的数据被改写, 因此具有上述数据堆栈的低端微控制器构架形式存在数据安全性差的缺点。 4 is a schematic diagram of a stack structure of a prior art low-end microcontroller. As shown in FIG. 4, in the prior art, for the low-end and mid-range microcontrollers, the data stack of the hardware structure is rarely used, and the on-chip general-purpose data memory is mostly used as the hardware foundation, and the data stack is simulated by software. Operation. Specifically, a memory of an address space of the general-purpose data memory is used as a data stack; a general-purpose data memory or a register is used as a stack pointer, and the address of the current top of the stack is stored, and all the push and pop operations are performed through ordinary A memory transfer or arithmetic instruction is completed. In these low In the terminal microcontroller, since the data stack needs to occupy part of the data space of the general data memory, it is difficult to ensure the relative independence of the protected data in the data stack from other data in the general data memory. Specifically, when the related program is executed to call other data of the general data memory, it is possible to misinterpret the contents of the data stack, thereby causing the data protected in the data stack to be overwritten, thus having the low end of the data stack. The form of microcontroller architecture has the disadvantage of poor data security.
图 5为现有技术的中高端微控制器中的堆栈结构示意图。如图 5所示, 对于中高端微控制器, 则多釆用硬件结构的数据堆栈, 为独立的数据堆栈 存储器。 具体地, 通过设置读或写控制寄存器所包括的数据堆栈读或写控 制位,对读或写緩冲寄存器暂存准备进栈的数据或出栈读出的数据进行操 作; 由特定的硬件寄存器作为堆栈指针, 存储当前栈顶的地址, 以进行进 栈或出栈操作。 在这些中高端微控制器的数据堆栈相关构架中, 由于需通 过读或写控制寄存器和读或写緩冲寄存器间接地对数据堆栈进行操作, 而 使得进栈与出栈操作执行效率不高。 发明内容  FIG. 5 is a schematic diagram of a stack structure in a prior art high-end microcontroller. As shown in Figure 5, for mid- to high-end microcontrollers, the data stack of the hardware structure is used as a separate data stack memory. Specifically, by setting a data stack read or write control bit included in the read or write control register, the read or write buffer register is temporarily operated on the data to be pushed onto the stack or the data read out of the stack; by a specific hardware register As a stack pointer, store the address of the current top of the stack for push or pop operations. In the data stack-related architecture of these mid- to high-end microcontrollers, stacking and popping operations are inefficient because of the need to indirectly manipulate the data stack through read or write control registers and read or write buffer registers. Summary of the invention
本发明提供一种数据堆栈存储电路及微控制器, 用以解决现有微控制 器中由于需通过读或写控制寄存器和读或写緩冲寄存器间接地对数据堆 栈进行操作, 而使得进栈与出栈操作执行效率不高的缺陷。  The present invention provides a data stack storage circuit and a microcontroller for solving the problem of the existing microcontroller by indirectly indirectly operating the data stack through a read or write control register and a read or write buffer register. Defects that are not efficient with pop-up operations.
本发明提供一种数据堆栈存储电路, 其中, 包括数据堆栈存储器和数 据堆栈控制电路; 所述数据堆栈存储器和数据堆栈控制电路相连接;  The present invention provides a data stack storage circuit including a data stack memory and a data stack control circuit; the data stack memory and the data stack control circuit are connected;
所述数据堆栈存储器连接于数据总线;  The data stack memory is coupled to the data bus;
所述数据堆栈控制电路连接于控制总线; 且数据堆栈控制电路用于根据所述控制总线中的进栈操作信号, 将所 述数据总线中已准备好压栈的数据压入所述数据堆栈存储器的栈顶, 或者 用于根据所述控制总线中的出栈操作信号, 将已准备好弹栈的数据从所述 数据堆栈存储器的栈顶弹出至所述数据总线中。 The data stack control circuit is connected to the control bus; And the data stack control circuit is configured to press the data of the data bus that has been ready to be pushed onto the top of the stack of the data stack memory according to the push operation signal in the control bus, or for controlling according to the control A pop operation signal in the bus ejects data ready for the stack from the top of the data stack memory to the data bus.
本发明提供一种微控制器, 包括控制器, 其中, 还包括数据堆栈存储电路; 所述控制器连接于控制总线 , 且所述控制器用于通过分析进栈指令的操 作码, 以生成第一控制信号集合并发送至所述控制总线; 或者, 用于通过分 析出栈指令的操作码, 以生成第二控制信号集合并发送至所述控制总线; 所述数据堆栈存储电路包括数据堆栈存储器和数据堆栈控制电路; 所 述数据堆栈存储器和数据堆栈控制电路相连接; 所述数据堆栈存储器连接 于数据总线; 所述数据堆栈控制电路连接于所述控制总线;  The present invention provides a microcontroller, including a controller, further comprising a data stack storage circuit; the controller is connected to a control bus, and the controller is configured to generate a first by analyzing an operation code of the push instruction Controlling the signal set and transmitting to the control bus; or for analyzing the opcode of the pop instruction to generate a second set of control signals and transmitting to the control bus; the data stack storage circuit includes a data stack memory and a data stack control circuit; the data stack memory and the data stack control circuit are connected; the data stack memory is connected to the data bus; the data stack control circuit is connected to the control bus;
且数据堆栈控制电路用于根据所述第一控制信号集合中的进栈操作 信号, 将所述数据总线中已准备好压栈的数据压入所述数据堆栈存储器的 栈顶, 或者用于根据所述第二控制信号集合中的出栈操作信号, 将已准备 好弹栈的数据从所述数据堆栈存储器的栈顶弹出至所述数据总线中。  And the data stack control circuit is configured to press the data of the data bus that has been ready to be pushed onto the top of the stack of the data stack memory according to the push operation signal in the first control signal set, or for The pop operation signal in the second control signal set pops the data ready for the stack from the top of the data stack memory to the data bus.
本发明的数据堆栈存储电路及微控制器, 通过数据堆栈存储电路所包 括的数据堆栈控制电路根据控制总线中的进栈操作信号, 将数据总线中已 准备好压栈的数据压入数据堆栈存储器的栈顶, 或者根据所控制总线中的 出栈操作信号, 将已准备好弹栈的数据从数据堆栈存储器的栈顶弹出至数 据总线中的技术方案, 解决了现有微控制器中由于需通过读或写控制寄存 器和读或写緩冲寄存器间接地对数据堆栈进行操作, 而使得进栈与出栈操 作执行效率不高的缺陷, 实现了进栈和出栈操作通过各自所对应的相关指 令即可完成的目的, 省去了读或写控制寄存器及读或写緩冲寄存器复杂的 芯片构架形式, 且提高了对数据堆栈进行进栈与出栈操作的执行效率。 附图说明 The data stack storage circuit and the microcontroller of the present invention, by the data stack control circuit included in the data stack storage circuit, press the data ready for stacking in the data bus into the data stack memory according to the push operation signal in the control bus. The top of the stack, or according to the pop operation signal in the controlled bus, the technical solution that pops the data of the ready stack from the top of the stack of the data stack memory to the data bus, solves the need in the existing microcontroller The indirect operation of the data stack by reading or writing the control register and the read or write buffer register, so that the stacking and popping operations are not efficient, and the stacking and popping operations are respectively implemented through respective correlations. Means For the purpose of completion, the complicated chip architecture of the read or write control register and the read or write buffer register is omitted, and the execution efficiency of stacking and popping the data stack is improved. DRAWINGS
图 1为本发明数据堆栈存储电路的结构示意图;  1 is a schematic structural diagram of a data stack storage circuit of the present invention;
图 2为本发明微控制器实施例一的结构示意图;  2 is a schematic structural diagram of Embodiment 1 of a microcontroller according to the present invention;
图 3为本发明微控制器实施例二的结构示意图;  3 is a schematic structural diagram of Embodiment 2 of a microcontroller according to the present invention;
图 4为现有技术的中低端微控制器的堆栈结构示意图;  4 is a schematic diagram of a stack structure of a prior art low-end microcontroller;
图 5为现有技术的中高端微控制器的堆栈结构示意图。 具体实施方式  FIG. 5 is a schematic diagram of a stack structure of a prior art high-end microcontroller. detailed description
为使本发明的目的、 技术方案和优点更加清楚, 下面将结合本发明中 的附图, 对本发明的技术方案进行描述。  In order to make the objects, technical solutions and advantages of the present invention more clear, the technical solutions of the present invention will be described below in conjunction with the drawings in the present invention.
图 1为本发明数据堆栈存储电路的结构示意图。 如图 1所示, 本实施 例的数据堆栈存储电路包括数据堆栈存储器 101 和数据堆栈控制电路 102, 该数据堆栈存储器 101和数据堆栈控制电路 102相连接, 其中, 数 据堆栈存储器 101连接于数据总线, 数据堆栈控制电路 102连接于控制总 线, 且数据堆栈控制电路 102包括进栈控制电路模块 1021和出栈控制电 路模块 1022。 其中, 数据堆栈存储器 101是专用来存放数据, 而不是存放 程序地址的; 且数据堆栈存储器与程序保护栈、 通用数据寄存器堆是相互 独立的, 对数据堆栈存储器 101的操作需通过进栈指令(在程序语言中可 标识为 PUSH指令) 和出栈指令(在程序语言中可标识为 POP指令) 来 进行,而不能用控制器的普通读写操作来对数据堆栈存储器 101进行操作。 在进栈操作的过程中, 数据堆栈控制电路 102 中的进栈控制电路模块 1021根据控制总线中的进栈操作信号, 将数据总线中已准备好压栈的数据压 入数据堆栈存储器 101的栈顶,其中已准备好压栈的数据可以为寻址 10口而 获得的数据、中断操作中所需保护的数据或者寻址数据存储器而获得的数据; 在出栈操作的过程中, 数据堆栈控制电路 102中的出栈控制电路模块 1022根据控制总线中的出栈操作信号,将已准备好弹栈的数据从数据堆栈 存储器 101的栈顶弹出至数据总线中。 FIG. 1 is a schematic structural diagram of a data stack storage circuit of the present invention. As shown in FIG. 1, the data stack storage circuit of this embodiment includes a data stack memory 101 and a data stack control circuit 102. The data stack memory 101 is connected to a data stack control circuit 102, wherein the data stack memory 101 is connected to the data bus. The data stack control circuit 102 is coupled to the control bus, and the data stack control circuit 102 includes a push control circuit module 1021 and a pop control circuit module 1022. The data stack memory 101 is dedicated to store data, instead of storing the program address; and the data stack memory and the program protection stack and the general data register file are independent of each other, and the operation of the data stack memory 101 needs to pass the push instruction ( Can be identified as a PUSH instruction in the programming language) and a pop instruction (identified as a POP instruction in the programming language) The data stack memory 101 is operated without the normal read and write operations of the controller. During the push operation, the push control circuit module 1021 in the data stack control circuit 102 pushes the data ready for stacking in the data bus into the stack of the data stack memory 101 according to the push operation signal in the control bus. Top, where the data ready to be pushed can be the data obtained by addressing 10 ports, the data to be protected in the interrupt operation, or the data obtained by addressing the data memory; during the pop operation, the data stack control The pop control circuit module 1022 in the circuit 102 pops the data ready for the stack from the top of the stack of the data stack memory 101 into the data bus based on the pop operation signal in the control bus.
在实际应用中, 数据堆栈存储器 101可为一个独立的存储器, 或者为 一个独立的存储器的部分存储空间, 或者为至少两个独立的存储器的组 合, 或者为至少一个独立的存储器和至少一个独立的存储器的部分存储空 间的组合, 或者为至少两个独立的存储器中部分存储空间的组合。  In practical applications, the data stack memory 101 can be a separate memory, or a partial memory space of a separate memory, or a combination of at least two independent memories, or at least one independent memory and at least one independent A combination of partial storage spaces of memory, or a combination of partial storage spaces in at least two separate memories.
进一步地, 本实施例的数据堆栈存储电路还包括硬件堆栈指针 103 , 该 硬件堆栈指针 103连接于控制总线和数据堆栈存储器 101 , 且硬件堆栈指针 103在进栈控制电路模块 1021根据控制总线中的进栈操作信号将数据总线 中已准备好压栈的数据压入数据堆栈存储器 101的栈顶后, 可根据所述控 制总线中的硬件堆栈指针加 1信号而自行加 1 ; 或者在出栈控制电路模块 1022 根据控制总线中的出栈操作信号将已准备好弹栈的数据从数据堆栈 存储器 101 的栈顶弹出至数据总线后, 可根据所述控制总线中的硬件堆栈 指针减 1信号而自行减 1。  Further, the data stack storage circuit of this embodiment further includes a hardware stack pointer 103 connected to the control bus and the data stack memory 101, and the hardware stack pointer 103 is in the push control circuit module 1021 according to the control bus. After the push operation signal pushes the data ready for stacking in the data bus into the top of the stack of the data stack memory 101, it may add 1 by itself according to the hardware stack pointer in the control bus; or in the pop control After the circuit module 1022 pops the data of the ready stack from the top of the stack of the data stack memory 101 to the data bus according to the pop operation signal in the control bus, the circuit stack pointer can be decremented by 1 according to the hardware stack pointer in the control bus. Minus 1.
再进一步地, 本实施例的数据堆栈存储电路还包括溢出标志寄存器 104, 该溢出标志寄存器 104连接于硬件堆栈指针 103 , 且该溢出标志寄存器 104包 括上溢标志位 1041和下溢标志位 1042; 在进栈操作过程中, 通过比较电路将 当前的硬件堆栈指针 103与上限值进行比较以监测硬件堆栈指针 103的状态, 当该硬件堆栈指针 103从最高地址加 1 而跳回最低地址时, 上溢标志位 1041 自动置 1 ,且该上限值为数据堆栈存储器 101的最高地址;在出栈操作过程中, 通过比较电路将当前的硬件堆栈指针 103 与下限值进行比较以监测硬件堆栈 指针 103的状态, 当该硬件堆栈指针 103从最低地址减 1而跳回最高地址时, 下溢标志位 1042自动置 1 , 且该下限值为数据堆栈存储器 101的最低地址。 Still further, the data stack storage circuit of this embodiment further includes an overflow flag register 104, which is connected to the hardware stack pointer 103, and the overflow flag register 104 packet The overflow flag bit 1041 and the underflow flag bit 1042 are included; during the push operation, the current hardware stack pointer 103 is compared with the upper limit value by a comparison circuit to monitor the state of the hardware stack pointer 103 when the hardware stack pointer When the 103 is incremented from the highest address and jumps back to the lowest address, the overflow flag 1041 is automatically set to 1, and the upper limit is the highest address of the data stack memory 101; during the pop operation, the current hardware is compared by the comparison circuit. The stack pointer 103 is compared with the lower limit value to monitor the state of the hardware stack pointer 103. When the hardware stack pointer 103 is decremented from the lowest address by one and jumps back to the highest address, the underflow flag bit 1042 is automatically set to 1, and the lower limit value is automatically set. Is the lowest address of the data stack memory 101.
本实施例的数据堆栈存储电路,通过数据堆栈控制电路根据控制总线中的 进栈操作信号, 将数据总线中已准备好压栈的数据压入数据堆栈存储器的栈 顶, 或者根据所控制总线中的出栈操作信号, 将已准备好弹栈的数据从数据堆 栈存储器的栈顶弹出至数据总线中的技术方案,解决了现有微控制器中由于需 通过读或写控制寄存器和读或写緩冲寄存器间接地对数据堆栈进行操作,而使 得进栈与出栈操作执行效率不高的缺陷,实现了进栈和出栈操作通过各自所对 应的相关指令即可完成的目的,省去了读或写控制寄存器及读或写緩冲寄存器 复杂的芯片构架形式, 且提高了对数据堆栈进行进栈与出栈操作的执行效率。  The data stack storage circuit of the embodiment, by the data stack control circuit, presses the data ready for stacking in the data bus into the top of the stack of the data stack memory according to the push operation signal in the control bus, or according to the controlled bus The pop-up operation signal, the technical solution for popping the data of the ready-to-stack data from the top of the stack of the data stack memory to the data bus, solves the problem that the existing microcontroller needs to pass the read or write control register and read or write. The buffer register indirectly operates on the data stack, so that the stacking and popping operations are not efficient, and the push and pop operations are completed by the corresponding corresponding instructions, which saves the need. Read or write control registers and read or write buffer registers in a complex chip architecture form, and improve the efficiency of the stack and pop operations of the data stack.
图 2为本发明敖控制器实施例一的结构示意图。 如图 2所示, 本实施例 的微控制器包括控制器 201 和数据堆栈存储电路 202, 其中, 该控制器 201 连接于控制总线, 且控制器 201 包括程序存储器、 指令寄存器、 指令译码器 和控制逻辑电路; 数据堆栈存储电路 202包括数据堆栈存储器 101和数据堆 栈控制电路 102, 该数据堆栈存储器 101和数据堆栈控制电路 102相连接, 且数据堆栈存储器 101连接于数据总线, 数据堆栈控制电路 102连接于控制 总线,且数据堆栈控制电路 102包括进栈控制电路模块 1021和出栈控制电路 模块 1022。 其中, 数据堆栈存储器 101是专用来存放数据, 而不是存放程序 地址的; 且数据堆栈存储器与程序保护栈、 通用数据寄存器堆是相互独立的, 对数据堆栈存储器 101的操作需通过进栈指令 (在程序语言中可标识为 PUSH 指令)和出栈指令(在程序语言中可标识为 POP指令)来进行, 而不能用控 制器 201的普通读写操作来对数据堆栈存储器 101进行操作。 2 is a schematic structural view of Embodiment 1 of the cymbal controller of the present invention. As shown in FIG. 2, the microcontroller of this embodiment includes a controller 201 and a data stack storage circuit 202, wherein the controller 201 is connected to a control bus, and the controller 201 includes a program memory, an instruction register, and an instruction decoder. And the control logic circuit; the data stack storage circuit 202 includes a data stack memory 101 and a data stack control circuit 102, the data stack memory 101 and the data stack control circuit 102 are connected, and the data stack memory 101 is connected to the data bus, the data stack control circuit 102 is coupled to the control bus, and the data stack control circuit 102 includes a push control circuit module 1021 and a pop control circuit Module 1022. The data stack memory 101 is dedicated to store data, instead of storing the program address; and the data stack memory and the program protection stack and the general data register file are independent of each other, and the operation of the data stack memory 101 needs to pass the push instruction ( The program language can be identified as a PUSH instruction and the pop instruction (which can be identified as a POP instruction in the programming language), and the data stack memory 101 cannot be operated with normal read and write operations of the controller 201.
进一步地, 数据堆栈存储电路 202还包括硬件堆栈指针 103和该溢出 标志寄存器 104, 其中硬件堆栈指针 103连接于控制总线和数据堆栈存储器 101 , 该溢出标志寄存器 104连接于硬件堆栈指针 103 , 且溢出标志寄存器 104包括上溢标志位 1041和下溢标志位 1042;  Further, the data stack storage circuit 202 further includes a hardware stack pointer 103 and the overflow flag register 104, wherein the hardware stack pointer 103 is connected to the control bus and the data stack memory 101, and the overflow flag register 104 is connected to the hardware stack pointer 103 and overflows. The flag register 104 includes an overflow flag bit 1041 and an underflow flag bit 1042;
在进栈操作过程中, 控制器 201 的指令寄存器从程序存储器读取的进栈 指令(在程序语言中可标识为 PUSH指令) , 然后通过指令译码器对指令寄 存器中进栈指令所包括的操作码进行译码以生成第一控制信号集合, 并由控 制逻辑电路通过控制总线发送到相关的模块电路以达到控制的目的, 该第一 控制信号集合至少包括进栈操作信号和硬件堆栈指针加 1信号; 数据堆栈控 制电路 102中的进栈控制电路模块 1021根据该进栈操作信号,将数据总线中 已准备好压栈的数据压入数据堆栈存储器 101的栈顶, 其中已准备好压栈的 数据可以为寻址 10口而获得的数据、中断操作中所需保护的数据或者寻址数 据存储器而获得的数据; 并且, 硬件堆栈指针 103在进栈控制电路模块 1021 根据进栈操作信号将数据总线中已准备好压栈的数据压入数据堆栈存储器 101的栈顶后, 可根据所述控制总线中的硬件堆栈指针加 1信号自行加 1 , 而 指向新的栈顶; 对于硬件堆栈指针 103的每次加 1的动作, 都通过比较电路 将当前的硬件堆栈指针 103与上限值进行比较以监测硬件堆栈指针 103的状 态, 当该硬件堆栈指针 103从最高地址加 1 而跳回最低地址时, 上溢标志位 1041 自动置 1 , 且该上限值为数据堆栈存储器 101的最高地址。 During the push operation, the instruction register of the controller 201 reads the push instruction (which can be identified as a PUSH instruction in the programming language) from the program memory, and then includes the push instruction included in the instruction register by the instruction decoder. The opcode is decoded to generate a first set of control signals, and is sent by the control logic to the associated module circuit via the control bus for control purposes. The first set of control signals includes at least a push operation signal and a hardware stack pointer plus 1 signal; the push control circuit module 1021 in the data stack control circuit 102 pushes the data ready for stacking in the data bus into the top of the stack of the data stack memory 101 according to the push operation signal, wherein the stack is ready to be pushed The data may be data obtained by addressing 10 ports, data to be protected in the interrupt operation, or data obtained by addressing the data memory; and, the hardware stack pointer 103 is pushed in the stack control circuit module 1021 according to the push operation signal After the data in the data bus ready to be pushed onto the top of the stack of the data stack memory 101, The hardware stack pointer plus 1 signal in the control bus adds 1 to itself and points to the new top of the stack. For each action of the hardware stack pointer 103, the current hardware stack pointer 103 and the upper limit are compared by the comparison circuit. Compare to monitor the hardware stack pointer 103 State, when the hardware stack pointer 103 is incremented from the highest address and jumps back to the lowest address, the overflow flag bit 1041 is automatically set to 1, and the upper limit value is the highest address of the data stack memory 101.
在出栈操作过程中, 控制器 201的指令寄存器从程序存储器读取的出 栈指令(在程序语言中可标识为 POP指令), 然后通过指令译码器对指令 寄存器中出栈指令所包括的操作码进行译码以生成第二控制信号集合, 并 由控制逻辑电路通过控制总线发送到相关的模块电路以达到控制的目的, 该第二控制信号集合至少包括出栈操作信号和硬件堆栈指针减 1信号; 数 据堆栈控制电路 102中的出栈控制电路模块 1022根据该出栈操作信号, 将已准备好弹栈的数据从数据堆栈存储器 101的栈顶弹出至数据总线中, 并可由第二控制信号集合中的控制信号控制相关电路模块接收该弹出至 数据总线的数据; 并且, 硬件堆栈指针 103在出栈控制电路模块 1022根据 出栈操作信号将已准备好弹栈的数据从数据堆栈存储器 101的栈顶弹出至 数据总线后, 可根据控制总线中的硬件堆栈指针减 1信号自行减 1 , 而指 向新的栈顶; 对于硬件堆栈指针 103的每次减 1的动作, 都通过比较电路将 当前的硬件堆栈指针 103与下限值进行比较以监测硬件堆栈指针 103的状态, 当该硬件堆栈指针 103从最低地址减 1 而跳回最高地址时, 下溢标志位 1042 自动置 1 , 且该下限值为数据堆栈存储器 101的最低地址。  During the pop operation, the instruction register of the controller 201 reads the pop instruction from the program memory (which can be identified as a POP instruction in the programming language), and then includes the pop-up instruction in the instruction register by the instruction decoder. The opcode is decoded to generate a second set of control signals, and is sent by the control logic to the associated module circuit via the control bus for control purposes. The second set of control signals includes at least a pop operation signal and a hardware stack pointer minus 1 signal; the pop control circuit module 1022 in the data stack control circuit 102 pops the data of the ready stack from the top of the stack of the data stack memory 101 into the data bus according to the pop operation signal, and can be controlled by the second The control signal control related circuit module in the signal set receives the data popped up to the data bus; and, the hardware stack pointer 103, at the pop control circuit module 1022, prepares the data of the ready stack from the data stack memory 101 according to the pop operation signal. After the top of the stack pops up to the data bus, it can be based on the hard in the control bus. The stack pointer minus 1 signal is decremented by 1 and points to the new top of the stack. For each action of the hardware stack pointer 103 minus 1, the current hardware stack pointer 103 is compared to the lower limit by the comparison circuit to monitor the hardware stack. The state of the pointer 103, when the hardware stack pointer 103 is decremented by one from the lowest address and jumps back to the highest address, the underflow flag 1042 is automatically set to 1, and the lower limit is the lowest address of the data stack memory 101.
在实际应用中, 数据堆栈存储器 101可为一个独立的存储器, 或者为 一个独立的存储器的部分存储空间, 或者为至少两个独立的存储器的组 合, 或者为至少一个独立的存储器和至少一个独立的存储器的部分存储空 间的组合, 或者为至少两个独立的存储器中部分存储空间的组合。  In practical applications, the data stack memory 101 can be a separate memory, or a partial memory space of a separate memory, or a combination of at least two independent memories, or at least one independent memory and at least one independent A combination of partial storage spaces of memory, or a combination of partial storage spaces in at least two separate memories.
本实施例的微控制器, 通过数据堆栈存储电路所包括的数据堆栈控制 电路根据控制总线中的进栈操作信号, 将数据总线中已准备好压栈的数据 压入数据堆栈存储器的栈顶, 或者根据所控制总线中的出栈操作信号, 将 已准备好弹栈的数据从数据堆栈存储器的栈顶弹出至数据总线中的技术 方案, 解决了现有微控制器中由于需通过读或写控制寄存器和读或写緩冲 寄存器间接地对数据堆栈进行操作, 而使得进栈与出栈操作执行效率不高 的缺陷, 实现了进栈和出栈操作通过各自所对应的相关指令即可完成的目 的, 省去了读或写控制寄存器及读或写緩冲寄存器复杂的芯片构架形式, 且提高了对数据堆栈进行进栈与出栈操作的执行效率。 The microcontroller of this embodiment is controlled by a data stack included in the data stack storage circuit The circuit presses the data ready for stacking in the data bus into the top of the stack of the data stack memory according to the push operation signal in the control bus, or according to the pop operation signal in the controlled bus, the ready stack is prepared. The technical solution of data being ejected from the top of the data stack memory to the data bus solves the problem that the existing microcontroller needs to operate the data stack indirectly through the read or write control register and the read or write buffer register. The disadvantages of inefficient stacking and popping operations are realized by the stacking and popping operations through the corresponding corresponding instructions, eliminating the need for read or write control registers and read or write buffer registers. The chip architecture form, and improve the efficiency of the stack and pop operations of the data stack.
图 3为本发明微控制器实施例二的结构示意图。结合图 2和图 3所示, 本实施例的微控制器在上述实施例的基础上还包括地址选择器 203和数据 存储器 204, 其中, 地址选择器 203连接于控制器 201、 地址总线和控制 总线; 数据存储器 204连接于控制总线、 数据总线和地址总线;  FIG. 3 is a schematic structural diagram of Embodiment 2 of a microcontroller according to the present invention. As shown in FIG. 2 and FIG. 3, the microcontroller of this embodiment further includes an address selector 203 and a data memory 204 based on the above embodiment, wherein the address selector 203 is connected to the controller 201, the address bus, and the control. a data memory 204 is coupled to the control bus, the data bus, and the address bus;
在本实施例中主要描述寻址数据存储器 204的数据, 并将该数据压入 数据堆栈存储器 101的进栈操作过程; 以及描述将数据堆栈存储器 101中 弹出的数据, 保存至数据存储器 204中的出栈操作过程; 具体地,  In the present embodiment, the data of the address data memory 204 is mainly described, and the data is pushed into the stack operation of the data stack memory 101; and the data popped up in the data stack memory 101 is stored in the data memory 204. Pop-up operation process; specifically,
在进栈操作过程中, 控制器 201 的指令寄存器从程序存储器读取的进栈 指令(在程序语言中可标识为 PUSH指令) , 然后通过指令译码器对指令寄 存器中进栈指令所包括的操作码进行译码以生成第一控制信号集合, 并由控 制逻辑电路通过控制总线发送到相关的模块电路以达到控制的目的, 该第一 控制信号集合包括进栈操作信号、 硬件堆栈指针加 1信号、 第一地址译码操 作信号和读数据存储器信号, 并且控制器 201的指令译码器将进栈指令所包 括的第一操作数发送给地址选择器 203; 地址选择器 203根据第一地址译码 操作信号, 对控制器 201所发送的第一操作数进行译码, 以生成第一数据存 储器地址并发送至地址总线上; 数据存储器 204根据读数据存储器信号和第 一数据存储器地址, 将准备压栈的数据写入数据总线上; 且数据堆栈控制电 路 102中的进栈控制电路模块 1021根据进栈操作信号,将数据总线中已准备 好压栈的数据压入数据堆栈存储器 101的栈顶, 其中已准备好压栈的数据为 寻址 10口而获得的数据; 硬件堆栈指针 103则在进栈控制电路模块 1021根 据进栈操作信号将数据总线中已准备好压栈的数据压入数据堆栈存储器 101 的栈顶后, 可根据所述控制总线中的硬件堆栈指针加 1信号自行加 1 , 而指 向新的栈顶; 对于硬件堆栈指针 103的每次加 1的动作, 都通过比较电路将 当前的硬件堆栈指针 103与上限值进行比较以监测硬件堆栈指针 103的状态, 当该硬件堆栈指针 103从最高地址加 1而跳回最低地址时, 上溢标志位 1041 自动置 1 , 且该上限值为数据堆栈存储器 101的最高地址。 During the push operation, the instruction register of the controller 201 reads the push instruction (which can be identified as a PUSH instruction in the programming language) from the program memory, and then includes the push instruction included in the instruction register by the instruction decoder. The opcode is decoded to generate a first set of control signals, and is sent by the control logic to the associated module circuit via the control bus for control purposes. The first set of control signals includes a push operation signal, a hardware stack pointer plus one. a signal, a first address decode operation signal, and a read data memory signal, and the instruction decoder of the controller 201 transmits the first operand included in the push instruction to the address selector 203; the address selector 203 is based on the first address Decoding The operation signal decodes the first operand sent by the controller 201 to generate a first data memory address and sends it to the address bus; the data memory 204 is ready to press according to the read data memory signal and the first data memory address. The data of the stack is written on the data bus; and the push control circuit module 1021 in the data stack control circuit 102 pushes the data ready for stacking in the data bus into the top of the stack of the data stack memory 101 according to the push operation signal. The data that has been prepared to be pushed is the data obtained by addressing 10 ports; the hardware stack pointer 103 pushes the data of the data bus that is ready to be pushed onto the data stack according to the push operation signal in the push control circuit module 1021. After the top of the memory 101 is stacked, it can be incremented by 1 according to the hardware stack pointer in the control bus, and points to the new top of the stack; for each increment of the hardware stack pointer 103, the comparison circuit will The current hardware stack pointer 103 is compared to the upper limit value to monitor the state of the hardware stack pointer 103 when the hardware stack pointer 103 is the most An address by adding 1 to the lowest address jump back, automatic overflow flag bit 1041 is set, the upper limit value and the highest address of the data stack memory 101.
在出栈操作过程中, 控制器 201 的指令寄存器从程序存储器读取的出栈 指令(在程序语言中可标识为 POP指令) , 然后通过指令译码器对指令寄存 器中出栈指令所包括的操作码进行译码以生成第二控制信号集合, 并由控制 逻辑电路通过控制总线发送到相关的模块电路以达到控制的目的, 该第二控 制信号集合包括出栈操作信号、 硬件堆栈指针减 1信号、 第二地址译码操作 信号和写数据存储器信号, 并且控制器 201 的指令译码器将进栈指令所包括 的第二操作数发送给地址选择器 203; 数据堆栈控制电路 102 中的出栈控制 电路模块 1022根据该出栈操作信号,将已准备好弹栈的数据从数据堆栈存储 器 101的栈顶弹出至数据总线中; 地址选择器 203根据第二地址译码操作信 号, 对控制器 201所发送的第二操作数进行译码, 以生成第二数据存储器地 址并发送至地址总线上; 数据存储器 204根据写数据存储器信号和第二数据 存储器地址, 从数据总线上读入已弹出栈的数据; 硬件堆栈指针 103则在出 栈控制电路模块 1022根据出栈操作信号将已准备好弹栈的数据从数据堆栈 存储器 101的栈顶弹出至数据总线后, 可根据硬件堆栈指针减 1信号自行减 1 , 而指向新的栈顶; 对于硬件堆栈指针 103的每次减 1的动作, 都通过比较 电路将当前的硬件堆栈指针 103与下限值进行比较以监测硬件堆栈指针 103 的状态, 当该硬件堆栈指针 103从最低地址减 1 而跳回最高地址时, 下溢标 志位 1042自动置 1 , 且该下限值为数据堆栈存储器 101的最低地址。 During the pop operation, the instruction register of the controller 201 reads the pop instruction from the program memory (which can be identified as a POP instruction in the programming language), and then includes the pop-up instruction in the instruction register by the instruction decoder. The opcode is decoded to generate a second set of control signals, and is sent by the control logic circuit to the associated module circuit through the control bus for control purposes. The second set of control signals includes a pop operation signal, and the hardware stack pointer is decremented by one. a signal, a second address decode operation signal, and a write data memory signal, and the instruction decoder of the controller 201 sends the second operand included in the push instruction to the address selector 203; the output in the data stack control circuit 102 The stack control circuit module 1022 pops the data of the ready stack from the top of the stack of the data stack memory 101 into the data bus according to the pop operation signal; the address selector 203 decodes the operation signal according to the second address, and controls the controller The second operand sent by 201 is decoded to generate a second data memory The address is sent to the address bus; the data memory 204 reads the data of the popped stack from the data bus according to the write data memory signal and the second data memory address; the hardware stack pointer 103 is popped according to the popup control circuit module 1022. After the operation signal pops the data of the ready stack from the top of the stack of the data stack memory 101 to the data bus, it can be decremented by 1 according to the hardware stack pointer minus 1 signal, and points to the new stack top; for each of the hardware stack pointers 103 The action of subtracting 1 times compares the current hardware stack pointer 103 with the lower limit value by the comparison circuit to monitor the state of the hardware stack pointer 103. When the hardware stack pointer 103 is decremented from the lowest address by 1 and jumps back to the highest address, The underflow flag bit 1042 is automatically set to 1, and the lower limit value is the lowest address of the data stack memory 101.
本实施例的微控制器, 通过数据堆栈存储电路所包括的数据堆栈控制 电路根据控制总线中的进栈操作信号, 将数据总线中已准备好压栈的数据 压入数据堆栈存储器的栈顶, 或者根据所控制总线中的出栈操作信号, 将 已准备好弹栈的数据从数据堆栈存储器的栈顶弹出至数据总线中的技术 方案, 解决了现有微控制器中由于需通过读或写控制寄存器和读或写緩冲 寄存器间接地对数据堆栈进行操作, 而使得进栈与出栈操作执行效率不高 的缺陷, 实现了进栈和出栈操作通过各自所对应的相关指令即可完成的目 的, 省去了读或写控制寄存器及读或写緩冲寄存器复杂的芯片构架形式, 且提高了对数据堆栈进行进栈与出栈操作的执行效率。  In the microcontroller of the embodiment, the data stack control circuit included in the data stack storage circuit presses the data ready for stacking in the data bus into the top of the stack of the data stack memory according to the push operation signal in the control bus. Or according to the pop operation signal in the controlled bus, the technical solution that pops the data of the ready stack from the top of the stack of the data stack memory to the data bus solves the problem that the existing microcontroller needs to pass the read or write. The control register and the read or write buffer register indirectly operate on the data stack, so that the push and pop operations are not efficient, and the push and pop operations are completed by the respective corresponding instructions. The purpose is to eliminate the complicated chip architecture of reading or writing control registers and reading or writing buffer registers, and improve the efficiency of performing stacking and popping operations on the data stack.
最后应说明的是: 以上实施例仅用以说明本发明的技术方案, 而非对 其限制; 尽管参照前述实施例对本发明进行了详细的说明, 本领域的普通 技术人员应当理解: 其依然可以对前述各实施例所记载的技术方案进行修 改, 或者对其中部分技术特征进行等同替换; 而这些修改或者替换, 并不 使相应技术方案的本质脱离本发明各实施例技术方案的精神和范围。  It should be noted that the above embodiments are only for explaining the technical solutions of the present invention, and are not intended to be limiting; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those skilled in the art that: The technical solutions described in the foregoing embodiments are modified, or some of the technical features are equivalently replaced. The modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

权 利 要 求 Rights request
1、 一种数据堆栈存储电路, 其特征在于, 包括数据堆栈存储器和数 据堆栈控制电路; 所述数据堆栈存储器和数据堆栈控制电路相连接; 所述数据堆栈存储器连接于数据总线;  A data stack storage circuit, comprising: a data stack memory and a data stack control circuit; the data stack memory and the data stack control circuit are connected; the data stack memory is connected to the data bus;
所述数据堆栈控制电路连接于控制总线;  The data stack control circuit is connected to the control bus;
且数据堆栈控制电路用于根据所述控制总线中的进栈操作信号, 将所 述数据总线中已准备好压栈的数据压入所述数据堆栈存储器的栈顶, 或者 用于根据所述控制总线中的出栈操作信号, 将已准备好弹栈的数据从所述 数据堆栈存储器的栈顶弹出至所述数据总线中。  And the data stack control circuit is configured to press the data of the data bus that has been ready to be pushed onto the top of the stack of the data stack memory according to the push operation signal in the control bus, or for controlling according to the control A pop operation signal in the bus ejects data ready for the stack from the top of the data stack memory to the data bus.
2、 根据权利要求 1 所述的数据堆栈存储电路, 其特征在于, 所述数 据堆栈存储器为一个独立的存储器, 或者为一个独立的存储器的部分存储 空间, 或者为至少两个独立的存储器的组合, 或者为至少一个独立的存储 器和至少一个独立的存储器的部分存储空间的组合, 或者为至少两个独立 的存储器中部分存储空间的组合。  2. The data stack storage circuit according to claim 1, wherein the data stack memory is a separate memory, or is a partial memory of a separate memory, or a combination of at least two independent memories. Or a combination of at least one independent memory and a partial storage space of at least one independent memory, or a combination of partial storage spaces in at least two independent memories.
3、 根据权利要求 1 所述的数据堆栈存储电路, 其特征在于, 所述数 据堆栈控制电路包括进栈控制电路模块和出栈控制电路模块;  3. The data stack storage circuit according to claim 1, wherein the data stack control circuit comprises a push control circuit module and a pop control circuit module;
所述进栈控制电路模块用于根据所述控制总线中的进栈操作信号, 将 所述数据总线中已准备好压栈的数据压入所述数据堆栈存储器的栈顶; 所述出栈控制电路模块用于根据所述控制总线中的出栈操作信号 , 将已 准备好弹栈的数据从所述数据堆栈存储器的栈顶弹出至所述数据总线中。  The push control circuit module is configured to press data ready for stacking in the data bus into a top of the stack of the data stack memory according to a push operation signal in the control bus; The circuit module is configured to pop the data of the prepared stack from the top of the stack of the data stack memory to the data bus according to the pop operation signal in the control bus.
4、 根据权利要求 1所述的数据堆栈存储电路, 其特征在于, 还包括硬件 堆栈指针, 所述硬件堆栈指针连接于所述控制总线和所述数据堆栈存储器; 所述硬件堆栈指针用于在所述数据总线中已准备好压栈的数据被压入 所述数据堆栈存储器的栈顶后, 根据所述控制总线中的硬件堆栈指针加 1 信号而自行加 1 ; 或者在已准备好弹栈的数据从所述数据堆栈存储器的栈 顶弹出至所述数据总线后, 根据所述控制总线中的硬件堆栈指针减 1 信号 而自行减 1。 4. The data stack storage circuit of claim 1, further comprising a hardware stack pointer, the hardware stack pointer being coupled to the control bus and the data stack memory; The hardware stack pointer is used to add 1 according to the hardware stack pointer plus 1 signal in the control bus after the data ready for stacking in the data bus is pushed onto the top of the stack of the data stack memory. Or, after the data ready to be bounced is popped from the top of the data stack memory to the data bus, the data is decremented by one according to the hardware stack pointer minus one signal in the control bus.
5、 根据权利要求 4所述的数据堆栈存储电路, 其特征在于, 还包括 溢出标志寄存器, 所述溢出标志寄存器连接于所述硬件堆栈指针,且所述溢 出标志寄存器包括上溢标志位和下溢标志位。  5. The data stack storage circuit of claim 4, further comprising an overflow flag register, the overflow flag register being coupled to the hardware stack pointer, and the overflow flag register including an overflow flag bit and a lower Overflow flag.
6、一种微控制器, 包括控制器, 其特征在于,还包括数据堆栈存储电路; 所述控制器连接于控制总线, 且所述控制器用于通过分析进栈指令的操 作码, 以生成第一控制信号集合并发送至所述控制总线; 或者, 用于通过分 析出栈指令的操作码, 以生成第二控制信号集合并发送至所述控制总线; 所述数据堆栈存储电路包括数据堆栈存储器和数据堆栈控制电路; 所 述数据堆栈存储器和数据堆栈控制电路相连接; 所述数据堆栈存储器连接 于数据总线; 所述数据堆栈控制电路连接于所述控制总线;  6. A microcontroller, comprising: a controller, further comprising: a data stack storage circuit; the controller is coupled to the control bus, and the controller is configured to analyze the operation code of the push instruction to generate a a control signal set and sent to the control bus; or, for analyzing an opcode of the pop instruction to generate a second control signal set and transmitting to the control bus; the data stack storage circuit including a data stack memory And a data stack control circuit; the data stack memory and the data stack control circuit are connected; the data stack memory is connected to the data bus; the data stack control circuit is connected to the control bus;
且数据堆栈控制电路用于根据所述第一控制信号集合中的进栈操作 信号, 将所述数据总线中已准备好压栈的数据压入所述数据堆栈存储器的 栈顶, 或者用于根据所述第二控制信号集合中的出栈操作信号, 将已准备 好弹栈的数据从所述数据堆栈存储器的栈顶弹出至所述数据总线中。  And the data stack control circuit is configured to press the data of the data bus that has been ready to be pushed onto the top of the stack of the data stack memory according to the push operation signal in the first control signal set, or for The pop operation signal in the second control signal set pops the data ready for the stack from the top of the data stack memory to the data bus.
7、 根据权利要求 6所述的微控制器, 其特征在于, 还包括地址选择 器, 所述地址选择器连接于所述控制器、 所述地址总线和所述控制总线; 所述地址选择器用于根据所述第一控制信号集合中的第一地址译码 操作信号, 对所述控制器所发送的进栈指令中的第一操作数进行译码, 以 生成第一数据存储器地址并发送至所述地址总线上; 7. The microcontroller according to claim 6, further comprising an address selector, said address selector being connected to said controller, said address bus and said control bus; said address selector Decoding according to the first address in the first set of control signals An operation signal, decoding a first operand in the push instruction sent by the controller to generate a first data memory address and transmitting the address to the address bus;
或者用于根据所述第二控制信号集合中的第二地址译码操作信号, 对 所述控制器所发送的出栈指令中的第二操作数进行译码, 以生成第二数据 存储器地址并发送至所述地址总线上。  Or for decoding, according to the second address decoding operation signal in the second control signal set, a second operand in the pop instruction sent by the controller to generate a second data memory address and Sent to the address bus.
8、 根据权利要求 7所述的微控制器, 其特征在于, 还包括数据存储 器,所述数据存储器连接于所述控制总线、所述数据总线和所述地址总线; 所述数据存储器用于根据所述第一控制信号集合中的读数据存储器 信号和第一数据存储器地址, 将准备压栈的数据写入所述数据总线上; 或者用于根据所述第二控制信号集合中的写数据存储器信号和第二 数据存储器地址, 从所述数据总线上读入已弹出栈的数据。  8. The microcontroller of claim 7, further comprising a data memory coupled to the control bus, the data bus, and the address bus; the data memory being configured to Reading data memory signals and first data memory addresses in the first control signal set, writing data to be pushed onto the data bus; or for writing data memory according to the second control signal set The signal and the second data memory address read data from the popped stack from the data bus.
9、 根据权利要求 6所述的微控制器, 其特征在于, 所述数据堆栈控 制电路包括进栈控制电路模块和出栈控制电路模块;  The microcontroller according to claim 6, wherein the data stack control circuit comprises a push control circuit module and a pop control circuit module;
所述进栈控制电路模块用于根据所述第一控制信号集合中的进栈操 作信号, 将所述数据总线中已准备好压栈的数据压入所述数据堆栈存储器 的栈顶;  The push control circuit module is configured to press data ready for stacking in the data bus into a top of the stack of the data stack memory according to a push operation signal in the first control signal set;
所述出栈控制电路模块用于根据所述第二控制信号集合中的出栈操 作信号, 将已准备好弹栈的数据从所述数据堆栈存储器的栈顶弹出至所述 数据总线中。  The pop-up control circuit module is configured to pop the data of the ready-to-bounce stack from the top of the stack of the data stack memory to the data bus according to the pop-up operation signal in the second set of control signals.
10、 根据权利要求 6所述的微控制器, 其特征在于, 还包括硬件堆栈 指针, 所述硬件堆栈指针连接于所述控制总线和所述数据堆栈存储器;  10. The microcontroller of claim 6, further comprising a hardware stack pointer, the hardware stack pointer being coupled to the control bus and the data stack memory;
所述硬件堆栈指针用于在所述数据总线中已准备好压栈的数据被压入 所述数据堆栈存储器的栈顶后, 根据所述控制总线中的硬件堆栈指针加 1 信号而自行加 1 ; 或者在已准备好弹栈的数据从所述数据堆栈存储器的栈 顶弹出至所述数据总线后, 根据所述控制总线中的硬件堆栈指针减 1 信号 而自行减 1。 The hardware stack pointer is used to push data that is ready to be pushed in the data bus After the top of the data stack memory is stacked, 1 is added according to the hardware stack pointer in the control bus plus 1 signal; or the data of the ready stack is popped from the top of the data stack memory to the After the data bus, it is decremented by one according to the hardware stack pointer minus 1 signal in the control bus.
11、 根据权利要求 10 所述的微控制器, 其特征在于, 还包括溢出标 志寄存器, 所述溢出标志寄存器连接于所述硬件堆栈指针, 且所述溢出标志 寄存器包括上溢标志位和下溢标志位。  11. The microcontroller of claim 10, further comprising an overflow flag register, the overflow flag register being coupled to the hardware stack pointer, and the overflow flag register including an overflow flag bit and an underflow Sign bit.
12、 根据权利要求 6所述的微控制器, 其特征在于, 所述数据堆栈存 储器为一个独立的存储器, 或者为一个独立的存储器的部分存储空间, 或 者为至少两个独立的存储器的组合, 或者为至少一个独立的存储器和至少 一个独立的存储器的部分存储空间的组合, 或者为至少两个独立的存储器 中部分存储空间的组合。  12. The microcontroller according to claim 6, wherein the data stack memory is a separate memory, or is a partial memory space of a separate memory, or a combination of at least two independent memories. Either a combination of at least one independent memory and at least one independent memory, or a combination of at least two separate memory locations.
PCT/CN2010/074117 2010-03-10 2010-06-21 Data stack memory circuit and microcontroller WO2011109970A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN 201010123197 CN102193868B (en) 2010-03-10 2010-03-10 Data stack storage circuit and microcontroller
CN201010123197.X 2010-03-10

Publications (1)

Publication Number Publication Date
WO2011109970A1 true WO2011109970A1 (en) 2011-09-15

Family

ID=44562808

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2010/074117 WO2011109970A1 (en) 2010-03-10 2010-06-21 Data stack memory circuit and microcontroller

Country Status (2)

Country Link
CN (1) CN102193868B (en)
WO (1) WO2011109970A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115080122A (en) * 2022-07-22 2022-09-20 飞腾信息技术有限公司 Processor, device, method and chip for saving and restoring context data

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20010028576A (en) * 1999-09-22 2001-04-06 강동구 Stacking package of memory by rerouting of data line
CN1701384A (en) * 2002-09-24 2005-11-23 桑迪士克股份有限公司 Highly compact non-volatile memory and method therefor with internal serial buses
CN101114236A (en) * 2007-09-18 2008-01-30 苏州市华芯微电子有限公司 B grade stacking device and data stack pushing and out-stack method

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US3786432A (en) * 1972-06-20 1974-01-15 Honeywell Inf Systems Push-pop memory stack having reach down mode and improved means for processing double-word items
DE19640316A1 (en) * 1996-09-30 1998-04-02 Siemens Ag Circuit arrangement with a microprocessor and a stack
JP2006309508A (en) * 2005-04-28 2006-11-09 Oki Electric Ind Co Ltd Stack control device and method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20010028576A (en) * 1999-09-22 2001-04-06 강동구 Stacking package of memory by rerouting of data line
CN1701384A (en) * 2002-09-24 2005-11-23 桑迪士克股份有限公司 Highly compact non-volatile memory and method therefor with internal serial buses
CN101114236A (en) * 2007-09-18 2008-01-30 苏州市华芯微电子有限公司 B grade stacking device and data stack pushing and out-stack method

Also Published As

Publication number Publication date
CN102193868B (en) 2013-06-19
CN102193868A (en) 2011-09-21

Similar Documents

Publication Publication Date Title
US7310726B2 (en) Booting from non-linear memory
JP4986431B2 (en) Processor
TWI808869B (en) Hardware processor and processor
US6647488B1 (en) Processor
JP5441918B2 (en) RISC processor unit and method for simulating floating point stack operations
CN114003365A (en) Fast interrupt system for RISC-V architecture
CN111625328B (en) Interrupt device, system and method suitable for RISC-V architecture
WO2011109970A1 (en) Data stack memory circuit and microcontroller
CN111782269A (en) Interrupt processing method and interrupt processing equipment
JPH0683615A (en) Computer for executing instruction set emulation
WO2013128624A1 (en) Microcomputer and non-volatile semiconductor device
KR20140135796A (en) Microcontroller with context switch
US20050278506A1 (en) Controller having decoding means
US9983932B2 (en) Pipeline processor and an equal model compensator method and apparatus to store the processing result
TWI444021B (en) Method for decrypting serial transmission signal
US8255672B2 (en) Single instruction decode circuit for decoding instruction from memory and instructions from an instruction generation circuit
CN2669241Y (en) Control circuit capable of reforming cipher coprocessor
US20130013820A1 (en) Method for initializing registers of peripherals in a microcontroller
JPH0934795A (en) Copy protection method for cpu program
TW202416123A (en) Hardware processor and processor
US20050262331A1 (en) Controller and method for processing instructions
JP2000298589A (en) Microprocessor
JP5993687B2 (en) One chip processor
JP2011150636A (en) Microprocessor and control method thereof
JP2009048322A (en) Interface module and semiconductor integrated circuit

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 10847228

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 10847228

Country of ref document: EP

Kind code of ref document: A1