verilog HDLBits刷题[Finite State Machines]“Fsm onehot”---One-hot FSM 1、题目Given the following state machine with 1 input and 2 outputs:Suppose this state machine uses one-hot encoding, where state[0] through state[9] correspond to the states S0 though S9, respectively. The outputs are zero unless otherwise specified.Implement thestate transition logicandoutput logicportions of the state machine (but not the state flip-flops). You are given the current state in state[9:0] and must produce next_state[9:0] and the two outputs. Derive the logic equations by inspection assuming a one-hot encoding. (The testbench will test with non-one hot inputs to make sure youre not trying to do something more complicated).2、分析独热编码只有1bit为1其它全为0。有S0-S9一共10个状态但输入已经有当前状态不需要自定义状态。除了图中标注的特定输出其它输出都为0.3、代码module top_module( input in, input [9:0] state, output [9:0] next_state, // wire不要reg output out1, output out2); assign next_state[0] (state[0]~in) | (state[1]~in) | (state[2]~in) | (state[3]~in) | (state[4]~in) | (state[7]~in) | (state[8]~in) | (state[9]~in); assign next_state[1] (state[0]in) | (state[8]in) | (state[9]in); assign next_state[2] (state[1]in); assign next_state[3] (state[2]in); assign next_state[4] (state[3]in); assign next_state[5] (state[4]in); assign next_state[6] (state[5]in); assign next_state[7] (state[6]in) | (state[7]in); assign next_state[8] (state[5]~in); assign next_state[9] (state[6]~in); assign out1 state[8] || state[9]; assign out2 state[7] || state[9]; endmodule 或者 module top_module( input in, input [9:0] state, output reg [9:0] next_state, output out1, output out2); always (*) begin next_state 10d0; // 初始全部清零避免锁存 if(state[0]) begin next_state[0] ~in; next_state[1] in; end if(state[1]) begin next_state[0] ~in; next_state[2] in; end if(state[2]) begin next_state[0] ~in; next_state[3] in; end if(state[3]) begin next_state[0] ~in; next_state[4] in; end if(state[4]) begin next_state[0] ~in; next_state[5] in; end if(state[5]) begin next_state[8] ~in; next_state[6] in; end if(state[6]) begin next_state[9] ~in; next_state[7] in; end if(state[7]) begin next_state[0] ~in; next_state[7] in; end if(state[8]) begin next_state[0] ~in; next_state[1] in; end if(state[9]) begin next_state[0] ~in; next_state[1] in; end end assign out1 state[8] || state[9]; assign out2 state[7] || state[9]; endmodule4、结果

相关新闻

最新新闻

Nginx 在Ubuntu上的安装实践

Nginx 在Ubuntu上的安装实践

一、安装依赖apt update && apt install -y gcc libpcre3 libpcre3-dev zlib1g zlib1g-dev openssl libssl-dev make二、解压 Nginxmkdir -p /usr/local/nginxtar -zxvf /opt/software/nginx-1.24.0.tar.gz -C /usr/local/nginx/三、进入解压目录cd /usr/local/nginx/n…

2026/7/30 23:41:47
未来展望:libguestfs的发展路线图与新功能预览

未来展望:libguestfs的发展路线图与新功能预览

未来展望:libguestfs的发展路线图与新功能预览 【免费下载链接】libguestfs library and tools for accessing and modifying virtual machine disk images. 项目地址: https://gitcode.com/gh_mirrors/li/libguestfs libguestfs是一个强大的库和工具集&…

2026/7/30 23:41:47
让Windows 11重获新生:Win11Debloat系统优化工具完全指南

让Windows 11重获新生:Win11Debloat系统优化工具完全指南

让Windows 11重获新生:Win11Debloat系统优化工具完全指南 【免费下载链接】Win11Debloat A simple, lightweight PowerShell script that allows you to remove pre-installed apps, disable telemetry, as well as perform various other changes to declutter and…

2026/7/30 23:41:46
CocoaPods-Rome:让Xcode外框架构建变得前所未有的简单

CocoaPods-Rome:让Xcode外框架构建变得前所未有的简单

CocoaPods-Rome:让Xcode外框架构建变得前所未有的简单 【免费下载链接】Rome Makes it easy to build a list of frameworks. 项目地址: https://gitcode.com/gh_mirrors/rome1/Rome CocoaPods-Rome是一款强大的CocoaPods插件,它能让开发者轻松构…

2026/7/30 23:41:46
QQ空间导出助手:如何一站式永久备份你的青春记忆?

QQ空间导出助手:如何一站式永久备份你的青春记忆?

QQ空间导出助手:如何一站式永久备份你的青春记忆? 【免费下载链接】QZoneExport QQ空间导出助手,用于备份QQ空间的说说、日志、私密日记、相册、视频、留言板、QQ好友、收藏夹、分享、最近访客为文件,便于迁移与保存 项目地址: …

2026/7/30 23:41:46
零代码AI数据大屏生成工具盘点与大屏展示效果实战选型攻略

零代码AI数据大屏生成工具盘点与大屏展示效果实战选型攻略

作为一个非技术出身的产品经理,以前每次提要做数据大屏,我都得求着开发团队排期。沟通需求费劲,做出来效果还不一定满意。直到我开始研究零代码AI大屏工具,才发现原来自己也能独立搞定。今天我就从实战角度,盘点几款主…

2026/7/30 23:36:46

月新闻