当前位置:网站首页>SD_ CMD_ RECEIVE_ SHIFT_ REGISTER
SD_ CMD_ RECEIVE_ SHIFT_ REGISTER
2022-07-05 07:07:00 【Eight four one one】
Catalog
1. Interface
- Normal clock reset soft reset
- Enter the current status of the entry in_current_state as well as sd Send the command line in_serial_cmd, Here's what's interesting , from sd The card was sent in_serial_cmd It is the single that makes up the response bit The signal
- Received bit Count in_has_receive_bit
- Response type in_long_response,1 Long 0 short
- Report crc Check for errors out_cmd_receive_crc_error
- Four response signals response[3:0]
input in_sd_clk ;
input hrst_n ;
input in_soft_reset ;
input [2:0] in_current_state ;
input in_serial_cmd ;
input [7:0] in_has_receive_bit ;
input in_long_response ;
output out_cmd_receive_crc_error ;
output response0 ;
output response1 ;
output response2 ;
output response3 ;
2. Response output generation
- The format of long response is shown in the following figure

- among start bit Not recorded , That is, from the transmission bit , We started from 8 Bit is also [7] Start shift deposit
- response3 The highest 8bit=0, be left over 24bit from in_serial_cmd Normal read
- Short response only response0 That's enough , The format is as follows :

always @(posedge in_sd_clk or negedge hrst_n) begin
if(!hrst_n)
begin
response0 <= 32'b0;
response1 <= 32'b0;
response2 <= 32'b0;
response3 <= 32'b0;
end
else if (!in_soft_reset)
begin
response0 <= 32'b0;
response1 <= 32'b0;
response2 <= 32'b0;
response3 <= 32'b0;
end
else if (in_current_state == `CMD_STATE_SEND)
begin
response0 <= 32'b0;
response1 <= 32'b0;
response2 <= 32'b0;
response3 <= 32'b0;
end
else if (in_current_state == `CMD_STATE_RECEIVE)
begin
if(in_long_response)
begin
if((in_has_receive_bit >= 7) && (in_has_receive_bit <=30))
response3 <= {
response3[30:0],in_serial_cmd};
else if((in_has_receive_bit >= 31) && (in_has_receive_bit <= 62))
response2 <= {
response2[30:0],in_serial_cmd};
else if((in_has_receive_bit >= 63) && (in_has_receive_bit <= 94))
response1 <= {
response1[30:0],in_serial_cmd};
else if((in_has_receive_bit >= 95) && (in_has_receive_bit <= 126))
response0 <= {
response0[30:0],in_serial_cmd};
end
else if((in_has_receive_bit >= 7) && (in_has_receive_bit <= 38))
response0 <= {
response0[30:0],in_serial_cmd};
end
end
3. Received by sd From card crc7 Check the signal
- First order crc yes 8 Bit
- Also by in_serial_cmd Single line transmission , Therefore, it is also necessary to move and deposit
- Appearance correspondence crc The position in the format is as follows :

- Short corresponding crc The position in the format is as follows :

always @(posedge in_sd_clk or negedge hrst_n) begin
if(!hrst_n)
receive_cec_reg <= 7'b0;
else if (!in_soft_reset)
receive_cec_reg <= 7'b0;
else if (in_current_state == `CMD_STATE_SEND)
receive_cec_reg <= 7'b0;
else if (in_current_state == `CMD_STATE_RECEIVE)
begin
if (in_long_response)
begin
if((in_has_receive_bit >= 127) && (in_has_receive_bit <= 133))
receive_cec_reg <= {
receive_cec_reg[5:0],in_serial_cmd};
end
else begin
if((in_has_receive_bit >= 39) && (in_has_receive_bit <= 45))
receive_cec_reg <= {
receive_cec_reg[5:0],in_serial_cmd};
end
end
end
4. Calculate for yourself crc7 Value
- You need to calculate again crc The value of comes from sd Card received crc compare
- If the same , Then the command is ok , If it is not the same , Report an error out_cmd_receive_crc_error
- Calculation crc7 Methods :[0] and [3] These two bits need to be XOR , Other shifts are ok , See the picture below

always @(posedge in_sd_clk or negedge hrst_n) begin
if(!hrst_n)
receive_cec_reg <= 7'b0;
else if (!in_soft_reset)
receive_crc_reg <= 7'b0;
else if(in_current_state == `CMD_STATE_SEND)
receive_crc_reg <= 7'b0;
else if (in_current_state == `CMD_STATE_RECEIVE)
begin
if(in_long_response)
begin
if((in_has_receive_bit >= 7) && (in_has_receive_bit <=126))
begin
generate_crc_reg[0] <= in_serial_cmd^generate_crc_reg[6];
generate_crc_reg[1] <= generate_crc_reg[0];
generate_crc_reg[2] <= generate_crc_reg[1];
generate_crc_reg[3] <= in_serial_cmd^generate_crc_reg[6]^generate_crc_reg[2];
generate_crc_reg[4] <= generate_crc_reg[3];
generate_crc_reg[5] <= generate_crc_reg[4];
generate_crc_reg[6] <= generate_crc_reg[5];
end
end
else
begin
if((in_has_receive_bit >= 0) && (in_has_receive_bit <=38))
begin
generate_crc_reg[0] <= in_serial_cmd^generate_crc_reg[6];
generate_crc_reg[1] <= generate_crc_reg[0];
generate_crc_reg[2] <= generate_crc_reg[1];
generate_crc_reg[3] <= in_serial_cmd^generate_crc_reg[6]^generate_crc_reg[2];
generate_crc_reg[4] <= generate_crc_reg[3];
generate_crc_reg[5] <= generate_crc_reg[4];
generate_crc_reg[6] <= generate_crc_reg[5];
end
end
end
end
5. contrast crc7 produce out_cmd_receive_crc_error
- We received receive_crc_reg
- Later we calculated generate_crc_reg
- After receiving, that is 135 perhaps 47bit You can make a comparison
always @(posedge in_sd_clk or negedge hrst_n) begin
if (!hrst_n)
out_cmd_receive_crc_error <= 1'b0;
else if (!in_soft_reset)
out_cmd_receive_crc_error <= 1'b0;
else if (in_current_state == `CMD_STATE_SEND)
out_cmd_receive_crc_error <= 1'b0;
else if (in_current_state == `CMD_STATE_RECEIVE)
begin
if (in_long_response)
begin
if(in_has_receive_bit == 134)
out_cmd_receive_crc_error <= !(generate_crc_reg == receive_crc_reg);
end
else if (in_has_receive_bit == 46)
out_cmd_receive_crc_error <= !(generate_crc_reg == receive_crc_reg);
end
end
边栏推荐
- Literacy Ethernet MII interface types Daquan MII, RMII, smii, gmii, rgmii, sgmii, XGMII, XAUI, rxaui
- 小米笔试真题一
- Log4qt usage of logbase in QT project
- Concurrent programming - deadlock troubleshooting and handling
- 2022年中纪实 -- 一个普通人的经历
- Ros2 - node (VII)
- 1290_FreeRTOS中prvTaskIsTaskSuspended()接口实现分析
- Cookie、Session、JWT、token四者间的区别与联系
- 摄像头的MIPI接口、DVP接口和CSI接口
- Qt项目中的日志库log4qt使用
猜你喜欢

你心目中的数据分析 Top 1 选 Pandas 还是选 SQL?

SD_CMD_RECEIVE_SHIFT_REGISTER

【无标题】

Database mysql all
![[algorithm post interview] interview questions of a small factory](/img/62/6e330b1eba38f2dc67b21a10f0e2a8.jpg)
[algorithm post interview] interview questions of a small factory

Ros2 - function package (VI)

数学分析_笔记_第8章:重积分

ROS2——ROS2对比ROS1(二)

Dameng database all

Build a microservice cluster environment locally and learn to deploy automatically
随机推荐
ethtool 原理介绍和解决网卡丢包排查思路(附ethtool源码下载)
ROS2——node节点(七)
Matlab在线性代数中的应用(四):相似矩阵及二次型
Sre core system understanding
并发编程 — 如何中断/停止一个运行中的线程?
Binary search (half search)
Build a microservice cluster environment locally and learn to deploy automatically
Concurrent programming - deadlock troubleshooting and handling
[untitled]
Error: “MountVolume.SetUp failed for volume pvc 故障处理
Unity 之 ExecuteAlways正在取代ExecuteInEditMode
Ros2 - function package (VI)
IPage can display data normally, but total is always equal to 0
window navicat连接阿里云服务器mysql步骤及常见问题
[OBS] x264 Code: "buffer_size“
Pycahrm reports an error: indentation error: unindent does not match any outer indentation
Application of MATLAB in Linear Algebra (4): similar matrix and quadratic form
Get class files and attributes by reflection
Mipi interface, DVP interface and CSI interface of camera
C#学习笔记