这几天连续睡眠不足,实在看花眼了。
这段代码就是无法切换状态
麻烦帮我看看为什么进不到状态机里!!
module Controller( //Inputs reset, clock_488, frame_synch,
//Outputs frame_load, //for Mux shift, //for Mux and shift register
load, //for 8bit register demux_sel, //for Demux data_out_enb //for Demux );
input reset, clock_488, frame_synch;
output frame_load, shift; reg frame_load, shift;
output load; reg load;
output [4:0] demux_sel; reg [4:0] demux_sel;
output data_out_enb; reg data_out_enb;
parameter S_idle = 4'b0001, S_sampling = 4'b0010, S_shifting = 4'b0100, S_dout = 4'b1000;
reg [3:0] state, next_state; reg [2:0] ld_counter; reg [7:0] sft_counter;
/*frame_synch or*/ always @(state) begin case(state) S_idle: begin frame_load = 0; load = 0; data_out_enb = 0; ld_counter = 0; sft_counter = 0; shift = 0; if(frame_synch) next_state = S_sampling; else next_state = S_idle; end S_sampling: //就是进不去这里啊!!!波形激励都没问题啊!!!!!! begin frame_load = 1; next_state = S_shifting; end S_shifting: begin shift = 1; //2 fanout, 1 for Mux , other for shiftRegister demux_sel = sft_counter / 8; //decide which output tunnel is selected
//when the shift register is full, load it to the holding register if(ld_counter == 7) load = 1; //when load is set, the data is held into register and output to registers // of Demux according to demux_sel else load = 0; ld_counter = ld_counter + 3'b001; //when the whole 256bit data was transported over, then begin next state if(sft_counter == 255) next_state = S_dout; else next_state = S_shifting; sft_counter = sft_counter + 8'h01; end S_dout: begin shift = 0; data_out_enb = 1; next_state = S_idle; end default: next_state = S_idle; endcase end /*or posedge frame_synch*/ always @(posedge clock_488 or posedge reset) begin if(reset) state <= S_idle; else state <= next_state; //按说这句执行以后就可以跳进上面的状态机了,但是就是不进去! end endmodule
[此贴子已经被作者于2006-5-25 23:29:45编辑过] |