当前位置:网站首页>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 .

边栏推荐
- 异步FIFO基本原理(基于Verilog的简单实现)
- Difference between reconnaissance aircraft and early warning aircraft
- Modeling Semantics with Gated Graph Neural Networks for KBQA
- Net framework
- 高速电路中电容的选型和应用——详解
- 解决SQL Server数据库独占的问题
- Azure Devops developed by visual studio 2015 team
- High speed circuit design practice -- Overview
- [Presto] common commands of Presto
- 侦察机与预警机的区别
猜你喜欢

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

net框架

High speed circuit design practice -- Overview

LNMP source code compilation and installation

Encountered.Sqlite file processing during Android Development

格雷码和二进制的转换及典型例题(4bits格雷码计数器)

Verilog daily question (vl27 settable counter)

Azure Devops developed by visual studio 2015 team

The practice of beego framework developed by goweb: Section 4 database configuration and connection

Vscode界面介绍
随机推荐
[sqoop] sqoop 1.4.7 installation integration cdh5.13
Learn about service discovery in kubernetes
Shell脚本之免交互操作
Verilog 每日一题(VL29 单端口RAM)
《Kubernetes》你需要掌握的 Service 和 Ingress
Linear algebra and matrix theory (10)
Linear algebra and matrix theory (IX)
LNMP source code compilation and installation
【CDH】通过 ClouderaManager 配置CDH组件用 prometheus 监控采集JMX信息
线性代数及矩阵论(七)
Using SQL server agent job to restore the database regularly
[atlas] atlas compilation error sorting (all)
MySQL detailed learning tutorial (recommended Collection)
Role of Fortress machine
【atlas】atlas 编译报错整理(全)
软考回顾总结
Classroom attendance system based on QT design (using RDS for MySQL cloud database)
Leetcode 2022.04.10 China Merchants Bank special competition D. store promotion (DP)
一文了解 Kubernetes 中的服务发现
Selection and application of capacitor in high speed circuit -- detailed explanation