WO2020155545A1 - Programmable gpio device and time sequence implementation method based on the device - Google Patents

Programmable gpio device and time sequence implementation method based on the device Download PDF

Info

Publication number
WO2020155545A1
WO2020155545A1 PCT/CN2019/093652 CN2019093652W WO2020155545A1 WO 2020155545 A1 WO2020155545 A1 WO 2020155545A1 CN 2019093652 W CN2019093652 W CN 2019093652W WO 2020155545 A1 WO2020155545 A1 WO 2020155545A1
Authority
WO
WIPO (PCT)
Prior art keywords
state
decoding
state machine
data
instruction
Prior art date
Application number
PCT/CN2019/093652
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 WO2020155545A1 publication Critical patent/WO2020155545A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms

Definitions

  • the invention relates to a programmable gpio device and a time sequence realization method based on the device, and belongs to the technical field of memory.
  • Each GPIO port can be configured as input or output by software, that is, the corresponding pin is controlled through the configuration register to realize interaction with peripherals. Because of the overhead of the CPU executing software code and the delay of data transfer within the chip including the system bus, the software cannot accurately control the transition time of the level on the GPIO pin and the timing relationship between the pins, so GPIO does not support high-speed interface protocols and then Can not realize data interaction with complex peripherals.
  • the present invention aims to extract the common characteristics of the timing of various interface protocols, and use hardware to implement programming of gpio according to timing waveforms to support various interface protocols.
  • This device classifies interface signals into clocks, control signals, and data signals; classifies the timing status as idle, control output, control input, data read in, data write out, condition trigger waiting, and control and data concurrent status, etc.;
  • This design has a set of instructions and uses a three-stage pipeline to ensure the accuracy of the interface timing.
  • the CPU configuration registers, built-in command SRAM, and data FIFO realize different interface applications.
  • the technical problem to be solved by the present invention is to provide a programmable gpio device and a time sequence implementation method based on the device, which can be programmed by the user and configured by the CPU. It has the characteristics of fast and flexible and does not require CPU intervention during operation. Only communicate with the kernel through some CPU signs and terminals.
  • a programmable gpio device including a CMD module, for storing instructions from software configuration
  • Mode register and default level register determines the input and output settings of each port of CTL. As the input CTL port, if its input level is inconsistent with the level of the corresponding bit in the default level register, all signals on the interface remain unchanged Until the two are consistent, the subsequent sequence evolution can be continued according to the command entry in the CMD and SRAM;
  • Read/write FIFO used to store data read from peripherals or data written to peripherals on DATA port
  • Pipeline control module includes an instruction fetching state machine, a decoding state machine, and an execution state machine.
  • the three state machines are responsible for extracting instructions from the command SRAM, parsing the extracted instructions, and executing the parsed instructions;
  • the interface with peripherals includes three types: PCLK, CTL, and DATA.
  • PCLK is output from the controller to the peripherals.
  • CTL and DATA are bidirectional ports.
  • bit[31:29] is the data control symbol
  • bit31 is the data valid control bit, when it is 1, it means that the current DATA interface is valid, and when it is 0, it means only The CTL interface is valid
  • bit30 is the read and write control bit, which indicates the read and write operations of the DATA interface. When it is 1, the DATA interface is output, and when it is 0, DATA is input. When bit31 is 1, this bit is valid; bit29 indicates whether the DATA cycle is multi-shot , When bit31 is valid and bit29 is 0, it means that only one-beat data is read and written in the current command.
  • bit29 When bit29 is 1, it means that multi-beat data transmission is performed, and the number of data transmissions and the actual command cycle number Consistent; bit[20:16] represents the command direction and the number of pclk cycles when the command is output. When it is 0, it means that the value on the CTL line configured as input needs to wait for it to become the corresponding bit in the default level register Execute the next command after the values are the same. At this time, if bit31 is valid, only one-shot data reading and writing operations are performed when bit29 is 0, and multi-shot operations are performed when bit29 is 1, that is, each pclk cycle of the waiting process is performed Read and write operations until the input becomes the default value;
  • the level signal of the CTL port in each PCLK cycle is determined by the currently executed CMD SRAM entry and the mode and level register.
  • the level signal of the DATA port is determined by the current executed CMD SRAM entries and mode and level registers, as well as writing data on the FIFO or the level of connected peripherals are jointly determined.
  • the input and output settings of each CTL port are determined by the mode register.
  • the output CTL port its output level is determined by The corresponding bit in [12:0] of the corresponding command entry in CMD SRAM is determined; as the input CTL port, its input level needs to be consistent with the level of the corresponding bit in the default level register to indicate that the command is completed, DATA port Whether it is valid and the input and output settings when it is valid are determined by the [31:30] bits of the CMD SRAM entry.
  • the DATA port is used as an output, data is ejected from the WR FIFO, and when it is used as an input, the data is pushed into the RDFIFO.
  • the state of the fetching state machine includes idle, first fetching, second fetching, normal fetching, trigger waiting, execution feedback, and the state of the decoding and executing state machine includes idle, control output, control input, Data read in, data write out, condition trigger waiting, control output and data read and write, control input and data write out, the states of the three state machines can jump in pairs with each other.
  • the next state of the decoding state machine depends on the analysis of the instructions output by the current state of the instruction fetching state machine.
  • the next state of the execution state machine depends on the current state of the decoding state machine.
  • the instruction fetching state machine is controlled by the mode and the default level register. The information and the execution feedback of the instructions determine whether to perform a state jump, so that the interface timing of the execution phase is completely consistent with the description in the instruction queue.
  • control signal CTL is 13 bits
  • width of the data signal DATA is configurable, and its width must be consistent with the bit width of the internal FIFO.
  • the invention also discloses a time sequence realization method based on the above programmable gpio device, which includes the following steps:
  • the instruction fetching state machine jumps to the state of fetching the second instruction, and at the same time, the decoding state machine jumps to the decoding timing state according to the decoding information;
  • the instruction fetching state machine jumps to the normal instruction fetching state.
  • the decoding state machine jumps to the second decoding timing state according to the information of the decoded second instruction, and the execution state machine Jump from the idle state to the previous decoding state;
  • the decoding information obtained from the decoding state determines the PCLK cycle required to execute the previous decoding state that the state machine jumps in step S03, and then the instruction fetching state machine enters the normal instruction fetching state from the waiting state, and the decoding state machine is based on the decoded state.
  • the information of the third instruction jumps to the third decoding timing state, and the execution state machine jumps from the decoding state jumped in step S03 to the previous decoding state;
  • the decoding information obtained from the decoding state determines the PCLK cycle required to execute the previous decoding state that the state machine jumped in step S04, and then the instruction fetching state machine enters the normal instruction fetching state from the waiting state, and the decoding state machine is based on the decoded
  • the information of the fourth instruction jumps to the fourth decoding timing state, and the execution state machine jumps from the decoding state jumped in step S04 to the previous decoding state;
  • step S07 Because the previous decoding state of the execution state machine jumped in step S06 needs to wait for a certain input signal on the CTL interface to be consistent with the corresponding bit of the mode register, the specific waiting time depends on the peripheral. After the two are consistent, fetch the instruction The state machine enters the idle state, the decoding state machine jumps to the fifth decoding timing state according to the information of the decoded fifth instruction, and the execution state machine jumps from the decoding state jumped in step S06 to the previous decoding state;
  • the decoding information obtained from the decoding state determines the PCLK cycle required for the previous decoding state that the execution state machine jumps in step S07, after which the decoding state machine enters the idle state, and the execution state machine jumps from the decoding state jumped in step S07 Go to the previous decoding state;
  • the decoding information obtained from the decoding state determines the PCLK cycle required for the previous decoding state to which the execution state machine jumps in step S08, and then the execution state machine enters the idle state.
  • step S03 the decoding timing state that the decoding state machine jumps to is the data writing state
  • step S04 the second decoding timing state that the decoding state machine jumps to is the data reading state
  • the execution state machine jumps The previous decoding state to be transferred is the data writing state.
  • step S05 the third decoding timing state of the decoding state machine jump is the waiting state, and the previous decoding state of the execution state machine jump is the data reading state.
  • step S06 the fourth decoding timing state where the decoding state machine jumps is the control output state
  • the last decoding state that executes the state machine jump is the waiting state
  • step S07 the fifth decoding timing state where the decoding state machine jumps It is the control input state
  • the last decoding state that executes the state machine jump is the control output state
  • step S08 the last decode state that executes the state machine jump is the control input state.
  • the traditional GPIO can only set the pin as input or output, and set the pin to a fixed level value or a high resistance state, and cannot realize complex timing control of the pin.
  • This design is actually a multi-function peripheral storage interface controller, which can be programmed by the user, and carries out large-scale pin configuration through the CPU, which is fast and flexible. And no CPU intervention is needed during operation, and only some CPU signs and interrupts are used to communicate with the kernel.
  • the flexible interface it enables can be used as a master device in an industrial standard or dedicated interface, and both parallel and serial interfaces can be implemented.
  • Figure 1 is a schematic block diagram of a programmable gpio device
  • Figure 2 is a schematic diagram of the pipeline when three state machines are running
  • Figure 3 is a schematic diagram of a mode control register
  • Figure 4 is a schematic diagram of the default level register
  • Figure 5 is a schematic diagram of the CPU configuration settings for CMD_SRAM.
  • This embodiment discloses a programmable gpio device, as shown in FIG. 1, including:
  • CMD module used to store instructions from software configuration
  • the mode register (represented as Mode Register in Figure 1) and the default level register (represented as Level Register in Figure 1) have a bit width of 13 bits. As shown in Figures 3 and 4, the mode register determines each port of the CTL Input and output settings, as the input CTL port, when the input level is inconsistent with the level of the corresponding bit in the default level register, all the signals on the interface remain unchanged until the two are consistent, and the subsequent commands in CMD SRAM can be continued. Timing evolution
  • Read/write FIFO used to store data read from peripherals or data written to peripherals on DATA port
  • the pipeline control module includes a fetch state machine (Fetch), a decoding state machine (Decode), and an execution state machine (Execute).
  • the three state machines are respectively responsible for extracting instructions from the command SRAM and parsing The extracted instructions and the parsed instructions;
  • the interface with peripherals includes three types: PCLK, CTL, and DATA.
  • PCLK is output from the controller to the peripherals.
  • CTL and DATA are bidirectional ports.
  • the width of the control signal CTL is 13 bits, and the width of the data signal DATA is configurable, and its width must be consistent with the bit width of the internal FIFO.
  • bit31 (DATA_VALID) is the data valid control bit, when it is 1, it means that the current DATA interface is valid , When it is 0, it means that only the CTL interface is valid; bit30 (RW) is the read and write control bit, which means the read and write operation of the DATA interface. When it is 1, the DATA interface is output, and when it is 0, DATA is input. When bit31 is 1, this bit is only Valid; bit29 (DATA_LENGTH) indicates whether the DATA cycle is multi-beat. When DATA_VALID is valid and bit29 is 0, it means that only one-beat data is read and written in the current command. When DATA_LENGTH is 1, it means multi-beat data transmission. And the number of data transmission is the same as the cycle number of the actual command, which is the value in [20:16].
  • bit[20:16](Command cycle counter) represents the command direction and the number of pclk cycles when the command is output. When it is 0, it means that the value on the CTL line configured as input needs to wait for the value to be changed to the default level register After the values of the corresponding bits are consistent, execute the next command. At this time, if DATA_VALID is valid, only one beat of data read and write operations will be performed when DATA_LENGTH is 0 (this operation is performed at the beat when the control line becomes the default value). At 1 o'clock, multi-shot operation is performed, that is, each pclk cycle of the waiting process performs read and write operations until the input becomes the default value.
  • the level signal of the CTL port in each PCLK cycle is determined by the currently executed CMD SRAM entry and the mode and level register, and the level signal of the DATA port is determined by the current execution
  • the received CMD SRAM entry, the mode and level register, and the data written on the FIFO or the level of the connected peripheral are jointly determined.
  • the input and output settings of each CTL port are determined by the mode register. As the output CTL port, its output power
  • the level is determined by the corresponding bit in [12:0] of the corresponding command entry in CMD SRAM; as the input CTL port, its input level needs to be consistent with the level of the corresponding bit in the default level register to indicate that the command is completed.
  • Whether the DATA port is valid and the input and output settings when it is valid are determined by the [31:30] bits of the CMD SRAM entry.
  • the DATA port is used as an output, data is ejected from the WRFIFO, and when it is used as an input, the data is pushed into the RDFIFO.
  • the states of the instruction fetching state machine include idle, first fetching, second fetching, normal fetching, trigger waiting, and execution feedback.
  • the states of the decoding state machine and the execution state machine include idle, control output , Control input, data read in, data write out, condition trigger waiting, control output and data read and write, control input and data write out, the states of the three state machines can jump two by two.
  • the next state of the decoding state machine depends on the analysis of the instructions output by the current state of the instruction fetching state machine, and the next state of the execution state machine depends on the current state of the decoding state machine.
  • the instruction fetching state machine decides whether to perform a state jump according to the mode control and default level register information and the execution feedback of the instruction, so that the interface timing of the execution stage is exactly the same as that described in the instruction queue. Since instruction fetching and decoding essentially only require one clock cycle, the advance speed of the pipeline depends on the execution time of each command. The execution time of a command depends on the content of the command, such as the number of cycles of writing data or the waiting time for waiting for input signal changes.
  • the mode control register indicates that CTL[12] is the output mode, CTL[11] is the input mode, CTL[1] is the input mode, and CTL[0] is the output mode.
  • the default level register indicates that the input CTL[11] is high by default, and CTL[1] is low.
  • CTL[11] is 1 and at the same time CTL[1] is 0. If they are not consistent, wait until the input changes to be consistent before proceeding to the next command.
  • This embodiment discloses a data reading and writing method based on the programmable gpio device of claim 1, which includes the following steps:
  • the instruction fetching state machine jumps to the state of fetching the second instruction.
  • the decoding state machine jumps to the first decoding timing state according to the decoding information.
  • the The state is the data write state
  • the instruction fetching state machine jumps to the normal instruction fetching state.
  • the decoding state machine jumps to the second decoding timing state according to the information of the decoded second instruction.
  • This embodiment In the second decoding state, the execution state machine jumps from the idle state to the previous decoding state. In this embodiment, this state is the data writing state;
  • the decoding information obtained from the decoding state determines the PCLK cycle required for the data writing state that the execution state machine jumps in step S03. In this embodiment, 10 pclk cycles are required, and then the instruction fetching state machine enters the normal state from the waiting state In the instruction fetching state, the decoding state machine jumps to the third decoding timing state (waiting state) according to the information of the decoded third instruction, and the execution state machine jumps from the data writing state to the previous decoding state (data reading in status);
  • the decoding information obtained from the decoding state determines that it takes 8 pclk cycles to execute the data read-in state of the state machine, and then the instruction fetching state machine enters the normal instruction fetching state from the waiting state, and the decoding state machine is based on the fourth instruction decoded
  • the information jumps to the fourth decoding timing state (control output state), and the execution state machine jumps from the data reading state to the previous decoding state (waiting state);
  • the decoding information obtained from the decoding state determines that the control output state of the execution state machine requires 16 pclk cycles, after which the decoding state machine enters the idle state, and the execution state machine jumps from the data writing state to the previous decoding state control input state ;
  • the fourth instruction ten pclk clock cycles, CTL[12] output is 1, CTL[0] output is 0, and at the same time ten groups of data are read in sequence on the DATA interface (into the RDFIFO in sequence).
  • the fifth instruction maintains the current state until it detects that the input CTL[11] becomes 1; in this pclk cycle, a group of data is read on the DATA port (press into the RD FIFO).
  • This device is actually a multi-function peripheral storage interface controller, which can be programmed by the user, and carries out large-scale pin configuration through the CPU, which is fast and flexible. And no CPU intervention is needed during operation, and only some CPU signs and interrupts are used to communicate with the kernel.
  • the flexible interface it enables can be used as a master device in an industrial standard or dedicated interface, and both parallel and serial interfaces can be implemented.

Abstract

Provided are a programmable gpio device and a time sequence implementation method based on the device, the programmable gpio device comprises a CMD module for storing instructions from software configuration, a read/write FIFO for storing data read from peripheral equipment or data written to the peripheral equipment on a DATA port, a pipeline control module and an interface connected with the peripheral equipment. The solution can be programmed by a user, carries out pin configuration through the CPU, which has the advantages of being rapid and flexible, intervention of the CPU is not needed in the operation process, and communication with the kernel is carried out only through some CPU marks and terminals.

Description

一种可编程gpio装置及基于该装置的时序实现方法Programmable GPIO device and time sequence realization method based on the device 技术领域Technical field
本发明涉及一种可编程gpio装置及基于该装置的时序实现方法,属于存储器技术领域。The invention relates to a programmable gpio device and a time sequence realization method based on the device, and belongs to the technical field of memory.
背景技术Background technique
每个GPIO端口可通过软件分别配置成输入或输出,即通过配置寄存器控制对应的引脚,实现与外设交互。因为CPU执行软件代码的开销和芯片内部包括系统总线传递数据的时延,软件无法精确控制GPIO管脚上电平的跳变时间和管脚之间的时序关系,因此GPIO不支持高速接口协议继而不能实现与复杂外设数据交互。Each GPIO port can be configured as input or output by software, that is, the corresponding pin is controlled through the configuration register to realize interaction with peripherals. Because of the overhead of the CPU executing software code and the delay of data transfer within the chip including the system bus, the software cannot accurately control the transition time of the level on the GPIO pin and the timing relationship between the pins, so GPIO does not support high-speed interface protocols and then Can not realize data interaction with complex peripherals.
随着工艺提高,高速接口协议成为主流,本发明旨在提取各类接口协议时序的共同特征,使用硬件实现根据时序波形编程gpio,以支持各类不同的接口协议。本装置将接口信号分类为时钟,控制信号,数据信号;将时序状态分类为空闲,控制输出,控制输入,数据读入,数据写出,条件触发等待及控制与数据并发的状态等;并据此设计一个指令集合,使用三级流水线,保证接口时序的准确无误,通过软件编程由CPU配置寄存器以及内置的命令SRAM,数据FIFO实现不同的接口应用。With the improvement of technology, high-speed interface protocols have become the mainstream. The present invention aims to extract the common characteristics of the timing of various interface protocols, and use hardware to implement programming of gpio according to timing waveforms to support various interface protocols. This device classifies interface signals into clocks, control signals, and data signals; classifies the timing status as idle, control output, control input, data read in, data write out, condition trigger waiting, and control and data concurrent status, etc.; This design has a set of instructions and uses a three-stage pipeline to ensure the accuracy of the interface timing. Through software programming, the CPU configuration registers, built-in command SRAM, and data FIFO realize different interface applications.
发明内容Summary of the invention
本发明要解决的技术问题是提供一种可编程gpio装置和基于该装置的时序实现方法,可由用户编程,通过CPU进行引脚配置,具有快速、灵活的特点,运行中不需要CPU的干预,仅通过一些CPU标志和终端与内核通讯。The technical problem to be solved by the present invention is to provide a programmable gpio device and a time sequence implementation method based on the device, which can be programmed by the user and configured by the CPU. It has the characteristics of fast and flexible and does not require CPU intervention during operation. Only communicate with the kernel through some CPU signs and terminals.
为了解决所述技术问题,本发明采用的技术方案是:一种可编程gpio装置,包括CMD模块,用于存储来自软件配置的指令;In order to solve the technical problem, the technical solution adopted by the present invention is: a programmable gpio device, including a CMD module, for storing instructions from software configuration;
模式寄存器和默认电平寄存器,模式寄存器决定CTL每个端口的输入输出设置,作为输入的CTL端口,其输入电平与默认电平寄存器中对应位的电平不一致时接口上所有信号维持不变直到两者一致时才能根据CMD SRAM中的命令条目继续后续的时序演进;Mode register and default level register. The mode register determines the input and output settings of each port of CTL. As the input CTL port, if its input level is inconsistent with the level of the corresponding bit in the default level register, all signals on the interface remain unchanged Until the two are consistent, the subsequent sequence evolution can be continued according to the command entry in the CMD and SRAM;
读/写FIFO,用于存储DATA端口上从外设读取的数据或者写往外设的数据;Read/write FIFO, used to store data read from peripherals or data written to peripherals on DATA port;
流水线控制模块,流水线控制模块包括取指状态机、解码状态机、执行状态机,三个状态机分别负责从命令SRAM中提取指令、解析提取到的指令、执行解析的指令;Pipeline control module. The pipeline control module includes an instruction fetching state machine, a decoding state machine, and an execution state machine. The three state machines are responsible for extracting instructions from the command SRAM, parsing the extracted instructions, and executing the parsed instructions;
与外设的接口,包括PCLK、CTL、DATA三类,PCLK是由控制器输出给外设,CTL和DATA都是双向端口。The interface with peripherals includes three types: PCLK, CTL, and DATA. PCLK is output from the controller to the peripherals. Both CTL and DATA are bidirectional ports.
进一步的,CMD模块存储的每条命令条目长度为32位,其中bit[31:29]为数据控制符,bit31为data有效控制位,为1时表示当前拍DATA接口有效,为0时表示只有CTL接口有效;bit30为读写控制位,表示DATA接口的读写操作,为1时DATA接口为输出,0时DATA为输入,当bit31为1时该位才有效;bit29表示DATA cycle是否多拍,当bit31有效,并且bit29为0时,表示在当前命令只进行一拍数据的读写操作,当bit29为1时,表示进行多拍数据传输,且进行数据传输个数与实际命令的cycle数一致;bit[20:16]表示命令方向以及命令为输出时的pclk cycle个数,当为0时,表示配置为输入的CTL线上的值需要等待变为与默认电平寄存器中对应位的值一致之后再执行下一条命令,此时如果bit31有效,则bit29为0时只进行一拍数据的读写操作,为1时,进行多拍操作,即等待过程的每一个pclk cycle都进行读写操作直到输入变为默认值;Further, the length of each command entry stored in the CMD module is 32 bits, where bit[31:29] is the data control symbol, bit31 is the data valid control bit, when it is 1, it means that the current DATA interface is valid, and when it is 0, it means only The CTL interface is valid; bit30 is the read and write control bit, which indicates the read and write operations of the DATA interface. When it is 1, the DATA interface is output, and when it is 0, DATA is input. When bit31 is 1, this bit is valid; bit29 indicates whether the DATA cycle is multi-shot , When bit31 is valid and bit29 is 0, it means that only one-beat data is read and written in the current command. When bit29 is 1, it means that multi-beat data transmission is performed, and the number of data transmissions and the actual command cycle number Consistent; bit[20:16] represents the command direction and the number of pclk cycles when the command is output. When it is 0, it means that the value on the CTL line configured as input needs to wait for it to become the corresponding bit in the default level register Execute the next command after the values are the same. At this time, if bit31 is valid, only one-shot data reading and writing operations are performed when bit29 is 0, and multi-shot operations are performed when bit29 is 1, that is, each pclk cycle of the waiting process is performed Read and write operations until the input becomes the default value;
bit[12:0]表示CTL接口上的输出电平或者是否检测输入控制线的电平,与bit[20:16]搭配,当cmd_count=0时代表只看输入控制线,且只看该位上与默认电平不一致的控制线。bit[12:0] indicates the output level on the CTL interface or whether to detect the level of the input control line. It is matched with bit[20:16]. When cmd_count=0, it means that only the input control line is looked at and only this bit Control lines that are inconsistent with the default level.
进一步的,在与外设的接口上,每个PCLK周期内CTL端口的电平信号由当前执行到的CMD SRAM条目及模式和电平寄存器共同决定,DATA端口的电平信号由当前执行到的CMD SRAM条目及模式和电平寄存器以及写FIFO上的数据或者所连接外设的电平共同决定,CTL每个端口的输入输出设置由模式寄存器决定,作为输出的CTL端口,其输出电平由CMD SRAM中对应命令条目的[12:0]中对应位决定;作为输入的CTL端口,其输入电平需要与默认电平寄存器中对应位的电平一致时才能表示该条命令完成,DATA端口是否有效及有效时的输入输出设置由CMD SRAM条目的[31:30]位决定,DATA端口作为输出时从WR FIFO弹出数据,作为输入时将数据压入RD FIFO中。Further, on the interface with peripherals, the level signal of the CTL port in each PCLK cycle is determined by the currently executed CMD SRAM entry and the mode and level register. The level signal of the DATA port is determined by the current executed CMD SRAM entries and mode and level registers, as well as writing data on the FIFO or the level of connected peripherals are jointly determined. The input and output settings of each CTL port are determined by the mode register. As the output CTL port, its output level is determined by The corresponding bit in [12:0] of the corresponding command entry in CMD SRAM is determined; as the input CTL port, its input level needs to be consistent with the level of the corresponding bit in the default level register to indicate that the command is completed, DATA port Whether it is valid and the input and output settings when it is valid are determined by the [31:30] bits of the CMD SRAM entry. When the DATA port is used as an output, data is ejected from the WR FIFO, and when it is used as an input, the data is pushed into the RDFIFO.
进一步的,取指状态机的状态包括空闲、第一次取指、第二次取指、正常取指、触发等待、执行反馈,解码和执行状态机的状态包括空闲、控制输出、控制输入、数据读入、数据写出、条件触发等待、控制输出并数据读写、控制输入并数据写出,三个状态机的状态彼此之间可以两两跳转。Further, the state of the fetching state machine includes idle, first fetching, second fetching, normal fetching, trigger waiting, execution feedback, and the state of the decoding and executing state machine includes idle, control output, control input, Data read in, data write out, condition trigger waiting, control output and data read and write, control input and data write out, the states of the three state machines can jump in pairs with each other.
解码状态机的下一个状态取决于对取指状态机当前状态输出的指令的解析,执行状态机的下一个状态取决于解码状态机的当前状态,取指状态机根据模式控制和默认电平寄存器信息以及指令的执行反馈情况决定是否进行状态跳转,使得执行阶段的接口时序与指令队列当中所描述的完全吻合。The next state of the decoding state machine depends on the analysis of the instructions output by the current state of the instruction fetching state machine. The next state of the execution state machine depends on the current state of the decoding state machine. The instruction fetching state machine is controlled by the mode and the default level register. The information and the execution feedback of the instructions determine whether to perform a state jump, so that the interface timing of the execution phase is completely consistent with the description in the instruction queue.
进一步的,控制信号CTL的宽度为13bits,数据信号DATA宽度可配置,其宽度必须与内部FIFO的位宽保持一致。Further, the width of the control signal CTL is 13 bits, and the width of the data signal DATA is configurable, and its width must be consistent with the bit width of the internal FIFO.
本发明还公开了一种基于上述可编程gpio装置的时序实现方法,包括以下步骤:The invention also discloses a time sequence realization method based on the above programmable gpio device, which includes the following steps:
S01)、CPU配置模式寄存器和默认电平寄存,并编码CMD SRAM;S01), CPU configuration mode register and default level register, and code CMD SRAM;
S02)、取指状态机从空闲状态跳转到取第一条指令的状态;S02), the instruction fetching state machine jumps from the idle state to the state of fetching the first instruction;
S03)、第一条指令取出后取指状态机跳转到取第二条指令的状态,与此同时,解码状态机根据解码信息跳转到解码时序状态;S03). After the first instruction is fetched, the instruction fetching state machine jumps to the state of fetching the second instruction, and at the same time, the decoding state machine jumps to the decoding timing state according to the decoding information;
S04)、第二条指令取出后取指状态机跳转到正常取指状态,与此同时,解码状态机根据所解码第二条指令的信息跳转到第二个解码时序状态,执行状态机从空闲状态跳转到上一个解码状态;S04). After the second instruction is fetched, the instruction fetching state machine jumps to the normal instruction fetching state. At the same time, the decoding state machine jumps to the second decoding timing state according to the information of the decoded second instruction, and the execution state machine Jump from the idle state to the previous decoding state;
S05)、由解码状态所得的解码信息确定执行状态机在步骤S03跳转的上一个解码状态需要的PCLK周期,之后取指状态机从等待状态进入普通取指状态,解码状态机根据所解码的第三条指令的信息跳转到第三个解码时序状态,执行状态机从步骤S03跳转的解码状态跳转到上一个解码状态;S05). The decoding information obtained from the decoding state determines the PCLK cycle required to execute the previous decoding state that the state machine jumps in step S03, and then the instruction fetching state machine enters the normal instruction fetching state from the waiting state, and the decoding state machine is based on the decoded state. The information of the third instruction jumps to the third decoding timing state, and the execution state machine jumps from the decoding state jumped in step S03 to the previous decoding state;
S06)、由解码状态所得的解码信息确定执行状态机在步骤S04跳转的上一个解码状态需要的PCLK周期,之后取指状态机从等待状态进入普通取指状态,解码状态机根据所解码的第四条指令的信息跳转到第四个解码时序状态,执行状态机从步骤S04跳转的解码状态跳转到上一个解码状态;S06), the decoding information obtained from the decoding state determines the PCLK cycle required to execute the previous decoding state that the state machine jumped in step S04, and then the instruction fetching state machine enters the normal instruction fetching state from the waiting state, and the decoding state machine is based on the decoded The information of the fourth instruction jumps to the fourth decoding timing state, and the execution state machine jumps from the decoding state jumped in step S04 to the previous decoding state;
S07)、因为执行状态机在步骤S06跳转的上一个解码状态需要等待CTL接口上的某个输入信号与模式寄存器的对应位一致,具体等待时长取决于外设,两者一致之后,取指状态机进入空闲状态,解码状态机根据所解码的第五条指令的信息跳转到第五个解码时序状态,执行状态机从步骤S06跳转的解码状态跳转到上一个解码状态;S07). Because the previous decoding state of the execution state machine jumped in step S06 needs to wait for a certain input signal on the CTL interface to be consistent with the corresponding bit of the mode register, the specific waiting time depends on the peripheral. After the two are consistent, fetch the instruction The state machine enters the idle state, the decoding state machine jumps to the fifth decoding timing state according to the information of the decoded fifth instruction, and the execution state machine jumps from the decoding state jumped in step S06 to the previous decoding state;
S08)、由解码状态所得的解码信息确定执行状态机在步骤S07跳转的上一个解码状态需要的PCLK周期,之后解码状态机进入空闲状态,执行状态机从步骤S07跳转的解码状态跳转到上一个解码状态;S08), the decoding information obtained from the decoding state determines the PCLK cycle required for the previous decoding state that the execution state machine jumps in step S07, after which the decoding state machine enters the idle state, and the execution state machine jumps from the decoding state jumped in step S07 Go to the previous decoding state;
S09)、由解码状态所得的解码信息确定执行状态机在步骤S08跳转的上一个解码状态需要的PCLK周期,之后执行状态机进入空闲状态。S09) The decoding information obtained from the decoding state determines the PCLK cycle required for the previous decoding state to which the execution state machine jumps in step S08, and then the execution state machine enters the idle state.
进一步的,步骤S03中,解码状态机跳转到的解码时序状态为数据写出状态,步骤S04中,解码状态机跳转到的第二个解码时序状态为数据读入状态,执行状态机跳转到的上一个解码状态是数据写出状态,步骤S05中,解码状态机跳转的第三个解码时序状态是等待状态,执行状态机跳转的上一个解码状态是数据读入状态,步骤S06中,解码状态机跳转的第四个解码时序状态是控制输出状态,执行状态机跳转的上一个解码状态是等待状态,步骤 S07中,解码状态机跳转的第五个解码时序状态是控制输入状态,执行状态机跳转的上一个解码状态是控制输出状态,步骤S08中,执行状态机跳转的上一个解码状态是控制输入状态。Further, in step S03, the decoding timing state that the decoding state machine jumps to is the data writing state, and in step S04, the second decoding timing state that the decoding state machine jumps to is the data reading state, and the execution state machine jumps The previous decoding state to be transferred is the data writing state. In step S05, the third decoding timing state of the decoding state machine jump is the waiting state, and the previous decoding state of the execution state machine jump is the data reading state. In S06, the fourth decoding timing state where the decoding state machine jumps is the control output state, the last decoding state that executes the state machine jump is the waiting state, and in step S07, the fifth decoding timing state where the decoding state machine jumps It is the control input state, the last decoding state that executes the state machine jump is the control output state, and in step S08, the last decode state that executes the state machine jump is the control input state.
本发明的有益效果:传统GPIO只能将引脚设置为输入或输出,设置引脚为固定电平值或者高阻态,不能实现引脚的复杂时序控制。本设计实际为一个多功能外设存储接口控制器,即可由用户编程的接口,通过CPU进行大篇幅的引脚配置,具有快速、灵活等特点。且运行中不需要CPU的干预,仅通过一些CPU标志和中断与内核通讯。其所启用的灵活接口可用作工业标准或专用接口中的主设备,并行和串行接口均可实现。The beneficial effects of the present invention: the traditional GPIO can only set the pin as input or output, and set the pin to a fixed level value or a high resistance state, and cannot realize complex timing control of the pin. This design is actually a multi-function peripheral storage interface controller, which can be programmed by the user, and carries out large-scale pin configuration through the CPU, which is fast and flexible. And no CPU intervention is needed during operation, and only some CPU signs and interrupts are used to communicate with the kernel. The flexible interface it enables can be used as a master device in an industrial standard or dedicated interface, and both parallel and serial interfaces can be implemented.
附图说明Description of the drawings
图1为可编程gpio装置的原理框图;Figure 1 is a schematic block diagram of a programmable gpio device;
图2为三个状态机运行时的流水线示意图;Figure 2 is a schematic diagram of the pipeline when three state machines are running;
图3为模式控制寄存器的示意图;Figure 3 is a schematic diagram of a mode control register;
图4为默认电平寄存器的示意图;Figure 4 is a schematic diagram of the default level register;
图5为CPU对CMD_SRAM的配置设置的示意图。Figure 5 is a schematic diagram of the CPU configuration settings for CMD_SRAM.
具体实施方式detailed description
下面结合附图和具体实施例对本发明作进一步的说明。The present invention will be further described below in conjunction with the drawings and specific embodiments.
实施例1Example 1
本实施例公开一种可编程gpio装置,如图1所示,包括:This embodiment discloses a programmable gpio device, as shown in FIG. 1, including:
CMD模块,用于存储来自软件配置的指令;CMD module, used to store instructions from software configuration;
模式寄存器(在图1中表示为Mode Register)和默认电平寄存器(在图1中表示为Level Register),位宽为13比特,如图3、4所示,模式寄存器决定CTL每个端口的输入输出设置,作为输入的CTL端口,其输入电平与默认电平寄存器中对应位的电平不一致时接口上所有信号维持不变直到两者一致时才能根据CMD SRAM中的命令条目继续后续的时序演进;The mode register (represented as Mode Register in Figure 1) and the default level register (represented as Level Register in Figure 1) have a bit width of 13 bits. As shown in Figures 3 and 4, the mode register determines each port of the CTL Input and output settings, as the input CTL port, when the input level is inconsistent with the level of the corresponding bit in the default level register, all the signals on the interface remain unchanged until the two are consistent, and the subsequent commands in CMD SRAM can be continued. Timing evolution
读/写FIFO,用于存储DATA端口上从外设读取的数据或者写往外设的数据;Read/write FIFO, used to store data read from peripherals or data written to peripherals on DATA port;
流水线控制模块,如图2所示,流水线控制模块包括取指状态机(Fetch)、解码状态机(Decode)、执行状态机(Execute),三个状态机分别负责从命令SRAM中提取指令、解析提取到的指令、执行解析的指令;The pipeline control module, as shown in Figure 2, the pipeline control module includes a fetch state machine (Fetch), a decoding state machine (Decode), and an execution state machine (Execute). The three state machines are respectively responsible for extracting instructions from the command SRAM and parsing The extracted instructions and the parsed instructions;
与外设的接口,包括PCLK、CTL、DATA三类,PCLK是由控制器输出给外设,CTL和DATA都是双向端口。控制信号CTL的宽度为13bits,数据信号DATA宽度可配置,其宽度 必须与内部FIFO的位宽保持一致。The interface with peripherals includes three types: PCLK, CTL, and DATA. PCLK is output from the controller to the peripherals. Both CTL and DATA are bidirectional ports. The width of the control signal CTL is 13 bits, and the width of the data signal DATA is configurable, and its width must be consistent with the bit width of the internal FIFO.
如图5所示,CMD模块存储的每条命令条目长度为32位,其中bit[31:29]为数据控制符,bit31(DATA_VALID)为data有效控制位,为1时表示当前拍DATA接口有效,为0时表示只有CTL接口有效;bit30(RW)为读写控制位,表示DATA接口的读写操作,为1时DATA接口为输出,0时DATA为输入,当bit31为1时该位才有效;bit29(DATA_LENGTH)表示DATA cycle是否多拍,当DATA_VALID有效,并且bit29为0时,表示在当前命令只进行一拍数据的读写操作,当DATA_LENGTH为1时,表示进行多拍数据传输,且进行数据传输个数与实际命令的cycle数一致即[20:16]中的数值。As shown in Figure 5, the length of each command entry stored by the CMD module is 32 bits, of which bit[31:29] is the data control symbol, bit31 (DATA_VALID) is the data valid control bit, when it is 1, it means that the current DATA interface is valid , When it is 0, it means that only the CTL interface is valid; bit30 (RW) is the read and write control bit, which means the read and write operation of the DATA interface. When it is 1, the DATA interface is output, and when it is 0, DATA is input. When bit31 is 1, this bit is only Valid; bit29 (DATA_LENGTH) indicates whether the DATA cycle is multi-beat. When DATA_VALID is valid and bit29 is 0, it means that only one-beat data is read and written in the current command. When DATA_LENGTH is 1, it means multi-beat data transmission. And the number of data transmission is the same as the cycle number of the actual command, which is the value in [20:16].
bit[20:16](Command cycle counter)表示命令方向以及命令为输出时的pclk cycle个数,当为0时,表示配置为输入的CTL线上的值需要等待变为与默认电平寄存器中对应位的值一致之后再执行下一条命令,此时如果DATA_VALID有效,则DATA_LENGTH为0时只进行一拍数据的读写操作(该操作在控制线变为默认值的那一拍进行),为1时,进行多拍操作,即等待过程的每一个pclk cycle都进行读写操作直到输入变为默认值。bit[20:16](Command cycle counter) represents the command direction and the number of pclk cycles when the command is output. When it is 0, it means that the value on the CTL line configured as input needs to wait for the value to be changed to the default level register After the values of the corresponding bits are consistent, execute the next command. At this time, if DATA_VALID is valid, only one beat of data read and write operations will be performed when DATA_LENGTH is 0 (this operation is performed at the beat when the control line becomes the default value). At 1 o'clock, multi-shot operation is performed, that is, each pclk cycle of the waiting process performs read and write operations until the input becomes the default value.
bit[12:0](Command)表示CTL接口上的输出电平或者是否检测输入控制线的电平,与bit[20:16]搭配,当cmd_count=0时代表只看输入控制线,且只看该位上与默认电平不一致的控制线。bit[12:0](Command) indicates the output level on the CTL interface or whether to detect the level of the input control line. It is matched with bit[20:16]. When cmd_count=0, it means that only the input control line is looked at. Look at the control line that is inconsistent with the default level on this bit.
本实施例中,在与外设的接口上,每个PCLK周期内CTL端口的电平信号由当前执行到的CMD SRAM条目及模式和电平寄存器共同决定,DATA端口的电平信号由当前执行到的CMD SRAM条目及模式和电平寄存器以及写FIFO上的数据或者所连接外设的电平共同决定,CTL每个端口的输入输出设置由模式寄存器决定,作为输出的CTL端口,其输出电平由CMD SRAM中对应命令条目的[12:0]中对应位决定;作为输入的CTL端口,其输入电平需要与默认电平寄存器中对应位的电平一致时才能表示该条命令完成,DATA端口是否有效及有效时的输入输出设置由CMD SRAM条目的[31:30]位决定,DATA端口作为输出时从WR FIFO弹出数据,作为输入时将数据压入RD FIFO中。In this embodiment, on the interface with peripherals, the level signal of the CTL port in each PCLK cycle is determined by the currently executed CMD SRAM entry and the mode and level register, and the level signal of the DATA port is determined by the current execution The received CMD SRAM entry, the mode and level register, and the data written on the FIFO or the level of the connected peripheral are jointly determined. The input and output settings of each CTL port are determined by the mode register. As the output CTL port, its output power The level is determined by the corresponding bit in [12:0] of the corresponding command entry in CMD SRAM; as the input CTL port, its input level needs to be consistent with the level of the corresponding bit in the default level register to indicate that the command is completed. Whether the DATA port is valid and the input and output settings when it is valid are determined by the [31:30] bits of the CMD SRAM entry. When the DATA port is used as an output, data is ejected from the WRFIFO, and when it is used as an input, the data is pushed into the RDFIFO.
本实施例中,取指状态机的状态包括空闲、第一次取指、第二次取指、正常取指、触发等待、执行反馈,解码状态机和执行状态机的状态包括空闲、控制输出、控制输入、数据读入、数据写出、条件触发等待、控制输出并数据读写、控制输入并数据写出,三个状态机的状态彼此之间可以两两跳转。解码状态机的下一个状态取决于对取指状态机当前状态输出的指令的解析,执行状态机的下一个状态取决于解码状态机的当前状态。取指状态机根据模式控制和默认电平寄存器信息以及指令的执行反馈情况决定是否进行状态跳转,使得执行 阶段的接口时序与指令队列当中所描述的完全吻合。因取指和译码实质只需要一个时钟周期,所以流水线的前进速度取决于每条命令的执行时间。一条命令执行时间长短取决于该指令所指代的内容,例如写数据周期数或者等待输入信号变化的等待时长。In this embodiment, the states of the instruction fetching state machine include idle, first fetching, second fetching, normal fetching, trigger waiting, and execution feedback. The states of the decoding state machine and the execution state machine include idle, control output , Control input, data read in, data write out, condition trigger waiting, control output and data read and write, control input and data write out, the states of the three state machines can jump two by two. The next state of the decoding state machine depends on the analysis of the instructions output by the current state of the instruction fetching state machine, and the next state of the execution state machine depends on the current state of the decoding state machine. The instruction fetching state machine decides whether to perform a state jump according to the mode control and default level register information and the execution feedback of the instruction, so that the interface timing of the execution stage is exactly the same as that described in the instruction queue. Since instruction fetching and decoding essentially only require one clock cycle, the advance speed of the pipeline depends on the execution time of each command. The execution time of a command depends on the content of the command, such as the number of cycles of writing data or the waiting time for waiting for input signal changes.
图5示例解析:模式控制寄存器表示第CTL[12]为输出模式,CTL[11]为输入模式,CTL[1]为输入模式,CTL[0]为输出模式。默认电平寄存器的表示作为输入的CTL[11]默认为高电平,CTL[1]为低电平。在输入模式下,每一个PCLK周期,判断CTL[11]是否为1并且同时CTL[1]是否为0,不一致则等待至输入改变为一致后再进行下一条命令的操作。Example analysis in Figure 5: The mode control register indicates that CTL[12] is the output mode, CTL[11] is the input mode, CTL[1] is the input mode, and CTL[0] is the output mode. The default level register indicates that the input CTL[11] is high by default, and CTL[1] is low. In the input mode, every PCLK cycle, it is judged whether CTL[11] is 1 and at the same time CTL[1] is 0. If they are not consistent, wait until the input changes to be consistent before proceeding to the next command.
实施例2Example 2
本实施例公开一种基于权利要求1所述可编程gpio装置的数据读写方法,包括以下步骤:This embodiment discloses a data reading and writing method based on the programmable gpio device of claim 1, which includes the following steps:
S01)、CPU配置模式寄存器和默认电平寄存,并编码CMD SRAM(假设配置了5条指令);S01), CPU configuration mode register and default level register, and code CMD SRAM (assuming 5 instructions are configured);
S02)、取指状态机从空闲状态跳转到取第一条指令的状态;S02), the instruction fetching state machine jumps from the idle state to the state of fetching the first instruction;
S03)、第一条指令取出后取指状态机跳转到取第二条指令的状态,与此同时,解码状态机根据解码信息跳转到第一个解码时序状态,本实施例中,本状态为数据写出状态;S03). After the first instruction is fetched, the instruction fetching state machine jumps to the state of fetching the second instruction. At the same time, the decoding state machine jumps to the first decoding timing state according to the decoding information. In this embodiment, the The state is the data write state;
S04)、第二条指令取出后取指状态机跳转到正常取指状态,与此同时,解码状态机根据所解码第二条指令的信息跳转到第二个解码时序状态,本实施例中,第二个解码为数据读入状态,执行状态机从空闲状态跳转到上一个解码状态,本实施例中,本状态为数据写出状态;S04). After the second instruction is fetched, the instruction fetching state machine jumps to the normal instruction fetching state. At the same time, the decoding state machine jumps to the second decoding timing state according to the information of the decoded second instruction. This embodiment In the second decoding state, the execution state machine jumps from the idle state to the previous decoding state. In this embodiment, this state is the data writing state;
S05)、由解码状态所得的解码信息确定执行状态机在步骤S03跳转的数据写出状态需要的PCLK周期,本实施例中,需要10个pclk周期,之后取指状态机从等待状态进入普通取指状态,解码状态机根据所解码的第三条指令的信息跳转到第三个解码时序状态(等待状态),执行状态机从数据写出状态跳转到上一个解码状态(数据读入状态);S05). The decoding information obtained from the decoding state determines the PCLK cycle required for the data writing state that the execution state machine jumps in step S03. In this embodiment, 10 pclk cycles are required, and then the instruction fetching state machine enters the normal state from the waiting state In the instruction fetching state, the decoding state machine jumps to the third decoding timing state (waiting state) according to the information of the decoded third instruction, and the execution state machine jumps from the data writing state to the previous decoding state (data reading in status);
S06)、由解码状态所得的解码信息确定执行状态机的数据读入状态需要8个pclk周期,之后取指状态机从等待状态进入普通取指状态,解码状态机根据所解码的第四条指令的信息跳转到第四个解码时序状态(控制输出状态),执行状态机从数据读入状态跳转到上一个解码状态(等待状态);S06). The decoding information obtained from the decoding state determines that it takes 8 pclk cycles to execute the data read-in state of the state machine, and then the instruction fetching state machine enters the normal instruction fetching state from the waiting state, and the decoding state machine is based on the fourth instruction decoded The information jumps to the fourth decoding timing state (control output state), and the execution state machine jumps from the data reading state to the previous decoding state (waiting state);
S07)、因为执行状态机等待状态需要等待CTL接口上的某个输入信号与模式寄存器的对应位一致,具体等待时长取决于外设,两者一致之后,取指状态机进入空闲状态,解码状态机根据所解码的第五条指令的信息跳转到第五个解码时序状态(控制输入状态),执行状态机从等待状态跳转到上一个解码状态控制输出状态;S07), because the execution state machine wait state needs to wait for a certain input signal on the CTL interface to be consistent with the corresponding bit of the mode register. The specific waiting time depends on the peripheral. After the two are consistent, the instruction fetching state machine enters the idle state and the decoding state The machine jumps to the fifth decoding timing state (control input state) according to the information of the decoded fifth instruction, and the execution state machine jumps from the waiting state to the previous decoding state to control the output state;
S08)、由解码状态所得的解码信息确定执行状态机的控制输出状态需要16个pclk周期,之 后解码状态机进入空闲状态,执行状态机从数据写出状态跳转到上一个解码状态控制输入状态;S08), the decoding information obtained from the decoding state determines that the control output state of the execution state machine requires 16 pclk cycles, after which the decoding state machine enters the idle state, and the execution state machine jumps from the data writing state to the previous decoding state control input state ;
S09)、由解码状态所得的解码信息确定执行状态机的控制输入状态需要4个pclk周期,之后执行状态机进入空闲状态。S09) It is determined from the decoding information obtained from the decoding state that the control input state of the execution state machine requires 4 pclk cycles, and then the execution state machine enters the idle state.
以图5CMD SRAM中的数据为例解析接口时序如下:Take the data in CMD SRAM in Figure 5 as an example to analyze the interface timing as follows:
第一条指令,一个pclk时钟周期,CTL[12]输出为0,CTL[0]输出为1The first instruction, one pclk clock cycle, CTL[12] output is 0, CTL[0] output is 1
第二条指令,三个pclk时钟周期,CTL[12]输出为1,CTL[0]输出为0The second instruction, three pclk clock cycles, CTL[12] output is 1, CTL[0] output is 0
第三条指令,维持当前状态直至检测到输入CTL[11]=1与CTL[1]=0同时成立;在此pclk周期内DATA写出一组数据(来源于WR FIFO)。The third instruction maintains the current state until it is detected that the input CTL[11]=1 and CTL[1]=0 are established at the same time; DATA writes a group of data (from WRFIFO) in this pclk cycle.
第四条指令,十个pclk时钟周期,CTL[12]输出为1,CTL[0]输出为0,同时DATA接口上依次读入十组数据(依次压入RD FIFO)。The fourth instruction, ten pclk clock cycles, CTL[12] output is 1, CTL[0] output is 0, and at the same time ten groups of data are read in sequence on the DATA interface (into the RDFIFO in sequence).
第五条指令,维持当前状态直至检测到输入CTL[11]变为1;在此pclk周期内DATA端口上读入一组数据(压入RD FIFO)。The fifth instruction maintains the current state until it detects that the input CTL[11] becomes 1; in this pclk cycle, a group of data is read on the DATA port (press into the RD FIFO).
传统GPIO只能将引脚设置为输入或输出,设置引脚为固定电平值或者高阻态,不能实现引脚的复杂时序控制。本装置实际为一个多功能外设存储接口控制器,即可由用户编程的接口,通过CPU进行大篇幅的引脚配置,具有快速、灵活等特点。且运行中不需要CPU的干预,仅通过一些CPU标志和中断与内核通讯。其所启用的灵活接口可用作工业标准或专用接口中的主设备,并行和串行接口均可实现。Traditional GPIO can only set the pin as input or output, and set the pin to a fixed level value or high impedance state, which cannot achieve complex timing control of the pin. This device is actually a multi-function peripheral storage interface controller, which can be programmed by the user, and carries out large-scale pin configuration through the CPU, which is fast and flexible. And no CPU intervention is needed during operation, and only some CPU signs and interrupts are used to communicate with the kernel. The flexible interface it enables can be used as a master device in an industrial standard or dedicated interface, and both parallel and serial interfaces can be implemented.
注:在本文中端口,引脚,管脚指代相同的意义。命令和指令代指相同意义。以上描述的仅是本发明的基本原理和优选实施例,本领域技术人员根据本发明做出的改进和替换,属于本发明的保护范围。Note: Ports, pins, and pins in this text refer to the same meaning. Command and instruction refer to the same meaning. What has been described above are only the basic principles and preferred embodiments of the present invention. Improvements and replacements made by those skilled in the art based on the present invention belong to the protection scope of the present invention.

Claims (8)

  1. 一种可编程gpio装置,其特征在于:包括A programmable gpio device, which is characterized in that it comprises
    CMD模块,用于存储来自软件配置的指令;CMD module, used to store instructions from software configuration;
    模式寄存器和默认电平寄存器,模式寄存器决定CTL每个端口的输入输出设置,作为输入的CTL端口,其输入电平与默认电平寄存器中对应位的电平不一致时接口上所有信号维持不变直到两者一致时才能根据CMD SRAM中的命令条目继续后续的时序演进;Mode register and default level register. The mode register determines the input and output settings of each port of CTL. As the input CTL port, if its input level is inconsistent with the level of the corresponding bit in the default level register, all signals on the interface remain unchanged Until the two are consistent, the subsequent sequence evolution can be continued according to the command entry in the CMD and SRAM;
    读/写FIFO,用于存储DATA端口上从外设读取的数据或者写往外设的数据;Read/write FIFO, used to store data read from peripherals or data written to peripherals on DATA port;
    流水线控制模块,流水线控制模块包括取指状态机、解码状态机、执行状态机,三个状态机分别负责从命令SRAM中提取指令、解析提取到的指令、执行解析的指令;Pipeline control module. The pipeline control module includes an instruction fetching state machine, a decoding state machine, and an execution state machine. The three state machines are responsible for extracting instructions from the command SRAM, parsing the extracted instructions, and executing the parsed instructions;
    与外设的接口,包括PCLK、CTL、DATA三类,PCLK是由控制器输出给外设的单向端口,CTL和DATA都是双向端口。The interface with peripherals includes three types: PCLK, CTL, and DATA. PCLK is a one-way port output by the controller to the peripheral. CTL and DATA are both two-way ports.
  2. 根据权利要求1所述的可编程gpio装置,其特征在于:CMD模块存储的每条命令条目长度为32位,其中bit[31:29]为数据控制符,bit31为data有效控制位,为1时表示当前拍DATA接口有效,为0时表示只有CTL接口有效;bit30为读写控制位,表示DATA接口的读写操作,为1时DATA接口为输出,为0时DATA为输入,当bit31为1时该位才有效;bit29表示DATA cycle是否多拍,当bit31有效,并且bit29为0时,表示在当前命令只进行一拍数据的读写操作,当bit29为1时,表示进行多拍数据传输,且进行数据传输个数与实际命令的cycle数一致;bit[20:16]表示命令方向以及命令为输出时的pclk cycle个数,当为0时,表示配置为输入的CTL线上的值需要等待变为与默认电平寄存器中对应位的值一致之后再执行下一条命令,此时如果bit31有效,则bit29为0时只进行一拍数据的读写操作,为1时,进行多拍操作,即等待过程的每一个pclk cycle都进行读写操作直到输入变为默认值;The programmable gpio device according to claim 1, wherein the length of each command entry stored in the CMD module is 32 bits, where bit[31:29] is a data control symbol, and bit31 is a data valid control bit, which is 1. When is the current DATA interface is valid, when it is 0, it means that only the CTL interface is valid; bit30 is the read and write control bit, which means the read and write operation of the DATA interface, when it is 1, the DATA interface is output, when it is 0, DATA is input, when bit31 is This bit is valid when 1; bit29 indicates whether the data cycle is multi-beat. When bit31 is valid and bit29 is 0, it means that only one-beat data is read and written in the current command. When bit29 is 1, it means multi-beat data. Transmission, and the number of data transmissions is the same as the number of cycles of the actual command; bit[20:16] indicates the command direction and the number of pclk cycles when the command is output. When it is 0, it indicates the CTL line configured as input You need to wait for the value to be consistent with the value of the corresponding bit in the default level register before executing the next command. At this time, if bit31 is valid, only one-shot data read and write operation is performed when bit29 is 0, and when it is 1, perform Multi-shot operation, that is, each pclk cycle of the waiting process performs read and write operations until the input becomes the default value;
    bit[12:0]表示CTL接口上的输出电平或者是否检测输入控制线的电平,与bit[20:16]搭配,当cmd_count=0时代表只看输入控制线,且只看该位上与默认电平不一致的控制线。bit[12:0] indicates the output level on the CTL interface or whether to detect the level of the input control line. It is matched with bit[20:16]. When cmd_count=0, it means that only the input control line is looked at and only this bit Control lines that are inconsistent with the default level.
  3. 根据权利要求2所述的可编程gpio装置,其特征在于:在与外设的接口上,每个PCLK周期内CTL端口的电平信号由当前执行到的CMD SRAM条目及模式和电平寄存器共同决定,DATA端口的电平信号由当前执行到的CMD SRAM条目及模式和电平寄存器以及写FIFO上的数据或者所连接外设的电平共同决定,CTL每个端口的输入输出设置由模式寄存器决定,作为输出的CTL端口,其输出电平由CMD SRAM中对应命令条目的[12:0]中对应位决定;作为输入的CTL端口,其输入电平需要与默认电平寄存器中对应位的电平一致时才能表示该条命令完成,DATA端口是否有效及有效时的输入输出设置由CMD SRAM条目 的[31:30]位决定,DATA端口作为输出时从WR FIFO弹出数据,作为输入时将数据压入RD FIFO中。The programmable gpio device according to claim 2, characterized in that: on the interface with the peripheral, the level signal of the CTL port in each PCLK cycle is shared by the currently executed CMD SRAM entry and the mode and level register Determined, the level signal of the DATA port is determined by the currently executed CMD SRAM entry, the mode and level register, and the data written on the FIFO or the level of the connected peripheral. The input and output settings of each CTL port are determined by the mode register It is decided that the output level of the CTL port as the output is determined by the corresponding bit in [12:0] of the corresponding command entry in CMD SRAM; the input level of the CTL port as the input needs to be the same as the corresponding bit in the default level register The command is completed only when the levels are the same. Whether the DATA port is valid and the input and output settings when it is valid are determined by the [31:30] bit of the CMD SRAM entry. When the DATA port is used as an output, the data will be popped from the WRFIFO. The data is pressed into the RD FIFO.
  4. 根据权利要求1所述的可编程gpio装置,其特征在于:取指状态机的状态包括空闲、第一次取指、第二次取指、正常取指、触发等待、执行反馈,解码状态机和执行状态机的状态包括空闲、控制输出、控制输入、数据读入、数据写出、条件触发等待、控制输出并数据读写、控制输入并数据读写,三个状态机各自的内部状态之间可以两两跳转。The programmable gpio device according to claim 1, wherein the state of the fetching state machine includes idle, first fetching, second fetching, normal fetching, trigger waiting, execution feedback, and decoding state machine The state of the execution state machine includes idle, control output, control input, data read in, data write out, condition trigger waiting, control output and data read and write, control input and data read and write, one of the internal states of the three state machines You can jump in pairs.
  5. 根据权利要求4所述的可编程gpio装置,其特征在于:解码状态机的下一个状态取决于对取指状态机当前状态输出的指令的解析,执行状态机的下一个状态取决于解码状态机的当前状态,取指状态机根据模式控制和默认电平寄存器信息以及指令的执行反馈情况决定是否进行状态跳转,使得执行阶段的接口时序与指令队列当中所描述的完全吻合。The programmable gpio device according to claim 4, wherein the next state of the decoding state machine depends on the analysis of the instruction output from the current state of the instruction fetching state machine, and the next state of the execution state machine depends on the decoding state machine The current state of the instruction fetching state machine determines whether to perform a state jump according to the mode control and the default level register information and the execution feedback of the instruction, so that the interface timing of the execution stage is completely consistent with the description in the instruction queue.
  6. 根据权利要求1所述的可编程gpio装置,其特征在于:控制信号CTL的宽度为13bits,数据信号DATA宽度可配置,其宽度必须与内部FIFO的位宽保持一致。The programmable gpio device according to claim 1, wherein the width of the control signal CTL is 13 bits, and the width of the data signal DATA is configurable, and its width must be consistent with the bit width of the internal FIFO.
  7. 一种基于权利要求3所述可编程gpio装置的时序实现方法,其特征在于:包括以下步骤:S01)、CPU配置模式寄存器和默认电平寄存,并编码CMD SRAM;A time sequence implementation method based on the programmable gpio device of claim 3, characterized in that it comprises the following steps: S01), CPU configuration mode register and default level register, and coding CMD SRAM;
    S02)、取指状态机从空闲状态跳转到取第一条指令的状态;S02), the instruction fetching state machine jumps from the idle state to the state of fetching the first instruction;
    S03)、第一条指令取出后取指状态机跳转到取第二条指令的状态,与此同时,解码状态机根据解码信息跳转到解码时序状态;S03). After the first instruction is fetched, the instruction fetching state machine jumps to the state of fetching the second instruction, and at the same time, the decoding state machine jumps to the decoding timing state according to the decoding information;
    S04)、第二条指令取出后取指状态机跳转到正常取指状态,与此同时,解码状态机根据所解码第二条指令的信息跳转到第二个解码时序状态,执行状态机从空闲状态跳转到上一个解码状态;S04). After the second instruction is fetched, the instruction fetching state machine jumps to the normal instruction fetching state. At the same time, the decoding state machine jumps to the second decoding timing state according to the information of the decoded second instruction, and the execution state machine Jump from the idle state to the previous decoding state;
    S05)、由解码状态所得的解码信息确定状态状态机在步骤S03跳转的上一个解码状态需要的PCLK周期,之后取指状态机从等待状态进入普通取指状态,解码状态机根据所解码的第三条指令的信息跳转到第三个解码时序状态,执行状态机从步骤S03跳转的解码状态跳转到上一个解码状态;S05), the decoding information obtained from the decoding state determines the PCLK cycle required by the previous decoding state that the state state machine jumps in step S03, and then the instruction fetching state machine enters the normal instruction fetching state from the waiting state, and the decoding state machine is based on the decoded state. The information of the third instruction jumps to the third decoding timing state, and the execution state machine jumps from the decoding state jumped in step S03 to the previous decoding state;
    S06)、由解码状态所得的解码信息确定执行状态机在步骤S04跳转的上一个解码状态需要的PCLK周期,之后取指状态机从等待状态进入普通取指状态,解码状态机根据所解码的第四条指令的信息跳转到第四个解码时序状态,执行状态机从步骤S04跳转的解码状态跳转到上一个解码状态;S06), the decoding information obtained from the decoding state determines the PCLK cycle required to execute the previous decoding state that the state machine jumped in step S04, and then the instruction fetching state machine enters the normal instruction fetching state from the waiting state, and the decoding state machine is based on the decoded The information of the fourth instruction jumps to the fourth decoding timing state, and the execution state machine jumps from the decoding state jumped in step S04 to the previous decoding state;
    S07)、因为执行状态机在步骤S06跳转的上一个解码状态需要等待CTL接口上的某个输入信号与模式寄存器的对应位一致,具体等待时长取决于外设,两者一致之后,取指状态机进 入空闲状态,解码状态机根据所解码的第五条指令的信息跳转到第五个解码时序状态,执行状态机从步骤S06跳转的解码状态跳转到上一个解码状态;S07). Because the previous decoding state of the execution state machine jumped in step S06 needs to wait for a certain input signal on the CTL interface to be consistent with the corresponding bit of the mode register, the specific waiting time depends on the peripheral. After the two are consistent, fetch the instruction The state machine enters the idle state, the decoding state machine jumps to the fifth decoding timing state according to the information of the decoded fifth instruction, and the execution state machine jumps from the decoding state jumped in step S06 to the previous decoding state;
    S08)、由解码状态所得的解码信息确定执行状态机在步骤S07跳转的上一个解码状态需要的PCLK周期,之后解码状态机进入空闲状态,执行状态机从步骤S07跳转的解码状态跳转到上一个解码状态;S08), the decoding information obtained from the decoding state determines the PCLK cycle required for the previous decoding state that the execution state machine jumps in step S07, after which the decoding state machine enters the idle state, and the execution state machine jumps from the decoding state jumped in step S07 Go to the previous decoding state;
    S09)、由解码状态所得的解码信息确定执行状态机在步骤S08跳转的上一个解码状态需要的PCLK周期,之后执行状态机进入空闲状态。S09) The decoding information obtained from the decoding state determines the PCLK cycle required by the previous decoding state that the execution state machine jumps to in step S08, and then the execution state machine enters the idle state.
  8. 根据权利要求7所述的可编程gpio装置的时序实现方法,其特征在于:步骤S03中,解码状态机跳转到的解码时序状态为数据写出状态,步骤S04中,解码状态机跳转到的第二个解码时序状态为数据读入状态,执行状态机跳转到的上一个解码状态是数据写出状态,步骤S05中,解码状态机跳转的第三个解码时序状态是等待状态,执行状态机跳转的上一个解码状态是数据读入状态,步骤S06中,解码状态机跳转的第四个解码时序状态是控制输出状态,执行状态机跳转的上一个解码状态是等待状态,步骤S07中,解码状态机跳转的第五个解码时序状态是控制输入状态,执行状态机跳转的上一个解码状态是控制输出状态,步骤S08中,执行状态机跳转的上一个解码状态是控制输入状态。The time sequence implementation method of a programmable gpio device according to claim 7, characterized in that: in step S03, the decoding time sequence state to which the decoding state machine jumps is the data write state, and in step S04, the decoding state machine jumps to The second decoding timing state of the decoding state machine is the data reading state, and the last decoding state that the execution state machine jumps to is the data writing state. In step S05, the third decoding timing state of the decoding state machine jumping is the waiting state. The last decoding state of the execution state machine jump is the data read state. In step S06, the fourth decoding timing state of the decoding state machine jump is the control output state, and the last decoding state of the execution state machine jump is the waiting state. In step S07, the fifth decoding timing state of the decoding state machine jump is the control input state, and the previous decoding state that executed the state machine jump is the control output state. In step S08, the previous decoding state of the state machine jump is executed. The state is the control input state.
PCT/CN2019/093652 2019-01-28 2019-06-28 Programmable gpio device and time sequence implementation method based on the device WO2020155545A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910077385.4A CN109857485B (en) 2019-01-28 2019-01-28 Programmable gpio device and time sequence implementation method based on programmable gpio device
CN201910077385.4 2019-01-28

Publications (1)

Publication Number Publication Date
WO2020155545A1 true WO2020155545A1 (en) 2020-08-06

Family

ID=66896316

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/093652 WO2020155545A1 (en) 2019-01-28 2019-06-28 Programmable gpio device and time sequence implementation method based on the device

Country Status (2)

Country Link
CN (1) CN109857485B (en)
WO (1) WO2020155545A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109857485B (en) * 2019-01-28 2021-06-15 山东华芯半导体有限公司 Programmable gpio device and time sequence implementation method based on programmable gpio device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101377764A (en) * 2008-09-12 2009-03-04 北京中星微电子有限公司 Allocating system of GPIO and data communicating method thereof
CN201590076U (en) * 2010-02-10 2010-09-22 青岛海信移动通信技术股份有限公司 Interface extending circuit and mobile terminal with the circuit
CN103297163A (en) * 2012-02-22 2013-09-11 安凯(广州)微电子技术有限公司 Method and device for simulating PCM communication through GPIO ports
US20180329837A1 (en) * 2017-05-10 2018-11-15 Qualcomm Incorporated Input/output direction decoding in mixed vgpio state exchange
CN109857485A (en) * 2019-01-28 2019-06-07 山东华芯半导体有限公司 A kind of programmable gpio device and the timing implementation method based on the device

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1292568C (en) * 2001-09-02 2006-12-27 中兴通讯股份有限公司 Device and method for group continuous transfer of multi-team data
CN101154207A (en) * 2006-09-29 2008-04-02 上海海尔集成电路有限公司 Operating method for configured interface of microcontroller
CN101154183B (en) * 2006-09-29 2011-12-28 上海海尔集成电路有限公司 Microcontroller built-in type on-line simulation debugging system
CN102929836B (en) * 2012-08-17 2015-06-10 中国科学院空间科学与应用研究中心 Special ASIC (Application Specific Integrated Circuit) chip system for spaceflight
US9129072B2 (en) * 2012-10-15 2015-09-08 Qualcomm Incorporated Virtual GPIO
CN103729165A (en) * 2014-01-16 2014-04-16 哈尔滨工业大学 PCI (peripheral component interconnect) slave unit core control module applied to high-speed motion control system
CN105224345B (en) * 2014-05-28 2019-02-15 株洲变流技术国家工程研究中心有限公司 A kind of programmable logic device remote update system and its method
US20170168966A1 (en) * 2015-12-10 2017-06-15 Qualcomm Incorporated Optimal latency packetizer finite state machine for messaging and input/output transfer interfaces
CN105808480A (en) * 2016-03-01 2016-07-27 联发科技(新加坡)私人有限公司 Role switching method and system of USB (Universal Serial Bus) OTG (On-The-Go) equipment, and USB OTG equipment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101377764A (en) * 2008-09-12 2009-03-04 北京中星微电子有限公司 Allocating system of GPIO and data communicating method thereof
CN201590076U (en) * 2010-02-10 2010-09-22 青岛海信移动通信技术股份有限公司 Interface extending circuit and mobile terminal with the circuit
CN103297163A (en) * 2012-02-22 2013-09-11 安凯(广州)微电子技术有限公司 Method and device for simulating PCM communication through GPIO ports
US20180329837A1 (en) * 2017-05-10 2018-11-15 Qualcomm Incorporated Input/output direction decoding in mixed vgpio state exchange
CN109857485A (en) * 2019-01-28 2019-06-07 山东华芯半导体有限公司 A kind of programmable gpio device and the timing implementation method based on the device

Also Published As

Publication number Publication date
CN109857485B (en) 2021-06-15
CN109857485A (en) 2019-06-07

Similar Documents

Publication Publication Date Title
TWI731200B (en) A slave device connnected to host by 12c bus and its communication method
US6701405B1 (en) DMA handshake protocol
US6829660B2 (en) Supercharge message exchanger
US20090210572A1 (en) Computer command and response for determining the state of an i/o operation
JPH02227765A (en) Data transfer apparatus for digital computer
US20090210579A1 (en) Open exchange limiting in an i/o processing system
CN101221541B (en) Programmable communication controller for SOC and its programming model
US20080177909A1 (en) Content Terminated DMA
US7640375B2 (en) DMA controller, method, information processing system, and program for transferring information blocks comprising data and descriptors
US20070055813A1 (en) Accessing external memory from an integrated circuit
WO2023174086A1 (en) Universal interface register system and rapid generation method
US6745301B2 (en) Microcontroller programmable method for accessing external memory in a page mode operation
US7197590B2 (en) Method and apparatus for connecting LPC bus and serial flash memory
CN103714026A (en) Memorizer access method and device supporting original-address data exchange
US20190310779A1 (en) Extensible storage system and method
CN113849433A (en) Bus controller execution method and device, bus controller, computer equipment and storage medium
CN106980587B (en) General input/output time sequence processor and time sequence input/output control method
US20190271740A1 (en) Non-intrusive on-chip debugger with remote protocol support
WO2020155545A1 (en) Programmable gpio device and time sequence implementation method based on the device
CN109783933B (en) Bridging method for SRAM on AHB bus access chip
CN103793263A (en) DMA transaction-level modeling method based on Power PC processor
EP3236350B1 (en) Tigersharc series dsp start-up management chip and method
CN102193860A (en) Microcontroller online debugging circuit and method as well as microcontroller
CN114721983B (en) DDR4 accelerating read-write device
CN104461796A (en) JTAG (joint test action group) debugging module and method for embedded 8051CPU (central processing unit)

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: 19912293

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: 19912293

Country of ref document: EP

Kind code of ref document: A1