夏宇闻老师书例子11-2

register.v

module register8(ena,clk,data,rst,out);
input ena,clk,rst;
input [7:0] data;
output [7:0] out;
wire [7:0] data;
reg[7:0] out;
  always @(posedge clk)
        if (!rst)
          out <= 0;
        else if (ena)
          out <= data;
 
endmodule

register1.v

// Copyright (C) 1991-2013 Altera Corporation
// Your use of Altera Corporation's design tools, logic functions 
// and other software and tools, and its AMPP partner logic 
// functions, and any output files from any of the foregoing 
// (including device programming or simulation files), and any 
// associated documentation or information are expressly subject 
// to the terms and conditions of the Altera Program License 
// Subscription Agreement, Altera MegaCore Function License 
// Agreement, or other applicable license agreement, including, 
// without limitation, that your use is for the sole purpose of 
// programming logic devices manufactured by Altera and sold by 
// Altera or its authorized distributors.  Please refer to the 
// applicable agreement for further details.

// *****************************************************************************
// This file contains a Verilog test bench template that is freely editable to  
// suit user's needs .Comments are provided in each section to help the user    
// fill out necessary details.                                                  
// *****************************************************************************
// Generated on "06/08/2024 07:43:11"
                                                                                
// Verilog Test Bench template for design : register8
// 
// Simulation tool : ModelSim (Verilog)
// 

`timescale 1 ns/ 100 ps
module register8_vlg_tst();
// constants                                           
// general purpose registers

// test vector input registers
reg clk;
reg [7:0] data;
reg ena;
reg rst;
// wires                                               
wire [7:0]  out;

// assign statements (if any)                          
register8 i1 (
// port map - connection between master ports and signals/registers   
    .clk(clk),
    .data(data),
    .ena(ena),
    .out(out),
    .rst(rst)
);
initial                                                
begin                                                  
// code that executes only once                        
// insert code here --> begin                          
    clk=0;
   forever  #5 clk=~clk;
// --> end                                             
                       
end                                                    
 initial                                              
// optional sensitivity list                           
// @(event1 or event2 or .... eventn)                  
begin                                                  
// code executes for every event on sensitivity list   
// insert code here --> begin                          
 #10 rst=0;
#10 rst=1;
#10 ena=1;
#10 data <= 16'h55;
 #10 data<=16'haa;
 #10 data<=16'h46;
  #10 $stop;                                           
// --> end                                             
end                                                    
endmodule

仿真效果图:

相关推荐

  1. python实现爬虫例子2

    2024-06-15 07:02:01       12 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-06-15 07:02:01       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-06-15 07:02:01       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-06-15 07:02:01       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-06-15 07:02:01       20 阅读

热门阅读

  1. Html_Css问答集(3)

    2024-06-15 07:02:01       7 阅读
  2. C++ 数据结构

    2024-06-15 07:02:01       7 阅读
  3. 设计模式之适配器模式

    2024-06-15 07:02:01       8 阅读
  4. GitHub每日最火火火项目(6.14)

    2024-06-15 07:02:01       11 阅读
  5. 人工智能中的哲学

    2024-06-15 07:02:01       6 阅读
  6. 安装xFormers时遇到的问题,以及正确的安装方式

    2024-06-15 07:02:01       7 阅读