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.

Regarding Verilog codes

Status
Not open for further replies.

josephine1234

Junior Member level 1
Joined
Nov 17, 2017
Messages
15
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
117

Code Verilog - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module fix(x,z,x1
    );
input signed [4:0]x;
output z;
output signed[14:0]x1;
localparam signed [11:0] y = 12'b100000000000;
reg [14:0]z;
always @* begin
 z=x*y;
end
 
// selecting msb 
reg z1;
always @* begin
   z1=x[4];
end
 
// to check if number is positive or negative  
reg [14:0]x1;
always @( z or z1)
begin
  if (z1 == 1)
    x1 = ~z;
  else
    x1 = z;
end
endmodule



this is the code to get one input .. can anyone help me in iterating this code so as to get 32 inputs... many thanks in advance....
 
Last edited by a moderator:

You don't iterate code (sounds like a sw coder writing verilog) you either use a generate-for loop or have an fsm that time shares a resource.

Here is the format for a generate-for loop to create 32 instances of some block of code.

Code Verilog - [expand]
1
2
3
4
5
generate
genvar i;
for (i=0;i<32;i=i+1) begin : gen_inputs
  // your code goes here
end



I'm not even sure what the point of this code is. A simple shift is all your really need here and an inversion (one's complement?) based on bit four of the input vector.

This code doesn't look like it takes into account what hardware is generated from synthesis.
 

thats the real to fixed point conversion codes
 

This makes me question Verilog's aliasing rules. For example, z -- a 1 bit wire -- has the same name as z -- a 15 bit signed reg. Does verilog allow this and what does this mean?
 

The declaration gives a vectored output z, both lines are combined. You probably get a compiler warning for the confused declaration.
 

This makes me wonder if there is a Verilog version of ioccc.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top