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

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

内容来源于网络如有侵权请私信删除

文章来源: 博客园

原文链接: https://www.cnblogs.com/magnolia666/p/16797365.html

你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!