当前位置:网站首页>Verilog daily question (vl4 shift operation and multiplication)
Verilog daily question (vl4 shift operation and multiplication)
2022-07-28 17:28:00 【Don't make any more errors】
Title Description :
It is known that d For one 8 digit , Please output this number in each clock cycle 1/3/7/8, And output a signal to inform the input at this time d It works (d The rising edge of the given signal indicates that the write is valid )

Waveform diagram :

Here I have two ways to solve problems :
(1) Create variables to count , Output through a loop
(2) Use state machine to design
Because the way of state machine is more intuitive , Here we use the state machine to solve the problem directly (merely type , Related to both input and current state )
Set up 5 States : A standby state , Four cyclic States , The specific solution ideas are as follows
`timescale 1ns/1ns
module multi_sel(
input [7:0]d ,
input clk,
input rst,
output reg input_grant,
output reg [10:0]out
);
//*************code***********//
parameter a=0,b=1,c=2,d1=3,e=4;
reg [7:0] d0;
reg [2:0] state,nstate;
always @(posedge clk,negedge rst)
begin
if(!rst) begin state=a;out=0;input_grant = 0; end
else begin
state = nstate;
d0 = (state==b)? d:d0;
//state==b When the value is assigned , And only when the state returns b The next assignment will be made only when
input_grant = (state==b);
out = (state==b)? d0 :(state==c)? 3*d0 :(state==d1)? 7*d0 :(state==e)?8*d0 :0;
// You can't write directly here d, Because in a cycle ,d The change of the value of does not affect the calculated four values with clk Appear along the rising edge , Added a d0 To replace
end
end
always @(*)
begin
case(state)
a: nstate = b; //a It's the initial state
b: nstate = c; // To state b The calculation starts at
c: nstate = d1;
d1: nstate = e;
e: nstate = b;
default nstate=a;
endcase
end
//*************code***********//
endmoduleFinally, I looked at the answer and directly used one case Circular , It's easier .

边栏推荐
- kubernetes service 原理解析
- Verilog daily question (vl28 plus and minus counter)
- 高速电路中电容的选型和应用——详解
- Verilog daily question (VL2 asynchronous reset Series T trigger - Niuke network)
- 【presto 】presto 新版本升级详情
- Verilog daily question (vl6 data series to parallel circuit)
- Basic principle of asynchronous FIFO (simple implementation based on Verilog)
- Shell脚本之AWK
- [Presto] common commands of Presto
- Linear algebra and matrix theory (VIII)
猜你喜欢

Problem solution of code heartstrings Junior Group (official competition) of Dalian University of Technology (Development Zone campus) in 2021

我为什么选择使用Go语言?

高速电路中电容的选型和应用——详解

Analysis of kubernetes service principle

线性代数及矩阵论(九)

Why do I choose to use go language?

Round 1C 2022 - Code jam 2022 b.square (Mathematics, thinking)

Verilog daily question (vl14 vending machine 1 -- FSM common question types)

MySQL详细学习教程(建议收藏)

高速电路中电感的选型和应用
随机推荐
【ansible】ansible shell 执行远程命令遇到awk 中$符号的问题
Goweb开发之Beego框架实战:第四节 数据库配置及连接
Verilog 每日一题(VL14 自动贩售机1--FSM常见题型)
Goweb开发之Iris框架实战:项目总结与回顾
Proof of the third scene (f) in 22 years
Cf/atc/lc topic score website
Gray code and binary conversion and typical examples (4bits gray code counter)
堡垒机的作用
Azure Devops developed by visual studio 2015 team
Verilog daily question (vl28 plus and minus counter)
[atlas] atlas compilation error sorting (all)
Reasoning Over Semantic-Level Graph for Fact Checking
Create a custom paging control
《Kubernetes》你需要掌握的 Service 和 Ingress
Source code of voice live broadcast app
Visual studio 2012/2015 releases web applications together with.Cs source code
在android开发过程中遇到.sqlite文件处理
【impala】【报错解决】 Impala cannot read or execute the parent directory of dfs.domain.socket.path的解决方法
WPF command button transparent style
线性代数及矩阵论(九)