RISC-V MCU中文社区

【分享】 Nuclei studio的NICE处理模块的debug和代码解析

发表于 开源蜂鸟E203 2023-05-06 15:59:23
0
837
5

报名编号:CICC5996

团队名称:我想静静

学校名称:杭州电子科技大学

队伍成员:张明明,肖昱,宋飞亮

指导老师:邓江峡、申东升

在官方的nuclei-board-labs中有对NICE指令集的一个例程,我们通过nuceil studio 对其进行了一个debug软件验证
图片alt
我们先对程序进行编译,然后debug,通过disassembly的模块获取到NICE 的R型指令然后在对照嵌入汇编和E203v2的nice核里的相关模块的寄存器进行对照,我们先放出对驱动程序的注释

int nice_case(unsigned int array[ROW_LEN][COL_LEN])
{
  volatile unsigned char i, j;
  volatile unsigned int col_sum[COL_LEN]={0};
  volatile unsigned int row_sum[ROW_LEN]={0};
  volatile unsigned int init_buf[3]={0};

  custom_lbuf((int)init_buf);// .insn r 0x7b, 2, 1, x0, %1, x0  0x207a07b
/*    opcode    func3            func7        rd            rs1            rs2
        0x7b    2                  1            x0            %1            x0
        custom3    只读取rs1的数据    第一种操作    零寄存器    保存addr地址    零寄存器
        1111011 010                 0000001    00000           01010    00000  
  /*     
 *      func7      rs2      rs1    func3           rd        opcode
 * 31---------24--------19------14------12----------------6----------0
 * | 0000001    | 00000  | 01111  |  010  |    00000      |  1111011 |
 * |------------------------------------------------------|----------|
 */    ass_code  0x207a07b  0000001  00000 01111   010   00000       1111011   
 */
  for (i = 0; i < ROW_LEN; i++)
  {
    row_sum[i] = custom_rowsum((int)array[i]);//0x7b, 6, 6, %0, %1, x0  
  /*    opcode    func3            func7        rd            rs1            rs2
        0x7b    6                 6            %0            %1            x0
        custom3    读取rs1、rd的数据    第六种操作    rowsum地址    保存addr地址    零寄存器
        1111011    110                0000110        01011        01010         00000
  /*     
 *      func7      rs2      rs1    func3           rd        opcode
 * 31---------24--------19------14------12----------------6----------0
 * | 0000110    | 00000  | 01111  |  110  |      01111    |  1111011 |
 * |------------------------------------------------------|----------|
 */     ass_code  0xc07e7fb  0000110  00000  01111  110 01111   1111011
 */


 //R型指令[[31:25]fun7,[24:20]rs2,[19:15]rs1,[14:12]func3,[11:7]rd,[6:0]opcode]

 }
  custom_sbuf((int)col_sum);// 0x7b, 2, 2, x0, %1, x0  0x407a07b    
   /*    opcode    func3            func7        rd            rs1            rs2
        0x7b    2                  2            x0            %1            x0
        custom3    只读取rs1的数据    第二种操作    零寄存器    保存addr地址    零寄存器
        1111011    010                0000010        00000        01010         00000
  /*     
 *      func7      rs2      rs1    func3           rd        opcode
 * 31---------24--------19------14------12----------------6----------0
 * | 0000010    | 00000  | 01111  |  010  |      00000    |  1111011 |
 * |------------------------------------------------------|----------|
 */       
 */ ass_code  0x407a07b   0000010  00000 01111  010  00000 1111011
#ifdef _DEBUG_INFO_
  printf ("the element of array is :\n\t");
  for (i = 0; i < ROW_LEN; i++) printf("%d\t", array[0][i]); printf("\n\t");
  for (i = 0; i < ROW_LEN; i++) printf("%d\t", array[1][i]); printf("\n\t");
  for (i = 0; i < ROW_LEN; i++) printf("%d\t", array[2][i]); printf("\n\n");
  printf ("the sum of each row is :\n\t\t");
  for (i = 0; i < ROW_LEN; i++) printf("%d\t", row_sum[i]); printf("\n");
  printf ("the sum of each col is :\n\t\t");
  for (j = 0; j < COL_LEN; j++) printf("%d\t", col_sum[j]); printf("\n");
#endif
  return 0;
}
喜欢5
用户评论

积分
问答
粉丝
关注
  • RV-STAR 开发板
  • RISC-V处理器设计系列课程
  • 培养RISC-V大学土壤 共建RISC-V教育生态
RV-STAR 开发板