HDLBits_Build a circuit from a simulation waveform部分

Sim/circuit1

代码如下:

module top_module (
    input a,
    input b,
    output q );//

    assign q = a && b ; // Fix me

endmodule

Sim/circuit2

代码如下:

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

代码如下:

module top_module (
    input a,
    input b,
    input c,
    input d,
    output q );//

    assign q = b || c ; // Fix me

endmodule

Sim/circuit5

代码如下:

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'd0: q = b ;
            4'd1: q = e ;
            4'd2: q = a ;
            4'd3: q = d ;
            default: q = 4'hf ;
        endcase
    end

endmodule

Sim/circuit6

代码如下:

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

Sim/circuit7

代码如下:

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

Sim/circuit8

代码如下:

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

Sim/circuit9

代码如下:

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 <= 4'd5) begin
            q <= q + 4'd1 ;
        end else begin
            q <= 4'd0 ;
        end
    end

endmodule

Sim/circuit10

代码如下:

module top_module (
    input clk,
    input a,
    input b,
    output q,
    output state  );
    assign q = a^b^state;
 
	always @(posedge clk) begin
        if (a && b) begin
			state <= 'd1;
        end else if ( ~a && ~b ) begin
			state <= 'd0;
		end else begin
			state <= state;
		end
	end

endmodule

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
《Spice: 电路模拟与分析指南》是一本关于电路模拟和分析使用的指南书籍。Spice(Simulation Program with Integrated Circuit Emphasis)是一种流行的电路仿真软件,它可以帮助工程师们设计、测试和分析各种类型的电路。 这本指南书籍首先介绍了Spice软件的基本原理和功能。它解释了Spice如何用数学模型来描述电子元件的行为,并利用这些模型来模拟和预测电路的性能。读者将学会如何使用Spice设置电路拓扑结构、选择元件参数和设置仿真参数。 随后,书中详细介绍了各种不同类型的电路和电子元件的模拟和分析技术。这些包括放大器、滤波器、振荡器、开关电路等。每一章节都包含具体的实例和实验,以帮助读者深入理解和掌握这些概念。 除了基础知识和技术外,这本指南还讨论了一些高级的主题,如内嵌模拟与混合信号电路设计。它向读者介绍了Spice如何与其他软件和工具进行集成,以实现更复杂的电路设计和分析。 最后,这本指南还包含了一些常见问题解答和实用技巧,以帮助读者解决在使用Spice时可能遇到的一些常见问题和困难。 总而言之,这本指南是一本全面而详细的关于Spice电路模拟和分析的指南。它适用于电子工程师、学生和任何对电路设计和分析感兴趣的人。读者将通过本书学会如何使用Spice软件,以提高电路设计的准确性和效率。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值