news 2026/5/12 17:44:22

Verification Sim/circuit1

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
Verification Sim/circuit1

Sim/circuit1

This is a combinational circuit. Read the simulation waveforms to determine what the circuit does, then implement it.

观察可以发现,这就是一个与门。

代码如下:

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

Sim/circuit2

This is a combinational circuit. Read the simulation waveforms to determine what the circuit does, then implement it.

看这个waveform,看q,第一个高电平:a,b,c,d全是1;第二个高电平:a,b低电平,c,d高电平;第三个高电平:a,c -->0,b,d--->1;a,d--->0,b,c--->1;a,d-->1,好的,咱们已经发现规律了,原来这是一个同或电路,也就是0个或者2个或者4个为1的时候,输出q为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

由于上一题的经验,我想直接猜抑或,但是不然,于是观察waveform,发现 bc & bd ad ac的时候q==1,那么代码如下:

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

Sim/circuit4

一看就是b+c,代码如下:

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

Sim/circuit5

c是选择信号sel,sel=0,c=0选择b这样子,代码如下:

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 case (c) 4'h0: q = b; 4'h1: q = e; 4'h2: q = a; 4'h3: q = d; default: q = 4'hf; // Covers c = 4 through F endcase end endmodule

Sim/circuit6

我们直接看这个电路,也是感觉和上一道题一样,a来选择q,代码如下:

module top_module ( input [2:0] a, output [15:0] q ); always @(*)begin case(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; 3'd7: q = 16'h2f19; endcase end endmodule

Sim/circuit7

这个clk开始,a上升沿q变成0,代码如下:

module top_module ( input clk, input a, output q ); always@(posedge clk)begin q <= 1; if(a)begin q <= 0; end end endmodule

Sim/circuit8

First we could see p, when clk and a is true, the p is set tobe true.

q只在clock的下降沿发生变化,代码如下:

module top_module ( input clock, input a, output reg p, output reg q ); // 逻辑 p:高电平透明锁存器 (High-level sensitive latch) // 规律:clock 为高时,p 实时跟随 a 的变化;clock 为低时,p 保持之前的值。 always @(*) begin if (clock) begin p = a; end // 注意:此处不写 else,会自动产生锁存行为,符合波形图 t=120 后的保持特征 end // 逻辑 q:下降沿触发器 (Negative-edge triggered flip-flop) // 规律:q 只在 clock 的下降沿(1变0的瞬间)改变,采样此时 p 的值。 always @(negedge clock) begin q <= p; end endmodule

Sim/circuit9

这个感觉像是计数器,每当a的下降沿的下一个clock开始从4开始计数,代码如下:

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

Sim/circuit10

直接懵了啊,看不出有啥规律,我只知道组合和逻辑都有,代码如下:

参考:https://blog.csdn.net/qq_24999747/article/details/124708510

module top_module ( input clk, input a, input b, output q, output state ); always@(posedge clk)begin if(a&&b) state <= 1'b1; else if(!(a||b)) state <= 1'b0; else state <= state; end assign q = state?(a~^b):(a^b); endmodule
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/5/12 17:43:26

AT_past202107_g べき表現 题解

AT_past202107_g べき表現 Link: https://atcoder.jp/contests/past202107-open/tasks/past202107_g 题目描述 给定一个整数 n(1≤n≤1015)n(1\le n\le 10^{15})n(1≤n≤1015)&#xff0c;请输出一个长为 m(1≤m≤100)m(1\le m\le 100)m(1≤m≤100) 的整数数列 aaa&#xff…

作者头像 李华
网站建设 2026/5/12 17:38:49

如何高效使用AutoClicker自动化鼠标点击:5大核心功能深度解析

如何高效使用AutoClicker自动化鼠标点击&#xff1a;5大核心功能深度解析 【免费下载链接】AutoClicker AutoClicker is a useful simple tool for automating mouse clicks. 项目地址: https://gitcode.com/gh_mirrors/au/AutoClicker AutoClicker是一款基于C#和WPF开发…

作者头像 李华
网站建设 2026/5/12 17:38:19

HTTP方式和MQ方式实现回调通知

HTTP方式首先提供一个bean给springboot&#xff0c;Configuration public class OKHttpClientConfig {Beanpublic OkHttpClient httpClient() {return new OkHttpClient();}}然后借助okHTTP发送http请求。Slf4j Service public class GroupBuyNotifyService {Resourceprivate O…

作者头像 李华