2021-08-05

设计理论

        1.设计输入

        2.写代码

        3.编译(语法错误)

        4.仿真(理想状态下)

        5.下板

        6.时序

设计思想:模块化

设计代码:module(模块) 文件名 (端口);

                端口类型(input output

                                        inoutput)

                数据类型:(reg wire)

                功能模块

                endmodule

        Field Programmable Gate Array 实现一个与门

 

         在电路里,理解为两个开关串联

        verilog

        module and_gate(
            input a,
            input b,
            output s
           );
    
            assign s = a & b;

        endmodule

        vhdl

        LIBRARY IEEE;
        USE IEEE.STD_LOGIC_1164.ALL;
        ENTITY and2 IS
            PORT(a,b:IN STD_LOGIC;
                c:OUT STD_LOGIC);
        END and2;
        ARCHITECTURE and2_behavior OF and2 IS
        BEGIN
            c<= a AND b;
        END and2_behavior;

        verilog tb

        module and_gate_tb;

            // Inputs
            reg a;(语法规定,人为定义)
            reg b;(语法规定,人为定义)

            // Outputs
            wire s;(语法规定)

            // Instantiate the Unit Under Test (UUT)
            and_gate and_gate_inst (            //实例化
                .a(a), 
                .b(b), 
                .s(s)
            );

            initial begin(赋值开始)
                // Initialize Inputs
                a = 0;
                b = 0;

                // Wait 100 ns for global reset to finish
                #100;
                a = 0;
                b = 1;
                #100;
                a = 1;
                b = 0;
                #100;
                a = 1;
                b = 1;
                #100;
                // Add stimulus here

            end
      
        endmodule

注:基于ise平台

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值