Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Verilog loop with certain registers

Status
Not open for further replies.

ismailov-e

Member level 1
Member level 1
Joined
Jan 26, 2015
Messages
34
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Visit site
Activity points
295
hi.
Let me say i have a 8-bit 9 register, one of them is output. Input wire 8-bit.

Code Verilog - [expand]
1
2
3
4
5
6
7
8
9
10
11
wire [7:0 ]input1;
reg [7:0] rega1 = 1;
reg [7:0] rega2 = 2;
reg [7:0] rega3 = 3;
reg [7:0] rega4 = 4;
reg [7:0] rega5 = 5;
reg [7:0] rega6 = 6;
reg [7:0] rega7 = 7;
reg [7:0] rega8 = 8;
reg [7:0] st = 0
reg [7:0] out = 0;


This input variable indicates only to use certain number of register. If input is 5 than use only first 5 registers.
For example i have to output first 5 registers each clock cycle.

Code Verilog - [expand]
1
2
3
4
5
6
st <= input1;
if (st != 0)
begin
st <= st - 1;
out <= rega[st];
end


I know that reg1,reg2 is string and code will not work.
Is there any syntaxis to use certain registers instead

Code Verilog - [expand]
1
rega[st]

?
 

Use an array of registers:

Code Verilog - [expand]
1
2
3
4
5
6
reg [7:0] rega [1:9];
//then this works:
rega[st] <= 1;
//and
out <= rega[st];
//also works

 

    V

    Points: 2
    Helpful Answer Positive Rating
Use an array of registers:

Code Verilog - [expand]
1
2
3
4
5
6
reg [7:0] rega [1:9];
//then this works:
rega[st] <= 1;
//and
out <= rega[st];
//also works

Cool man!!. Once i saw such syntax, but did't know what is mean.
Thanks ads-ee.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top