好象是可以了,但总觉得没有C语言中在不同函数中对同一变量赋值方便,请高手看是否可行。
module(reset,clk,wr,rd,add,status)
input reset,clk,wr,rd;
input [2:0] add;
output status;
wire [7:0] cs;
wire **;
reg [3:0] counter;
assign cs = ~(1<<add);
assign ** = cs[1] | wr;
always @ (posedge clk)
begin
if (!reset)counter <= 0;
else
begin
if(counter=7)counter<=0;
else counter<= counter + 1;
end
end
always @(negedge wr)
begin
if(!cs[2])....... //do something
end
always @(posedge counter[3] or negedge **)
begin
if(!**) status <= 0;
else if (counter[3])status <=1;
end
endmodule
|