Digital Signal Processing Reference
In-Depth Information
default : state = ABout;
endcase
end
// combine sensor bits for case statements above
// { } operators combine bits
wire [1:0] sensor12 = {sensor1, sensor2};
wire [1:0] sensor13 = {sensor1, sensor3};
wire [1:0] sensor24 = {sensor2, sensor4};
// These outputs do not depend on the state
wire switch3 = 0;
// Outputs that depend on state, use state to select value
// Be sure to specify every output for every state
// values will not default to zero!
always @(state)
begin
case (state)
A B o u t :
begin
s w i t c h 1 = 0 ;
s w i t c h 2 = 0 ;
dirA = 2'b 01;
dirB = 2'b 01;
end
A i n :
begin
s w i t c h 1 = 0 ;
s w i t c h 2 = 0 ;
dirA = 2'b 01;
dirB = 2'b 01;
end
B i n :
begin
s w i t c h 1 = 1 ;
s w i t c h 2 = 1 ;
dirA = 2'b 01;
dirB = 2'b 01;
end
A s t o p :
begin
s w i t c h 1 = 1 ;
s w i t c h 2 = 1 ;
dirA = 2'b 00;
dirB = 2'b 01;
end
Bstop:
begin
s w i t c h 1 = 0 ;
s w i t c h 2 = 0 ;
dirA = 2'b 01;
dirB = 2'b 00;
end
Search WWH ::




Custom Search