在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 4275|回复: 7

[原创] SD card, SPI, Verilog model.

[复制链接]
发表于 2016-6-16 20:36:45 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
自製. 純分享.
歡迎討論.




  1. //SD Card, SPI mode, verilog simulation model
  2. //
  3. //Version history:
  4. //1.0        2016.06.13        1st released by tsuhuai.chan@gmail.com
  5. //                        Most of the Card information is referenced
  6. //                        from Toshiba 2G and 256MB SD card
  7. //

  8. //parsed commands:
  9. // CMD0, CMD8, CMD9, CMD10, CMD12, CMD13, CMD16, CMD17, CMD18,
  10. // CMD24, CMD25, CMD27, CMD55, CMD51, CMD58, ACMD13, ACMD51
  11. //Not parsed command: (still responses based on spec)
  12. // CMD1, CMD6, CMD9, CMD10, CMD30, CMD32, CMD33, CMD42, CMD56,
  13. // CMD59, ACMD22, ACMD23, ACMD41, ACMD42

  14. //Memory size of this model should be 2GB, however only 2MB is
  15. // implemened to reduce system memory required during simulation.
  16. // The initial value of all internal memory is word_address+3.

  17. //Detail command status
  18. // 1. card response of ACMD51: not sure
  19. // 2. lock/unlock: not implemented
  20. // 3. erase: not implemented
  21. // 4. read multiple block: seems verify OK
  22. // 5. write single block: seems verify OK
  23. // 6. write multiple block: not verified
  24. // 7. partial access: not implemented
  25. // 8. misalign: no check
  26. // 9. SDHC address: not verified

  27. `timescale 1ns/1ns
  28. `define UD 1
  29. module spi_sd_model        (rstn, ncs, sclk, miso, mosi);
  30. input        rstn;
  31. input        ncs;
  32. input        sclk;
  33. input        mosi;
  34. output        miso;

  35. parameter        tNCS                = 1;//0 ~
  36. parameter        tNCR                = 1;//1 ~ 8
  37. parameter        tNCX                = 0;//0 ~ 8
  38. parameter        tNAC                = 1;//from CSD
  39. parameter        tNWR                = 1;//1 ~
  40. parameter        tNBR                = 0;//0 ~
  41. parameter        tNDS                = 0;//0 ~
  42. parameter        tNEC                = 0;//0 ~
  43. parameter        tNRC                = 1;//

  44. parameter MEM_SIZE        = 2048*1024;//2M
  45. parameter PowerOff        = 0;
  46. parameter PowerOn        = 1;
  47. parameter IDLE                = 2;
  48. parameter CmdBit47        = 3;
  49. parameter CmdBit46        = 4;
  50. parameter CommandIn        = 5;
  51. parameter CardResponse        = 6;
  52. parameter ReadCycle        = 7;
  53. parameter WriteCycle        = 8;
  54. parameter DataResponse        = 9;
  55. parameter CsdCidScr        = 10;
  56. parameter WriteStop        = 11;
  57. parameter WriteCRC        = 12;

  58. integer i = 0;//counter index
  59. integer j = 0;//counter index
  60. integer k = 0;//for MISO (bit count of a byte)
  61. integer m = 0;//for MOSI (bit count during CMD12)

  62. reg miso;
  63. reg [7:0] flash_mem [0:MEM_SIZE-1];
  64. reg [7:0] token;//captured token during CMD24, CMD25
  65. reg [15:0] crc16_in;
  66. reg [6:0] crc7_in;
  67. reg [7:0] sck_cnt;//74 sclk after power on
  68. reg [31:0] csd_reg;
  69. reg [31:0] block_cnt;
  70. reg init_done;//must be defined before ocr.v
  71. reg [3:0] st;//SD Card internal state
  72. reg app_cmd;//
  73. reg [7:0] datain;
  74. reg [511:0] ascii_command_state;
  75. reg [2:0] ist;//initialization stage
  76. reg [45:0] cmd_in, serial_in;
  77. wire [5:0] cmd_index = cmd_in[45:40];
  78. wire [31:0] argument = cmd_in[39:8];
  79. wire [6:0] crc = cmd_in[7:1];
  80. wire read_single = (cmd_index == 17);
  81. wire read_multi = (cmd_index == 18);
  82. wire write_single = (cmd_index == 24);
  83. wire write_multi = (cmd_index == 25);
  84. wire pgm_csd = (cmd_index == 27);
  85. wire send_csd = (cmd_index == 9);
  86. wire send_cid = (cmd_index == 10);
  87. wire send_scr = (cmd_index == 51) && app_cmd;
  88. wire read_cmd = read_single | read_multi;
  89. wire write_cmd = write_single | write_multi;
  90. wire mem_rw = read_cmd | write_cmd;
  91. reg [31:0] start_addr;
  92. reg [31:0] block_len;
  93. reg [7:0] capture_data;//for debugging
  94. reg [3:0] VHS;//Input VHS through MOSI
  95. reg [7:0] check_pattern;//for CMD8
  96. wire [3:0] CARD_VHS = 4'b0001;//SD card accept voltage range
  97. wire VHS_match = (VHS == CARD_VHS);
  98. reg [1:0] multi_st;//for CMD25
  99. reg [45:0] serial_in1;//for CMD25
  100. wire [5:0] cmd_in1 = serial_in1[45:40];//for CMD25
  101. wire stop_transmission = (cmd_in1 == 12);//for CMD25

  102. //Do not change the positions of these include files
  103. //Also, ocr.v must be included before csd.v
  104. `include "./ocr.v"
  105. `include "./csd.v"
  106. `include "./cid.v"
  107. `include "./scr.v"
  108. `include "./ssr.v"
  109. `include "./csr.v"
  110. //
  111. task R1;
  112. input [7:0] data;
  113. begin
  114.    $display("   SD R1: 0x%2h at %0t ns",data, $realtime);
  115.    k = 0;
  116.    while (k < 8) begin
  117.       @(negedge sclk) miso = data[7-k];
  118.       k = k + 1;
  119.    end
  120. end
  121. endtask
  122.    
  123. task R1b;
  124. input [7:0] data;
  125. begin
  126.    $display("   SD R1B: 0x%2h at %0t ns",data, $realtime);
  127.    k = 0;
  128.    while (k < 8) begin
  129.       @(negedge sclk) miso = data[7-k];
  130.       k = k + 1;
  131.    end
  132. end
  133. endtask

  134. task R2;
  135. input [15:0] data;
  136. begin
  137.    $display("   SD R2: 0x%2h at %0t ns",data, $realtime);
  138.    k = 0;
  139.    while (k < 16) begin
  140.       @(negedge sclk) miso = data[15-k];
  141.       k = k + 1;
  142.    end
  143. end
  144. endtask

  145. task R3;
  146. input [39:0] data;
  147. begin
  148.    $display("   SD R3: 0x%10h at %0t ns",data, $realtime);
  149.    for (k =0; k < 40; k = k + 1) begin
  150.       @(negedge sclk) ;
  151.           miso = data[39 - k];
  152.    end
  153. end
  154. endtask

  155. task R7;
  156. input [39:0] data;
  157. begin
  158.    $display("   SD R7: 0x%10h at %0t ns",data,$realtime);
  159.    k = 0;
  160.    while (k < 40) begin
  161.       @(negedge sclk) miso = data[39-k];
  162.       k = k + 1;
  163.    end
  164. end
  165. endtask

  166. task DataOut;
  167. input [7:0] data;
  168. begin
  169.    $display("   SD DataOut 0x%2H at %0t ns",data, $realtime);
  170.    k = 0;
  171.    while (k < 8) begin       @(negedge sclk) miso = data[7 - k];       k = k + 1;    end end endtask     task DataIn; begin    for (k = 7; k >= 0; k = k - 1) begin
  172.       @(posedge sclk) capture_data[k] = mosi;
  173.    end
  174.    $display("   SD DataIn: %2h at %0t ns",capture_data, $realtime);
  175. end
  176. endtask

  177. always @(*) begin
  178.    if (pgm_csd) csd_reg = argument;
  179. end

  180. task CRCOut;
  181. input [15:0] data;
  182. begin
  183.    $display("   SD CRC Out 0x%4H at %0t ns",data, $realtime);
  184.    k = 0;
  185.    while (k < 16) begin
  186.       @(negedge sclk) miso = data[15 - k];
  187.       k = k + 1;
  188.    end
  189. end
  190. endtask

  191. task TokenOut;
  192. input [7:0] data;
  193. begin
  194.    $display("   SD TokenOut 0x%2H at %0t ns",data, $realtime);
  195.    k = 0;
  196.    while (k < 8) begin
  197.       @(negedge sclk) miso = data[7 - k];
  198.       k = k + 1;
  199.    end
  200. end
  201. endtask

  202. always @(*) begin
  203.    if (~rstn) app_cmd = 1'b0;
  204.    else if (cmd_index == 55 && st == IDLE) app_cmd = 1;
  205.    else if (cmd_index != 55 && st == IDLE) app_cmd = 0;
  206. end

  207. always @(*) begin
  208.    if (sdsc && mem_rw) start_addr = argument;
  209.    else if (v2sdhc && mem_rw) start_addr = argument * block_len;
  210. end

  211. always @(*) begin
  212.    if (v2sdhc) block_len = 512;
  213.    else if (sdsc && cmd_index == 0) block_len = (READ_BL_LEN == 9) ? 512 : (READ_BL_LEN == 10) ? 1024 : 2048;
  214.    else if (sdsc && cmd_index == 16) block_len = argument[31:0];
  215. end

  216. always @(*) begin
  217.    if (cmd_index == 8) VHS = argument[11:8];
  218.    if (cmd_index == 8) check_pattern = argument[7:0];
  219. end

  220. always @(*) begin
  221.    if (ist == 0 && cmd_index == 0) begin
  222.       $display("iCMD0 at %0t ns",$realtime);
  223.       ist <= 1;
  224.    end
  225.    if (ist == 1 && cmd_index == 8) begin
  226.       $display("iCMD8 at %0t ns",$realtime);
  227.       ist <= 2;
  228.    end
  229.    if (ist == 2 && cmd_index == 58) begin
  230.       $display("iCMD58 at %0t ns",$realtime);
  231.       ist <= 3;
  232.    end
  233.    if (ist == 3 && cmd_index == 55) begin
  234.       $display("iCMD55 at %0t ns",$realtime);
  235.       ist <= 4;
  236.    end
  237.    if (ist == 4 && cmd_index == 41) begin
  238.       $display("iACMD41 at %0t ns",$realtime);
  239.       ist <= 5;
  240.    end
  241.    if (ist == 5 && cmd_index == 58 && CSD_VER == 1) begin
  242.       $display("iCMD58 at %0t ns",$realtime);
  243.       ist <= 6;
  244.    end
  245.    else if (ist == 5 && CSD_VER == 0) ist <= 6;
  246.    if (ist == 6 && st == IDLE) begin
  247.       $display("Init Done at %0t ns",$realtime);
  248.       if (v2sdhc) $display("Ver 2, SDHC detected");
  249.       else if (v2sdsc) $display("Ver 2, SDSC detected");
  250.       else if (v1sdsc) $display("Ver 1, SDSC detected");
  251.       init_done = 1;
  252.       ist <= 7;
  253.    end
  254. end

  255. always @(*) begin
  256.    if (st == ReadCycle) begin
  257.       case (multi_st)
  258.         0:
  259.                 begin
  260.                    @(posedge sclk) if (~ncs && ~mosi) multi_st = 1; else multi_st = 0;
  261.                 end
  262.         1:
  263.                 begin
  264.                    @(posedge sclk); if (mosi) multi_st = 2; else multi_st = 1;
  265.                 end
  266.         2:
  267.                 begin
  268.                    m = 0;
  269.                    while (m < 46) begin
  270.                       @(posedge sclk) serial_in1[45-m] = mosi;
  271.                       #1 m = m + 1;
  272.                    end
  273.                      multi_st = 0;
  274.                 end
  275.       endcase
  276.    end
  277. end
  278.    
  279. always @(*) begin
  280.    case (st)
  281.         PowerOff:
  282.                 begin
  283.                    @(posedge rstn) st <= PowerOn;
  284.                 end
  285.         PowerOn:
  286.                 begin
  287.                    if (sck_cnt < 73) begin
  288.                       @(posedge sclk) sck_cnt = sck_cnt + 1;
  289.                    end
  290.                    if (sck_cnt == 73) st <= IDLE; else st <= PowerOn;
  291.                 end
  292.         IDLE:
  293.                 begin
  294.                    @(posedge sclk) if (~ncs && ~mosi) st <= CmdBit46; else st <= IDLE;
  295.                 end
  296.         CmdBit46:
  297.                 begin
  298.                    @(posedge sclk); if (mosi) st <= CommandIn; else st <= CmdBit46;                 end         CommandIn://capture command input -> NCR
  299.                 begin
  300.                   for (i = 0; i < 46; i = i + 1)  begin
  301.                      @(posedge sclk) ;serial_in[45-i] = mosi;
  302.                   end
  303.                   cmd_in = serial_in;
  304.                   repeat (tNCR*8) @(posedge sclk);
  305.                   st <= CardResponse;                 end         CardResponse://CardResponse -> delay
  306.                 begin
  307.                    if (~app_cmd) begin
  308.                       case (cmd_index)
  309.                       6'd0:        R1(8'b0000_0001);
  310.                       6'd1,
  311.                       6'd6,
  312.                       6'd16,
  313.                       6'd17,
  314.                       6'd18,
  315.                       6'd24,
  316.                       6'd25,
  317.                       6'd27,
  318.                       6'd30,
  319.                       6'd32,
  320.                       6'd33,
  321.                       6'd42,
  322.                       6'd55,
  323.                       6'd56,
  324.                       6'd59:         R1(8'b0110_1010);
  325.                       6'd9,
  326.                       6'd10:    if (init_done) R1(8'b1010_0001); else R1(0000_0100);
  327.                       6'd12,
  328.                       6'd28,
  329.                       6'd29,
  330.                       6'd38:         R1b(8'b0011_1010);
  331.                       6'd8:         if (VHS_match) begin
  332.                                    $display("   VHS match");
  333.                                    R7({8'h01 | (VHS_match ? 8'h04 : 8'h00), 20'h00000, VHS, check_pattern});
  334.                                 end
  335.                                 else begin
  336.                                    $display("   VHS not match");
  337.                                    R7({8'h01 | (VHS_match ? 8'h04 : 8'h00), 20'h00000, 4'b0, check_pattern});
  338.                                 end
  339.                       6'd13:         R2({1'b0, OUT_OF_RANGE, ADDRESS_ERROR, ERASE_SEQ_ERROR, COM_CRC_ERROR,
  340.                                     ILLEGAL_COMMAND, ERASE_RESET, IN_IDLE_ST, OUT_OF_RANGE | CSD_OVERWRITE,
  341.                                     ERASE_PARAM, WP_VIOLATION, CARD_ECC_FAILED, CC_ERROR, ERROR,
  342.                                     WP_ERASE_SKIP | LOCK_UNLOCK_FAILED, CARD_IS_LOCKED});
  343.                       6'd58:         R3({8'b0000_0000, OCR});
  344.                       default:        R1(8'b0000_0100);//illegal command
  345.                       endcase
  346.                    end
  347.                    else if (~read_multi) begin
  348.                       case (cmd_index)
  349.                       6'd22,
  350.                       5'd23,
  351.                       6'd41,
  352.                       6'd42,
  353.                       6'd51:        R1(8'b0000_0000);
  354.                       6'd13:        R2({1'b0, OUT_OF_RANGE, ADDRESS_ERROR, ERASE_SEQ_ERROR, COM_CRC_ERROR,
  355.                                    ILLEGAL_COMMAND, ERASE_RESET, IN_IDLE_ST, OUT_OF_RANGE | CSD_OVERWRITE,
  356.                                    ERASE_PARAM, WP_VIOLATION, CARD_ECC_FAILED, CC_ERROR, ERROR,
  357.                                    WP_ERASE_SKIP | LOCK_UNLOCK_FAILED, CARD_IS_LOCKED});
  358.                       default:        R1(8'b0000_0100);//illegal command
  359.                       endcase
  360.                    end
  361.                    @(posedge sclk);
  362.                    if (read_cmd && init_done && ~stop_transmission) begin
  363.                       miso = 1;
  364.                       repeat (tNAC*8) @(posedge sclk);
  365.                       st <= ReadCycle;
  366.                    end
  367.                    else if (read_cmd && init_done && stop_transmission) begin
  368.                       miso = 1;
  369.                       repeat (tNEC*8) @(posedge sclk);
  370.                       st <= IDLE;
  371.                    end
  372.                    else if ((send_csd || send_cid || send_scr) && init_done) begin
  373.                       miso = 1;
  374.                       repeat (tNCX*8) @(posedge sclk);
  375.                       st <= CsdCidScr;
  376.                    end
  377.                    else if (write_cmd && init_done) begin
  378.                       miso = 1;
  379.                       repeat (tNWR*8) @(posedge sclk);
  380.                       st <= WriteCycle;
  381.                    end
  382.                    else begin
  383.                       repeat (tNEC*8) @(posedge sclk);
  384.                       st <= IDLE;
  385.                    end
  386.                 end
  387.         CsdCidScr:
  388.                 begin
  389.                    if (send_csd) begin
  390.                       DataOut(CSD[127:120]);
  391.                       DataOut(CSD[119:112]);
  392.                       DataOut(CSD[111:104]);
  393.                       DataOut(CSD[103:96]);
  394.                       DataOut(CSD[95:88]);
  395.                       DataOut(CSD[87:80]);
  396.                       DataOut(CSD[79:72]);
  397.                       DataOut(CSD[71:64]);
  398.                       DataOut(CSD[63:56]);
  399.                       DataOut(CSD[55:48]);
  400.                       DataOut(CSD[47:40]);
  401.                       DataOut(CSD[39:32]);
  402.                       DataOut(CSD[31:24]);
  403.                       DataOut(CSD[23:16]);
  404.                       DataOut(CSD[15:8]);
  405.                       DataOut(CSD[7:0]);
  406.                    end
  407.                    else if (send_cid) begin
  408.                       DataOut(CID[127:120]);
  409.                       DataOut(CID[119:112]);
  410.                       DataOut(CID[111:104]);
  411.                       DataOut(CID[103:96]);
  412.                       DataOut(CID[95:88]);
  413.                       DataOut(CID[87:80]);
  414.                       DataOut(CID[79:72]);
  415.                       DataOut(CID[71:64]);
  416.                       DataOut(CID[63:56]);
  417.                       DataOut(CID[55:48]);
  418.                       DataOut(CID[47:40]);
  419.                       DataOut(CID[39:32]);
  420.                       DataOut(CID[31:24]);
  421.                       DataOut(CID[23:16]);
  422.                       DataOut(CID[15:8]);
  423.                       DataOut(CID[7:0]);
  424.                    end
  425.                    else if (send_scr) begin
  426.                       DataOut(SCR[63:56]);
  427.                       DataOut(SCR[55:48]);
  428.                       DataOut(SCR[47:40]);
  429.                       DataOut(SCR[39:32]);
  430.                       DataOut(SCR[31:24]);
  431.                       DataOut(SCR[23:16]);
  432.                       DataOut(SCR[15:8]);
  433.                       DataOut(SCR[7:0]);
  434.                    end
  435.                    @(posedge sclk);
  436.                    repeat (tNEC*8) @(posedge sclk);
  437.                    st <= IDLE;                 end         ReadCycle://Start Token -> Data -> CRC(stucked at 16'hAAAA) -> NEC(or NAC)  
  438.                 begin
  439.                    if (read_single) begin
  440.                       TokenOut(8'hFE);//Start Token
  441.                       for (i = 0; i < block_len; i = i + 1) begin
  442.                          DataOut(flash_mem[start_addr+i]);
  443.                       end
  444.                       CRCOut(16'haaaa);//CRC[15:0]
  445.                       @(posedge sclk);
  446.                       repeat (tNEC*8) @(negedge sclk);
  447.                       st <= IDLE;
  448.                    end
  449.                    else if (read_multi) begin:loop_1
  450.                       for (j = 0; ; j  = j + 1) begin
  451.                          TokenOut(8'hFE);//Start Token
  452.                          i = 0;
  453.                          while (i < block_len) begin
  454.                             DataOut(flash_mem[start_addr+i+block_len*j]);
  455.                             i = i + 1;
  456.                          end
  457.                          CRCOut(16'haaaa);
  458.                          if (stop_transmission) begin//check stop_tx at end of each data block?
  459.                             repeat (tNEC*8) @(posedge sclk);
  460.                             $display("STOP transmission");
  461.                             @(posedge sclk) begin
  462.                                   R1(8'b0000_0000);
  463.                                   repeat (tNEC*8) @(posedge sclk);
  464.                                   st <= IDLE;
  465.                                   disable loop_1;
  466.                             end
  467.                          end
  468.                          else repeat (tNAC*8) @(negedge sclk);
  469.                       end
  470.                       repeat (tNEC*8) @(posedge sclk);
  471.                       st <= IDLE;                    end                                     end         WriteCycle://Start Token -> Data
  472.                 begin
  473.                    i = 0;
  474.                    while (i < 8) begin
  475.                       @(posedge sclk)  token[7-i] = mosi;
  476.                       i = i + 1;
  477.                    end
  478.                    if (token == 8'hfe && write_single) $display("Single Write Start Token OK");
  479.                    else if (token != 8'hfe && write_single) $display("Single Write Start Token NG");
  480.                    if (token == 8'hfc && write_multi)  $display("Multiblock Write Start Token OK");
  481.                    else if ((token != 8'hfc && token != 8'hfd) && write_multi)  $display("Multiblock Write Start Token NG");
  482.                    if (token == 8'hfd && write_multi) begin
  483.                       $display("Multiblock Write Stop Token");
  484.                       st <= WriteStop;
  485.                    end
  486.                    i = 0;
  487.                    while (i < block_len) begin
  488.                       DataIn;
  489.                       flash_mem[start_addr + i] = capture_data;
  490.                       i = i + 1;
  491.                      end
  492.                    st <= WriteCRC;
  493.                 end
  494.         WriteCRC://Capture incoming CRC of data
  495.                 begin
  496.                    i = 0;
  497.                    while (i < 16) begin
  498.                       @(posedge sclk) crc16_in[15-i] = mosi;
  499.                       i = i + 1;
  500.                    end
  501.                    st <= DataResponse;
  502.                 end
  503.         DataResponse://All clock after data response CRC
  504.                 begin
  505.                    DataOut(8'b00000101);
  506.                    @(negedge sclk); miso = 0;
  507.                    repeat (tNEC*8) @(negedge sclk);

  508.                    repeat  (tNDS*8) @(negedge sclk);
  509.                    miso = 1'bz;
  510.                    @(negedge sclk);
  511.                    miso = 1'b0;
  512.                    repeat (100) @(negedge sclk);
  513.                    miso = 1;
  514.                    @(negedge sclk);
  515.                    miso = 1;
  516.                    repeat (5) @(posedge sclk);
  517.                    if (write_single) st <= IDLE;
  518.                    else if (write_multi) st <= WriteCycle;
  519.                 end
  520.         WriteStop:
  521.                 begin
  522.                    repeat (tNBR*8) @(posedge sclk);
  523.                    miso = 0;
  524.                    repeat (tNEC*8) @(posedge sclk);
  525.                    repeat (tNDS*8) @(posedge sclk) miso = 1'bz;
  526.                    @(posedge sclk) miso = 1'b0;
  527.                    #1000000;//1ms processing time for each block programming
  528.                    @(posedge sclk) miso = 1'b1;
  529.                    repeat (tNEC*8) @(posedge sclk);
  530.                    @(posedge sclk);
  531.                    st <= IDLE;
  532.                 end
  533.         default: st <= IDLE;
  534.    endcase
  535. end
  536.        
  537. always @(st) begin
  538.    case (st)
  539.         PowerOff:        ascii_command_state = "PowerOff";
  540.         PowerOn:        ascii_command_state = "PowerOn";
  541.         IDLE:                ascii_command_state = "IDLE";
  542.         CmdBit47:        ascii_command_state = "CmdBit47";
  543.         CmdBit46:        ascii_command_state = "CmdBit46";
  544.         CommandIn:        ascii_command_state = "CommandIn";
  545.         CardResponse:        ascii_command_state = "CardResponse";
  546.         ReadCycle:        ascii_command_state = "ReadCycle";
  547.         WriteCycle:        ascii_command_state = "WriteCycle";
  548.         DataResponse:        ascii_command_state = "DataResponse";
  549.         CsdCidScr:        ascii_command_state = "CsdCidScr";
  550.         WriteStop:        ascii_command_state = "WriteStop";
  551.         WriteCRC:        ascii_command_state = "WriteCRC";
  552.         default:          ascii_command_state = "ERROR";
  553.    endcase
  554. end

  555. initial
  556.    begin
  557.       sck_cnt = 0;
  558.       cmd_in = 46'h3fffffffffff;
  559.       serial_in = 46'h3f0f0f0f0f0e;
  560.       crc16_in = 16'h0;
  561.       crc7_in = 7'h0;
  562.       token = 8'h0;
  563.       st <= PowerOff;
  564.       miso = 1'b1;
  565.       init_done = 0;
  566.       ist = 0;
  567.       capture_data = 8'hff;
  568.       start_addr = 32'h0;
  569.       VHS = 4'h0;
  570.       serial_in1 = 46'h0;
  571.       multi_st = 0;
  572.       block_len = 0;
  573.       for (i = 0; i < MEM_SIZE - 1; i = i + 1) begin
  574.          flash_mem[i] = i[7:0]+3;
  575.       end
  576.    end

  577. endmodule


复制代码
发表于 2016-6-17 18:46:44 | 显示全部楼层
thanks!
发表于 2016-9-5 14:06:47 | 显示全部楼层
thanks!
发表于 2018-4-12 23:53:45 | 显示全部楼层
回复 1# thjan65


    thanks
发表于 2018-7-22 23:27:03 | 显示全部楼层
you  are handsome
发表于 2019-4-16 02:50:01 | 显示全部楼层
非常好的资料!!!
发表于 2020-3-19 18:55:22 | 显示全部楼层
`include "./ocr.v"
`include "./csd.v"
`include "./cid.v"
`include "./scr.v"
`include "./ssr.v"

没有该文件
`include "./csr.v"
发表于 2022-3-3 15:09:36 | 显示全部楼层
thanks for sharing
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /1 下一条

×

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-3-28 17:07 , Processed in 0.224474 second(s), 11 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表