日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

HDLBits答案(24)_由波形图描述电路

發(fā)布時(shí)間:2023/12/19 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 HDLBits答案(24)_由波形图描述电路 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Build a circuit from a simulation waveform

HDLBits鏈接


前言

今天更新HDLBits習(xí)題由波形圖描述電路的部分,看圖寫代碼。


題庫

Combinational circuit 1

由圖可見,q=a&b

Solution

module top_module (input a,input b,output q );//assign q = a & b; // Fix meendmodule

Combinational circuit 2

由圖列出卡諾圖描述出來即可。

Solution

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

Combinational circuit 3

由波形圖列出卡諾圖化簡(jiǎn)可得。

Solution:

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

Combinational circuit 4

與上題同理

Solution

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

Combinational circuit 5

由波形圖可見這是個(gè)多路選擇器,通過c路信號(hào)進(jìn)行信號(hào)選擇;

Solution:

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 @(*) begincase(c)4'd0: q <= b;4'd1: q <= e;4'd2: q <= a;4'd3: q <= d;default:q <= 4'hf;endcaseendendmodule

Combinational circuit 6

Solution

module top_module (input [2:0] a,output [15:0] q ); always @(*) begincase(a)3'd0: q <= 16'h1232;3'd1: q <= 16'haee0;3'd2: q <= 16'h27d4;3'd3: q <= 16'h5a0e;3'd4: q <= 16'h2066;3'd5: q <= 16'h64ce;3'd6: q <= 16'hc526;default:q <= 16'h2f19;endcaseendendmodule

Sequential circuit 7

Solution

module top_module (input clk,input a,output q );always @(posedge clk) beginq <= ~a;endendmodule

Sequential circuit 8

由圖可見,p為a在clock為高電平時(shí)的選通信號(hào),q為clock下降沿觸發(fā)的信號(hào),存放p的值。

Solution:

module top_module (input clock,input a,output p,output q );reg clk_0;assign p = clock ? a : p;always @(negedge clock) beginq <= p;endendmodule

Sequential circuit 9

由圖可見,q應(yīng)當(dāng)是一個(gè)從0-6的計(jì)數(shù)器,當(dāng)a為高電平時(shí),q保持為4,直到a為低電平時(shí),再繼續(xù)計(jì)數(shù);

Solution

module top_module (input clk,input a,output [3:0] q );always @(posedge clk) beginif(a) beginq <= 4'd4;endelse if(q == 4'd6) beginq <= 4'd0;endelse beginq <= q + 4'd1;endendendmodule

Sequential circuit 10

q為a,b和state的組合邏輯,列出真值表即可;

Solution

module top_module (input clk,input a,input b,output q,output state );assign q = a ^ b ^ state;always @(posedge clk) beginif(a & b) beginstate <= 1'b1;endelse if(~a & ~b) beginstate <= 1'b0;endelse beginstate <= state;endendendmodule

結(jié)語

該小結(jié)就算更新結(jié)束了,勝利就在眼前,哈哈哈!本章的解法并不唯一,大家有什么其他思路歡迎在評(píng)論區(qū)討論交流。

總結(jié)

以上是生活随笔為你收集整理的HDLBits答案(24)_由波形图描述电路的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。