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、结果

相关新闻

最新新闻

SerenityOS 命令行选项解析指南:getopt 与 getopt_long 用法、返回值与底层实现

SerenityOS 命令行选项解析指南:getopt 与 getopt_long 用法、返回值与底层实现

SerenityOS 命令行选项解析指南:getopt 与 getopt_long 用法、返回值与底层实现 【免费下载链接】serenity The Serenity Operating System 🐞 项目地址: https://gitcode.com/GitHub_Trending/se/serenity 导读 本文以 getopt(3) 手册 为核心&a…

2026/10/3 16:42:15
轻量服务器还是ECS?大促云服务器选购与避坑实战指南

轻量服务器还是ECS?大促云服务器选购与避坑实战指南

每年大促节点,群里永远有人在问同一个问题:“38元的轻量服务器到底怎么抢?为什么我每次点进去都是已售罄?68元直购和99元的ECS我到底选哪个?”作为一个常年帮团队和自己采购云服务器的老用户,我太清楚这种纠…

2026/10/3 16:42:30
为 AI 代理的 Review 动作编写 Cedar 审批门控策略:review-agent-governance 策略编写实战指南

为 AI 代理的 Review 动作编写 Cedar 审批门控策略:review-agent-governance 策略编写实战指南

为 AI 代理的 Review 动作编写 Cedar 审批门控策略:review-agent-governance 策略编写实战指南 【免费下载链接】agents Multi-harness agentic plugin marketplace for Claude Code, Codex, Cursor, OpenCode, GitHub Copilot, and Google Antigravity 项目地址:…

2026/10/3 16:42:22
PaddleOCR 手写数学公式识别算法 CAN 实战指南:Counting-Aware Network 训练、评估与推理部署

PaddleOCR 手写数学公式识别算法 CAN 实战指南:Counting-Aware Network 训练、评估与推理部署

PaddleOCR 手写数学公式识别算法 CAN 实战指南:Counting-Aware Network 训练、评估与推理部署 【免费下载链接】PaddleOCR Turn any PDF or image document into structured data for your AI. A powerful, lightweight OCR toolkit that bridges the gap between i…

2026/10/3 7:41:27
Spring源码解析:构造器注入的类型转换与候选匹配机制

Spring源码解析:构造器注入的类型转换与候选匹配机制

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/3 16:42:24
openai-agents-python 多模型接入指南:深入解析 AnyLLMModel 适配层与 any-llm 路由

openai-agents-python 多模型接入指南:深入解析 AnyLLMModel 适配层与 any-llm 路由

openai-agents-python 多模型接入指南:深入解析 AnyLLMModel 适配层与 any-llm 路由 【免费下载链接】openai-agents-python A lightweight, powerful framework for multi-agent workflows 项目地址: https://gitcode.com/GitHub_Trending/op/openai-agents-pyth…

2026/10/3 16:42:28

日新闻

周新闻

月新闻