随笔分类 - HDLBits
摘要:Tb/clock 这题要求给dut模块一个时钟。 module top_module ( ); reg clk; always #5 clk=~clk; initial begin clk = 0; end dut u0(clk); endmodule Tb/tb1 产生指定的波形,使用延时语句给信
阅读全文
摘要:Sim/circuit1 从波形不难看出ab是相与的关系。 module top_module ( input a, input b, output q );// assign q = a&b; // Fix me endmodule Sim/circuit2 根据波形图可以画出卡诺图并且之前有写过
阅读全文
摘要:Bugs mux2 原本代码的逻辑是反的,这不是坑人吗。 module top_module ( input sel, input [7:0] a, input [7:0] b, output [7:0]out ); assign out = ({8{sel}} & a) | ({8{~sel}}
阅读全文
摘要:Exams/review2015 count1k 计数到999再清零即可。 module top_module ( input clk, input reset, output reg[9:0] q); always@(posedge clk) begin if(reset) q <= 'd0; e
阅读全文
摘要:Fsm1 这里需要实现一个简单的摩尔状态机,即输出只与状态有关的状态机。 我这里代码看上去比长一点,答案用的case和三目运算符,结果是一样的。 module top_module( input clk, input areset, // Asynchronous reset to state B
阅读全文
摘要:Rule90 第一次见这东西有点莫名其妙,但是其实看懂了之后就是左移和右移相异或,注意这里使用的是逻辑右移,会自动补零,不能使用算数左移<<<。 module top_module( input clk, input load, input [511:0] data, output reg[511:
阅读全文
摘要:Shift4 异步复位同步置数和使能。 module top_module( input clk, input areset, // async active-high reset to zero input load, input ena, input [3:0] data, output reg
阅读全文
摘要:Count15 module top_module ( input clk, input reset, // Synchronous active-high reset output [3:0] q); always@(posedge clk) begin if(reset) q <= 4'd0;
阅读全文
摘要:Dff 这一节终于开始时序电路了。首先是一个用的最多的D触发器。 module top_module ( input clk, // Clocks are used in sequential circuits input d, output reg q );// // Use a clocked
阅读全文
摘要:Kmap1 化简卡诺图即可。 module top_module( input a, input b, input c, output out ); assign out=b|c|a; endmodule Kmap2 我是这样化简的。 module top_module( input a, inpu
阅读全文
摘要:Mux2to1 module top_module( input a, b, sel, output out ); assign out=sel?b:a; endmodule Mux2to1v 100位和1位的是一样的。 module top_module( input [99:0] a, b, i
阅读全文
摘要:Exams/m2014 q4h module top_module ( input in, output out); assign out=in; endmodule Exams/m2014 q4i module top_module ( output out); assign out=1'b0;
阅读全文
摘要:Conditional 使用三目运算符可以实现一个数据选择器,可以替代if语句,不过:?可读性较差,复杂逻辑还是推荐用if。 注意这道题中间变量的定义,不定义中间变量表达式会变得十分复杂且可读性差。 module top_module ( input [7:0] a, b, c, d, output
阅读全文
摘要:Alwaysblock1 组合逻辑always块的使用,注意这里的wire和reg综合出来的结果是一样的,这里只是verilog语法导致二者声明不一样。 // synthesis verilog_input_version verilog_2001 module top_module( input
阅读全文
摘要:Module 模块例化的两种方式:按端口位置例化、按端口名例化。 module top_module ( input a, input b, output out ); mod_a instance1 ( .in1(a), .in2(b), .out(out) ); endmodule Module
阅读全文
摘要:Vector0 向量赋值。 module top_module ( input wire [2:0] vec, output wire [2:0] outv, output wire o2, output wire o1, output wire o0 ); // Module body start
阅读全文
摘要:挺早以前就刷了里面一些题,结果不知道为啥登录账号刷题记录又没了,强迫症又让我不想从中间开始刷。既然如此,那就从头开始刷吧。QWQ Step one 第一题,没啥好说的。 module top_module( output one ); // Insert your code here assign
阅读全文
浙公网安备 33010602011771号