下面是一个4位的双向移位寄存器程序 该程序正确吗? module UniversalShift (S1 S0 Din Dsl Dsr Q
已帮助 人
下面是一个4位的双向移位寄存器程序,该程序正确吗? module UniversalShift (S1,S0,Din,Dsl,Dsr,Q,CP,CLR_); input S1, S0; //Select inputs input Dsl, Dsr; //Serial Data inputs input CP, CLR_; //Clock and Reset input [3:0] Din; //Parallel Data input output [3:0] Q; //Register output reg [3:0] Q; always @ (posedge CP or negedge CLR_) if (~CLR_) Q <= 4"b0000; else case ({S1,S0}) 2"b00: Q <= Q; //No change 2"b01: Q <= {Dsr,Q[3:1]}; //Shift right 2"b10: Q <= {Q[2:0],Ds

回答
共1条回复-
正确
