码迷,mamicode.com
首页 > 其他好文 > 详细

Answers For HDLbits - Verilog Language_Procedures

时间:2021-01-18 10:48:31      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:lang   put   output   module   nbsp   lse   tps   its   http   

链接https://hdlbits.01xz.net/wiki/Alwaysblock1

 

(1)Alwaysblock1

module top_module(
    input a, 
    input b,
    output wire out_assign,
    output reg out_alwaysblock
);
	assign out_assign = a & b;
	always @(*)
        out_alwaysblock = a & b ;
endmodule

 

(2)Alwaysblock2

module top_module(
    input clk,
    input a,
    input b,
    output wire out_assign,
    output reg out_always_comb,
    output reg out_always_ff   );
	assign out_assign = a ^ b;
    always@(*) 
        out_always_comb = a ^ b;
    always@(posedge clk) 
        out_always_ff <= a ^ b;
endmodule

 

(3)Always if

module top_module(
    input a,
    input b,
    input sel_b1,
    input sel_b2,
    output wire out_assign,
    output reg out_always   ); 
    
    assign out_assign = sel_b1? sel_b2? b:a :a;

    always@(*)
        if(sel_b1&sel_b2)
            out_always = b;
        else
            out_always = a;
endmodule

 

(4)待续

Answers For HDLbits - Verilog Language_Procedures

标签:lang   put   output   module   nbsp   lse   tps   its   http   

原文地址:https://www.cnblogs.com/Bain-M/p/14286766.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!