Rule
1) Traffic Light는 차량이 없을 때 초록색에서 노란색을 거쳐 빨간색으로 변한다.
2) Moore FSM 사용
Next State Logic
module ns_logic(TA,TB,state,next_state);
input [1:0] TA,TB;
input [1:0] state;
output [1:0] next_state;
wire w0,w1;
_xor2 U0_xor2(.a(state[1]),.b(state[0]),.y(next_state[1]));
_and3 U1_and3(.a(~(state[1])),.b(~(state[0])),.c(~(TA)),.y(w0));
_and3 U2_and3(.a(state[1]),.b(~(state[0])),.c(~(TB)),.y(w1));
_or2 U3_or2(.a(w0),.b(w1),.y(next_state[0]));
endmodule
이를 토대로한 Bool 식
Output Logic
os_logic(state,LA,LB);
input [1:0] state;
output [1:0] LA,LB;
assign LA[1] = state[1];
_and2 U0_and2(.a(~state[1]),.b(state[0]),.y(LA[0]));
assign LB[1] = ~state[1];
_and2 U1_and2(.a(state[1]),.b(state[0]),.y(LB[0]));
endmodule
Traffic Light Controller
module tl_cntr(clk,reset_n,TA,TB,LA,LB);
input clk,reset_n,TA,TB;
output [1:0] LA,LB;
wire [1:0] state,next_state;
ns_logic U0_ns_logic(.TA(TA),.TB(TB),.state(state),.next_state(next_state));
os_logic U1_os_logic(.state(next_state),.LA(LA),.LB(LB));
_register2_r U2_register2_r(.clk(clk),.reset_n(reset_n),.d(next_state),.q(state));
endmodule
'Computer > Computer Structure' 카테고리의 다른 글
I/O Mapped I/O vs Memory Mapped I/O (0) | 2013.05.20 |
---|---|
Blocking vs Non-Blocking (Verilog) (0) | 2013.05.20 |
Shifter (0) | 2013.05.14 |
Counter (0) | 2013.05.13 |
Finite State Machine(FSM) (0) | 2013.05.12 |