给定以下状态机,假设此状态机使用独热编码,此状态及具有1个输入和2个输出:
解题关键想法是:对于一个状态机,有当先状态和下一个状态,以及当前输出。且该题是单纯组合逻辑实现
module top_module(
input in,
input [9:0] state,
output [9:0] next_state,
output out1,
output out2);
always@(*)begin
next_state[0] = (state[0]|state[1]|state[2]|state[3]|state[4]|state[7]|state[8]|state[9])&(!in);
next_state[1] = (state[0]|state[8]|state[9])∈
next_state[2] = state[1]∈
next_state[3] = state[2]∈
next_state[4] = state[3]∈
next_state[5] = state[4]∈
next_state[6] = state[5]∈
next_state[7] = (state[6]|state[7])∈
next_state[8] = state[5]&!in;
next_state[9] = state[6]&!in;
out1 = state[8]|state[9];
out2 = state[7]|state[9];
end
endmodule
其中state[ i ]代表了每个状态机当前状态,next_state[ i ]代表每个状态机下一个状态,out1、out2为当前状态时的输出, 从state[ i ]跳转到哪个next_state[ i ]是通过in进行选择实现的