verilog hdl 时序逻辑电路0

testshixu.v

`timescale 1ns / 1ps
//
// Company: 
// Engineer: 
// 
// Create Date:    11:48:22 05/06/2017 
// Design Name: 
// Module Name:    testshixu 
// Project Name: 
// Target Devices: 
// Tool versions: 
// Description: 
//
// Dependencies: 
//
// Revision: 
// Revision 0.01 - File Created
// Additional Comments: 
//
//
module testshixu(iClk,oLed,rst);




//endmodule




//module led_run(iClk,oLed,rst);


input iClk;
input rst;
output [3:0] oLed;
reg [3:0] oLed;
reg [1:0] count;
reg [1:0] state;
wire clk;


always @(posedge iClk or negedge rst)
begin
  if(!rst)
     count = 0; 
      else
         count = count+1;
end


//assign clk=count[1];


 


always @(posedge iClk or negedge rst)
begin
    if(!rst)
       oLed <=4'b0000;
    else
       begin
         case(count)
           2'b00: oLed<=4'b0001;
           2'b01: oLed<=4'b0010;
           2'b10: oLed<=4'b0100;
           2'b11: oLed<=4'b1000;
         endcase
         //state=state+1;
       end
end
endmodule



test_testshixu.v




`timescale 1ns / 1ps



// Company: 
// Engineer:
//
// Create Date:   12:00:03 05/06/2017
// Design Name:   testshixu
// Module Name:   D:/ise147/prj/testshixu/test.v
// Project Name:  testshixu
// Target Device:  
// Tool versions:  
// Description: 
//
// Verilog Test Fixture created by ISE for module: testshixu
//
// Dependencies:
// 
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
// 



module test;


// Inputs
reg iClk;
reg rst;


// Outputs
wire [3:0] oLed;
//reg [1:0] state;


// Instantiate the Unit Under Test (UUT)
testshixu uut (
.iClk(iClk), 
.oLed(oLed), 
.rst(rst)
);



    initial
    begin
      iClk = 1'b0;
      rst  = 1'b0;

      #5
      iClk = 1'b1;
      rst  = 1'b1;
    end
    always #10 
iClk = ~iClk;




      
endmodule









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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值