【HDLBits刷题笔记】01 Getting Started & Basics
  SpwcTktXWK0M 2023年11月02日 65 0

挺早以前就刷了里面一些题,结果不知道为啥登录账号刷题记录又没了,强迫症又让我不想从中间开始刷。既然如此,那就从头开始刷吧。QWQ

Step one

第一题,没啥好说的。

module top_module( output one );

// Insert your code here
    assign one = 1'b1;

endmodule

Zero

同样没啥好说的。

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

Wire

assign赋值。

module top_module( input in, output out );

    assign out = in;
endmodule

Wire4

注意input和output的默认类型为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

Notgate

一个反向,注意verilog有按位取反:~ 和 逻辑反:!。

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

andgate

与门同样有按位与:&和逻辑与:&&。

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

Norgate

或非门,或门同样有按位或:|和逻辑或:||。

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

Xnorgate

同或门,或者叫异或非门,可以先异或再取反

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

Wire decl

多了几个assign,也没啥好说的。

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

endmodule

7458

同样是一堆简单的门电路。

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

今天的题都比较简单,也没刷多久,就当放松了。

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  Vf84xTcexQdo   2024年01月04日   15   0   0 Verilog
  UXm2NDaWG8OP   2024年03月28日   53   0   0 Verilog
  sAAkk3Vxfaa8   2023年11月02日   194   0   0 VerilogHTMLhtmlVerilog
SpwcTktXWK0M