STM32通过FSMC与FPGA通信
时间:10-02
整理:3721RD
点击:
各位朋友好,STM32通过FSMC与FPGA通信,我该怎样测试通信是正常的? FPGA 代码如下
- module verilog_prj(
- clk,
- arm_clk,
- led0,
- ab, //address
- db, //data
- wrn, //wr
- rdn, //rd
- csn //cs
- );
- input clk; //25MHz
- output led0;
- output arm_clk;
- wire clk_8m; //输入时钟的4倍频,100MHz
- wire locked; //PLL输出有效标志位,高有效
- input[2:0] ab;
- inout[15:0] db;
- input wrn;
- input rdn;
- input csn;
- reg [15:0] outa;
- reg [15:0] outb;
- reg [15:0] outc;
- reg [15:0] outd;
- reg [15:0] oute;
- reg [15:0] outf;
- reg [15:0] outg;
- reg [15:0] outh;
- reg [15:0] out;
- //reg [15:0] ina;
- //reg [15:0] inb;
- //reg [15:0] inc;
- //reg [15:0] ind;
- //reg [15:0] ine;
- //reg [15:0] inf;
- //reg [15:0] ing;
- //reg [15:0] inh;
- //wire rd;
- //wire wr;
- reg [15:0] indata;
- //assign rd = !(csn & rdn); //get rd pulse ____|~~~~|______
- //assign wr = !(csn & wrn); //get wr pulse ____|~~~~|______
- assign db = !rdn ? indata:16'hzzzz;
- // assign db = indata ;
- /*
- ****************************************************************
- *
- * PLL例化
- *
- ****************************************************************
- */
- PLL_ctrl PLL_ctrl_inst (
- .inclk0(clk), //PLL输入时钟
- .c0(clk_8m), //8MHz to ARM
- .locked(locked) //PLL输出有效标志位,高有效
- );
-
- /*
- ****************************************************************
- *
- * LED0闪烁
- *
- ****************************************************************
- */
- reg[24:0] cnt1;
- always @ (posedge clk) begin
- if(cnt1 == 25'd25_000_000)
- begin
- cnt1 <= 25'd0;
- out <= out+1'b1;
- end
- else
- begin
- cnt1 <= cnt1+1'b1;
-
- end
- end
- assign led0 = cnt1[24];
- assign arm_clk = clk_8m;
- /*
- ****************************************************************
- *
- * FSMC读写
- *
- ****************************************************************
- */
- //write data, 根据地址线选择八个空间写入,每个空间16位
- always @(negedge wrn)
- begin
- if(csn == 0)
- begin
- case (ab)
- 3'b000:outa <= db;
- 3'b001:outb <= db;
- 3'b010:outc <= db;
- 3'b011:outd <= db;
- 3'b100:oute <= db;
- 3'b101:outf <= db;
- 3'b110:outg <= db;
- 3'b111:outh <= db;
- default:;
- endcase
- end
- end
-
- //red data 根据地址线选择8个空间读取,每个空间 16位
- always @( rdn )
- begin
- if(csn == 0)
- begin
- case (ab)
- 3'b000:indata <= out;
- 3'b001:indata <= outb;
- 3'b010:indata <= outc;
- 3'b011:indata <= outd;
- 3'b100:indata <= oute;
- 3'b101:indata <= outf;
- 3'b110:indata <= outg;
- 3'b111:indata <= outh;
- default:;
- endcase
- end
- end
- endmodule
stm32通过FSMC与FPGA通信 地址线连接3根,数据线16根,片选1根、读信号1根、写信号1根; 是这样吗
STM32通过FSMC与FPGA通信