首页IT科技刷题策略(【HDLBits刷题笔记】16 Buid a circuit from a simulation waveform)

刷题策略(【HDLBits刷题笔记】16 Buid a circuit from a simulation waveform)

时间2025-06-13 14:23:42分类IT科技浏览4040
导读:Sim/circuit1 从波形不难看出ab是相与的关系。...

Sim/circuit1

从波形不难看出ab是相与的关系              。

Sim/circuit2

根据波形图可以画出卡诺图并且之前有写过这个卡诺图的逻辑表达式              ,不难看出相邻逻辑输出会取反                  ,所以这个是一个四变量的异或      ,0000输出为1           ,所以还要再取反                  。

module top_module ( input a, input b, input c, input d, output q );// assign q = ~(a^b^c^d); // Fix me endmodule

Sim/circuit3

继续画卡诺图

module top_module ( input a, input b, input c, input d, output q );// assign q = (b&d)||(a&d)||(b&c)||(a&c); // Fix me endmodule

Sim/circuit4

还是画卡诺图                   ,把四个0的位置确定好就行      。

module top_module ( input a, input b, input c, input d, output q );// assign q = b|c; // Fix me endmodule

Sim/circuit5

显然这是一个数据选择器         ,c的0123分别选择bead       ,c为别的值的时候输出值为f           。

module top_module ( input [3:0] a, input [3:0] b, input [3:0] c, input [3:0] d, input [3:0] e, output [3:0] q ); always@(*) begin q=4hf; case(c) 0:q=b; 1:q=e; 2:q=a; 3:q=d; endcase end endmodule

Sim/circuit6

暴力强解                   。

module top_module ( input [2:0] a, output [15:0] q ); always@(*) begin case(a) 0:q=16h1232; 1:q=16haee0; 2:q=16h27d4; 3:q=16h5a0e; 4:q=16h2066; 5:q=16h64ce; 6:q=16hc526; 7:q=16h2f19; default:q=0; endcase end endmodule

Sim/circuit7

由图中不难看出来q是对a的取反                    ,采取时序逻辑恰好延后了一个周期         。

module top_module ( input clk, input a, output reg q ); always@(posedge clk) begin q <= ~a; end endmodule

Sim/circuit8

从波形图不难看出p在clock高电平时改变            ,低电平锁存   ,所以是一个锁存器       。q在时钟下降沿发生变化                    ,是一个下降沿触发的触发器                    。

module top_module ( input clock, input a, output reg p, output reg q ); always@(*) begin if(clock) p = a; end always@(negedge clock) begin q <= a; end endmodule

Sim/circuit9

该电路在a为低电平时计数               ,高电平置为4,并且计数最多到6就清零            。

module top_module ( input clk, input a, output [3:0] q ); always@(posedge clk) begin if(~a) q <= (q<6)?(q+1):0; else q <= 4; end endmodule

Sim/circuit10

仔细看波形图                 ,状态在ab同为1跳转为1                  ,ab同为0跳转为0   。

分别观察两个状态的逻辑   ,发现恰好一个是异或一个异或非                    。

module top_module ( input clk, input a, input b, output q, output reg state ); parameter A=0,B=1; reg next_state; always@(posedge clk) begin state <= next_state; end always@(*) begin if(a&b) next_state <= B; else if(~(a|b)) next_state <= A; end assign q=state?~(a^b):(a^b); endmodule
声明:本站所有文章              ,如无特殊说明或标注                  ,均为本站原创发布               。任何个人或组织      ,在未征得本站同意时           ,禁止复制            、盗用                    、采集      、发布本站内容到任何网站         、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益                   ,可联系我们进行处理                 。

创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!

展开全文READ MORE
vuecli2搭建项目(如何使用vue-cli来搭建vue项目?详细步骤跟着我来吧!) 谨遵SEO优化外链发布技巧,让网站排名更靠前!(学会正确的外链发布技巧,让您的网站流量快速增长)