|
请教个问题:如何实现16位寄存器的8位接收,同时低8位移到高8位?
我现在做的项目有个问题:就是使用串口接收8位数据,但是16位数据才组成一个控制命令,我想使用一个16位寄存器的低8位接收最新的数据,在接收最新数据的同时,低8位数据移动到高8位,如何实现此功能?
像下面这样写是否可以,在一个时钟周期command2是否能同时完成低8位接收、同时低8位移动到高8位的两个动作?
begin
command2[7:0] <=command;
command2 <=command2<<8'd8;
end
//------------------------------------
`timescale 1ns / 1ps
module cis_ctrl(
clk,
rst_n,
rcv_data_sig,
command,
rtn,
state0,
state1,
state_trg
);
//
input clk;
input rst_n;
input rcv_data_sig;
input command;
output state0;
output state1;
output [7:0]state_trg;
output rtn;
reg [15:0]command2;
reg command1;
always @(posedge clk or negedge rst_n)
if(!rst_n)
command2<=16'd0;
else if(rcv_data_sig)
begin
command2[7:0] <=command;
command2 <=command2<<8'd8;
end
endmodule |
阿莫论坛20周年了!感谢大家的支持与爱护!!
知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)
|