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.

Help required in developing generic Verilog code

Status
Not open for further replies.

er.akhilkumar

Full Member level 2
Joined
Feb 1, 2011
Messages
120
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,298
Location
Noida
Activity points
2,418
Hello all,

I am trying to develop generic RTL, in which I am trying to load a memory of generic width and generic depth with input data which is smaller than memory width.

Suppose memory width is 32 and memory depth is 16, but input data width is 16-bit. Means to write one location of memory we need two write accesses. I will write this logic as:

always @(posedge clock) begin
if(writing)
case (address[0])
0: memory[address%2] [15:0] <= input_data;
1: memory[address%2] [31:16] <= input_data;
endcase
end


Now suppose input data width is 8 bit. Means now 4 accesses will be needed to write one location of memory. So now the code will be

always @(posedge clock) begin
if(writing)
case (address[1:0])
2'b00: memory[address%4] [7:0] <= input_data;
2'b01: memory[address%4] [15:8] <= input_data;
2'b10: memory[address%4] [23:16] <= input_data;
2'b01: memory[address%4] [31:24] <= input_data;
endcase
end


But this is totally a manual work, I need to develop a generic code. Can anyone please help me out how can we develop generic code for above logic? And it should be synthesizable also.

Thanx
 

Hi!

I think the most easy way to do so is to write your own preprocessing script to generate the code you want according to some input parameter (in your case the data width). Since the code you are going to generate is very simple you won't have problems in writing a simple script. Then, invoke the script along the flow before going to synthesis.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top