当前位置:网站首页>FSM onehot answer record
FSM onehot answer record
2022-07-27 10:14:00 【IC learners】
https://hdlbits.01xz.net/wiki/Fsm_onehot
No problem with the title , It just didn't describe the requirements clearly .
Gradually clear in the submission process over and over
You can see ifdef Three situations of
// nodefine
// All the wrong inputs fall into idle
// # Hint: Output 'next_state' has 1157 mismatches. First mismatch occurred at time 1120.
// # Hint: Output 'out1' has 724 mismatches. First mismatch occurred at time 1120.
// # Hint: Output 'out2' has 744 mismatches. First mismatch occurred at time 1120.
// # Hint: Total mismatched samples is 1157 out of 1422 samples
// `define CUSTOM
// Wrong input with priority , Lower priority higher , Be exclusive
// # Hint: Output 'next_state' has 922 mismatches. First mismatch occurred at time 1125.
// # Hint: Output 'out1' has no mismatches.
// # Hint: Output 'out2' has no mismatches.
// # Hint: Total mismatched samples is 922 out of 1422 samples
`define FINAL
// Unique hot code without priority , It can be compatible with multiple hot codes
Three different attempts
module top_module(
// input clk,
input in,
// input rst_n,
input [9:0] state,
output [9:0] next_state,
output out1,
output out2);
localparam s0 = 10'b0000_0001,
s1 = 10'b0000_0010,
s2 = 10'b0000_0100,
s3 = 10'b0000_1000,
s4 = 10'b0001_0000,
s5 = 10'b0010_0000,
s6 = 10'b0100_0000,
s7 = 10'b1000_0000,
s8 = 10'b1_0000_0000,
s9 = 10'b10_0000_0000,
idle = 10'b0;
// nodefine
// All the wrong inputs fall into idle
// # Hint: Output 'next_state' has 1157 mismatches. First mismatch occurred at time 1120.
// # Hint: Output 'out1' has 724 mismatches. First mismatch occurred at time 1120.
// # Hint: Output 'out2' has 744 mismatches. First mismatch occurred at time 1120.
// # Hint: Total mismatched samples is 1157 out of 1422 samples
// `define CUSTOM
// Wrong input with priority , Lower priority higher , Be exclusive
// # Hint: Output 'next_state' has 922 mismatches. First mismatch occurred at time 1125.
// # Hint: Output 'out1' has no mismatches.
// # Hint: Output 'out2' has no mismatches.
// # Hint: Total mismatched samples is 922 out of 1422 samples
`define FINAL
// Unique hot code without priority , It can be compatible with multiple hot codes
`ifdef CUSTOM
[email protected](*)begin
casez(state)
10'bzz_zzzz_zzz1:next_state = in? s1:s0;
10'bzz_zzzz_zz10:next_state = in? s2:s0;
10'bzz_zzzz_z100:next_state = in? s3:s0;
10'bzz_zzzz_1000:next_state = in? s4:s0;
10'bzz_zzz1_0000:next_state = in? s5:s0;
10'bzz_zz10_0000:next_state = in? s6:s8;
10'bzz_z100_0000:next_state = in? s7:s9;
10'bzz_1000_0000:next_state = in? s7:s0;
10'bz1_0000_0000:next_state = in? s1:s0;
10'b10_0000_0000:next_state = in? s1:s0;
default:next_state = idle;
endcase
end
`elsif FINAL
assign next_state[0] = ~in && (state[0]|state[1]|state[2]|state[3]|state[4]|state[7]|state[8]|state[9]) ;
assign next_state[1] = in && (state[8]|state[9]|state[0]);
assign next_state[2] = in && state[1];
assign next_state[3] = in && state[2];
assign next_state[4] = in && state[3];
assign next_state[5] = in && state[4];
assign next_state[6] = in && state[5];
assign next_state[7] = in && (state[6]|state[7]) ;
assign next_state[8] = ~in && state[5] ;
assign next_state[9] = ~in && state[6] ;
`else
always @(*) begin
case (state)
s0:
if(in)
next_state <= s1;
else
next_state <= s0;
s1:
if(in)
next_state <= s2;
else
next_state <= s0;
s2:
if(in)
next_state <= s3;
else
next_state <= s0;
s3:
if(in)
next_state <= s4;
else
next_state <= s0;
s4:
if(in)
next_state <= s5;
else
next_state <= s0;
s5:
if(in)
next_state <= s6;
else
next_state <= s8;
s6:
if(in)
next_state <= s7;
else
next_state <= s9;
s7:
if(in)
next_state <= s7;
else
next_state <= s0;
s8:
if(in)
next_state <= s1;
else
next_state <= s0;
s9:
if(in)
next_state <= s1;
else
next_state <= s0;
default:
next_state <= idle;
endcase
end
`endif
// assign next_state = next_state;
`ifdef CUSTOM
assign out1 = state[8] | state[9];
assign out2 = state[7] | state[9];
`elsif FINAL
assign out1 = state[8] | state[9];
assign out2 = state[7] | state[9];
`else
assign out1 = (state == s8 || state == s9);
assign out2 = (state == s9 || state == s7);
`endif
endmodule
边栏推荐
- Review summary of engineering surveying examination
- Nacos configuration center dynamically refreshes the data source
- 二叉树习题总结
- Brush the title "sword finger offer" day04
- Understand chisel language. 27. Chisel advanced finite state machine (I) -- basic finite state machine (Moore machine)
- Example of ICP registration for PCL
- Exercises --- quick arrangement, merging, floating point number dichotomy
- PCL的ICP配准示例
- Shell综合应用案例,归档文件、发送消息
- DCGAN论文改进之处+简化代码
猜你喜欢

Anchor free detector: centernet

Decision tree principle and case application - Titanic survival prediction

使用 LSM-Tree 思想基于.NET 6.0 C# 写个 KV 数据库(案例版)
![Shell function, system function, basename [string / pathname] [suffix] can be understood as taking the file name in the path, dirname file absolute path, and user-defined function](/img/3d/d7276d2010f1d77a3bd572cc66eced.png)
Shell function, system function, basename [string / pathname] [suffix] can be understood as taking the file name in the path, dirname file absolute path, and user-defined function

二叉树习题总结

Shell process control (emphasis), if judgment, case statement, let usage, for ((initial value; loop control condition; variable change)) and for variable in value 1 value 2 value 3..., while loop

WGAN、WGAN-GP、BigGAN

Summary of binary tree exercises

Anaconda installation (very detailed)

Food safety | the more you eat junk food, the more you want to eat it? Please keep this common food calorimeter
随机推荐
Exercises --- quick arrangement, merging, floating point number dichotomy
Oracle RAC 19C PDB instance is down
省应急管理厅:广州可争取推广幼儿应急安全宣教经验
数据库性能系列之子查询
Configuration of pytorch deep learning environment based on cuda10.0
pytorch中对BatchNorm2d()函数的理解
活体检测综述
Simple use of tflite
StyleGAN论文笔记+修改代码尝试3D点云生成
Open3d library installation, CONDA common instructions, importing open3d times this error solving environment: failed with initial frozen solve Retrying w
Final examination paper of engineering materials
vs2019社区版下载教程(详细)
并发之线程状态转换
Switch port mirroring Configuration Guide
PCL各模块概述(1.6)
Text processing tool in shell, cut [option parameter] filename Description: the default separator is the built-in variable of tab, awk [option parameter] '/pattern1/{action1}filename and awk
About getter/setter methods
TFlite 的简单使用
LeetCode.1260. 二维网格迁移____原地暴力 / 降维+循环数组直接定位
LeetCode.814. 二叉树剪枝____DFS