Exams/2014 q4a
2023. 6. 19. 15:31ㆍFPGA/HDLBits
728x90
Problem Statement
Consider the n-bit shift register circuit shown below:
Write a Verilog module named top_module for one stage of this circuit, including both the flip-flop and multiplexers.
module top_module (
input clk,
input w, R, E, L,
output Q
);
wire out_mux1;
wire out_mux2;
assign out_mux1 = E ? w : Q;
assign out_mux2 = L ? R : out_mux1;
always @ (posedge clk)begin
Q <= out_mux2;
end
endmodule
//실패 코드
module top_module (
input clk,
input w, R, E, L,
output Q
);
wire out_mux1;
wire out_mux2;
assign out_mux1 = E ? w : 1'b0;
assign out_mux2 = L ? R : out_mux1;
always @ (posedge clk)begin
Q <= out_mux2;
end
endmodule
- 플립플롭들은 출력 신호가 입력으로 들어가는 피드백루프를 구성하기 때문에 reset을 이용해서 초기 출력을 0으로 잡아두고 시작한다. -> Qn-1을 1'b0으로 잡고 시작하였다 (실패) -> Q출력을 out_mux1의 조건문으로 넣어서 해결 완료.
'FPGA > HDLBits' 카테고리의 다른 글
Exams/ece241 2013 q7 (0) | 2023.06.19 |
---|---|
Exams/ece241 2014 q4 (0) | 2023.06.19 |
Mt2015 muxdff (0) | 2023.06.19 |
Exams/m2014 q4b (0) | 2023.06.19 |
Bugs addsubz (0) | 2023.06.18 |