madalin1990
Full Member level 2
- Joined
- Apr 4, 2012
- Messages
- 124
- Helped
- 2
- Reputation
- 4
- Reaction score
- 2
- Trophy points
- 1,298
- Activity points
- 2,090
wire [2:0] variable [23:0] ;
How to declare and use a 2 dimension variable?Is this declaration correct:
Code:wire [2:0] variable [23:0] ;
module module_name U_module_name(
.signal1(variable[0],
.signal2(variable[1],
.signal3(variable[2]
);
So if i want to use this signal called variable to connect to 3 different 24-bits ports i write:
Code:module module_name U_module_name( .signal1(variable[0], .signal2(variable[1], .signal3(variable[2] );
Correct?
wire [23:0] variable [0:2];
// which can then be used like:
// Note the differences in this instantiation.
module_name U_module_name (
.signal1 (variable[0]),
.signal2 (variable[1]),
.signal3 (variable[2])
);
// Here is the explicit connection of the array using both dimensions:
module_name U_module_name (
.signal1 (variable[0][23:0]),
.signal2 (variable[1][23:0]),
.signal3 (variable[2][23:0])
);
module MUX3TO1(IN0,IN1,IN2,IN3,SEL,OUT);
parameter width = 5;
input [width-1:0] IN0,IN1,IN2,IN3;
input [1:0] SEL;
output reg [width-1:0] OUT;
always @(SEL or IN0 or IN1 or IN2 or IN3)
case( SEL )
2'b00:OUT <= IN0;
2'b01:OUT <= IN1;
2'b10:OUT <= IN2;
2'b11:OUT <= IN3;
default: OUT<= width'bx;
endcase
endmodule
default: OUT<= width'bx;
default: OUT <= {width{1'bx}};
parameter HD = 800;
wire BAR_WIDTH ;
assign BAR_WIDTH = HD/8 ;
parameter HD = 800;
localparam BAR_WIDTH = HD/8;
module ramA #
( parameter N = 3,
parameter W = 8)
( input clk,
input we,
input [N-1:0] addr,
input [W-1:0] di,
output [W-1:0] dout);
localparam M = 2**N;
reg [W-1:0] mem [0:M-1];
always @ (posedge clk)
if (we) //
mem[addr] <= di;
assign dout = mem[addr];
endmodule
RGB = mem[addr]
I want to write an image pixels value in a memory using readmemh.The problem is that the adress should be bidimensional.I know that for reading the memword at a certain address i write:
But how can i proceed for a bidimensional address?Code:RGB = mem[addr]
Code Verilog - [expand] 1 2 3 wire [7:0] addr [0:4][0:4]; assign RGB = mem[addr[adr_dim1][adr_dim2]];
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?