我有一个注册:
reg [7:0] dout; //output of memory bus
dout中的位组表示有意义的内容,如:
我想从always语句中读取和写入这个寄存器dout。我想用这些标签来解决它。 这个例子传达了我的尝试:
reg [7:0] dout; //output of memory bus
wire [2:0] dout_state;
wire dout_flag;
wire [3:0] dout_data;
//alias labels
assign dout_state[2:0] = dout[2:0];
assign dout_flag = dout[3];
assign dout_data = dout[7:4];
always(@posedge clk) begin
dout_state <= 3'b1;
dout_flag <= 1'b1;
end
程序分配失败,因为dout_state和dout_flag是连线。
我希望这些标签能够作为代表dout总线部分的别名。
我怎样才能做到这一点?
答案 0 :(得分:1)
The always block already drives dout_state
and dout_flag
signals, so the other assignments should be reversed. Your current code never drives dout
.
//alias labels
assign dout[2:0] = dout_state;
assign dout[3] = dout_flag;
assign dout[7:4] = dout_data;
Now the signal definitions also should be updated. If dout
is a port, the reg
definition should be removed. If not, it should be a wire
.
wire [7:0] dout; //output of memory bus
Because of the always block, dout_state
and dout_flag
signals should be reg
.
reg [2:0] dout_state;
reg dout_flag;