当前位置:网站首页>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
边栏推荐
- Output of character pointer to string in C language
- Functions and arrays of shell scripts
- Browser local storage
- Week 10 - task 1- fill in the blank: line class inherits point class
- Failure: unable to log in to "taxpayer equity platform"
- Design and practice of kubernetes cluster and application monitoring scheme
- P5 DS - component and document Association
- Pointer from beginner to advanced (2)
- How to hand over complex legacy systems?
- Analysis comp122 the Caesar cipher
猜你喜欢

配置Flutter开发环境

2022.02.15 - 240. Lucky number in matrix

Pytest (7) -yield and termination function

Sum of digits under k-ary representation of leetcode simple problem

Segment in Lucene

Use of sed in shell script

Rearrangement string of leetcode simple question

Hyperledger Fabric 2. X custom smart contract

百度小程序自动提交搜索

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?
随机推荐
2022-01 Microsoft vulnerability notification
Illustrate plug-in -- AI plug-in development -- creative plug-in -- astute graphics -- multi axis mirroring function
Personal blog item: processing of reading number +1 after viewing article details
MySQL learning notes
DANGER! V** caught climbing over the wall!
flutter配置国内镜像,连接真机
Establishing the development environment of esp8266
Single application and microservice application
Call the computer calculator and use it to convert several base numbers
Fault: KDC warning log for id29
Two houses with different colors and the farthest distance
String and variable are spliced into variable name
Part 63 - interpreter and compiler adaptation (II)
Leetcode simple problem building arrays with stack operation
National Defense University project summary
Internet enterprises need CRM software to help
Hustoj SPJ example
[chromium] win10 vs2019 environment chromium configuration and compilation.
Hyperledger Fabric 2. X custom smart contract
融入STEAM教育的劳动技能课程