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

边栏推荐
- 2022 Niuke multi school second CDE
- net框架
- Selection and application of capacitor in high speed circuit -- detailed explanation
- 部分情况下Error:(xx, xx) Failed to resolve: xxxxxx解决。
- 【impala】【报错解决】 Impala cannot read or execute the parent directory of dfs.domain.socket.path的解决方法
- 连接设计与测试平台——SystemVerilog 接口知识点总结
- UNIQUE VISION Programming Contest 2022(AtCoder Beginner Contest 248)G. GCD cost on the tree
- Batch download files
- Verilog daily question (vl5 signal generator)
- The practice of beego framework developed by goweb: Section 4 database configuration and connection
猜你喜欢
![[kibana] problem sorting kibana 7.x no indices match pattern](/img/36/0f85dbe7eea49db8f845a4a4f302cf.png)
[kibana] problem sorting kibana 7.x no indices match pattern "APM-*“

高速电路中电阻的选择

Shopee code League 2022 - qualification round p3.connecting the numbers (segment tree / bipartite graph determination, to be discussed)

LNMP source code compilation and installation

Verilog daily question (vl5 signal generator)

Proof of the third scene (f) in 22 years

Verilog daily question (VL2 asynchronous reset Series T trigger - Niuke network)

Verilog 每日一题(VL2 异步复位的串联T触发器--牛客网)

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

Verilog 每日一题 (VL28 加减计数器)
随机推荐
Codeforces round 768 (Div. 2) e.paint the middle (greedy / interval relationship processing)
C#遍历集合
批量下载文件
Code implementation additive attention
Some attention code explanations
Selection and application of capacitor in high speed circuit -- detailed explanation
Connection design and test platform -- Summary of SystemVerilog interface knowledge points
The practice of beego framework developed by goweb: Section 4 database configuration and connection
堡垒机的作用
【impala】【报错解决】 Impala cannot read or execute the parent directory of dfs.domain.socket.path的解决方法
[ansible] the ansible shell encountered the problem of $symbol in awk when executing remote commands
C # traversal set
The practice of the beego framework for goweb development: Section V project construction and user registration
Verilog 每日一题(VL29 单端口RAM)
Verilog daily question (vl27 settable counter)
Verilog 每日一题 (VL27 可置位计数器)
[sqoop] sqoop 1.4.7 installation integration cdh5.13
部分情况下Error:(xx, xx) Failed to resolve: xxxxxx解决。
Export word according to the template, generate compound format tables and variable column tables
CNSA与CASC和CASIC的区别