当前位置:网站首页>Analysis of cross clock transmission in tinyriscv
Analysis of cross clock transmission in tinyriscv
2022-06-30 07:36:00 【Snow fish】
I am a Snow fish , a FPGA lovers , The research direction is FPGA Architecture exploration .
Official account , Pull you in “IC Design communication group
”.
List of articles
I wrote this blog at the invitation of a friend , Explain tinyriscv Cross clock domain transmission in .
The resolved code path :
- tinyriscv\rtl\utils\full_handshake_rx
- tinyriscv\rtl\utils\full_handshake_tx
One 、full_handshake_rx
1.1 Input and output signals
Let's look at the interface first , The compiled schematic diagram is as follows :
On the left is the input signal , On the right is the output signal .
Signal name | Direction | effect |
---|---|---|
clk | input | Clock signal |
rst_n | input | Reset signal |
req_i | input | TX End request signal |
req_data_i | input | TX Input data at the end |
ack_o | output | RX Terminal response TX Terminal signal |
recv_data_o | output | RX The data received by the terminal |
recv_rdy_o | output | RX Whether the terminal receives the data signal |
1.2 Code logic
Look at the code first :
The classic three segment state machine , I have marked it with a red box , A three-stage state machine is a machine that will
- The transfer of state
- The generation of substates
- Generation of output results
Three are placed in three always Block , The advantage is clear logic , Fast , The disadvantage is that it takes up a lot of hardware resources .
This state machine , There are only two states , One is STATE_IDLE
, One is STATE_DEASSERT
.
After initial reset, it is in STATE_IDLE state , here
- When the request signal req = 1 when , Will be taken from STATE_IDLE The state shifts to STATE_DEASSERT state , And receive the data sent by the sender , And feedback the response signal .
So only in STATE_IDLE Status and req = 1 when , The receiving end can effectively receive data and respond .
There is another one in the code always block , It synchronizes the signal by taking two beats .
Two 、full_handshake_tx
2.1 Input and output signals
Let's look at the interface first , The compiled schematic diagram is as follows :
On the left is the input signal , On the right is the output signal .
Signal name | Direction | effect |
---|---|---|
clk | input | Clock signal |
rst_n | input | Reset signal |
ack_i | input | RX End response signal |
req_data_i | input | TX Data to be sent at the end , Just keep it up for one clock |
req_i | input | TX End request signal , Just keep it up for one clock |
idle_o | output | TX Whether the terminal is idle , Data can only be sent when idle |
req_o | output | TX End request signal |
req_data_o | output | TX Data to be sent at the end |
2.2 Code logic
Look at the code first :
The same classic three-stage state machine .
This state machine , There are three states :
- STATE_IDLE
- STATE_ASSERT
- STATE_DEASSERT
After initial reset, it is in STATE_IDLE state , here
- When the request signal req = 1 when , Will be taken from STATE_IDLE The state shifts to STATE_ASSERT state , And lock the data to be sent , And make a request to send data .
So only in STATE_IDLE Status and req = 1 when , The sending end can effectively send data and request the lower level rx Receiving data at the terminal .
3、 ... and 、 Cross clock domain transmission summary
First of all, you need to know why you need to synchronize across clock domains , stay tinyriscv Debug module for jtag_top
in , Two sub modules are implemented , Namely jtag_dm
and jtag_driver
, jtag_driver Realized JTAG TAP and DMI, Used to send according to the external debugger JTAG The signal came right DM Access operation . Here the problem arises , This access operation is based on JTAG TCK Signal generation ,tinyriscv The author is set to 1MHz, and jtag_dm The clock signal of is the system clock 50MHz, Accessing when the clock is out of sync is an error in most cases , Or the transmission data is wrong , Or the control signal is wrong when the data is correct , It should be well understood .
adopt full_handshake_tx
and full_handshake_rx
To realize that data is transmitted only when handshaking , Ensure the stability and correctness of data transmission .
In two modules with different clock domains , Both modules are added , Such as jtag_driver adopt full_handshake_tx Send data to jtag_dm
that jtag_dm adopt full_handshake_rx To receive data , Re pass full_handshake_tx Send feedback back to jtag_driver,jtag_driver adopt full_handshake_rx receive ,over. So this is Full handshake protocol
, Complete orientation dm Write data and reply back will shake hands four times . As shown in the figure below ,tx And rx A request or response to a is a handshake , That is, an arrow in the figure represents a handshake , Four times in all .
边栏推荐
- STM32 infrared communication 3 brief
- Introduction to ecostruxure (1) IEC61499 new scheme
- Intersection of two lines
- Mailbox application routine of running wild fire RT thread
- Final review -php learning notes 9-php session control
- Basic knowledge of compiling learning records
- C51 minimum system board infrared remote control LED light on and off
- halcon:读取摄像头并二值化
- Basic knowledge of system software development
- Distance from point to line
猜你喜欢
Parameter calculation of deep learning convolution neural network
Binary tree related operations (based on recursion, implemented in C language)
Keil plug-in Usage Summary
Raspberry pie 4B Getting Started Guide
Dynamic memory management
24C02
Final review -php learning notes 3-php process control statement
Thread pool - C language
2021 private equity fund market report (62 pages)
动态内存管理
随机推荐
Installation software operation manual (continuous update)
Log service management
National technology n32g45x series about timer timing cycle calculation
套接字socket编程——UDP
02 - bare metal and RTOS development modes: five development modes of bare metal and the introduction of RTOS
Efga design open source framework fabulous series (I) establishment of development environment
Video player (I): process
2021 private equity fund market report (62 pages)
Raspberry pie 4B Getting Started Guide
期末复习-PHP学习笔记4-PHP自定义函数
期末複習-PHP學習筆記6-字符串處理
4diac getting started example
Adjacency matrix representation of weighted undirected graph (implemented in C language)
Periodic planning work
C51 minimum system board infrared remote control LED light on and off
Dynamic memory management
線程池——C語言
Line fitting (least square method)
Digital white paper on total cost management in chain operation industry
Firewall firewalld