module project(
input wire clk,
input wire reset_n,
input wire [7:0] plx_data_in,
input wire [3:0] plx_addr_in,
output reg [7:0] received_data //接收到的数据给到led灯
);
reg [7:0] data; //接收到的数据先存储在寄存器中
reg [3:0] expected_addr = 4'h4; // 期望的地址值
reg [2:0] state;
always @(posedge clk or negedge reset_n) begin
if (~reset_n) begin
state <= 3'b000; // 初始化状态
end else begin
case (state)
3'b000: begin // 等待主板发送数据
state <= 3'b001; // 进入接收状态
end
3'b001: begin // 接收数据
data <= plx_data_in;// 存储接收到的数据
if (plx_addr_in == expected_addr) begin // 判断地址是否一致
received_data <= data; // 执行相关操作,例如处理接收到的数据
end
state <= 3'b000; // 返回等待状态
end
endcase
end
end
endmodule
我写了一个关于CPLD并口通信的程序,接收来自上位机1字节的数据,上位机使用PLxBusIopWrite函数发送函数,一直通信不了,大家可以帮我看一下吗
举报
更多回帖