2020年4月3日 星期五

Modulo-10 counter in Verilog

Modulo-10 counter in Verilog



//====================
module Mod_10(out,rst,clk);
output [3:0]out;
input clk,rst;
reg [3:0]out;

always @(posedge clk)
begin
if(rst|out==4'b1001)
out<=4'b0000;
else
out<=out+1;
end

endmodule
//====================
// 時間單位 1ns, 時間精確度1 ps
`timescale 100ns/10ps
module TB_Mod_10;
/*
module Mod_10(out,rst,clk);
output [3:0]out;
input clk,rst;
reg [3:0]out;
*/
  //input
  reg clk,rst;
    //output 
  wire [3:0]out;
 
  Mod_10 UUT (out,rst,clk);
  initial
     clk= 1'b0; 

  always
     #5  clk=~clk; 
  initial
     begin
       #2  rst=1'b1;
       #10 rst=1'b0;
       #500 $stop;
     end
 
   initial
       $monitor("clk=%b,rst=%b,out=%b",clk,rst,out);
endmodule
//====================


沒有留言:

張貼留言

  清除項目編譯快取 執行 flutter clean 重新取得套件依賴 執行 flutter pub get 完整重新編譯並執行 flutter run 1. 新增專案套件 (pubspec.yaml) 在 Flutter 專案根目錄下的 pubspec.yaml 中,新增 ...