![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
verilog学习
一纸苍生
分享大学学习中遇到的问题,和解决方法
展开
-
逻辑运算
module alutask(code,a,b,c); input[1:0]code; input [3:0]a,b; output [4:0]c; reg [4:0] c; task my_and; input [3:0]a,b; output [4:0]out; integer i; begin for(i=3;i>=0;i=i-1) out[i]=a[i]&b[i]; end endtask always@(code or a or b) be原创 2020-11-26 19:08:09 · 141 阅读 · 0 评论 -
有限状态机 11001
module seq_11001_1(input clk,output led); reg [31:0] divclk_cnt=0; reg divclk=0; reg q0=0; reg q1=0; reg q2=0; always@(posedge clk) begin //if(divclk_cnt==25000000) if(divclk_cnt==25) begin divclk=~divclk; divclk_cnt=0; end.原创 2020-11-26 19:06:46 · 349 阅读 · 0 评论 -
阶乘
Verilog 设计代码 `timescale 1ns / 1ps module funct(clk,n,result,reset); output[31:0]result; input[3:0]n; input reset,clk; reg[31:0]result; always@(posedge clk) begin if(!reset)result<=0; else begin result<=2*factorial(n); end原创 2020-11-26 19:02:56 · 118 阅读 · 0 评论 -
译码器
Verilog module decode4_7(decodeout,indec ); output[6:0]decodeout; input [3:0] indec; reg[6:0]decodeout; always@(indec) begin case(indec) 4'd0:decodeout=7'b1111110; 4'd1:decodeout=7'b0110000; 4'd2:decodeout=7'b1101101;原创 2020-11-26 19:00:36 · 252 阅读 · 0 评论 -
四位超前进位加法器
四位超前进位加法器 门级建模 module FullAdder(A, B, CarryIn, Sum, CarryOut); output Sum, CarryOut; input A, B, CarryIn; wire A,B,CarryOut,Sum; wire A_bar,B_bar,CarryIn_bar; not not1(A_bar, A); not not2(B_bar, B); not not3(CarryIn_bar, CarryIn); and and4(and4_out, A_bar,原创 2020-11-26 18:55:20 · 1598 阅读 · 0 评论 -
verilog 四位全加器
行为级建模 module adder4_1( //串行 a,b,cin,sum ); input [3:0]a,b; input cin; output [3:0]sum; assign sum=a+b+cin; endmodule 仿真 module sim1(); reg [3:0] a,b; reg cin; wire [3:0]sum; initial begin #10 a=4'h0001;b=4'h0001原创 2020-11-20 16:28:26 · 1915 阅读 · 2 评论