当前位置:网站首页>VerilogA——计数器
VerilogA——计数器
2022-06-29 06:32:00 【夏风喃喃】
带有低电平有效复位的 8-bit 循环计数器VerilogA代码
// VerilogA for COUNTER_8B, veriloga
`include "constants.vams"
`include "disciplines.vams"
module COUNTER_8B (B7, B6, B5, B4, B3, B2, B1, B0, CLK, RSTN);
electrical B7, B6, B5, B4, B3, B2, B1, B0, CLK, RSTN;
parameter real trise = 1p;
parameter real tfall = 1p;
parameter real tdely = 0;
parameter real vlogic_high = 1;
parameter real vlogic_low = 0;
parameter real vtrans_clk = 0.5;
`define num_bits 8
real i;
real t;
real halfscal;
real fun[0:`num_bits-1];
integer m;
analog begin
@ (initial_step) begin
i=0;
halfscal = 128;
end
@ (cross(V(CLK) - vtrans_clk, +1) or cross(V(RSTN) - vtrans_clk, -1)) begin
if(V(RSTN) < vtrans_clk) begin
i = 0;
end
else if (i == 255) begin
i = 0;
end
else
begin
i=i+1;
end
t = i;
for (m=(`num_bits-1); m >=0; m=m-1) begin
fun[m] = 0;
if (t > halfscal-1) begin
fun[m]=vlogic_high;
t = t - halfscal;
end
else begin
fun[m]=vlogic_low;
end
t = t * 2;
end
end
V(B7) <+ transition( fun[7], tdely, trise, tfall );
V(B6) <+ transition( fun[6], tdely, trise, tfall );
V(B5) <+ transition( fun[5], tdely, trise, tfall );
V(B4) <+ transition( fun[4], tdely, trise, tfall );
V(B3) <+ transition( fun[3], tdely, trise, tfall );
V(B2) <+ transition( fun[2], tdely, trise, tfall );
V(B1) <+ transition( fun[1], tdely, trise, tfall );
V(B0) <+ transition( fun[0], tdely, trise, tfall );
`undef num_bits
end
endmodule
边栏推荐
- 多线程工具类 CompletableFuture
- AIRNET notes 1
- Teach you how to develop your own NPM package (publish to the NPM official website)
- Antlr4 recognizes the format of escape string containing quotation marks
- The simple problem of leetcode is to divide an array into three parts equal to sum
- Failure: unable to log in to "taxpayer equity platform"
- What are the uses of final?
- Testing grpc service with grpcui
- What is MES? What does it do?
- Design of leetcode simple problem goal parser
猜你喜欢

Installing modules in pycharm

Linux Installation redis
![[C language series] - initial C language (4)](/img/3b/b20d6e0194f2114f8c27a17d58369a.jpg)
[C language series] - initial C language (4)

Will the order of where conditions in MySQL affect the union index? Will where 1 =1 affect the use of the index? Does where 1 =1 affect the use of indexes?

MySQL learning notes

RedisTemplate处理hash整数类型的问题解析

National Defense University project summary

The simple problem of leetcode is to divide an array into three parts equal to sum

Agile invincible event

Why can't the article be posted?
随机推荐
目标检测——使用yolov6进行视频推理
Implementation of queue
Segment in Lucene
MySQL learning notes
Fault: KDC warning log for id29
Skills of writing test cases efficiently
力扣每日一题-第30天-1523.位1的个数
Browser local storage
Fault: NetBt log for id4321
Go basic data type conversion
How to hand over complex legacy systems?
2022.02.15 - 240. Lucky number in matrix
51 lines of code, self-made TX to MySQL software!
Conditional test, if and case conditional test statements of shell script
Leetcode simple problem building arrays with stack operation
Functions and arrays of shell scripts
层次分析法
Linux Installation redis
What are the uses of static?
作为一名合格的网工,你必须掌握的 DHCP Snooping 知识!