Xilinx FPGA:vivado fpga与EEPROM的IIC通信,串口显示数据,含使用debug教程

news2024/9/27 23:30:52

一、实验要求

实现FPGA与EEPROM的通信,要求FPGA对EEPROM实现先“写”后“读”,读出的值给uart发送端并显示到电脑上,按下按键1让fpga对EEPROM写入数据;按下按键2让fpga读出对EEPROM写入过的数据。

二、信号流向图

三、程序设计

(1)按键消抖模块

`timescale 1ns / 1ps
module key(
  input                     sys_clk     ,
  input                     rst_n       ,
  (* MARK_DEBUG="true" *)input                     key1        ,
  (* MARK_DEBUG="true" *)input                     key2        ,
  (* MARK_DEBUG="true" *)output                    key_flag_1  ,
  (* MARK_DEBUG="true" *)output                    key_flag_2
     
    );
  parameter                delay = 20'd1_000_000 ;        //20ms=20_000_000  20_000_000/20 == 10_000_00
  reg[19:0]                 cnt1               ;
  reg[19:0]                 cnt2               ;
  
  always@(posedge sys_clk )
       if(!rst_n)
          cnt1 <= 0 ;
       else if ( key1 == 0 )begin
            if ( cnt1 == delay -1 )
                 cnt1 <= cnt1 ;
            else
                 cnt1 <= cnt1 +1 ;
       end
       else
       cnt1 <= 0 ;
  
   always@(posedge sys_clk )
        if(!rst_n)
           cnt2 <= 0 ;
        else if ( key2 == 0 )begin
             if ( cnt2 == delay -1 )
                  cnt2 <= cnt2 ;
             else
                  cnt2 <= cnt2 +1 ;
        end
        else
        cnt2 <= 0 ;
        
        
assign  key_flag_1 = ( cnt1 == delay -2 )?1:0 ;
assign  key_flag_2 = ( cnt2 == delay -2 )?1:0 ;


endmodule

(2)数据产生模块

`timescale 1ns / 1ps
module data_generate(
    input                        sys_clk   ,
    input                        rst_n     ,
    input                        iic_end   ,
    input                        key_flag_1 ,
    input                        key_flag_2 ,
    (* MARK_DEBUG="true" *)output        reg            wr_en     ,
    (* MARK_DEBUG="true" *)output        reg            rd_en     ,
    (* MARK_DEBUG="true" *)output        reg            iic_start  //按键消抖后延迟1000个时钟周期
    );
    
    always@(posedge sys_clk )
         if(!rst_n)
            wr_en <= 0 ;
         else if ( key_flag_1 )
            wr_en <= 1 ;
         else if ( iic_end )
            wr_en <= 0 ;
         else
            wr_en <= wr_en ;
    
    always@(posedge sys_clk )
         if(!rst_n)
            rd_en <= 0 ;
         else if ( key_flag_2 )
            rd_en <= 1 ;
         else if ( iic_end )
            rd_en <= 0 ;
         else
            rd_en <= rd_en ; 
  
  ///cnt
  parameter              TIME_COUNT = 10'd1000 ;
   (* MARK_DEBUG="true" *)reg[9:0]                cnt  ;
    
     always@(posedge sys_clk )
          if(!rst_n )
             cnt <= 0 ;
          else if ( wr_en || rd_en )begin
               if ( cnt == TIME_COUNT -1 )
                    cnt <= cnt ;
               else
                    cnt <= cnt +1 ;
          end
          else
          cnt <= 0 ;
    
    iic_start
      always@(posedge sys_clk )
           if(!rst_n)
              iic_start <= 0 ;
           else if ( cnt == TIME_COUNT -2 )
              iic_start <= 1 ;
           else
              iic_start <= 0 ;      

endmodule

(3)IIC模块

`timescale 1ns / 1ps
module IIC_2
#(
    parameter       SYSCLK    = 50_000_000         ,
                     IIC_CLK   = 400_000           ,
                     DEVICE_ID = 7'b1010_000
)
(
    input                   sysclk              ,
    input                   rst_n               ,
    input   [7:0]           data_in             ,
    input   [7:0]           addr                ,
       input                   iic_start           ,   尖峰脉冲
       input                   wr_en               ,   ///按键1按下触发
       input                   rd_en               ,   ///按键2按下触发
       (* MARK_DEBUG="true" *)output                  tx_start            ,
       (* MARK_DEBUG="true" *)output  reg     [7:0]   rd_data             ,
       (* MARK_DEBUG="true" *)output  reg             SCL                 ,
       (* MARK_DEBUG="true" *)inout                   SDA                 ,
       (* MARK_DEBUG="true" *)output                  iic_end                 /尖峰脉冲
    );
localparam          DELAY = SYSCLK/IIC_CLK          ;
//三态门
wire        sda_en          ;  ///SDA先作为输出时候的使能信号线
wire        sda_in          ;  从机给主机的数据线
reg         sda_out         ;  /主机给从机的数据线
assign      SDA = (sda_en == 1) ? sda_out : 1'bz        ;
assign      sda_in  =  SDA;
状态机
localparam          IDLE          = 4'd0     ,
                    START1        = 4'd1     ,
                    SEND_DEVICE_W = 4'd2     ,
                    ACK1          = 4'd3     ,
                    SEND_ADDR_W   = 4'd4     ,
                    ACK2          = 4'd5     ,
                    SEND_DATA_W   = 4'd6     ,
                    ACK3          = 4'd7     ,
                    STOP          = 4'd8     ,
                                             
                    START2        = 4'd9     ,
                    SEND_DEVICE_R = 4'd10    ,
                    ACK4          = 4'd11    ,
                    READ_DATA     = 4'd12    ,
                    NOACK         = 4'd13    ;                 
(* MARK_DEBUG="true" *)reg     [3:0]       cur_state       ;
reg     [3:0]       next_state       ;
 (* MARK_DEBUG="true" *)reg     [7:0]       cnt             ;
 (* MARK_DEBUG="true" *)reg     [2:0]       cnt_bit         ;
 (* MARK_DEBUG="true" *)reg                 ack_flag        ;
assign      sda_en = (cur_state == ACK1 || cur_state == ACK2 ||
                      cur_state == ACK3 || cur_state == ACK4 || cur_state == READ_DATA) ? 0 : 1;
assign      tx_start = (cur_state == READ_DATA && cnt_bit == 7 && cnt == DELAY - 1) ? 1 : 0;
assign      iic_end  = (cur_state == STOP && cnt == DELAY - 1) ? 1 : 0; 
/state1
always@(posedge sysclk)
    if(!rst_n)
        cur_state <= IDLE;
    else
        cur_state <= next_state;
/state2
always@(*)   
    case(cur_state)
        IDLE          : begin
            if(iic_start == 1)
                next_state = START1;
            else
                next_state = cur_state;
        end  
        START1        :begin
            if(cnt == DELAY - 1)
                next_state = SEND_DEVICE_W;
            else
                next_state = cur_state;
        end
        SEND_DEVICE_W :begin
            if(cnt == DELAY - 1 && cnt_bit == 7)
                next_state = ACK1;
            else
                next_state = cur_state;
        end
        ACK1          :begin
            if(cnt == DELAY - 1 && ack_flag == 0)   /应答有效
                next_state = SEND_ADDR_W;
            else if(cnt == DELAY - 1 && ack_flag == 1)   /应答无效
                next_state = IDLE;
            else
                next_state = cur_state;
        end
        SEND_ADDR_W   :begin
            if(cnt == DELAY - 1 && cnt_bit == 7)
                next_state = ACK2;
            else
                next_state = cur_state;
        end
        ACK2          :begin
            if(cnt == DELAY - 1 && ack_flag == 0 && wr_en)   /应答有效
                next_state = SEND_DATA_W;
            else if(cnt == DELAY - 1 && ack_flag == 0 && rd_en)   /应答有效
                next_state = START2;
            else if(cnt == DELAY - 1 && ack_flag == 1)   /应答无效
                next_state = IDLE;
            else
                next_state = cur_state;
        end
        SEND_DATA_W   :begin
            if(cnt == DELAY - 1 && cnt_bit == 7)
                next_state = ACK3;
            else
                next_state = cur_state;
        end
        ACK3          :begin
            if(cnt == DELAY - 1 && ack_flag == 0)   /应答有效
                next_state = STOP;
            else if(cnt == DELAY - 1 && ack_flag == 1)   /应答无效
                next_state = IDLE;
            else
                next_state = cur_state;
        end
        STOP          :begin
            if(cnt == DELAY - 1)
                next_state = IDLE;
            else
                next_state = cur_state;
        end
        START2        : begin
            if(cnt == DELAY - 1)
                next_state = SEND_DEVICE_R;
            else
                next_state = cur_state;
        end
        SEND_DEVICE_R :begin
            if(cnt == DELAY - 1 && cnt_bit == 7)
                next_state = ACK4;
            else
                next_state = cur_state;
        end
        ACK4          :begin
            if(cnt == DELAY - 1 && ack_flag == 0)   /应答有效
                next_state = READ_DATA;
            else if(cnt == DELAY - 1 && ack_flag == 1)   /应答无效
                next_state = IDLE;
            else
                next_state = cur_state;
        end
        READ_DATA     :begin
            if(cnt == DELAY - 1 && cnt_bit == 7)
                next_state = NOACK;
            else
                next_state = cur_state;
        end
        NOACK         :begin
            if(cnt == DELAY - 1)
                next_state = STOP;
            else
                next_state = cur_state;
        end
        default:next_state = IDLE;  
    endcase
state3
always@(posedge sysclk)
    if(!rst_n)begin
        cnt <= 0;
        cnt_bit <= 0;
        sda_out <= 1;  空闲为1
        SCL <= 1;空闲为1
        ack_flag <= 1;  无效应答
        rd_data <= 0;
    end
    else
        case(cur_state)
            IDLE          :begin
                rd_data <= 0;
                cnt <= 0;
                cnt_bit <= 0;
                sda_out <= 1; 
                SCL <= 1;
                ack_flag <= 1;
            end    
            START1        :begin
                ack_flag <= 1;
                if(cnt >= DELAY*3/4 - 1)
                    SCL <= 0;
                else
                    SCL <= 1;
                if(cnt >= DELAY/2 - 1)
                    sda_out <= 0;
                else
                    sda_out <= 1;
                cnt_bit <= 0;
                if(cnt == DELAY - 1)
                    cnt <= 0;
                else
                    cnt <= cnt + 1;
            end
            SEND_DEVICE_W :begin   先发最高位  0-7  0-6  7
                ack_flag <= 1;
                if(cnt >= DELAY/4 - 1 && cnt <= DELAY*3/4 - 1)
                    SCL <= 1;
                else
                    SCL <= 0;
                if(cnt_bit >=0 && cnt_bit < 7)
                    sda_out <= DEVICE_ID[6-cnt_bit];
                else    /cnt_bit == 7
                    sda_out <= 0;   //写标志位
                if(cnt == DELAY - 1)
                    cnt <= 0;
                else
                    cnt <= cnt + 1;
                if(cnt == DELAY - 1)
                    cnt_bit <= cnt_bit + 1;
                else
                    cnt_bit <= cnt_bit;
            end
            ACK1          :begin   /从机给主机数据
                if(cnt == DELAY/2 - 1)
                    ack_flag <= sda_in  ;
                else
                    ack_flag <= ack_flag;
                if(cnt >= DELAY/4 - 1 && cnt <= DELAY*3/4 - 1)
                    SCL <= 1;
                else
                    SCL <= 0;
                sda_out <= 1;
                cnt_bit <= 0;
                if(cnt == DELAY - 1)
                    cnt <= 0;
                else
                    cnt <= cnt + 1;
            end
            SEND_ADDR_W   :begin
                ack_flag <= 1;
                if(cnt >= DELAY/4 - 1 && cnt <= DELAY*3/4 - 1)
                    SCL <= 1;
                else
                    SCL <= 0;
                sda_out <= addr[7-cnt_bit];
                if(cnt == DELAY - 1)
                    cnt <= 0;
                else
                    cnt <= cnt + 1;
                if(cnt == DELAY - 1)
                    cnt_bit <= cnt_bit + 1;
                else
                    cnt_bit <= cnt_bit;
            end
            ACK2          :begin
                if(cnt == DELAY/2 - 1)
                    ack_flag <= sda_in  ;
                else
                    ack_flag <= ack_flag;
                if(cnt >= DELAY/4 - 1 && cnt <= DELAY*3/4 - 1)
                    SCL <= 1;
                else
                    SCL <= 0;
                sda_out <= 1;
                cnt_bit <= 0;
                if(cnt == DELAY - 1)
                    cnt <= 0;
                else
                    cnt <= cnt + 1;
            end
            SEND_DATA_W   :begin
                ack_flag <= 1;
                if(cnt >= DELAY/4 - 1 && cnt <= DELAY*3/4 - 1)
                    SCL <= 1;
                else
                    SCL <= 0;
                sda_out <= data_in[7-cnt_bit];
                if(cnt == DELAY - 1)
                    cnt <= 0;
                else
                    cnt <= cnt + 1;
                if(cnt == DELAY - 1)
                    cnt_bit <= cnt_bit + 1;
                else
                    cnt_bit <= cnt_bit;
            end
            ACK3          :begin
                if(cnt == DELAY/2 - 1)
                    ack_flag <= sda_in  ;
                else
                    ack_flag <= ack_flag;
                if(cnt >= DELAY/4 - 1 && cnt <= DELAY*3/4 - 1)
                    SCL <= 1;
                else
                    SCL <= 0;
                sda_out <= 1;
                cnt_bit <= 0;
                if(cnt == DELAY - 1)
                    cnt <= 0;
                else
                    cnt <= cnt + 1;
            end
            STOP          :begin
                ack_flag <= 1;
                if(cnt >= DELAY/4 - 1)
                    SCL <= 1;
                else
                    SCL <= 0;
                if(cnt >= DELAY/2 - 1)
                    sda_out <= 1;
                else
                    sda_out <= 0;
                cnt_bit <= 0;
                if(cnt == DELAY - 1)
                    cnt <= 0;
                else
                    cnt <= cnt + 1;
            end
                          
            START2        :begin
                ack_flag <= 1;
                if(cnt >= DELAY*3/4 - 1)
                    SCL <= 0;
                else
                    SCL <= 1;
                if(cnt >= DELAY/2 - 1)
                    sda_out <= 0;
                else
                    sda_out <= 1;
                cnt_bit <= 0;
                if(cnt == DELAY - 1)
                    cnt <= 0;
                else
                    cnt <= cnt + 1;
            end
            SEND_DEVICE_R :begin
                ack_flag <= 1;
                if(cnt >= DELAY/4 - 1 && cnt <= DELAY*3/4 - 1)
                    SCL <= 1;
                else
                    SCL <= 0;
                if(cnt_bit >=0 && cnt_bit < 7)
                    sda_out <= DEVICE_ID[6-cnt_bit];
                else    /cnt_bit == 7
                    sda_out <= 1;   //读标志位
                if(cnt == DELAY - 1)
                    cnt <= 0;
                else
                    cnt <= cnt + 1;
                if(cnt == DELAY - 1)
                    cnt_bit <= cnt_bit + 1;
                else
                    cnt_bit <= cnt_bit;
            end
            ACK4          :begin
                if(cnt == DELAY/2 - 1)
                    ack_flag <= sda_in  ;
                else
                    ack_flag <= ack_flag;
                if(cnt >= DELAY/4 - 1 && cnt <= DELAY*3/4 - 1)
                    SCL <= 1;
                else
                    SCL <= 0;
                sda_out <= 1;
                cnt_bit <= 0;
                if(cnt == DELAY - 1)
                    cnt <= 0;
                else
                    cnt <= cnt + 1;
            end
            READ_DATA     :begin
                if(cnt == DELAY/2 - 1)
//                    rd_data[7-cnt_bit] <= sda_in;  /法1
                    rd_data <= {rd_data[6:0],sda_in};  法2
                else
                    rd_data <= rd_data;
                ack_flag <= 1;
                if(cnt >= DELAY/4 - 1 && cnt <= DELAY*3/4 - 1)
                    SCL <= 1;
                else
                    SCL <= 0;
                sda_out <= 1;
                if(cnt == DELAY - 1)
                    cnt <= 0;
                else
                    cnt <= cnt + 1;
                if(cnt == DELAY - 1)
                    cnt_bit <= cnt_bit + 1;
                else
                    cnt_bit <= cnt_bit;
            end
            NOACK         :begin
                ack_flag <= 1;
                if(cnt >= DELAY/4 - 1 && cnt <= DELAY*3/4 - 1)
                    SCL <= 1;
                else
                    SCL <= 0;
                sda_out <= 1;
                cnt_bit <= 0;
                if(cnt == DELAY - 1)
                    cnt <= 0;
                else
                    cnt <= cnt + 1;
            end 
        endcase
endmodule

(4)发送端模块

`timescale 1ns / 1ps
module uart_tx(
    input                 sys_clk   ,
    input                 rst_n     ,
    input                 tx_start  ,
      (* MARK_DEBUG="true" *) input     [7:0]       rd_data   ,
      (* MARK_DEBUG="true" *)output    reg         tx_data   ,
    output    reg         tx_done
    );
    parameter            SYSCLK = 50_000_000 ;
    parameter            Baud   = 115200     ;
    parameter            COUNT  = SYSCLK/Baud;
    parameter            MID    = COUNT/2    ;
    

    
    //start_flag
    reg              tx_reg1 ;
    reg              tx_reg2 ;
    (* MARK_DEBUG="true" *)wire             start_flag ;
    
    always@(posedge sys_clk )
         if(!rst_n)begin
            tx_reg1 <= 0 ;
            tx_reg2 <= 0 ;
         end
         else
             begin
                  tx_reg1 <= tx_start ;
                  tx_reg2 <= tx_reg1  ;
             end
   assign start_flag = tx_reg1 & ~tx_reg2 ;
   
   //tx_flag
  (* MARK_DEBUG="true" *) reg              tx_flag  ;
  (* MARK_DEBUG="true" *) reg [9:0]        cnt      ;
  (* MARK_DEBUG="true" *) reg [4:0]        cnt_bit  ; //0 12345678 9 10 
   
   always@(posedge sys_clk )
        if(!rst_n)
           tx_flag <= 0 ;
        else if ( start_flag )
           tx_flag <= 1 ;
        else if ( cnt == COUNT -1 && cnt_bit == 10 )
           tx_flag <= 0 ;
        else
           tx_flag <= tx_flag ;
   
   //cnt
   always@(posedge sys_clk )
        if(!rst_n)
           cnt <= 0 ;
        else if ( tx_flag )begin
             if ( cnt == COUNT -1 )
                  cnt <= 0 ;
             else
                  cnt <= cnt +1 ;
        end
        else
        cnt <= 0 ;
   
   //cnt_bit 
     always@(posedge sys_clk )
          if(!rst_n)
             cnt_bit <= 0 ;
          else if ( tx_flag )begin
               if ( cnt == COUNT -1 )begin
                   if ( cnt_bit == 10 )
                        cnt_bit <= 0 ;
                   else
                        cnt_bit <= cnt_bit +1 ;
               end
               else
               cnt_bit <= cnt_bit ;
          end
          else
          cnt_bit <= 0 ;
   
   
       //寄存rd_data     rd_data随着cur_state变为STOP后清零,在uart_tx模块
    //中,cnt_bit == 0 的时候可以捕捉到数据
   (* MARK_DEBUG="true" *) reg[7:0]              data_reg  ;
    always@(posedge sys_clk )
         if(!rst_n)
            data_reg <= 0 ;
         else if ( tx_flag )begin
              if ( cnt_bit == 0 && cnt == MID -1 )
                  data_reg <= rd_data ;
              else
                  data_reg <= data_reg ;
         end
         else
         data_reg <= data_reg ;
   
     
   
   //tx_data
   parameter                  MODE_CHECK = 0 ;
   always@(posedge sys_clk )
        if(!rst_n)                  //cnt_bit: 0 12345678 9 10
            tx_data <= 0 ;          //rd_data: 01234567
        else if ( tx_flag )begin
             if ( cnt_bit > 0 && cnt_bit <9 )
                  tx_data <= data_reg [ cnt_bit -1 ] ;
             else if ( cnt_bit == 0 )
                  tx_data <= 0 ;
             else if ( cnt_bit == 10 )
                  tx_data <= 1 ;
             else if ( cnt_bit == 9 )
                  tx_data <= (MODE_CHECK == 0 )? ^rd_data : ~^rd_data ;
             else
                  tx_data <= tx_data ;                
        end
        else
        tx_data <= 1 ;
    
    //tx_done 
    always@(posedge sys_clk )
         if(!rst_n)
            tx_done <= 0 ;
         else if ( tx_flag )begin
              if ( cnt == COUNT -1 && cnt_bit == 10 )
                   tx_done <= 1 ;
              else
                   tx_done <= 0 ;
         end
         else
         tx_done <= 0 ;
            
   
   
   
            
    
    
    
    
endmodule

(5)TOP模块

`timescale 1ns / 1ps
module IIC_TOP(
   input                  sys_clk   ,
   input                  rst_n     ,
   input                  key1      ,
   input                  key2      ,
   output                 tx_data   ,
   output                 SCL       ,
   inout                  SDA
    );
  key
  wire                   key_flag_1 ;
  wire                   key_flag_2 ;
    key  key_u1(
               .    sys_clk     (sys_clk    )   ,
               .    rst_n       (rst_n      )   ,
               .    key1        (key1       )   ,
               .    key2        (key2       )   ,
               .    key_flag_1  (key_flag_1 )   ,
               .    key_flag_2  (key_flag_2 )
     
    );
 
 ///data_generate
    wire               iic_end    ;
    wire               wr_en      ;
    wire               rd_en      ;
    wire               iic_start  ;
 
    data_generate data_generate_u1(
                   .    sys_clk     (sys_clk   )  ,
                   .    rst_n       (rst_n     )  ,
                   .    iic_end     (iic_end   )  ,
                   .    key_flag_1  (key_flag_1)  ,
                   .    key_flag_2  (key_flag_2)  ,
                   .    wr_en       (wr_en     )  ,
                   .    rd_en       (rd_en     )  ,
                   .    iic_start   (iic_start )    //按键消抖后延迟1000个时钟周期
    );
    
    IIC
   wire              tx_start   ;
   wire      [7:0]   rd_data    ;
    IIC_2
    #(
              .   SYSCLK     (50_000_000 )        ,
              .   IIC_CLK    (400_000    )        ,
              .   DEVICE_ID  (7'b1010_000)
    )
    IIC_2_u1(
              .     sysclk      (sys_clk)        ,
              .     rst_n       (rst_n )        ,
              .     data_in     (8'h45)        ,
              .     addr        (8'h12)        ,
              .     iic_start   (iic_start)        ,   尖峰脉冲
              .     wr_en       (wr_en   )        ,   ///按键1按下触发
              .     rd_en       (rd_en   )        ,   ///按键2按下触发
              .     tx_start    (tx_start)        ,
              .     rd_data     (rd_data )        ,
              .     SCL         (SCL     )        ,
              .     SDA         (SDA     )        ,
              .     iic_end     (iic_end )            /尖峰脉冲
        );
 
 ///uart_tx
 wire               tx_done    ;
 uart_tx uart_tx_u1(
              .     sys_clk   (sys_clk )  ,
              .     rst_n     (rst_n   )  ,
              .     tx_start  (tx_start)  ,
              .     rd_data   (rd_data )  ,
              .     tx_data   (tx_data )  ,
              .     tx_done   (tx_done )
    );
 
 
 

    
    
    
endmodule

(6)绑定管脚

set_property IOSTANDARD LVCMOS33 [get_ports key1]
set_property IOSTANDARD LVCMOS33 [get_ports key2]
set_property IOSTANDARD LVCMOS33 [get_ports rst_n]
set_property IOSTANDARD LVCMOS33 [get_ports SCL]
set_property IOSTANDARD LVCMOS33 [get_ports SDA]
set_property IOSTANDARD LVCMOS33 [get_ports sys_clk]
set_property IOSTANDARD LVCMOS33 [get_ports tx_data]
set_property PACKAGE_PIN M19 [get_ports key1]
set_property PACKAGE_PIN M20 [get_ports key2]
set_property PACKAGE_PIN P15 [get_ports rst_n]
set_property PACKAGE_PIN F19 [get_ports SCL]
set_property PACKAGE_PIN F20 [get_ports SDA]
set_property PACKAGE_PIN K17 [get_ports sys_clk]
set_property PACKAGE_PIN U18 [get_ports tx_data]

四、set up debug使用步骤

然后点set up debug

XDC文件变成这样就是保存成功了

set_property IOSTANDARD LVCMOS33 [get_ports key1]
set_property IOSTANDARD LVCMOS33 [get_ports key2]
set_property IOSTANDARD LVCMOS33 [get_ports rst_n]
set_property IOSTANDARD LVCMOS33 [get_ports SCL]
set_property IOSTANDARD LVCMOS33 [get_ports SDA]
set_property IOSTANDARD LVCMOS33 [get_ports sys_clk]
set_property IOSTANDARD LVCMOS33 [get_ports tx_data]
set_property PACKAGE_PIN M19 [get_ports key1]
set_property PACKAGE_PIN M20 [get_ports key2]
set_property PACKAGE_PIN P15 [get_ports rst_n]
set_property PACKAGE_PIN F19 [get_ports SCL]
set_property PACKAGE_PIN F20 [get_ports SDA]
set_property PACKAGE_PIN K17 [get_ports sys_clk]
set_property PACKAGE_PIN U18 [get_ports tx_data]


create_debug_core u_ila_0 ila
set_property ALL_PROBE_SAME_MU true [get_debug_cores u_ila_0]
set_property ALL_PROBE_SAME_MU_CNT 1 [get_debug_cores u_ila_0]
set_property C_ADV_TRIGGER false [get_debug_cores u_ila_0]
set_property C_DATA_DEPTH 4096 [get_debug_cores u_ila_0]
set_property C_EN_STRG_QUAL false [get_debug_cores u_ila_0]
set_property C_INPUT_PIPE_STAGES 0 [get_debug_cores u_ila_0]
set_property C_TRIGIN_EN false [get_debug_cores u_ila_0]
set_property C_TRIGOUT_EN false [get_debug_cores u_ila_0]
set_property port_width 1 [get_debug_ports u_ila_0/clk]
connect_debug_port u_ila_0/clk [get_nets [list sys_clk_IBUF_BUFG]]
set_property PROBE_TYPE DATA_AND_TRIGGER [get_debug_ports u_ila_0/probe0]
set_property port_width 8 [get_debug_ports u_ila_0/probe0]
connect_debug_port u_ila_0/probe0 [get_nets [list {IIC_2_u1/cnt[0]} {IIC_2_u1/cnt[1]} {IIC_2_u1/cnt[2]} {IIC_2_u1/cnt[3]} {IIC_2_u1/cnt[4]} {IIC_2_u1/cnt[5]} {IIC_2_u1/cnt[6]} {IIC_2_u1/cnt[7]}]]
create_debug_port u_ila_0 probe
set_property PROBE_TYPE DATA_AND_TRIGGER [get_debug_ports u_ila_0/probe1]
set_property port_width 3 [get_debug_ports u_ila_0/probe1]
connect_debug_port u_ila_0/probe1 [get_nets [list {IIC_2_u1/cnt_bit[0]} {IIC_2_u1/cnt_bit[1]} {IIC_2_u1/cnt_bit[2]}]]
create_debug_port u_ila_0 probe
set_property PROBE_TYPE DATA_AND_TRIGGER [get_debug_ports u_ila_0/probe2]
set_property port_width 4 [get_debug_ports u_ila_0/probe2]
connect_debug_port u_ila_0/probe2 [get_nets [list {IIC_2_u1/cur_state[0]} {IIC_2_u1/cur_state[1]} {IIC_2_u1/cur_state[2]} {IIC_2_u1/cur_state[3]}]]
create_debug_port u_ila_0 probe
set_property PROBE_TYPE DATA_AND_TRIGGER [get_debug_ports u_ila_0/probe3]
set_property port_width 10 [get_debug_ports u_ila_0/probe3]
connect_debug_port u_ila_0/probe3 [get_nets [list {data_generate_u1/cnt[0]} {data_generate_u1/cnt[1]} {data_generate_u1/cnt[2]} {data_generate_u1/cnt[3]} {data_generate_u1/cnt[4]} {data_generate_u1/cnt[5]} {data_generate_u1/cnt[6]} {data_generate_u1/cnt[7]} {data_generate_u1/cnt[8]} {data_generate_u1/cnt[9]}]]
create_debug_port u_ila_0 probe
set_property PROBE_TYPE DATA_AND_TRIGGER [get_debug_ports u_ila_0/probe4]
set_property port_width 8 [get_debug_ports u_ila_0/probe4]
connect_debug_port u_ila_0/probe4 [get_nets [list {uart_tx_u1/rd_data[0]} {uart_tx_u1/rd_data[1]} {uart_tx_u1/rd_data[2]} {uart_tx_u1/rd_data[3]} {uart_tx_u1/rd_data[4]} {uart_tx_u1/rd_data[5]} {uart_tx_u1/rd_data[6]} {uart_tx_u1/rd_data[7]}]]
create_debug_port u_ila_0 probe
set_property PROBE_TYPE DATA_AND_TRIGGER [get_debug_ports u_ila_0/probe5]
set_property port_width 8 [get_debug_ports u_ila_0/probe5]
connect_debug_port u_ila_0/probe5 [get_nets [list {IIC_2_u1/rd_data[0]} {IIC_2_u1/rd_data[1]} {IIC_2_u1/rd_data[2]} {IIC_2_u1/rd_data[3]} {IIC_2_u1/rd_data[4]} {IIC_2_u1/rd_data[5]} {IIC_2_u1/rd_data[6]} {IIC_2_u1/rd_data[7]}]]
create_debug_port u_ila_0 probe
set_property PROBE_TYPE DATA_AND_TRIGGER [get_debug_ports u_ila_0/probe6]
set_property port_width 1 [get_debug_ports u_ila_0/probe6]
connect_debug_port u_ila_0/probe6 [get_nets [list IIC_2_u1/ack_flag]]
create_debug_port u_ila_0 probe
set_property PROBE_TYPE DATA_AND_TRIGGER [get_debug_ports u_ila_0/probe7]
set_property port_width 1 [get_debug_ports u_ila_0/probe7]
connect_debug_port u_ila_0/probe7 [get_nets [list IIC_2_u1/iic_end]]
create_debug_port u_ila_0 probe
set_property PROBE_TYPE DATA_AND_TRIGGER [get_debug_ports u_ila_0/probe8]
set_property port_width 1 [get_debug_ports u_ila_0/probe8]
connect_debug_port u_ila_0/probe8 [get_nets [list data_generate_u1/iic_start]]
create_debug_port u_ila_0 probe
set_property PROBE_TYPE DATA_AND_TRIGGER [get_debug_ports u_ila_0/probe9]
set_property port_width 1 [get_debug_ports u_ila_0/probe9]
connect_debug_port u_ila_0/probe9 [get_nets [list key_u1/key1]]
create_debug_port u_ila_0 probe
set_property PROBE_TYPE DATA_AND_TRIGGER [get_debug_ports u_ila_0/probe10]
set_property port_width 1 [get_debug_ports u_ila_0/probe10]
connect_debug_port u_ila_0/probe10 [get_nets [list key_u1/key2]]
create_debug_port u_ila_0 probe
set_property PROBE_TYPE DATA_AND_TRIGGER [get_debug_ports u_ila_0/probe11]
set_property port_width 1 [get_debug_ports u_ila_0/probe11]
connect_debug_port u_ila_0/probe11 [get_nets [list key_u1/key_flag_1]]
create_debug_port u_ila_0 probe
set_property PROBE_TYPE DATA_AND_TRIGGER [get_debug_ports u_ila_0/probe12]
set_property port_width 1 [get_debug_ports u_ila_0/probe12]
connect_debug_port u_ila_0/probe12 [get_nets [list key_u1/key_flag_2]]
create_debug_port u_ila_0 probe
set_property PROBE_TYPE DATA_AND_TRIGGER [get_debug_ports u_ila_0/probe13]
set_property port_width 1 [get_debug_ports u_ila_0/probe13]
connect_debug_port u_ila_0/probe13 [get_nets [list data_generate_u1/rd_en]]
create_debug_port u_ila_0 probe
set_property PROBE_TYPE DATA_AND_TRIGGER [get_debug_ports u_ila_0/probe14]
set_property port_width 1 [get_debug_ports u_ila_0/probe14]
connect_debug_port u_ila_0/probe14 [get_nets [list IIC_2_u1/SCL]]
create_debug_port u_ila_0 probe
set_property PROBE_TYPE DATA_AND_TRIGGER [get_debug_ports u_ila_0/probe15]
set_property port_width 1 [get_debug_ports u_ila_0/probe15]
connect_debug_port u_ila_0/probe15 [get_nets [list IIC_2_u1/SDA_IBUF]]
create_debug_port u_ila_0 probe
set_property PROBE_TYPE DATA_AND_TRIGGER [get_debug_ports u_ila_0/probe16]
set_property port_width 1 [get_debug_ports u_ila_0/probe16]
connect_debug_port u_ila_0/probe16 [get_nets [list IIC_2_u1/SDA_OBUF]]
create_debug_port u_ila_0 probe
set_property PROBE_TYPE DATA_AND_TRIGGER [get_debug_ports u_ila_0/probe17]
set_property port_width 1 [get_debug_ports u_ila_0/probe17]
connect_debug_port u_ila_0/probe17 [get_nets [list uart_tx_u1/tx_data]]
create_debug_port u_ila_0 probe
set_property PROBE_TYPE DATA_AND_TRIGGER [get_debug_ports u_ila_0/probe18]
set_property port_width 1 [get_debug_ports u_ila_0/probe18]
connect_debug_port u_ila_0/probe18 [get_nets [list IIC_2_u1/tx_start]]
create_debug_port u_ila_0 probe
set_property PROBE_TYPE DATA_AND_TRIGGER [get_debug_ports u_ila_0/probe19]
set_property port_width 1 [get_debug_ports u_ila_0/probe19]
connect_debug_port u_ila_0/probe19 [get_nets [list data_generate_u1/wr_en]]
set_property C_CLK_INPUT_FREQ_HZ 300000000 [get_debug_cores dbg_hub]
set_property C_ENABLE_CLK_DIVIDER false [get_debug_cores dbg_hub]
set_property C_USER_SCAN_CHAIN 1 [get_debug_cores dbg_hub]
connect_debug_port dbg_hub/clk [get_nets sys_clk_IBUF_BUFG]

"4"对应后面几个cnt_bit

五、实验结果

按下控制“写”的按键,再按下“读”的按键后,pc端返回45

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1919935.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Spring-Spring、IoC、DI、注解开发

1、Spring是什么 Spring是一个轻量级的控制反转(IoC)和面向切面(AOP)的容器(框架)。 Spring整体架构 Spring优点&#xff1a; Spring属于低侵入设计。IOC将对象之间的依赖关系交给Spring,降低组件之间的耦合&#xff0c;实现各个层之间的解耦&#xff0c;让我们更专注于业务…

Day1每日编程题日记:数字统计、两个数组的交集、点击消除

前言&#xff1a;该篇用于记录自看。曾回看昨天的做题代码&#xff0c;竟然会觉得陌生&#xff0c;这竟然是我写的&#xff0c;细细读了一下&#xff0c;原来我当时是这么想的。因此我觉得记代码没有实际用处&#xff0c;重点是领悟了思想&#xff0c;这样子代码就在心中&#…

怎样将aac转换mp3格式?推荐四个aac转MP3的方法

怎样将aac转换mp3格式&#xff1f;当需要将aac格式音频转换为MP3格式时&#xff0c;有几种方法可以轻松实现这一目标。MP3是一种广泛支持的音频格式&#xff0c;几乎所有设备和平台都能播放MP3文件&#xff0c;包括各种音乐播放器、手机、平板电脑和汽车音响系统。而且它也提供…

MQTT协议网关解决方案及实施简述-天拓四方

MQTT协议网关是一个中间件&#xff0c;负责接收来自不同MQTT客户端的消息&#xff0c;并将这些消息转发到MQTT服务器&#xff1b;同时&#xff0c;也能接收来自MQTT服务器的消息&#xff0c;并将其转发给相应的MQTT客户端。MQTT协议网关的主要功能包括协议转换、消息过滤、安全…

YOLOv10改进 | 主干/Backbone篇 | 利用RT-DETR特征提取网络PPHGNetV2改进YOLOv10

一、本文介绍 本文给大家带来利用RT-DETR模型主干HGNet去替换YOLOv10的主干&#xff0c;RT-DETR是今年由百度推出的第一款实时的ViT模型&#xff0c;其在实时检测的领域上号称是打败了YOLO系列&#xff0c;其利用两个主干一个是HGNet一个是ResNet&#xff0c;其中HGNet就是我们…

会声会影分割音频怎么不能用 会声会影分割音频方法 会声会影视频制作教程 会声会影下载免费中文版2023

将素材中的音频分割出来&#xff0c;对声音部分进行单独编辑&#xff0c;是剪辑过程中的常用操作。会声会影视频剪辑软件在分割音频后&#xff0c;还可以对声音素材进行混音编辑、音频调节、添加音频滤镜等操作。有关会声会影分割音频怎么不能用&#xff0c;会声会影分割音频方…

加密软件|让数据传输更安全

加密软件在当今数字化时代扮演着至关重要的角色&#xff0c;它们通过先进的加密算法和技术&#xff0c;确保数据在存储、传输和分享过程中的安全性&#xff0c;从而保护个人隐私和企业机密。一、加密软件的基本作用数据加密&#xff1a;加密软件通过应用复杂的加密算法&#xf…

回归树模型

目录 一、回归树模型vs决策树模型&#xff1a;二、回归树模型的叶结点&#xff1a;三、如何决定每个非叶结点上的特征类型&#xff1a; 本文只介绍回归树模型与决策树模型的区别。如需了解完整的理论&#xff0c;请看链接&#xff1a;决策树模型笔记 一、回归树模型vs决策树模…

欣奇随机美图源码

欣赏养眼美图让人心情愉悦 新增正能量进站引导首页 上传文件解压即可用有手就行 美图输出接口自判断版 http://mt.xqia.net/api.php http://mt.xqia.net/api.php?typejson 源码下载&#xff1a;https://download.csdn.net/download/m0_66047725/89520368 更多资源下载&…

Kotlin MultiPlatform(KMP)

Kotlin MultiPlatform 1.KMP 是什么 Kotlin Multiplatform 是一个工具&#xff0c;它让我们用同一种编程语言&#xff08;Kotlin&#xff09;写代码&#xff0c;这些代码可以同时在不同的设备上运行&#xff0c;比如手机、电脑和网页。这样做可以节省时间&#xff0c;因为你不…

昇思25天学习打卡营第23天|K近邻算法实现红酒聚类

学AI还能赢奖品&#xff1f;每天30分钟&#xff0c;25天打通AI任督二脉 (qq.com) K近邻算法实现红酒聚类 本实验主要介绍使用MindSpore在部分wine数据集上进行KNN实验。 1、实验目的 了解KNN的基本概念&#xff1b;了解如何使用MindSpore进行KNN实验。 2、K近邻算法原理介绍…

液晶电子看板助力工厂打造车间精益管理数字化

在当今竞争激烈的市场环境下&#xff0c;企业追求生产智能化已成为提升竞争力的关键。要实现这一目标&#xff0c;生产现场设备联网进行数据采集是首要且基础的步骤。工业生产设备作为核心要素&#xff0c;其产生的各类数据与产品质量及企业运营效率息息相关。 在这样的背景下&…

自然语言处理基本概念

自然语言处理基本概念 所有学习循环神经网络的人都是看这一篇博客长大的&#xff1a; https://colah.github.io/posts/2015-08-Understanding-LSTMs/ import jieba import torch from torch import nns1 "我吃饭了&#xff01;" s2 "今天天气很好&#xff01…

加减计数器

目录 描述 输入描述&#xff1a; 输出描述&#xff1a; 参考代码 描述 请编写一个十进制计数器模块&#xff0c;当mode信号为1&#xff0c;计数器输出信号递增&#xff0c;当mode信号为0&#xff0c;计数器输出信号递减。每次到达0&#xff0c;给出指示信号zero。 模块的接…

【鸿蒙学习笔记】使用httpRequest进行HTTP数据请求

官方文档&#xff1a;网络管理开发概述 目录标题 访问淘宝公开接口&#xff08;测试数据&#xff09;第1步&#xff1a;module.json5 配置网络授权第2步&#xff1a;源码第3步&#xff1a;启动模拟器第4步&#xff1a;启动entry第5步&#xff1a;操作 访问淘宝公开接口&#x…

区分modbus tcp和tcp/ip

Modbus 对某些人来说&#xff0c;这听起来可能很复杂&#xff0c;也很令人费解&#xff0c;但是一旦你了解了它的工作原理&#xff0c;那就是一个特别简单的过程。MODBUS 这是一种请求和响应协议。MODBUS 主站将发起请求&#xff0c;从站将响应错误或请求信息。这就是 modbus 简…

海外媒体软文发稿:南非新闻通稿宣发,谷歌新闻收录

南非媒体介绍 南非作为非洲大陆最先进的经济体之一&#xff0c;拥有着丰富多样的媒体资源。在南非&#xff0c;各种类型的新闻报纸、杂志和网站充斥着市场。以下是一些南非主要媒体的 大舍传媒 大舍传媒是专注南非最有影响力的发稿平台之一&#xff0c;其新闻报道覆盖了南非…

【深度学习】基于深度学习的模式识别基础

一 模式识别基础 “模式”指的是数据中具有某些相似特征或属性的事物或事件的集合。具体来说&#xff0c;模式可以是以下几种形式&#xff1a; 视觉模式 在图像或视频中&#xff0c;模式可以是某种形状、颜色组合或纹理。例如&#xff0c;人脸、文字字符、手写数字等都可以视…

【鸿蒙学习笔记】通过用户首选项实现数据持久化

官方文档&#xff1a;通过用户首选项实现数据持久化 目录标题 使用场景第1步&#xff1a;源码第2步&#xff1a;启动模拟器第3步&#xff1a;启动entry第6步&#xff1a;操作样例2 使用场景 Preferences会将该数据缓存在内存中&#xff0c;当用户读取的时候&#xff0c;能够快…

千呼新零售2.0-OCR图像识别采购单视频介绍

千呼新零售2.0系统是零售行业连锁店一体化收银系统&#xff0c;包括线下收银线上商城连锁店管理ERP管理商品管理供应商管理会员营销等功能为一体&#xff0c;线上线下数据全部打通。 适用于商超、便利店、水果、生鲜、母婴、服装、零食、百货、宠物等连锁店使用。 详细介绍请…