Example: Traffic Light Controller
module FSM(HR, HY, HG, FR, FY, FG, ST, TS, TL, C, reset, Clk); output HR; output HY; output HG; output FR; output FY; output FG; output ST; input TS; input TL; input C; input reset; input Clk; reg [6:1] state; reg ST;
`define highwaygreen 6'b001100 `define highwayyellow 6'b010100 `define farmroadgreen 6'b100001 `define farmroadyellow 6'b100010
assign HR = state[6]; assign HY = state[5]; assign HG = state[4]; assign FR = state[3]; assign FY = state[2]; assign FG = state[1];
specify state bits and codes for each state as well as connections to outputs
Specification of inputs, outputs, and state elements