HDLBits网站题目答案—第一波Started and Basics

目录

Getting Started

Output Zero

 Simple wire

Four wire

Inverter

AND gate

NOR gate

XNOR gate

Declaring wires

7458 chip


Getting Started

module top_module( output one );

// Insert your code here
    assign one = 1;

endmodule

Output Zero

module top_module(
    output zero
);// Module body starts after semicolon
assign zero = 1'b0;
endmodule

 Simple wire

module top_module( input in, output out );
assign out =in;
endmodule

Four wire

module top_module( 
    input a,b,c,
    output w,x,y,z );
    assign w = a;
    assign x = b;
    assign y = b; 
    assign z = c;
            
endmodule

Inverter

module top_module( input in, output out );
assign out = ~in;
endmodule

AND gate

module top_module( 
    input a, 
    input b, 
    output out );
assign out = a & b;
endmodule

NOR gate

module top_module( 
    input a, 
    input b, 
    output out );
    assign out = ~(a|b);
endmodule

XNOR gate

module top_module( 
    input a, 
    input b, 
    output out );
    assign out = a ^~ b;
endmodule

Declaring wires

`default_nettype none
module top_module(
    input a,
    input b,
    input c,
    input d,
    output out,
    output out_n   ); 
    wire ab_and,cd_and;
    assign ab_and = a & b;
    assign cd_and = c & d;
    assign out = ab_and | cd_and;
    assign out_n = ~out;
    

endmodule

7458 chip

module top_module ( 
    input p1a, p1b, p1c, p1d, p1e, p1f,
    output p1y,
    input p2a, p2b, p2c, p2d,
    output p2y );
    wire w0,w1,w2,w3;
    assign w0=p1a & p1b & p1c;
    assign w1=p1d & p1e & p1f;
    assign w2=p2a & p2b;
    assign w3=p2c & p2d;
    assign p1y=w0 | w1;
    assign p2y=w2 | w3;

endmodule

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值