FPGA基本学习记录

FPGA:现场可编程逻辑门阵列(Field Programmable Gate Array)

环境:

        编译软件:Quartus II 13.1

FPGA形成简单的门代码:

module LED ( a,b,out_and,out_or,out_not );  //模块  模块名 (入口参数);
    input a,b;                //讲输入参数进行定义
    output out_and,out_or,out_not;
    
    assign out_not  = ~a;  //非(not) ~;与(and)&;或(or)|
    assign out_and  = a&b;  //非(not) ~;与(and)&;或(or)|
    assign out_or   = a|b;  //非(not) ~;与(and)&;或(or)|  
endmodule   //结束这个模块

RTL:

 数值判断:

module LED ( equal,a,b );
    output equal; //声明输出信号equal
    input [1:0] a,b; //声明输入信号a,b
    assign equal =(a==b)?1:0 ;   //三目运算
    //如果a、b 两个输入信号相等,输出为1。否则为0*/

endmodule

调用多模块

module FPGA_TOP ( top_out,top_a,top_b ,top_c,top_d );
    output top_out; //声明输出信号equal
    input top_a,top_b,top_c,top_d; //声明输入信号a,b
    
    wire line_1;            //创建两个连接线,分别接入第一个模块与第二个模块之间,
    wire line_2;            //与第二个模块到第三个模块之间。
    
FPGAand FPGAand_u(          //实例化与门
.a(top_a),                  //与门的入口参数
.b(top_b),
.out_and(line_1)            //与门的输出参数
);

FPGAand FPGAand_u1(         //实例化第二个与门
.a(line_1),                 //与门的入口参数
.b(top_d),
.out_and(line_2)            //与门的输出参数
);

FPGAor FPGAor_u(            //实例化或门       
.a(line_2),                 //或门的入口参数
.b(top_c),
.out_or(top_out)            //或门的输出参数
);
    
endmodule
module FPGAor ( a,b,out_or );  //创建或门模块
    input a,b;
    output out_or;
    assign out_or =a|b;
endmodule
module FPGAand ( a,b,out_and );//创建与门模块
    input a,b;
    output out_and;
    assign out_and =a&b;
endmodule

其RTL:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值