这是我写的代码 编译通过可 但是用RTL viewer看电路图 觉得很畸形 希望有人能帮我看看 或者给出例程
先谢谢了
module stack
#(
parameter N = 8, //number of bits in a word
W = 2 //number of address bits
)
(
input wire clk,reset,
input wire [N-1:0] d_in,
output reg [N-1:0] d_out
);
//conttrol signal declaration
reg [N-1:0] stack_reg [2**W-1:0];
wire ptr_bottom,ptr_top;
reg ptr_now;
wire push,pop;
//
assign ptr_bottom = stack_reg[2**W-1];
assign ptr_top = stack_reg[0];
//body
//register file push operation
always @(posedge clk)
if(!reset)
ptr_now <= ptr_bottom;
else if(push & (ptr_now < ptr_top))
stack_reg[ptr_now + 1] <= d_in;
else if(pop & (ptr_now > ptr_bottom))
d_out <= stack_reg[ptr_now];
endmodule
-
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>