Bus system based on RISC-V instruction set architecture data encryption chip and control method

By designing an embedded encryption chip based on the RISC-V instruction set architecture, encapsulating the encryption module as IP and plugging it into the on-chip bus, the problem of increased overhead and non-universality of hardware-level encryption methods is solved, and high performance suitable for embedded devices is achieved. , low-power encryption system.

CN118535523APending Publication Date: 2024-08-23LIAONING UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410602564.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-15
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

The existing data encryption method of the RISC-V instruction set architecture increases the processor hardware overhead at the hardware level and is not versatile, making it difficult to meet the high-speed security encryption requirements of embedded devices.

Method used

A data encryption chip based on RISC-V instruction set architecture is designed. The encryption module is packaged into encryption IP and plugged into the on-chip bus to form a SOC encryption system. It supports AES and DES encryption and decryption without adding circuit logic and instructions. Users do not need to Understand the underlying principles of encryption and apply to embedded devices.

Benefits of technology

It implements a compact, flexible, and versatile encryption system that consumes low resources and is suitable for embedded devices. Its performance is higher than that of Cortex-M0 and E203 processors, and it has high security and low power consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535523A
    Figure CN118535523A
Patent Text Reader

Abstract

According to the bus system on the data encryption chip based on the RISC-V instruction set architecture and the control method, the requirements for minimizing energy consumption and size in the design are considered, and the balance of pipeline resource allocation is ensured, so that the overall time sequence performance is not sacrificed. Based on the requirements, a simplified and efficient three-stage pipeline design is provided, and according to the design, the memory access stage and the write-back stage in a traditional five-stage pipeline are integrated into the execution stage, so that the power consumption and the physical size of a processor are reduced. Furthermore, the invention designs a processor device of an RV32IM instruction set architecture provided with an AXI-Lite interface. An AXI-Lite system bus is established on the basis of a self-developed processor core, a peripheral module with a corresponding bus interface is designed according to the research of a UART transmission protocol and a DES encryption and decryption algorithm, and finally the design work of the data encryption SoC system is successfully completed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of integrated circuit design and processor design, and specifically relates to a bus system and a control method on a data encryption chip based on a RISC-V instruction set architecture. Background Art

[0002] RISC-V is an open source instruction set architecture designed according to the RISC principle. Its instruction set embodies the characteristics of simplicity and modularity, adopts an ordered instruction encoding format, and provides abundant expansion space. Generally, commercial data encryption methods are mainly divided into two types: software level and hardware level. In software-level encryption, the underlying chip architecture is not involved, which is more versatile. However, considering the limited efficiency and security of software encryption on CPU resources, and the increasing possibility of software encryption being cracked due to external threats, software encryption can no longer meet the needs of high-speed and secure encryption. At present, RISC-V has officially launched the scalar encryption instruction set standard, which provides design guidance for encryption operations at the hardware level. All instructions proposed in it use common X registers and comply with 2 read-1 write register access constraints. These instructions are designed to be lightweight and suitable for 32-bit and 64-bit infrastructures, from embedded IoT-like cores to large application-like cores that do not implement vector units. The encryption instruction set implements encryption functions at the instruction level, which requires additional logic circuits for decoding and execution, increasing the hardware overhead of the processor and posing challenges to embedded and other usage scenarios. At the same time, the use of encryption instructions requires understanding the underlying chip architecture and is not universal. Summary of the invention

[0003] In order to solve the above problems, the present invention proposes a bus system and control method based on the RISC-V instruction set architecture data encryption chip. The present invention encapsulates each encryption module into an encryption IP, and plugs it into the on-chip bus to form a SOC encryption system. The system does not need to add relevant circuit logic and instructions, and users do not need to understand the underlying encryption principles when using it. It has the characteristics of being small, flexible, and universal. It supports AES and DES encryption and decryption, and is suitable for miniaturization demand scenarios such as embedded systems.

[0004] The present invention is achieved through the following technical solutions:

[0005] The bus system on the data encryption chip based on the RISC-V instruction set architecture includes serial port I, processor core, AXI system bus module, data storage module, AES encryption and decryption module, DES encryption and decryption module, serial port II, and GPIO module;

[0006] Serial port I transmits host computer instructions to the processor core; the processor core exchanges data with the data storage module, AES encryption and decryption module, DES encryption and decryption module, serial port II, and GPIO module through the AXI system bus module; the serial port II exchanges data with the host computer.

[0007] Serial port I consists of a baud rate generating module and a receiving module. The baud rate generating module simulates bit rate sampling through a counter and generates a sampling clock at the midpoint of the count value to reduce the generation of glitches during the sampling process. The sampling clock output by the baud rate generating module drives the receiving module to sample the serial port signal. After sampling 8 times, the sampling bytes are output, and the sampling bytes are spliced ​​into an instruction word in the sending order. Then, the instruction word is output and the effective enable signal is pulled high.

[0008] The processor core includes a register Regfile module, a control module CTRL module, an instruction fetch IF module, a decoding ID module, an execution EX module, a divider DIV module, a multiplier MUL module, an external interrupt arbitration module, an external interrupt control clint module, and a special control status register CSR module.

[0009] The data of the external instruction memory is transmitted to the instruction fetch IF module, the data of the instruction fetch IF module is transmitted to the decoding ID module, the data of the decoding ID module is transmitted to the execution EX module, and the data of the execution EX module is transmitted to the external data memory; the division instruction of the decoding ID module is transmitted to the divider DIV module, and then transmitted to the execution EX module by the divider DIV module; the multiplication instruction of the execution EX module is transmitted to the multiplier MUL module, and then returned to the execution EX module by the multiplier MUL module;

[0010] The EX module data is written back to the special control status register CSR module; the EX module data is written back to the register Regfile module, and the register Regfile module data is transmitted to the static score prediction BP in the decoding ID module and the instruction fetching IF module;

[0011] The external interrupt data is transmitted to the external interrupt arbitration module, the external interrupt arbitration module data is transmitted to the external interrupt control clint module, and the external interrupt control clint module data is transmitted to the special control status register CSR module;

[0012] The control application of the decoding ID module, the execution EX module and the external interrupt control clint module is transmitted to the control module CTRL module; the control signal of the control module CTRL module is transmitted to the execution EX module, the decoding ID module and the instruction fetch IF module; the jump signal of the control module CTRL module is transmitted to the instruction fetch IF module.

[0013] The AXI system bus module is composed of an AXI bus interconnection module, an AXI slave interface and an AXI host interface, wherein the AXI bus interconnection module and the AXI slave interface adopt the IP core officially provided by Xilinx, and the AXI host interface is composed of an AXI master bus module and a transmission state machine; when the AXI master initiates reading and writing, the state machine initiates a CPU pipeline pause and enters a state of waiting for transmission completion; when the AXI bus transmission is completed, the completion signal AXI_DONE is pulled high, the state machine applies to end the CPU pause and enters an initial state to wait for the next AXI reading and writing operation.

[0014] The control method of the bus system on the data encryption chip based on the RISC-V instruction set architecture is as follows:

[0015] 1) The host computer sends the control instruction to the serial port I module through the serial transmission bus. The serial port I module splices the received bytes into 32-bit instructions and transmits them to the instruction memory in the processor core for storage;

[0016] 2) After the instruction is transmitted, the host computer transmits the data to be encrypted and decrypted to the serial port II module through the serial transmission bus, and the serial port II module stores the data to be encrypted and decrypted in the internal receiving FIFO;

[0017] 3) After the processor core starts working, it decodes and executes the instructions, reads the data to be encrypted and decrypted in the receiving FIFO of the serial port II module through the system bus, and transmits it to the AES encryption and decryption module or the DES encryption and decryption module for encryption and decryption operations;

[0018] 4) After encryption and decryption are completed, the data is read out from the encryption and decryption module and sent back to the sending FIFO in the serial port II module for storage of the data to be sent. When the sending FIFO in the serial port II module is not empty, the data is automatically transmitted to the host computer.

[0019] The instruction fetch IF module in the processor core fetches instructions from the instruction memory, which is composed of a program counter module and a branch prediction module; the program counter outputs the instruction address of the instruction to be fetched, and after the instruction is fetched, it is input into the branch prediction module for static branch prediction. Since the instruction memory needs one clock cycle to output the instruction, it is necessary to perform beat alignment before inputting it into the branch prediction module; the program counter is controlled by the control module; the static branch prediction realizes the jump of the J-type instruction and predicts the jump status of the B-type instruction. At the same time, the static branch prediction module decodes the source register RS1 and reads the value of the register;

[0020] The decoding ID module in the processor core decodes the instruction according to the instruction type, generates the write destination register enable, write destination register address, operand 1, operand 2, decodes the source register RS1 and reads the value of the register, and reads the corresponding CSR register value; the decoding stage makes a judgment on the final jump of the B-type instruction and its jump address based on the conditional jump prediction generated by the branch prediction module, and makes a corresponding pipeline flush request; if the instruction is a division instruction, a divider pause signal request is generated to the control module in the decoding stage to pause the pipeline.

[0021] The execution EX module in the processor core further calculates the write destination register value according to the instruction type; when encountering an instruction to read or write an external device, the execution module generates corresponding read / write signals, addresses and data; when the write CSR register instruction reaches the execution stage, it generates relevant write CSR register signals and data; the execution EX module also generates the multiplicand and multiplier values ​​required for multiplication and generates a multiplication pause pipeline request signal at the same time to pause the pipeline;

[0022] The external interrupt arbitration module in the processor core provides four external interrupt input interfaces, and uses arbitration polling to arbitrate the priority of external interrupts. Polling arbitration allows the four external interrupt inputs to have the same chance to be processed by the CPU. After arbitration, the priority external interrupt number is input to the external interrupt control module.

[0023] The external interrupt control clint module in the processor core is used to judge and process the input external interrupt; when the external interrupt signal is valid, the external interrupt control module will judge the type of interrupt, generate the return address, select the exception cause, and configure the relevant CSR register status, and then control the instruction fetch module to jump to the entry address of the interrupt service function, so that the program executes the interrupt service function; when exiting the exception, the external interrupt control module will judge and configure the relevant special register status, control the instruction fetch module to jump to the return function address, and thus return to the main function.

[0024] The encryption and decryption method is specifically as follows:

[0025] The DES encryption and decryption module uses a pipeline structure, dividing the encryption process into multiple pipeline stages, namely initial permutation, first round of encryption, second round of encryption, ..., sixteenth round of encryption, and inverse permutation;

[0026] The bus writes the data to be encrypted and decrypted into the encryption and decryption module through the AXI interface. After the data is transmitted to the module, it enters the IP module for initial transposition. After the transposition is completed, it enters the first round of encryption module of des for encryption and decryption. The encryption and decryption module consists of a key generation module and an encryption polling module. The key generation module will select the current number of polling according to the encryption and decryption requirements. The key is provided from 0 to 15 during encryption and from 15 to 0 during decryption; according to the number of polling, the corresponding secret key is provided to the encryption polling module for iteration. The encryption polling module is responsible for completing the extended transposition, XOR with the key, S box lookup table replacement, P box replacement, and XOR with the left plaintext. After each round of polling, the left and right inscriptions required for the next round will be output. After the polling is completed, the ciphertext is obtained through inverse transformation, and the ciphertext and work_done signal are output; the work_done signal is ANDed with the read handshake signal of the AXI interface. When work_done is valid, AXI can read the data encrypted and decrypted by the module.

[0027] Each round of DES encryption and decryption module consists of a key generation module and an encryption polling module; the key generation module provides the subkeys required for each round of encryption polling, and the subkeys are generated by the master key through the key scheduling algorithm. The key scheduling algorithm of the DES algorithm divides the 64-bit master key into 16 subkeys, each with 48 bits, which are used to perform XOR operations with the input data in each round of encryption; after the 64-bit key enters the key generation module, it is first PC-1 permuted. After the permutation is completed, the key becomes 56 bits, which is divided into two 28-bit left and right data blocks for cyclic left shift operations respectively. The rule is that according to the number of polling i=1, 2, ..., 16, for C i and D i If i is 1, 2, 9 or 16, it will be shifted left by one bit, otherwise it will be shifted left by two bits. After the cycle is completed, PC-2 permutation is performed, and the key output after permutation is 48 bits;

[0028] The encryption polling module consists of expansion permutation, XOR with subkey, S box permutation, and P box permutation; the encryption formula for each round is specified in DES encryption

[0029]

[0030] L i =R i-1

[0031] It can be seen that the left plaintext of the next round of encrypted data is equal to the right inscription of the previous round of encryption, and the right inscription will be expanded and permuted to 48 bits after entering the Fi function, and then XORed with the subkey, and then enter the S box for table lookup. The S box will perform nonlinear encryption on the data to compress the 48-bit result to 32 bits, and then perform P box permutation to obtain the output of the F function of this round, and then XOR with the left plaintext to obtain the right plaintext of the next round of encrypted data;

[0032] The AES encryption and decryption module design uses a state machine to divide the AES encryption process into byte substitution module, row shift module, column mixing module, round key addition module, and key expansion module for encryption and decryption operations. In each state, these modules are referenced according to the AES encryption and decryption rules to complete the encryption and decryption tasks. The overall operating frequency of the AES module is 530MHZ, and the data encryption and decryption performance is 1.689Gbps.

[0033] When the host computer sends the data to be encrypted and decrypted through the serial port II, the data will be input into the serial port receive FIFO through the serial port receive pin RX for buffering. When the serial port II receive FIFO is empty, rx_fifo_empty is pulled high, the serial port receive FIFO does not buffer any data, and the AXI interface is prohibited from reading at this time; when rx_fifo_empty is at a low level, the AXI interface can read the data; when the encryption and decryption is completed, the system sends the data to the host computer through the serial port II module. After the data on the AXI bus enters the serial port II module, the data is received through the AXI slave interface and then transmitted to the transmit FIFO; when the serial port transmit FIFO is empty, tx_fifo_empty is pulled high, and the serial port transceiver module is prohibited from sending; otherwise, the serial port send state machine jumps to the send state and starts sending the encrypted and decrypted data; when the send FIFO is full, the tx_fifo_full signal is high, and the AXI interface is prohibited from writing the data to be sent.

[0034] The beneficial effects created by the present invention are as follows: the present SoC consumes a total of 2224 Slices units, of which 5884 LUT logic units are consumed. The overall resource consumption of the SoC is very small, and it can be transplanted on various FPGA development boards. It has the characteristics of miniaturization and meets the design requirements of embedded devices. The total power consumption is only 0.171W, which has the characteristics of low power consumption. The operating frequency of the processor is 100M, and the logic resources consumed are 3895 LUTs. The performance is much higher than that of the Cortex-M0 and the E203 processor of Core Technology. The DES and AES encryption and decryption modules have very high encryption and decryption performance. Therefore, the present invention has very high security. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Figure 1 The overall structure diagram of the system;

[0036] Figure 2 This is the structure diagram of the serial port I module;

[0037] Figure 3 This is a diagram of the processor pipeline structure;

[0038] Figure 4 This is the top-level structure diagram of the processor;

[0039] Figure 5This is the overall structure diagram of the DES encryption module;

[0040] Figure 6 This is the structure diagram of each round of encryption and decryption module;

[0041] Figure 7 This is the structure diagram of the serial port 2 module. DETAILED DESCRIPTION

[0042] The present invention is composed of a processor core, an AXI system bus module, a data storage module, an AES encryption and decryption module, a DES encryption and decryption module, a serial port I, a serial port module II, and a GPIO module. The overall design structure diagram is shown in FIG. Figure 1 As shown.

[0043] The host computer sends the control instruction to the serial port I module through the serial transmission bus. The serial port I module splices the received bytes into 32-bit instructions and transmits them to the instruction memory in the processor core for storage. After transmitting the instruction, the host computer transmits the data to be encrypted and decrypted to the serial port II module through the serial transmission bus. The serial port II module stores the data to be encrypted and decrypted in the internal receiving FIFO. After the processor core starts working, it decodes and executes the instruction, reads the data to be encrypted and decrypted in the receiving FIFO of the serial port II module through the system bus, and transmits it to the AES encryption and decryption module or the DES encryption and decryption module for encryption and decryption operations. After the encryption and decryption is completed, the data is read from the encryption and decryption module and returned to the sending FIFO in the serial port II module for storage of the data to be sent. When the sending FIFO in the serial port II module is not empty, the data is automatically transmitted to the host computer. This design uses RISC-V assembly language to read and write access and control related peripherals, and realizes functions such as data encryption and data interaction with the host computer.

[0044] The serial port I module consists of a baud rate generation module and a receiving module. The baud rate generation module simulates bit rate sampling through a counter, and generates a sampling clock at the midpoint of the count value to reduce the generation of glitches during the sampling process. The sampling clock output by the baud rate generation module drives the receiving module to sample the serial port signal, and outputs the sampled bytes after sampling 8 times. At the same time, the sampled bytes are spliced, and after being spliced ​​into an instruction word in the sending order, the instruction word is output and the enable valid signal is pulled high. The design diagram of the serial port module is shown in the figure below. Figure 2 shown.

[0045] The processor core is a multi-cycle three-stage pipeline CPU design based on the RISC-V IM instruction set architecture, which is divided into three stages: instruction fetch, decode, and execute. The processor implements the interrupt function and adds the WFI instruction to achieve the processor's low-power operation mode. The processor operation stage diagram and overall architecture diagram are shown in the figure. Figure 3 , Figure 4 shown.

[0046] The IF module is an instruction fetch module that fetches instructions from the instruction memory. It consists of a program counter module and a branch prediction module. The program counter outputs the instruction address of the instruction to be fetched. After the instruction is fetched, it is input into the branch prediction module for static branch prediction. Since the instruction memory needs one clock cycle to output the instruction, it is necessary to align the clock before inputting it into the branch prediction module. At the same time, the program counter is controlled by the control module. Static branch prediction implements the jump of J-type instructions and predicts the jump status of B-type instructions. At the same time, the static branch prediction module decodes the source register RS1 and reads the value of the register.

[0047] The decoding module ID decodes the instruction accordingly according to the instruction type, generates the write destination register enable, write destination register address, operand 1, operand 2, decodes the source register RS1 and reads the value of the register, and reads the corresponding CSR register value. The decoding stage makes a judgment on the final jump of the B-type instruction and its jump address based on the conditional jump prediction generated by the branch prediction module, and the corresponding pipeline flush request. If the instruction is a division instruction, a divider pause signal request is generated to the control module in the decoding stage to pause the pipeline.

[0048] The execution module EX further calculates the write destination register value according to the instruction type. When encountering an instruction to read or write an external device, the execution module generates corresponding read and write signals, addresses and data. When the instruction to write the CSR register reaches the execution stage, it generates relevant write CSR register signals and data. The execution module also generates the multiplicand and multiplier values ​​required for multiplication and simultaneously generates a multiplication pause pipeline request signal to pause the pipeline.

[0049] The external interrupt arbitration module provides four external interrupt input interfaces, and uses arbitration polling to arbitrate the priority of external interrupts. Polling arbitration allows the four external interrupt inputs to have the same chance to be processed by the CPU. After arbitration, the priority external interrupt number is input to the external interrupt control module.

[0050] The external interrupt control module is used to judge and process the input external interrupt. When the external interrupt signal is valid, the external interrupt control module will judge the type of interrupt, generate the return address, select the exception cause, and configure the relevant CSR register status, and then control the instruction fetch module to jump to the entry address of the interrupt service function, so that the program executes the interrupt service function. Similarly, when the exception is exited, the external interrupt control module will judge and configure the status of the relevant special registers, and then control the instruction fetch module to jump to the return function address, thereby returning to the main function.

[0051] The AXI system bus module consists of an AXI bus interconnect module, an AXI slave interface, and an AXI host interface. The AXI bus interconnect module and the AXI slave interface use the IP core officially provided by Xilinx. The AXI host interface consists of an AXI master bus module and a transmission state machine. When the AXI master initiates a read or write, the state machine initiates a CPU pipeline pause and enters the waiting state for the transmission. When the AXI bus transmission is completed, the completion signal AXI_DONE is pulled high, and the state machine applies to end the CPU pause and enter the initial state to wait for the next AXI read or write operation.

[0052] The DES encryption module uses a pipeline structure, dividing the encryption process into multiple pipeline stages, namely initial permutation, first round of encryption, second round of encryption, ..., sixteenth round of encryption, and inverse permutation. Due to the use of a pipeline structure, this module has a large data throughput.

[0053] The module operates at a frequency of 530MHZ, has a data throughput of 33.92Gbps, and a data encryption and decryption performance of 1.88Gbps, meeting the design requirements. The overall structure of the DES encryption module is shown in the figure below. Figure 5 shown.

[0054] The bus writes the data to be encrypted and decrypted into the encryption and decryption module through the AXI interface. After the data is transmitted to the module, it enters the IP module for initial transposition. After the transposition is completed, it enters the first round of encryption module of des for encryption and decryption. The encryption and decryption module consists of a key generation module and an encryption polling module. The key generation module will select the current number of polling according to the encryption and decryption requirements. The key is provided from 0 to 15 during encryption and from 15 to 0 during decryption. The corresponding secret key is provided to the encryption polling module for iteration according to the number of polling. The encryption polling module is responsible for completing the extended transposition, XOR with the key, S box lookup table replacement, P box replacement, and XOR with the left plaintext. After each round of polling, the left and right inscriptions required for the next round will be output. After the polling is completed, the ciphertext is obtained through inverse transformation, and the ciphertext and work_done signal are output. The work_done signal is ANDed with the read handshake signal of the AXI interface. When work_done is valid, AXI can read the data encrypted and decrypted by the module.

[0055] Each round of DES encryption and decryption modules is as follows Figure 6 As shown, it consists of a key generation module and an encryption polling module. The DES encryption module operates at a frequency of 530MHZ, has a data throughput of 33.92Gbps, and a data encryption and decryption performance of 1.88Gbps.

[0056] The key generation module provides the subkeys required for each round of encryption polling. The subkeys are generated from the master key through the key scheduling algorithm. The key scheduling algorithm of the DES algorithm can divide the 64-bit master key into 16 subkeys, each with 48 bits, which are used for XOR operation with the input data in each round of encryption. After the 64-bit key enters the key generation module, it first undergoes PC-1 permutation. After the permutation, the key becomes 56 bits. It is divided into two 28-bit data blocks on the left and right and performs cyclic left shift operations respectively. The rule is that according to the number of polling i=1, 2,..., 16, for Ci and Di, if i is 1, 2, 9 or 16, it is cyclically shifted to the left by one bit, otherwise it is cyclically shifted to the left by two bits. After the cycle is completed, PC-2 permutation is performed, and the permuted key output is 48 bits.

[0057] The encryption polling module consists of expansion permutation, XOR with subkey, S box permutation, and P box permutation. The encryption formula for each round in DES encryption is

[0058]

[0059] L i =R i-1

[0060] It can be seen that the left plaintext of the next round of encrypted data is equal to the right inscription of the previous round of encryption, and after the right inscription enters the Fi function, it will first be expanded and permuted to 48 bits, and then XORed with the subkey, and then enter the S box for table lookup. The S box will perform nonlinear encryption on the data to compress the 48-bit result to 32 bits, and then perform P box permutation to obtain the output of this round of F function. After the output, it will be XORed with the left plaintext to obtain the right plaintext of the next round of encrypted data.

[0061] The AES module design uses a state machine to divide the AES encryption process into byte substitution module, row shift module, column mixing module, round key addition module, and key expansion module for encryption and decryption operations. In each state, these modules are referenced according to the AES encryption and decryption rules to complete the encryption and decryption tasks. The overall operating frequency of the AES module is 530MHZ, and the data encryption and decryption performance is 1.689Gbps.

[0062] The serial port II module consists of an AXI slave interface, a receive FIFO, a transmit FIFO, and a serial port transceiver module. The depth is set to 16 and the width is 8 bits. Figure 7 shown.

[0063] When the host computer sends the data to be encrypted and decrypted through the serial port 2, the data will be input to the serial port receive FIFO through the serial port receive pin RX for buffering. When the serial port receive FIFO is empty, rx_fifo_empty is pulled high, and the serial port receive FIFO does not buffer any data. At this time, the AXI interface is prohibited from reading; when rx_fifo_empty is low, the AXI interface can read the data. When the encryption and decryption is completed, the system sends the data to the host computer through the serial port II module. After the data on the AXI bus enters the serial port II module, the data is received through the AXI slave interface and then transmitted to the transmit FIFO. When the serial port transmit FIFO is empty, tx_fifo_empty is pulled high, and the serial port transceiver module is prohibited from sending; otherwise, the serial port send state machine jumps to the send state and starts to send the encrypted and decrypted data. When the transmit FIFO is full, the tx_fifo_full signal is high, and the AXI interface is prohibited from writing the data to be sent.

Claims

1. Bus system on the data encryption chip based on RISC-V instruction set architecture, It is characterized in that Including serial port I, processor core, AXI system bus module, data storage module, AES encryption and decryption module, DES encryption and decryption module, serial port II, GPIO module; The serial port I transmits the host computer instructions to the processor core; the processor core exchanges data with the data storage module, AES encryption and decryption module, DES encryption and decryption module, serial port II, and GPIO module through the AXI system bus module; the serial port II exchanges data with the host computer.

2. The bus system on a data encryption chip based on the RISC-V instruction set architecture according to claim 1, It is characterized in that The serial port I is composed of a baud rate generating module and a receiving module. The baud rate generating module simulates bit rate sampling through a counter, and generates a sampling clock at the midpoint of the count value to reduce the generation of burrs during the sampling process; the sampling clock output by the baud rate generating module drives the receiving module to sample the serial port signal, and outputs the sampling bytes after sampling 8 times. The sampling bytes are spliced, and after being spliced ​​into an instruction word in the sending order, the instruction word is output and the effective enable signal is pulled high.

3. The bus system on a data encryption chip based on the RISC-V instruction set architecture according to claim 1, It is characterized in that The processor core comprises a register Regfile module, a control module CTRL module, an instruction fetch IF module, a decoding ID module, an execution EX module, a divider DIV module, a multiplier MUL module, an external interrupt arbitration module, an external interrupt control clint module, and a special control status register CSR module.

4. The bus system on a RISC-V instruction set architecture data encryption chip according to claim 3, It is characterized in that The data of the external instruction memory is transmitted to the instruction fetch IF module, the data of the instruction fetch IF module is transmitted to the decoding ID module, the data of the decoding ID module is transmitted to the execution EX module, and the data of the execution EX module is transmitted to the external data memory; the division instruction of the decoding ID module is transmitted to the divider DIV module, and then transmitted to the execution EX module by the divider DIV module; the multiplication instruction of the execution EX module is transmitted to the multiplier MUL module, and then returned to the execution EX module by the multiplier MUL module; The EX module data is written back to the special control status register CSR module; the EX module data is written back to the register Regfile module, and the register Regfile module data is transmitted to the static score prediction BP in the decoding ID module and the instruction fetching IF module; The external interrupt data is transmitted to the external interrupt arbitration module, the external interrupt arbitration module data is transmitted to the external interrupt control clint module, and the external interrupt control clint module data is transmitted to the special control status register CSR module; The control application of the decoding ID module, the execution EX module and the external interrupt control clint module is transmitted to the control module CTRL module; the control signal of the control module CTRL module is transmitted to the execution EX module, the decoding ID module and the instruction fetch IF module; the jump signal of the control module CTRL module is transmitted to the instruction fetch IF module.

5. The bus system on a data encryption chip based on the RISC-V instruction set architecture according to claim 1, It is characterized in that The AXI system bus module is composed of an AXI bus interconnection module, an AXI slave interface and an AXI host interface, wherein the AXI bus interconnection module and the AXI slave interface adopt the IP core officially provided by Xilinx, and the AXI host interface is composed of an AXI master bus module and a transmission state machine; when the AXI master initiates reading and writing, the state machine initiates a CPU pipeline pause and enters a state of waiting for transmission completion; when the AXI bus transmission is completed, the completion signal AXI_DONE is pulled high, the state machine applies to end the CPU pause and enters an initial state to wait for the next AXI reading and writing operation.

6. A method for controlling a bus system on a RISC-V instruction set architecture data encryption chip using any one of claims 1 to 5, It is characterized in that The steps are: 1) The host computer sends the control instruction to the serial port I module through the serial transmission bus. The serial port I module splices the received bytes into 32-bit instructions and transmits them to the instruction memory in the processor core for storage; 2) After the instruction is transmitted, the host computer transmits the data to be encrypted and decrypted to the serial port II module through the serial transmission bus, and the serial port II module stores the data to be encrypted and decrypted in the internal receiving FIFO; 3) After the processor core starts working, it decodes and executes the instructions, reads the data to be encrypted and decrypted in the receiving FIFO of the serial port II module through the system bus, and transmits it to the AES encryption and decryption module or the DES encryption and decryption module for encryption and decryption operations; 4) After encryption and decryption are completed, the data is read out from the encryption and decryption module and sent back to the sending FIFO in the serial port II module for storage of the data to be sent. When the sending FIFO in the serial port II module is not empty, the data is automatically transmitted to the host computer.

7. The control method of the bus system on the RISC-V instruction set architecture data encryption chip according to claim 6, It is characterized in that The instruction fetch IF module in the processor core fetches instructions from the instruction memory, and is composed of a program counter module and a branch prediction module; the program counter outputs the instruction address of the instruction to be fetched, and after the instruction is fetched, it is input into the branch prediction module for static branch prediction. Since the instruction memory needs one clock cycle to output the instruction, it is necessary to perform beat alignment before inputting it into the branch prediction module; the program counter is controlled by the control module; the static branch prediction realizes the jump of the J-type instruction and predicts the jump state of the B-type instruction, and at the same time, the static branch prediction module decodes the source register RS1 and reads the value of the register; The decoding ID module in the processor core decodes the instruction accordingly according to the instruction type, generates the write destination register enable, the write destination register address, operand 1, operand 2, decodes the source register RS1 and reads the value of the register, and reads the corresponding CSR register value; the decoding stage makes a judgment on the final jump of the B-type instruction and its jump address according to the conditional jump prediction generated by the branch prediction module, and simultaneously makes a corresponding pipeline flush request; if the instruction is a division instruction, a divider pause signal application is generated to the control module in the decoding stage to pause the pipeline. The execution EX module in the processor core further calculates the write destination register value according to the instruction type; when encountering an instruction to read or write an external device, the execution module generates corresponding read / write signals, addresses and data; when the write CSR register instruction reaches the execution stage, it generates relevant write CSR register signals and data; the execution EX module also generates the multiplicand and multiplier values ​​required for multiplication and simultaneously generates a multiplication pause pipeline request signal to pause the pipeline; The external interrupt arbitration module in the processor core provides four external interrupt input interfaces, and uses arbitration polling to perform priority arbitration on the external interrupts. The polling arbitration ensures that the four external interrupt inputs have the same chance to be processed by the CPU. After arbitration, the priority external interrupt number is input to the external interrupt control module; The external interrupt control clint module in the processor core is used to judge and process the input external interrupt; when the external interrupt signal is valid, the external interrupt control module will judge the type of interrupt, generate the return address, select the exception cause, and configure the relevant CSR register state, and then control the instruction fetch module to jump to the entry address of the interrupt service function, so that the program executes the interrupt service function; when exiting the exception, the external interrupt control module will judge and configure the relevant special register state, control the instruction fetch module to jump to the return function address, and thus return to the main function.

8. The control method of the bus system on the RISC-V instruction set architecture data encryption chip according to claim 6, It is characterized in that The encryption and decryption method is specifically as follows: The DES encryption and decryption module uses a pipeline structure, dividing the encryption process into multiple pipeline stages, namely initial permutation, first round encryption, second round encryption, ..., sixteenth round encryption, and inverse permutation; The bus writes the data to be encrypted and decrypted into the encryption and decryption module through the AXI interface. After the data is transmitted to the module, it enters the IP module for initial transposition. After the transposition is completed, it enters the first round of encryption module of des for encryption and decryption. The encryption and decryption module consists of a key generation module and an encryption polling module. The key generation module will select the current number of polling according to the encryption and decryption requirements. The key is provided from 0 to 15 during encryption and from 15 to 0 during decryption; according to the number of polling, the corresponding secret key is provided to the encryption polling module for iteration. The encryption polling module is responsible for completing the extended transposition, XOR with the key, S box lookup table replacement, P box replacement, and XOR with the left plaintext. After each round of polling, the left and right inscriptions required for the next round will be output. After the polling is completed, the ciphertext is obtained through inverse transformation, and the ciphertext and work_done signal are output; the work_done signal is ANDed with the read handshake signal of the AXI interface. When work_done is valid, AXI can read the data encrypted and decrypted by the module. Each round of DES encryption and decryption module consists of a key generation module and an encryption polling module; the key generation module provides the subkeys required for each round of encryption polling, and the subkeys are generated by the master key through the key scheduling algorithm. The key scheduling algorithm of the DES algorithm divides the 64-bit master key into 16 subkeys, each with 48 bits, which are used to perform XOR operations with the input data in each round of encryption; after the 64-bit key enters the key generation module, it is first PC-1 permuted. After the permutation is completed, the key becomes 56 bits, which is divided into two 28-bit left and right data blocks for cyclic left shift operations respectively. The rule is that according to the number of polling i=1, 2, ..., 16, for C i and D i If i is 1, 2, 9 or 16, it will be shifted left by one bit, otherwise it will be shifted left by two bits. After the cycle is completed, PC-2 permutation is performed, and the key output after permutation is 48 bits; The encryption polling module consists of expansion permutation, XOR with subkey, S box permutation, and P box permutation; the encryption formula for each round is specified in DES encryption L i =R i-1 It can be seen that the left plaintext of the next round of encrypted data is equal to the right inscription of the previous round of encryption, and the right inscription will be expanded and permuted to 48 bits after entering the Fi function, and then XORed with the subkey, and then enter the S box for table lookup. The S box will perform nonlinear encryption on the data to compress the 48-bit result to 32 bits, and then perform P box permutation to obtain the output of the F function of this round, and then XOR with the left plaintext to obtain the right plaintext of the next round of encrypted data; The AES encryption and decryption module design uses a state machine to divide the AES encryption process into byte substitution module, row shift module, column mixing module, round key addition module, and key expansion module for encryption and decryption operations. In each state, these modules are referenced according to the AES encryption and decryption rules to complete the encryption and decryption tasks. The overall operating frequency of the AES module is 530MHZ, and the data encryption and decryption performance is 1.689Gbps.

9. The control method of the bus system on the RISC-V instruction set architecture data encryption chip according to claim 6, It is characterized in that When the host computer sends the data to be encrypted and decrypted through the serial port II, the data will be input into the serial port receive FIFO through the serial port receive pin RX for buffering. When the serial port II receive FIFO is empty, rx_fifo_empty is pulled high, the serial port receive FIFO does not buffer any data, and the AXI interface is prohibited from reading at this time; when rx_fifo_empty is at a low level, the AXI interface can read the data; when the encryption and decryption is completed, the system sends the data to the host computer through the serial port II module. After the data on the AXI bus enters the serial port II module, the data is received through the AXI slave interface and then transmitted to the transmit FIFO; when the serial port transmit FIFO is empty, tx_fifo_empty is pulled high, and the serial port transceiver module is prohibited from sending; otherwise, the serial port send state machine jumps to the send state and starts to send the encrypted and decrypted data; when the send FIFO is full, the tx_fifo_full signal is high, and the AXI interface is prohibited from writing the data to be sent.