当前位置:网站首页>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
边栏推荐
- 关于 localStorage 的一些高阶用法
- What is the "danksharding" of V God Kop on Valentine's day?
- Can I cast int to a variable of type byte? What happens if the value is larger than the range of byte type?
- Pytest (7) -yield and termination function
- AIRNET notes 1
- Internet enterprises need CRM software to help
- Segment in Lucene
- What is 'EC2-Other' filter in 'Cost Explorer' dashboard mean? [closed]
- ASP. Net core 6 framework unveiling example demonstration [03]:dapr initial experience
- Jenkins operation Chapter 5 trigger, configuration webhook, Jenkins parameterized construction
猜你喜欢

Hustoj SPJ example

Establishing the development environment of esp8266

Chapter IV introduction to FPGA development platform

QT writing map comprehensive application 58 compatible with multi browser kernel

Clickhouse data type

Alphacode made its debut! The programming version of "Alpha dog" competed quietly and defeated half of the programmers

What is MES? What does it do?

Creation of Arduino uno development environment

层次分析法
![[C language series] - initial C language (4)](/img/3b/b20d6e0194f2114f8c27a17d58369a.jpg)
[C language series] - initial C language (4)
随机推荐
SCM engineering experience - time slice
[C language series] - initial C language (4)
What is 'EC2-Other' filter in 'Cost Explorer' dashboard mean? [closed]
Easy to understand TCP four waves (multi picture explanation)
About: deleting unwanted event log lists
[high concurrency] deeply analyze the callable interface
Mongodb paging method
I would like to ask what securities dealers recommend? Is it safe to open an account online?
Sourcetree remote red exclamation point
After “Go to Definition”, is there a command to return to where you came from?
Venn diagram proportional and color shading with semi transparency
Internet enterprises need CRM software to help
VLAN experiment
The echares map is implemented separately by provinces, and the tooltip user-defined prompt box, scattered annotation and scattered illumination are explained in detail
What are the uses of final?
flutter配置国内镜像,连接真机
Pytest (7) -yield and termination function
Illustrate plug-in -- AI plug-in development -- creative plug-in -- astute graphics -- length and angle measurement function
Hyperledger Fabric 2. X custom smart contract
Fresnel diffraction with rectangular aperture based on MATLAB