|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
写了一个程序仿真结果都正常,但把程序下载到FPGA里面就无法工作。下面是状态机的程序,现在是实际电路中检测不到S0状态中的triggle_rising,不知道程序哪里有问题,求大神来看看呐。
- module fsm(
- output reg rw,
- output reg endatapath,
- input spi_cs,
- input full,
- input triggle,
- input clk
- );
-
- reg[1:0] state,next_state;
- parameter S0 = 2'b00,
- S1 = 2'b01,
- S2 = 2'b10,
- S3 = 2'b11;
- reg sync_cs1;
- reg sync_cs2;
- reg sync_triggle1;
- reg sync_triggle2;
- reg triggle_low;
- reg triggle_high;
- wire triggle_rising;
- always @(posedge clk)
- begin
- sync_cs1 <= spi_cs;
- sync_cs2 <= sync_cs1;
- sync_triggle1 <= triggle;
- sync_triggle2 <= sync_triggle1;
- triggle_low <= sync_triggle2;
- triggle_high <= triggle_low;
- end
- assign triggle_rising = (triggle_low)&(~triggle_high);
- always @(posedge clk)
- begin
- state <= next_state;
- end
- always @(state,full,sync_cs2,triggle_rising)
- begin
- rw = 1'b0;
- endatapath = 1'b0;
- next_state = S0;
- case(state)
- S0 : begin
- if(triggle_rising) next_state = S1;
- else next_state = S0;
- end
- S1 : begin
- rw = 1'b1;
- endatapath = 1'b1;
- if(full) next_state = S2;
- else next_state = S1;
- end
- S2 : begin
- next_state = S2;
- if(sync_cs2)
- next_state = S3;
- end
- S3 : begin
- endatapath = 1'b1;
- rw = 1'b0;
- if(full) next_state = S0;
- else next_state = S3;
- end
- endcase
- end
- endmodule
复制代码 |
|