reg have_data = 0;
reg [3:0] diqing = 4'b0000;
- wire new = (wr) && (!have_data) && decode;
+ wire newdata = (wr) && (!have_data) && decode;
assign odata = have_data ? 8'b1 : 8'b0;
- always @ (negedge clk)
+ always @ (posedge clk)
begin
/* deal with diqing */
- if(new) begin
+ if(newdata) begin
data_stor <= data;
have_data <= 1;
diqing <= 4'b0000;
end
/* deal with clkdiv */
- if((new && !have_data) || clkdiv == `CLK_DIV)
+ if((newdata && !have_data) || clkdiv == `CLK_DIV)
clkdiv <= 0;
else
clkdiv <= clkdiv + 1;